@@ -44,530 +44,530 @@ |
||
44 | 44 | class OrganizationSettings extends FormHandler |
45 | 45 | { |
46 | 46 | |
47 | - /** |
|
48 | - * @var EE_Organization_Config |
|
49 | - */ |
|
50 | - protected $organization_config; |
|
47 | + /** |
|
48 | + * @var EE_Organization_Config |
|
49 | + */ |
|
50 | + protected $organization_config; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var EE_Core_Config |
|
54 | - */ |
|
55 | - protected $core_config; |
|
52 | + /** |
|
53 | + * @var EE_Core_Config |
|
54 | + */ |
|
55 | + protected $core_config; |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * @var EE_Network_Core_Config |
|
60 | - */ |
|
61 | - protected $network_core_config; |
|
58 | + /** |
|
59 | + * @var EE_Network_Core_Config |
|
60 | + */ |
|
61 | + protected $network_core_config; |
|
62 | 62 | |
63 | - /** |
|
64 | - * @var CountrySubRegionDao $countrySubRegionDao |
|
65 | - */ |
|
66 | - protected $countrySubRegionDao; |
|
63 | + /** |
|
64 | + * @var CountrySubRegionDao $countrySubRegionDao |
|
65 | + */ |
|
66 | + protected $countrySubRegionDao; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Form constructor. |
|
70 | - * |
|
71 | - * @param EE_Registry $registry |
|
72 | - * @param EE_Organization_Config $organization_config |
|
73 | - * @param EE_Core_Config $core_config |
|
74 | - * @param EE_Network_Core_Config $network_core_config |
|
75 | - * @param CountrySubRegionDao $countrySubRegionDao |
|
76 | - * @throws InvalidArgumentException |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws DomainException |
|
79 | - */ |
|
80 | - public function __construct( |
|
81 | - EE_Registry $registry, |
|
82 | - EE_Organization_Config $organization_config, |
|
83 | - EE_Core_Config $core_config, |
|
84 | - EE_Network_Core_Config $network_core_config, |
|
85 | - CountrySubRegionDao $countrySubRegionDao |
|
86 | - ) { |
|
87 | - $this->organization_config = $organization_config; |
|
88 | - $this->core_config = $core_config; |
|
89 | - $this->network_core_config = $network_core_config; |
|
90 | - $this->countrySubRegionDao = $countrySubRegionDao; |
|
91 | - parent::__construct( |
|
92 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
93 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
94 | - 'organization_settings', |
|
95 | - '', |
|
96 | - FormHandler::DO_NOT_SETUP_FORM, |
|
97 | - $registry |
|
98 | - ); |
|
99 | - } |
|
68 | + /** |
|
69 | + * Form constructor. |
|
70 | + * |
|
71 | + * @param EE_Registry $registry |
|
72 | + * @param EE_Organization_Config $organization_config |
|
73 | + * @param EE_Core_Config $core_config |
|
74 | + * @param EE_Network_Core_Config $network_core_config |
|
75 | + * @param CountrySubRegionDao $countrySubRegionDao |
|
76 | + * @throws InvalidArgumentException |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws DomainException |
|
79 | + */ |
|
80 | + public function __construct( |
|
81 | + EE_Registry $registry, |
|
82 | + EE_Organization_Config $organization_config, |
|
83 | + EE_Core_Config $core_config, |
|
84 | + EE_Network_Core_Config $network_core_config, |
|
85 | + CountrySubRegionDao $countrySubRegionDao |
|
86 | + ) { |
|
87 | + $this->organization_config = $organization_config; |
|
88 | + $this->core_config = $core_config; |
|
89 | + $this->network_core_config = $network_core_config; |
|
90 | + $this->countrySubRegionDao = $countrySubRegionDao; |
|
91 | + parent::__construct( |
|
92 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
93 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
94 | + 'organization_settings', |
|
95 | + '', |
|
96 | + FormHandler::DO_NOT_SETUP_FORM, |
|
97 | + $registry |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * creates and returns the actual form |
|
104 | - * |
|
105 | - * @return EE_Form_Section_Proper |
|
106 | - * @throws EE_Error |
|
107 | - * @throws InvalidArgumentException |
|
108 | - * @throws InvalidDataTypeException |
|
109 | - * @throws InvalidInterfaceException |
|
110 | - * @throws ReflectionException |
|
111 | - */ |
|
112 | - public function generate() |
|
113 | - { |
|
114 | - $has_sub_regions = EEM_State::instance()->count( |
|
115 | - array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO)) |
|
116 | - ); |
|
117 | - $form = new EE_Form_Section_Proper( |
|
118 | - array( |
|
119 | - 'name' => 'organization_settings', |
|
120 | - 'html_id' => 'organization_settings', |
|
121 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
122 | - 'subsections' => array( |
|
123 | - 'contact_information_hdr' => new EE_Form_Section_HTML( |
|
124 | - EEH_HTML::h2( |
|
125 | - esc_html__('Contact Information', 'event_espresso') |
|
126 | - . ' ' |
|
127 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), |
|
128 | - '', |
|
129 | - 'contact-information-hdr' |
|
130 | - ) |
|
131 | - ), |
|
132 | - 'organization_name' => new EE_Text_Input( |
|
133 | - array( |
|
134 | - 'html_name' => 'organization_name', |
|
135 | - 'html_label_text' => esc_html__('Organization Name', 'event_espresso'), |
|
136 | - 'html_help_text' => esc_html__( |
|
137 | - 'Displayed on all emails and invoices.', |
|
138 | - 'event_espresso' |
|
139 | - ), |
|
140 | - 'default' => $this->organization_config->get_pretty('name'), |
|
141 | - 'required' => false, |
|
142 | - ) |
|
143 | - ), |
|
144 | - 'organization_address_1' => new EE_Text_Input( |
|
145 | - array( |
|
146 | - 'html_name' => 'organization_address_1', |
|
147 | - 'html_label_text' => esc_html__('Street Address', 'event_espresso'), |
|
148 | - 'default' => $this->organization_config->get_pretty('address_1'), |
|
149 | - 'required' => false, |
|
150 | - ) |
|
151 | - ), |
|
152 | - 'organization_address_2' => new EE_Text_Input( |
|
153 | - array( |
|
154 | - 'html_name' => 'organization_address_2', |
|
155 | - 'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), |
|
156 | - 'default' => $this->organization_config->get_pretty('address_2'), |
|
157 | - 'required' => false, |
|
158 | - ) |
|
159 | - ), |
|
160 | - 'organization_city' => new EE_Text_Input( |
|
161 | - array( |
|
162 | - 'html_name' => 'organization_city', |
|
163 | - 'html_label_text' => esc_html__('City', 'event_espresso'), |
|
164 | - 'default' => $this->organization_config->get_pretty('city'), |
|
165 | - 'required' => false, |
|
166 | - ) |
|
167 | - ), |
|
168 | - 'organization_country' => new EE_Country_Select_Input( |
|
169 | - null, |
|
170 | - array( |
|
171 | - EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL, |
|
172 | - 'html_name' => 'organization_country', |
|
173 | - 'html_label_text' => esc_html__('Country', 'event_espresso'), |
|
174 | - 'default' => $this->organization_config->CNT_ISO, |
|
175 | - 'required' => false, |
|
176 | - 'html_help_text' => sprintf( |
|
177 | - esc_html__( |
|
178 | - '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s', |
|
179 | - 'event_espresso' |
|
180 | - ), |
|
181 | - '<span class="reminder-spn">', |
|
182 | - '</span>' |
|
183 | - ), |
|
184 | - ) |
|
185 | - ), |
|
186 | - 'organization_state' => new EE_State_Select_Input( |
|
187 | - null, |
|
188 | - array( |
|
189 | - 'html_name' => 'organization_state', |
|
190 | - 'html_label_text' => esc_html__('State/Province', 'event_espresso'), |
|
191 | - 'default' => $this->organization_config->STA_ID, |
|
192 | - 'required' => false, |
|
193 | - 'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions |
|
194 | - ? sprintf( |
|
195 | - esc_html__( |
|
196 | - 'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s', |
|
197 | - 'event_espresso' |
|
198 | - ), |
|
199 | - '<span class="reminder-spn">', |
|
200 | - '</span>', |
|
201 | - '<br />' |
|
202 | - ) |
|
203 | - : '', |
|
204 | - ) |
|
205 | - ), |
|
206 | - 'organization_zip' => new EE_Text_Input( |
|
207 | - array( |
|
208 | - 'html_name' => 'organization_zip', |
|
209 | - 'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), |
|
210 | - 'default' => $this->organization_config->get_pretty('zip'), |
|
211 | - 'required' => false, |
|
212 | - ) |
|
213 | - ), |
|
214 | - 'organization_email' => new EE_Text_Input( |
|
215 | - array( |
|
216 | - 'html_name' => 'organization_email', |
|
217 | - 'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), |
|
218 | - 'html_help_text' => sprintf( |
|
219 | - esc_html__( |
|
220 | - 'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', |
|
221 | - 'event_espresso' |
|
222 | - ), |
|
223 | - '<code>[CO_FORMATTED_EMAIL]</code>', |
|
224 | - '<code>[CO_EMAIL]</code>' |
|
225 | - ), |
|
226 | - 'default' => $this->organization_config->get_pretty('email'), |
|
227 | - 'required' => false, |
|
228 | - ) |
|
229 | - ), |
|
230 | - 'organization_phone' => new EE_Text_Input( |
|
231 | - array( |
|
232 | - 'html_name' => 'organization_phone', |
|
233 | - 'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
|
234 | - 'html_help_text' => esc_html__( |
|
235 | - 'The phone number for your organization.', |
|
236 | - 'event_espresso' |
|
237 | - ), |
|
238 | - 'default' => $this->organization_config->get_pretty('phone'), |
|
239 | - 'required' => false, |
|
240 | - ) |
|
241 | - ), |
|
242 | - 'organization_vat' => new EE_Text_Input( |
|
243 | - array( |
|
244 | - 'html_name' => 'organization_vat', |
|
245 | - 'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), |
|
246 | - 'html_help_text' => esc_html__( |
|
247 | - 'The VAT/Tax Number may be displayed on invoices and receipts.', |
|
248 | - 'event_espresso' |
|
249 | - ), |
|
250 | - 'default' => $this->organization_config->get_pretty('vat'), |
|
251 | - 'required' => false, |
|
252 | - ) |
|
253 | - ), |
|
254 | - 'company_logo_hdr' => new EE_Form_Section_HTML( |
|
255 | - EEH_HTML::h2( |
|
256 | - esc_html__('Company Logo', 'event_espresso') |
|
257 | - . ' ' |
|
258 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), |
|
259 | - '', |
|
260 | - 'company-logo-hdr' |
|
261 | - ) |
|
262 | - ), |
|
263 | - 'organization_logo_url' => new EE_Admin_File_Uploader_Input( |
|
264 | - array( |
|
265 | - 'html_name' => 'organization_logo_url', |
|
266 | - 'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), |
|
267 | - 'html_help_text' => esc_html__( |
|
268 | - 'Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
269 | - 'event_espresso' |
|
270 | - ), |
|
271 | - 'default' => $this->organization_config->get_pretty('logo_url'), |
|
272 | - 'required' => false, |
|
273 | - ) |
|
274 | - ), |
|
275 | - 'social_links_hdr' => new EE_Form_Section_HTML( |
|
276 | - EEH_HTML::h2( |
|
277 | - esc_html__('Social Links', 'event_espresso') |
|
278 | - . ' ' |
|
279 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) |
|
280 | - . EEH_HTML::br() |
|
281 | - . EEH_HTML::p( |
|
282 | - esc_html__( |
|
283 | - 'Enter any links to social accounts for your organization here', |
|
284 | - 'event_espresso' |
|
285 | - ), |
|
286 | - '', |
|
287 | - 'description' |
|
288 | - ), |
|
289 | - '', |
|
290 | - 'social-links-hdr' |
|
291 | - ) |
|
292 | - ), |
|
293 | - 'organization_facebook' => new EE_Text_Input( |
|
294 | - array( |
|
295 | - 'html_name' => 'organization_facebook', |
|
296 | - 'html_label_text' => esc_html__('Facebook', 'event_espresso'), |
|
297 | - 'other_html_attributes' => ' placeholder="facebook.com/profile.name"', |
|
298 | - 'default' => $this->organization_config->get_pretty('facebook'), |
|
299 | - 'required' => false, |
|
300 | - ) |
|
301 | - ), |
|
302 | - 'organization_twitter' => new EE_Text_Input( |
|
303 | - array( |
|
304 | - 'html_name' => 'organization_twitter', |
|
305 | - 'html_label_text' => esc_html__('Twitter', 'event_espresso'), |
|
306 | - 'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"', |
|
307 | - 'default' => $this->organization_config->get_pretty('twitter'), |
|
308 | - 'required' => false, |
|
309 | - ) |
|
310 | - ), |
|
311 | - 'organization_linkedin' => new EE_Text_Input( |
|
312 | - array( |
|
313 | - 'html_name' => 'organization_linkedin', |
|
314 | - 'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), |
|
315 | - 'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"', |
|
316 | - 'default' => $this->organization_config->get_pretty('linkedin'), |
|
317 | - 'required' => false, |
|
318 | - ) |
|
319 | - ), |
|
320 | - 'organization_pinterest' => new EE_Text_Input( |
|
321 | - array( |
|
322 | - 'html_name' => 'organization_pinterest', |
|
323 | - 'html_label_text' => esc_html__('Pinterest', 'event_espresso'), |
|
324 | - 'other_html_attributes' => ' placeholder="pinterest.com/profilename"', |
|
325 | - 'default' => $this->organization_config->get_pretty('pinterest'), |
|
326 | - 'required' => false, |
|
327 | - ) |
|
328 | - ), |
|
329 | - 'organization_instagram' => new EE_Text_Input( |
|
330 | - array( |
|
331 | - 'html_name' => 'organization_instagram', |
|
332 | - 'html_label_text' => esc_html__('Instagram', 'event_espresso'), |
|
333 | - 'other_html_attributes' => ' placeholder="instagram.com/handle"', |
|
334 | - 'default' => $this->organization_config->get_pretty('instagram'), |
|
335 | - 'required' => false, |
|
336 | - ) |
|
337 | - ), |
|
338 | - ), |
|
339 | - ) |
|
340 | - ); |
|
341 | - if (is_main_site()) { |
|
342 | - $form->add_subsections( |
|
343 | - array( |
|
344 | - 'site_license_key_hdr' => new EE_Form_Section_HTML( |
|
345 | - EEH_HTML::h2( |
|
346 | - esc_html__('Your Event Espresso License Key', 'event_espresso') |
|
347 | - . ' ' |
|
348 | - . EEH_HTML::span( |
|
349 | - EEH_Template::get_help_tab_link('site_license_key_info') |
|
350 | - ), |
|
351 | - '', |
|
352 | - 'site-license-key-hdr' |
|
353 | - ) |
|
354 | - ), |
|
355 | - 'site_license_key' => $this->getSiteLicenseKeyField() |
|
356 | - ) |
|
357 | - ); |
|
358 | - $form->add_subsections( |
|
359 | - array( |
|
360 | - 'uxip_optin_hdr' => new EE_Form_Section_HTML( |
|
361 | - $this->uxipOptinText() |
|
362 | - ), |
|
363 | - 'ueip_optin' => new EE_Checkbox_Multi_Input( |
|
364 | - array( |
|
365 | - true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso') |
|
366 | - ), |
|
367 | - array( |
|
368 | - 'html_name' => EE_Core_Config::OPTION_NAME_UXIP, |
|
369 | - 'html_label_text' => esc_html__( |
|
370 | - 'UXIP Opt In?', |
|
371 | - 'event_espresso' |
|
372 | - ), |
|
373 | - 'default' => isset($this->core_config->ee_ueip_optin) |
|
374 | - ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN) |
|
375 | - : false, |
|
376 | - 'required' => false, |
|
377 | - ) |
|
378 | - ), |
|
379 | - ), |
|
380 | - 'organization_instagram', |
|
381 | - false |
|
382 | - ); |
|
383 | - } |
|
384 | - return $form; |
|
385 | - } |
|
102 | + /** |
|
103 | + * creates and returns the actual form |
|
104 | + * |
|
105 | + * @return EE_Form_Section_Proper |
|
106 | + * @throws EE_Error |
|
107 | + * @throws InvalidArgumentException |
|
108 | + * @throws InvalidDataTypeException |
|
109 | + * @throws InvalidInterfaceException |
|
110 | + * @throws ReflectionException |
|
111 | + */ |
|
112 | + public function generate() |
|
113 | + { |
|
114 | + $has_sub_regions = EEM_State::instance()->count( |
|
115 | + array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO)) |
|
116 | + ); |
|
117 | + $form = new EE_Form_Section_Proper( |
|
118 | + array( |
|
119 | + 'name' => 'organization_settings', |
|
120 | + 'html_id' => 'organization_settings', |
|
121 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
122 | + 'subsections' => array( |
|
123 | + 'contact_information_hdr' => new EE_Form_Section_HTML( |
|
124 | + EEH_HTML::h2( |
|
125 | + esc_html__('Contact Information', 'event_espresso') |
|
126 | + . ' ' |
|
127 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), |
|
128 | + '', |
|
129 | + 'contact-information-hdr' |
|
130 | + ) |
|
131 | + ), |
|
132 | + 'organization_name' => new EE_Text_Input( |
|
133 | + array( |
|
134 | + 'html_name' => 'organization_name', |
|
135 | + 'html_label_text' => esc_html__('Organization Name', 'event_espresso'), |
|
136 | + 'html_help_text' => esc_html__( |
|
137 | + 'Displayed on all emails and invoices.', |
|
138 | + 'event_espresso' |
|
139 | + ), |
|
140 | + 'default' => $this->organization_config->get_pretty('name'), |
|
141 | + 'required' => false, |
|
142 | + ) |
|
143 | + ), |
|
144 | + 'organization_address_1' => new EE_Text_Input( |
|
145 | + array( |
|
146 | + 'html_name' => 'organization_address_1', |
|
147 | + 'html_label_text' => esc_html__('Street Address', 'event_espresso'), |
|
148 | + 'default' => $this->organization_config->get_pretty('address_1'), |
|
149 | + 'required' => false, |
|
150 | + ) |
|
151 | + ), |
|
152 | + 'organization_address_2' => new EE_Text_Input( |
|
153 | + array( |
|
154 | + 'html_name' => 'organization_address_2', |
|
155 | + 'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), |
|
156 | + 'default' => $this->organization_config->get_pretty('address_2'), |
|
157 | + 'required' => false, |
|
158 | + ) |
|
159 | + ), |
|
160 | + 'organization_city' => new EE_Text_Input( |
|
161 | + array( |
|
162 | + 'html_name' => 'organization_city', |
|
163 | + 'html_label_text' => esc_html__('City', 'event_espresso'), |
|
164 | + 'default' => $this->organization_config->get_pretty('city'), |
|
165 | + 'required' => false, |
|
166 | + ) |
|
167 | + ), |
|
168 | + 'organization_country' => new EE_Country_Select_Input( |
|
169 | + null, |
|
170 | + array( |
|
171 | + EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL, |
|
172 | + 'html_name' => 'organization_country', |
|
173 | + 'html_label_text' => esc_html__('Country', 'event_espresso'), |
|
174 | + 'default' => $this->organization_config->CNT_ISO, |
|
175 | + 'required' => false, |
|
176 | + 'html_help_text' => sprintf( |
|
177 | + esc_html__( |
|
178 | + '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s', |
|
179 | + 'event_espresso' |
|
180 | + ), |
|
181 | + '<span class="reminder-spn">', |
|
182 | + '</span>' |
|
183 | + ), |
|
184 | + ) |
|
185 | + ), |
|
186 | + 'organization_state' => new EE_State_Select_Input( |
|
187 | + null, |
|
188 | + array( |
|
189 | + 'html_name' => 'organization_state', |
|
190 | + 'html_label_text' => esc_html__('State/Province', 'event_espresso'), |
|
191 | + 'default' => $this->organization_config->STA_ID, |
|
192 | + 'required' => false, |
|
193 | + 'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions |
|
194 | + ? sprintf( |
|
195 | + esc_html__( |
|
196 | + 'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s', |
|
197 | + 'event_espresso' |
|
198 | + ), |
|
199 | + '<span class="reminder-spn">', |
|
200 | + '</span>', |
|
201 | + '<br />' |
|
202 | + ) |
|
203 | + : '', |
|
204 | + ) |
|
205 | + ), |
|
206 | + 'organization_zip' => new EE_Text_Input( |
|
207 | + array( |
|
208 | + 'html_name' => 'organization_zip', |
|
209 | + 'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), |
|
210 | + 'default' => $this->organization_config->get_pretty('zip'), |
|
211 | + 'required' => false, |
|
212 | + ) |
|
213 | + ), |
|
214 | + 'organization_email' => new EE_Text_Input( |
|
215 | + array( |
|
216 | + 'html_name' => 'organization_email', |
|
217 | + 'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), |
|
218 | + 'html_help_text' => sprintf( |
|
219 | + esc_html__( |
|
220 | + 'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', |
|
221 | + 'event_espresso' |
|
222 | + ), |
|
223 | + '<code>[CO_FORMATTED_EMAIL]</code>', |
|
224 | + '<code>[CO_EMAIL]</code>' |
|
225 | + ), |
|
226 | + 'default' => $this->organization_config->get_pretty('email'), |
|
227 | + 'required' => false, |
|
228 | + ) |
|
229 | + ), |
|
230 | + 'organization_phone' => new EE_Text_Input( |
|
231 | + array( |
|
232 | + 'html_name' => 'organization_phone', |
|
233 | + 'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
|
234 | + 'html_help_text' => esc_html__( |
|
235 | + 'The phone number for your organization.', |
|
236 | + 'event_espresso' |
|
237 | + ), |
|
238 | + 'default' => $this->organization_config->get_pretty('phone'), |
|
239 | + 'required' => false, |
|
240 | + ) |
|
241 | + ), |
|
242 | + 'organization_vat' => new EE_Text_Input( |
|
243 | + array( |
|
244 | + 'html_name' => 'organization_vat', |
|
245 | + 'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), |
|
246 | + 'html_help_text' => esc_html__( |
|
247 | + 'The VAT/Tax Number may be displayed on invoices and receipts.', |
|
248 | + 'event_espresso' |
|
249 | + ), |
|
250 | + 'default' => $this->organization_config->get_pretty('vat'), |
|
251 | + 'required' => false, |
|
252 | + ) |
|
253 | + ), |
|
254 | + 'company_logo_hdr' => new EE_Form_Section_HTML( |
|
255 | + EEH_HTML::h2( |
|
256 | + esc_html__('Company Logo', 'event_espresso') |
|
257 | + . ' ' |
|
258 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), |
|
259 | + '', |
|
260 | + 'company-logo-hdr' |
|
261 | + ) |
|
262 | + ), |
|
263 | + 'organization_logo_url' => new EE_Admin_File_Uploader_Input( |
|
264 | + array( |
|
265 | + 'html_name' => 'organization_logo_url', |
|
266 | + 'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), |
|
267 | + 'html_help_text' => esc_html__( |
|
268 | + 'Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
269 | + 'event_espresso' |
|
270 | + ), |
|
271 | + 'default' => $this->organization_config->get_pretty('logo_url'), |
|
272 | + 'required' => false, |
|
273 | + ) |
|
274 | + ), |
|
275 | + 'social_links_hdr' => new EE_Form_Section_HTML( |
|
276 | + EEH_HTML::h2( |
|
277 | + esc_html__('Social Links', 'event_espresso') |
|
278 | + . ' ' |
|
279 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) |
|
280 | + . EEH_HTML::br() |
|
281 | + . EEH_HTML::p( |
|
282 | + esc_html__( |
|
283 | + 'Enter any links to social accounts for your organization here', |
|
284 | + 'event_espresso' |
|
285 | + ), |
|
286 | + '', |
|
287 | + 'description' |
|
288 | + ), |
|
289 | + '', |
|
290 | + 'social-links-hdr' |
|
291 | + ) |
|
292 | + ), |
|
293 | + 'organization_facebook' => new EE_Text_Input( |
|
294 | + array( |
|
295 | + 'html_name' => 'organization_facebook', |
|
296 | + 'html_label_text' => esc_html__('Facebook', 'event_espresso'), |
|
297 | + 'other_html_attributes' => ' placeholder="facebook.com/profile.name"', |
|
298 | + 'default' => $this->organization_config->get_pretty('facebook'), |
|
299 | + 'required' => false, |
|
300 | + ) |
|
301 | + ), |
|
302 | + 'organization_twitter' => new EE_Text_Input( |
|
303 | + array( |
|
304 | + 'html_name' => 'organization_twitter', |
|
305 | + 'html_label_text' => esc_html__('Twitter', 'event_espresso'), |
|
306 | + 'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"', |
|
307 | + 'default' => $this->organization_config->get_pretty('twitter'), |
|
308 | + 'required' => false, |
|
309 | + ) |
|
310 | + ), |
|
311 | + 'organization_linkedin' => new EE_Text_Input( |
|
312 | + array( |
|
313 | + 'html_name' => 'organization_linkedin', |
|
314 | + 'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), |
|
315 | + 'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"', |
|
316 | + 'default' => $this->organization_config->get_pretty('linkedin'), |
|
317 | + 'required' => false, |
|
318 | + ) |
|
319 | + ), |
|
320 | + 'organization_pinterest' => new EE_Text_Input( |
|
321 | + array( |
|
322 | + 'html_name' => 'organization_pinterest', |
|
323 | + 'html_label_text' => esc_html__('Pinterest', 'event_espresso'), |
|
324 | + 'other_html_attributes' => ' placeholder="pinterest.com/profilename"', |
|
325 | + 'default' => $this->organization_config->get_pretty('pinterest'), |
|
326 | + 'required' => false, |
|
327 | + ) |
|
328 | + ), |
|
329 | + 'organization_instagram' => new EE_Text_Input( |
|
330 | + array( |
|
331 | + 'html_name' => 'organization_instagram', |
|
332 | + 'html_label_text' => esc_html__('Instagram', 'event_espresso'), |
|
333 | + 'other_html_attributes' => ' placeholder="instagram.com/handle"', |
|
334 | + 'default' => $this->organization_config->get_pretty('instagram'), |
|
335 | + 'required' => false, |
|
336 | + ) |
|
337 | + ), |
|
338 | + ), |
|
339 | + ) |
|
340 | + ); |
|
341 | + if (is_main_site()) { |
|
342 | + $form->add_subsections( |
|
343 | + array( |
|
344 | + 'site_license_key_hdr' => new EE_Form_Section_HTML( |
|
345 | + EEH_HTML::h2( |
|
346 | + esc_html__('Your Event Espresso License Key', 'event_espresso') |
|
347 | + . ' ' |
|
348 | + . EEH_HTML::span( |
|
349 | + EEH_Template::get_help_tab_link('site_license_key_info') |
|
350 | + ), |
|
351 | + '', |
|
352 | + 'site-license-key-hdr' |
|
353 | + ) |
|
354 | + ), |
|
355 | + 'site_license_key' => $this->getSiteLicenseKeyField() |
|
356 | + ) |
|
357 | + ); |
|
358 | + $form->add_subsections( |
|
359 | + array( |
|
360 | + 'uxip_optin_hdr' => new EE_Form_Section_HTML( |
|
361 | + $this->uxipOptinText() |
|
362 | + ), |
|
363 | + 'ueip_optin' => new EE_Checkbox_Multi_Input( |
|
364 | + array( |
|
365 | + true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso') |
|
366 | + ), |
|
367 | + array( |
|
368 | + 'html_name' => EE_Core_Config::OPTION_NAME_UXIP, |
|
369 | + 'html_label_text' => esc_html__( |
|
370 | + 'UXIP Opt In?', |
|
371 | + 'event_espresso' |
|
372 | + ), |
|
373 | + 'default' => isset($this->core_config->ee_ueip_optin) |
|
374 | + ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN) |
|
375 | + : false, |
|
376 | + 'required' => false, |
|
377 | + ) |
|
378 | + ), |
|
379 | + ), |
|
380 | + 'organization_instagram', |
|
381 | + false |
|
382 | + ); |
|
383 | + } |
|
384 | + return $form; |
|
385 | + } |
|
386 | 386 | |
387 | 387 | |
388 | - /** |
|
389 | - * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
390 | - * returns a string of HTML that can be directly echoed in a template |
|
391 | - * |
|
392 | - * @return string |
|
393 | - * @throws EE_Error |
|
394 | - * @throws InvalidArgumentException |
|
395 | - * @throws InvalidDataTypeException |
|
396 | - * @throws InvalidInterfaceException |
|
397 | - * @throws LogicException |
|
398 | - */ |
|
399 | - public function display() |
|
400 | - { |
|
401 | - $this->form()->enqueue_js(); |
|
402 | - return parent::display(); |
|
403 | - } |
|
388 | + /** |
|
389 | + * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
390 | + * returns a string of HTML that can be directly echoed in a template |
|
391 | + * |
|
392 | + * @return string |
|
393 | + * @throws EE_Error |
|
394 | + * @throws InvalidArgumentException |
|
395 | + * @throws InvalidDataTypeException |
|
396 | + * @throws InvalidInterfaceException |
|
397 | + * @throws LogicException |
|
398 | + */ |
|
399 | + public function display() |
|
400 | + { |
|
401 | + $this->form()->enqueue_js(); |
|
402 | + return parent::display(); |
|
403 | + } |
|
404 | 404 | |
405 | 405 | |
406 | - /** |
|
407 | - * handles processing the form submission |
|
408 | - * returns true or false depending on whether the form was processed successfully or not |
|
409 | - * |
|
410 | - * @param array $form_data |
|
411 | - * @return bool |
|
412 | - * @throws InvalidFormSubmissionException |
|
413 | - * @throws EE_Error |
|
414 | - * @throws LogicException |
|
415 | - * @throws InvalidArgumentException |
|
416 | - * @throws InvalidDataTypeException |
|
417 | - * @throws ReflectionException |
|
418 | - */ |
|
419 | - public function process($form_data = array()) |
|
420 | - { |
|
421 | - // process form |
|
422 | - $valid_data = (array) parent::process($form_data); |
|
423 | - if (empty($valid_data)) { |
|
424 | - return false; |
|
425 | - } |
|
406 | + /** |
|
407 | + * handles processing the form submission |
|
408 | + * returns true or false depending on whether the form was processed successfully or not |
|
409 | + * |
|
410 | + * @param array $form_data |
|
411 | + * @return bool |
|
412 | + * @throws InvalidFormSubmissionException |
|
413 | + * @throws EE_Error |
|
414 | + * @throws LogicException |
|
415 | + * @throws InvalidArgumentException |
|
416 | + * @throws InvalidDataTypeException |
|
417 | + * @throws ReflectionException |
|
418 | + */ |
|
419 | + public function process($form_data = array()) |
|
420 | + { |
|
421 | + // process form |
|
422 | + $valid_data = (array) parent::process($form_data); |
|
423 | + if (empty($valid_data)) { |
|
424 | + return false; |
|
425 | + } |
|
426 | 426 | |
427 | - if (is_main_site()) { |
|
428 | - $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key']) |
|
429 | - ? sanitize_text_field($form_data['ee_site_license_key']) |
|
430 | - : $this->network_core_config->site_license_key; |
|
431 | - } |
|
432 | - $this->organization_config->name = isset($form_data['organization_name']) |
|
433 | - ? sanitize_text_field($form_data['organization_name']) |
|
434 | - : $this->organization_config->name; |
|
435 | - $this->organization_config->address_1 = isset($form_data['organization_address_1']) |
|
436 | - ? sanitize_text_field($form_data['organization_address_1']) |
|
437 | - : $this->organization_config->address_1; |
|
438 | - $this->organization_config->address_2 = isset($form_data['organization_address_2']) |
|
439 | - ? sanitize_text_field($form_data['organization_address_2']) |
|
440 | - : $this->organization_config->address_2; |
|
441 | - $this->organization_config->city = isset($form_data['organization_city']) |
|
442 | - ? sanitize_text_field($form_data['organization_city']) |
|
443 | - : $this->organization_config->city; |
|
444 | - $this->organization_config->STA_ID = isset($form_data['organization_state']) |
|
445 | - ? absint($form_data['organization_state']) |
|
446 | - : $this->organization_config->STA_ID; |
|
447 | - $this->organization_config->CNT_ISO = isset($form_data['organization_country']) |
|
448 | - ? sanitize_text_field($form_data['organization_country']) |
|
449 | - : $this->organization_config->CNT_ISO; |
|
450 | - $this->organization_config->zip = isset($form_data['organization_zip']) |
|
451 | - ? sanitize_text_field($form_data['organization_zip']) |
|
452 | - : $this->organization_config->zip; |
|
453 | - $this->organization_config->email = isset($form_data['organization_email']) |
|
454 | - ? sanitize_email($form_data['organization_email']) |
|
455 | - : $this->organization_config->email; |
|
456 | - $this->organization_config->vat = isset($form_data['organization_vat']) |
|
457 | - ? sanitize_text_field($form_data['organization_vat']) |
|
458 | - : $this->organization_config->vat; |
|
459 | - $this->organization_config->phone = isset($form_data['organization_phone']) |
|
460 | - ? sanitize_text_field($form_data['organization_phone']) |
|
461 | - : $this->organization_config->phone; |
|
462 | - $this->organization_config->logo_url = isset($form_data['organization_logo_url']) |
|
463 | - ? esc_url_raw($form_data['organization_logo_url']) |
|
464 | - : $this->organization_config->logo_url; |
|
465 | - $this->organization_config->facebook = isset($form_data['organization_facebook']) |
|
466 | - ? esc_url_raw($form_data['organization_facebook']) |
|
467 | - : $this->organization_config->facebook; |
|
468 | - $this->organization_config->twitter = isset($form_data['organization_twitter']) |
|
469 | - ? esc_url_raw($form_data['organization_twitter']) |
|
470 | - : $this->organization_config->twitter; |
|
471 | - $this->organization_config->linkedin = isset($form_data['organization_linkedin']) |
|
472 | - ? esc_url_raw($form_data['organization_linkedin']) |
|
473 | - : $this->organization_config->linkedin; |
|
474 | - $this->organization_config->pinterest = isset($form_data['organization_pinterest']) |
|
475 | - ? esc_url_raw($form_data['organization_pinterest']) |
|
476 | - : $this->organization_config->pinterest; |
|
477 | - $this->organization_config->google = isset($form_data['organization_google']) |
|
478 | - ? esc_url_raw($form_data['organization_google']) |
|
479 | - : $this->organization_config->google; |
|
480 | - $this->organization_config->instagram = isset($form_data['organization_instagram']) |
|
481 | - ? esc_url_raw($form_data['organization_instagram']) |
|
482 | - : $this->organization_config->instagram; |
|
483 | - $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0]) |
|
484 | - ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN) |
|
485 | - : false; |
|
486 | - $this->core_config->ee_ueip_has_notified = true; |
|
427 | + if (is_main_site()) { |
|
428 | + $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key']) |
|
429 | + ? sanitize_text_field($form_data['ee_site_license_key']) |
|
430 | + : $this->network_core_config->site_license_key; |
|
431 | + } |
|
432 | + $this->organization_config->name = isset($form_data['organization_name']) |
|
433 | + ? sanitize_text_field($form_data['organization_name']) |
|
434 | + : $this->organization_config->name; |
|
435 | + $this->organization_config->address_1 = isset($form_data['organization_address_1']) |
|
436 | + ? sanitize_text_field($form_data['organization_address_1']) |
|
437 | + : $this->organization_config->address_1; |
|
438 | + $this->organization_config->address_2 = isset($form_data['organization_address_2']) |
|
439 | + ? sanitize_text_field($form_data['organization_address_2']) |
|
440 | + : $this->organization_config->address_2; |
|
441 | + $this->organization_config->city = isset($form_data['organization_city']) |
|
442 | + ? sanitize_text_field($form_data['organization_city']) |
|
443 | + : $this->organization_config->city; |
|
444 | + $this->organization_config->STA_ID = isset($form_data['organization_state']) |
|
445 | + ? absint($form_data['organization_state']) |
|
446 | + : $this->organization_config->STA_ID; |
|
447 | + $this->organization_config->CNT_ISO = isset($form_data['organization_country']) |
|
448 | + ? sanitize_text_field($form_data['organization_country']) |
|
449 | + : $this->organization_config->CNT_ISO; |
|
450 | + $this->organization_config->zip = isset($form_data['organization_zip']) |
|
451 | + ? sanitize_text_field($form_data['organization_zip']) |
|
452 | + : $this->organization_config->zip; |
|
453 | + $this->organization_config->email = isset($form_data['organization_email']) |
|
454 | + ? sanitize_email($form_data['organization_email']) |
|
455 | + : $this->organization_config->email; |
|
456 | + $this->organization_config->vat = isset($form_data['organization_vat']) |
|
457 | + ? sanitize_text_field($form_data['organization_vat']) |
|
458 | + : $this->organization_config->vat; |
|
459 | + $this->organization_config->phone = isset($form_data['organization_phone']) |
|
460 | + ? sanitize_text_field($form_data['organization_phone']) |
|
461 | + : $this->organization_config->phone; |
|
462 | + $this->organization_config->logo_url = isset($form_data['organization_logo_url']) |
|
463 | + ? esc_url_raw($form_data['organization_logo_url']) |
|
464 | + : $this->organization_config->logo_url; |
|
465 | + $this->organization_config->facebook = isset($form_data['organization_facebook']) |
|
466 | + ? esc_url_raw($form_data['organization_facebook']) |
|
467 | + : $this->organization_config->facebook; |
|
468 | + $this->organization_config->twitter = isset($form_data['organization_twitter']) |
|
469 | + ? esc_url_raw($form_data['organization_twitter']) |
|
470 | + : $this->organization_config->twitter; |
|
471 | + $this->organization_config->linkedin = isset($form_data['organization_linkedin']) |
|
472 | + ? esc_url_raw($form_data['organization_linkedin']) |
|
473 | + : $this->organization_config->linkedin; |
|
474 | + $this->organization_config->pinterest = isset($form_data['organization_pinterest']) |
|
475 | + ? esc_url_raw($form_data['organization_pinterest']) |
|
476 | + : $this->organization_config->pinterest; |
|
477 | + $this->organization_config->google = isset($form_data['organization_google']) |
|
478 | + ? esc_url_raw($form_data['organization_google']) |
|
479 | + : $this->organization_config->google; |
|
480 | + $this->organization_config->instagram = isset($form_data['organization_instagram']) |
|
481 | + ? esc_url_raw($form_data['organization_instagram']) |
|
482 | + : $this->organization_config->instagram; |
|
483 | + $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0]) |
|
484 | + ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN) |
|
485 | + : false; |
|
486 | + $this->core_config->ee_ueip_has_notified = true; |
|
487 | 487 | |
488 | - $this->registry->CFG->currency = new EE_Currency_Config( |
|
489 | - $this->organization_config->CNT_ISO |
|
490 | - ); |
|
491 | - /** @var EE_Country $country */ |
|
492 | - $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO); |
|
493 | - if ($country instanceof EE_Country) { |
|
494 | - $country->set('CNT_active', 1); |
|
495 | - $country->save(); |
|
496 | - $this->countrySubRegionDao->saveCountrySubRegions($country); |
|
497 | - } |
|
498 | - return true; |
|
499 | - } |
|
488 | + $this->registry->CFG->currency = new EE_Currency_Config( |
|
489 | + $this->organization_config->CNT_ISO |
|
490 | + ); |
|
491 | + /** @var EE_Country $country */ |
|
492 | + $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO); |
|
493 | + if ($country instanceof EE_Country) { |
|
494 | + $country->set('CNT_active', 1); |
|
495 | + $country->save(); |
|
496 | + $this->countrySubRegionDao->saveCountrySubRegions($country); |
|
497 | + } |
|
498 | + return true; |
|
499 | + } |
|
500 | 500 | |
501 | 501 | |
502 | - /** |
|
503 | - * @return string |
|
504 | - */ |
|
505 | - private function uxipOptinText() |
|
506 | - { |
|
507 | - ob_start(); |
|
508 | - Stats::optinText(false); |
|
509 | - return ob_get_clean(); |
|
510 | - } |
|
502 | + /** |
|
503 | + * @return string |
|
504 | + */ |
|
505 | + private function uxipOptinText() |
|
506 | + { |
|
507 | + ob_start(); |
|
508 | + Stats::optinText(false); |
|
509 | + return ob_get_clean(); |
|
510 | + } |
|
511 | 511 | |
512 | 512 | |
513 | - /** |
|
514 | - * Return whether the site license key has been verified or not. |
|
515 | - * @return bool |
|
516 | - */ |
|
517 | - private function licenseKeyVerified() |
|
518 | - { |
|
519 | - if (empty($this->network_core_config->site_license_key)) { |
|
520 | - return false; |
|
521 | - } |
|
522 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
523 | - $verify_fail = get_option($ver_option_key, false); |
|
524 | - return $verify_fail === false |
|
525 | - || (! empty($this->network_core_config->site_license_key) |
|
526 | - && $verify_fail === false |
|
527 | - ); |
|
528 | - } |
|
513 | + /** |
|
514 | + * Return whether the site license key has been verified or not. |
|
515 | + * @return bool |
|
516 | + */ |
|
517 | + private function licenseKeyVerified() |
|
518 | + { |
|
519 | + if (empty($this->network_core_config->site_license_key)) { |
|
520 | + return false; |
|
521 | + } |
|
522 | + $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
523 | + $verify_fail = get_option($ver_option_key, false); |
|
524 | + return $verify_fail === false |
|
525 | + || (! empty($this->network_core_config->site_license_key) |
|
526 | + && $verify_fail === false |
|
527 | + ); |
|
528 | + } |
|
529 | 529 | |
530 | 530 | |
531 | - /** |
|
532 | - * @return EE_Text_Input |
|
533 | - */ |
|
534 | - private function getSiteLicenseKeyField() |
|
535 | - { |
|
536 | - $text_input = new EE_Text_Input( |
|
537 | - array( |
|
538 | - 'html_name' => 'ee_site_license_key', |
|
539 | - 'html_id' => 'site_license_key', |
|
540 | - 'html_label_text' => esc_html__('Support License Key', 'event_espresso'), |
|
541 | - /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */ |
|
542 | - 'html_help_text' => sprintf( |
|
543 | - esc_html__( |
|
544 | - 'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.', |
|
545 | - 'event_espresso' |
|
546 | - ), |
|
547 | - '<strong>', |
|
548 | - '</strong>' |
|
549 | - ), |
|
550 | - /** phpcs:enable */ |
|
551 | - 'default' => isset($this->network_core_config->site_license_key) |
|
552 | - ? $this->network_core_config->site_license_key |
|
553 | - : '', |
|
554 | - 'required' => false, |
|
555 | - 'form_html_filter' => new VsprintfFilter( |
|
556 | - '%2$s %1$s', |
|
557 | - array($this->getValidationIndicator()) |
|
558 | - ) |
|
559 | - ) |
|
560 | - ); |
|
561 | - return $text_input; |
|
562 | - } |
|
531 | + /** |
|
532 | + * @return EE_Text_Input |
|
533 | + */ |
|
534 | + private function getSiteLicenseKeyField() |
|
535 | + { |
|
536 | + $text_input = new EE_Text_Input( |
|
537 | + array( |
|
538 | + 'html_name' => 'ee_site_license_key', |
|
539 | + 'html_id' => 'site_license_key', |
|
540 | + 'html_label_text' => esc_html__('Support License Key', 'event_espresso'), |
|
541 | + /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */ |
|
542 | + 'html_help_text' => sprintf( |
|
543 | + esc_html__( |
|
544 | + 'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.', |
|
545 | + 'event_espresso' |
|
546 | + ), |
|
547 | + '<strong>', |
|
548 | + '</strong>' |
|
549 | + ), |
|
550 | + /** phpcs:enable */ |
|
551 | + 'default' => isset($this->network_core_config->site_license_key) |
|
552 | + ? $this->network_core_config->site_license_key |
|
553 | + : '', |
|
554 | + 'required' => false, |
|
555 | + 'form_html_filter' => new VsprintfFilter( |
|
556 | + '%2$s %1$s', |
|
557 | + array($this->getValidationIndicator()) |
|
558 | + ) |
|
559 | + ) |
|
560 | + ); |
|
561 | + return $text_input; |
|
562 | + } |
|
563 | 563 | |
564 | 564 | |
565 | - /** |
|
566 | - * @return string |
|
567 | - */ |
|
568 | - private function getValidationIndicator() |
|
569 | - { |
|
570 | - $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red'; |
|
571 | - return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>'; |
|
572 | - } |
|
565 | + /** |
|
566 | + * @return string |
|
567 | + */ |
|
568 | + private function getValidationIndicator() |
|
569 | + { |
|
570 | + $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red'; |
|
571 | + return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>'; |
|
572 | + } |
|
573 | 573 | } |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php esc_html_e( |
12 | - 'Select your country from the dropdown field. Selecting a different country will partially re-load the page and show updated information.', |
|
13 | - 'event_espresso' |
|
14 | - ); ?> |
|
12 | + 'Select your country from the dropdown field. Selecting a different country will partially re-load the page and show updated information.', |
|
13 | + 'event_espresso' |
|
14 | + ); ?> |
|
15 | 15 | </p> |
16 | 16 | <p class="ee-attention"> |
17 | 17 | <?php esc_html_e( |
18 | - 'Notice: Certain options in Country Details and States/Provinces use a 1 or 0 to indicate a selection. A value of 1 equals yes. A value of 0 equals no.', |
|
19 | - 'event_espresso' |
|
20 | - ); ?> |
|
18 | + 'Notice: Certain options in Country Details and States/Provinces use a 1 or 0 to indicate a selection. A value of 1 equals yes. A value of 0 equals no.', |
|
19 | + 'event_espresso' |
|
20 | + ); ?> |
|
21 | 21 | </p> |
22 | 22 | <p> |
23 | 23 | <strong><?php esc_html_e('Country Details', 'event_espresso'); ?></strong> |
@@ -26,32 +26,32 @@ discard block |
||
26 | 26 | <?php esc_html_e('Fine tune currency and contact data for your own country.', 'event_espresso'); ?> |
27 | 27 | <br /> |
28 | 28 | <?php esc_html_e( |
29 | - 'Your country selection affects the currency that is used throughout Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP. If you do change your country, be sure to update your contact information on the Your Organization page. This will ensure that your currency and organization information is up-to-date throughout Event Espresso.', |
|
30 | - 'event_espresso' |
|
31 | - ); ?> |
|
29 | + 'Your country selection affects the currency that is used throughout Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP. If you do change your country, be sure to update your contact information on the Your Organization page. This will ensure that your currency and organization information is up-to-date throughout Event Espresso.', |
|
30 | + 'event_espresso' |
|
31 | + ); ?> |
|
32 | 32 | </p> |
33 | 33 | <p> |
34 | 34 | <strong><?php esc_html_e('States/Provinces', 'event_espresso'); ?></strong> |
35 | 35 | </p> |
36 | 36 | <p> |
37 | 37 | <?php esc_html_e( |
38 | - 'Define the states/provinces that are used in Event Espresso. New states / provinces can be added using the Add New State/Province field.', |
|
39 | - 'event_espresso' |
|
40 | - ); ?> |
|
38 | + 'Define the states/provinces that are used in Event Espresso. New states / provinces can be added using the Add New State/Province field.', |
|
39 | + 'event_espresso' |
|
40 | + ); ?> |
|
41 | 41 | </p> |
42 | 42 | <p> |
43 | 43 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
44 | 44 | <br /> |
45 | 45 | <?php esc_html_e( |
46 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
47 | - 'event_espresso' |
|
48 | - ); ?> |
|
46 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
47 | + 'event_espresso' |
|
48 | + ); ?> |
|
49 | 49 | </p> |
50 | 50 | <p> |
51 | 51 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
52 | 52 | <br /> |
53 | 53 | <?php esc_html_e( |
54 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
55 | - 'event_espresso' |
|
56 | - ); ?> |
|
54 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
55 | + 'event_espresso' |
|
56 | + ); ?> |
|
57 | 57 | </p> |
58 | 58 | \ No newline at end of file |
@@ -9,77 +9,77 @@ |
||
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php printf( |
12 | - esc_html__( |
|
13 | - 'Enter your support license key in this field to benefit from one-click updates. To manage your support license key, please %1$slogin to your Event Espresso account%2$s. Then click on Edit Account Details which appears in the left sidebar menu.', |
|
14 | - 'event_espresso' |
|
15 | - ), |
|
16 | - '<a href="https://eventespresso.com/wp-login.php">', |
|
17 | - '</a>' |
|
18 | - );?> |
|
12 | + esc_html__( |
|
13 | + 'Enter your support license key in this field to benefit from one-click updates. To manage your support license key, please %1$slogin to your Event Espresso account%2$s. Then click on Edit Account Details which appears in the left sidebar menu.', |
|
14 | + 'event_espresso' |
|
15 | + ), |
|
16 | + '<a href="https://eventespresso.com/wp-login.php">', |
|
17 | + '</a>' |
|
18 | + );?> |
|
19 | 19 | </p> |
20 | 20 | <p class="ee-attention"> |
21 | 21 | <?php printf( |
22 | - esc_html__( |
|
23 | - 'Site license keys are now called support license keys. Your support license key should only be entered on live/production sites. If this is a development or test site, %sdo not%s enter your support license key.', |
|
24 | - 'event_espresso' |
|
25 | - ), |
|
26 | - '<strong>', |
|
27 | - '</strong>' |
|
28 | - ); ?> |
|
22 | + esc_html__( |
|
23 | + 'Site license keys are now called support license keys. Your support license key should only be entered on live/production sites. If this is a development or test site, %sdo not%s enter your support license key.', |
|
24 | + 'event_espresso' |
|
25 | + ), |
|
26 | + '<strong>', |
|
27 | + '</strong>' |
|
28 | + ); ?> |
|
29 | 29 | </p> |
30 | 30 | <p> |
31 | 31 | <strong><?php esc_html_e('Contact Information', 'event_espresso'); ?></strong> |
32 | 32 | </p> |
33 | 33 | <p> |
34 | 34 | <?php esc_html_e( |
35 | - 'Enter information about your organization here. Be sure to keep your information up-to-date.', |
|
36 | - 'event_espresso' |
|
37 | - ); ?><br /> |
|
35 | + 'Enter information about your organization here. Be sure to keep your information up-to-date.', |
|
36 | + 'event_espresso' |
|
37 | + ); ?><br /> |
|
38 | 38 | <?php esc_html_e( |
39 | - 'Changing your country on this page will also change your country on the Countries page. This will affect your currency options which are used through Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?> |
|
39 | + 'Changing your country on this page will also change your country on the Countries page. This will affect your currency options which are used through Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?> |
|
42 | 42 | </p> |
43 | 43 | <p> |
44 | 44 | <strong><?php esc_html_e('Company Logo', 'event_espresso'); ?></strong> |
45 | 45 | </p> |
46 | 46 | <p> |
47 | 47 | <?php esc_html_e( |
48 | - 'You can upload a new logo here. We recommend an image that is 400 pixels wide or smaller. Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
49 | - 'event_espresso' |
|
50 | - ); ?> |
|
48 | + 'You can upload a new logo here. We recommend an image that is 400 pixels wide or smaller. Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
49 | + 'event_espresso' |
|
50 | + ); ?> |
|
51 | 51 | </p> |
52 | 52 | <p> |
53 | 53 | <strong><?php esc_html_e('Social Links', 'event_espresso'); ?></strong> |
54 | 54 | </p> |
55 | 55 | <p> |
56 | 56 | <?php esc_html_e( |
57 | - 'These URLs can be displayed automatically within your emails (using shortcodes) and front-end templates (using template tags).', |
|
58 | - 'event_espresso' |
|
59 | - ); ?> |
|
57 | + 'These URLs can be displayed automatically within your emails (using shortcodes) and front-end templates (using template tags).', |
|
58 | + 'event_espresso' |
|
59 | + ); ?> |
|
60 | 60 | </p> |
61 | 61 | <p> |
62 | 62 | <strong><?php esc_html_e('User eXperience Improvement Program (UXIP)', 'event_espresso'); ?></strong> |
63 | 63 | </p> |
64 | 64 | <p> |
65 | 65 | <?php esc_html_e( |
66 | - 'You can take part in making Event Espresso better! Your information will never be sold, traded, or misused in any way. This programs is voluntary and you can opt out at any time.', |
|
67 | - 'event_espresso' |
|
68 | - ); ?> |
|
66 | + 'You can take part in making Event Espresso better! Your information will never be sold, traded, or misused in any way. This programs is voluntary and you can opt out at any time.', |
|
67 | + 'event_espresso' |
|
68 | + ); ?> |
|
69 | 69 | </p> |
70 | 70 | <p> |
71 | 71 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
72 | 72 | <br /> |
73 | 73 | <?php esc_html_e( |
74 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
75 | - 'event_espresso' |
|
76 | - ); ?> |
|
74 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
75 | + 'event_espresso' |
|
76 | + ); ?> |
|
77 | 77 | </p> |
78 | 78 | <p> |
79 | 79 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
80 | 80 | <br /> |
81 | 81 | <?php esc_html_e( |
82 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
83 | - 'event_espresso' |
|
84 | - ); ?> |
|
82 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
83 | + 'event_espresso' |
|
84 | + ); ?> |
|
85 | 85 | </p> |
86 | 86 | \ No newline at end of file |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'This page shows all critical pages that Event Espresso needs to work correctly.', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'This page shows all critical pages that Event Espresso needs to work correctly.', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | <p><strong><?php esc_html_e('Shortcodes', 'event_espresso'); ?></strong></p> |
11 | 11 | <ul> |
@@ -13,77 +13,77 @@ discard block |
||
13 | 13 | <strong><?php esc_html_e('Registration Checkout Page', 'event_espresso'); ?></strong> |
14 | 14 | <br /> |
15 | 15 | <?php printf( |
16 | - esc_html__( |
|
17 | - 'This page displays all your events and is required. It is important that this page always contain the %s shortcode. It is not required to be in your navigation menu.', |
|
18 | - 'event_espresso' |
|
19 | - ), |
|
20 | - '<strong>[ESPRESSO_CHECKOUT]</strong>' |
|
21 | - ); ?> |
|
16 | + esc_html__( |
|
17 | + 'This page displays all your events and is required. It is important that this page always contain the %s shortcode. It is not required to be in your navigation menu.', |
|
18 | + 'event_espresso' |
|
19 | + ), |
|
20 | + '<strong>[ESPRESSO_CHECKOUT]</strong>' |
|
21 | + ); ?> |
|
22 | 22 | </li> |
23 | 23 | <li> |
24 | 24 | <strong><?php esc_html_e('Transactions Page', 'event_espresso'); ?></strong> |
25 | 25 | <br /> |
26 | 26 | <?php printf( |
27 | - esc_html__( |
|
28 | - 'This page processes the payments and is required. It should only contain the %s shortcode. No other content should be added and it should be hidden from your navigation menu.', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - '<strong>[ESPRESSO_TXN_PAGE]</strong>' |
|
32 | - ); ?> |
|
27 | + esc_html__( |
|
28 | + 'This page processes the payments and is required. It should only contain the %s shortcode. No other content should be added and it should be hidden from your navigation menu.', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + '<strong>[ESPRESSO_TXN_PAGE]</strong>' |
|
32 | + ); ?> |
|
33 | 33 | </li> |
34 | 34 | <li> |
35 | 35 | <strong><?php esc_html_e('Thank You Page', 'event_espresso'); ?></strong> |
36 | 36 | <br /> |
37 | 37 | <?php printf( |
38 | - esc_html__( |
|
39 | - 'This page is displayed after a successful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', |
|
40 | - 'event_espresso' |
|
41 | - ), |
|
42 | - '<strong>[ESPRESSO_THANK_YOU]</strong>' |
|
43 | - ); ?> |
|
38 | + esc_html__( |
|
39 | + 'This page is displayed after a successful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', |
|
40 | + 'event_espresso' |
|
41 | + ), |
|
42 | + '<strong>[ESPRESSO_THANK_YOU]</strong>' |
|
43 | + ); ?> |
|
44 | 44 | </li> |
45 | 45 | <li> |
46 | 46 | <strong><?php esc_html_e('Cancel / Return Page', 'event_espresso'); ?></strong> |
47 | 47 | <br /> |
48 | 48 | <?php printf( |
49 | - esc_html__( |
|
50 | - 'This page is displayed after an unsuccessful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', |
|
51 | - 'event_espresso' |
|
52 | - ), |
|
53 | - '<strong>[ESPRESSO_CANCELLED]</strong>' |
|
54 | - ); ?> |
|
49 | + esc_html__( |
|
50 | + 'This page is displayed after an unsuccessful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', |
|
51 | + 'event_espresso' |
|
52 | + ), |
|
53 | + '<strong>[ESPRESSO_CANCELLED]</strong>' |
|
54 | + ); ?> |
|
55 | 55 | </li> |
56 | 56 | <li> |
57 | 57 | <strong><?php esc_html_e('Event List', 'event_espresso'); ?></strong> |
58 | 58 | <br /> |
59 | 59 | <?php printf( |
60 | - esc_html__( |
|
61 | - 'If you would like to style the look of your events archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', |
|
62 | - 'event_espresso' |
|
63 | - ), |
|
64 | - '<a href="https://codex.wordpress.org/Post_Type_Templates">', |
|
65 | - '</a>' |
|
66 | - ); ?> |
|
60 | + esc_html__( |
|
61 | + 'If you would like to style the look of your events archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', |
|
62 | + 'event_espresso' |
|
63 | + ), |
|
64 | + '<a href="https://codex.wordpress.org/Post_Type_Templates">', |
|
65 | + '</a>' |
|
66 | + ); ?> |
|
67 | 67 | <ul> |
68 | 68 | <li style="list-style-type: circle;"> |
69 | 69 | <?php printf( |
70 | - esc_html__( |
|
71 | - 'Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
72 | - 'event_espresso' |
|
73 | - ), |
|
74 | - '<strong>archive-espresso_events.php</strong>', |
|
75 | - 'wp-content/themes/twenty-fourteen' |
|
76 | - ); ?> |
|
70 | + esc_html__( |
|
71 | + 'Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
72 | + 'event_espresso' |
|
73 | + ), |
|
74 | + '<strong>archive-espresso_events.php</strong>', |
|
75 | + 'wp-content/themes/twenty-fourteen' |
|
76 | + ); ?> |
|
77 | 77 | </li> |
78 | 78 | <li style="list-style-type: circle;"> |
79 | 79 | <?php printf( |
80 | - esc_html__( |
|
81 | - 'Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
82 | - 'event_espresso' |
|
83 | - ), |
|
84 | - '<strong>single-espresso_events.php</strong>', |
|
85 | - 'wp-content/themes/twenty-fourteen' |
|
86 | - ); ?> |
|
80 | + esc_html__( |
|
81 | + 'Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
82 | + 'event_espresso' |
|
83 | + ), |
|
84 | + '<strong>single-espresso_events.php</strong>', |
|
85 | + 'wp-content/themes/twenty-fourteen' |
|
86 | + ); ?> |
|
87 | 87 | </li> |
88 | 88 | </ul> |
89 | 89 | </li> |
@@ -91,33 +91,33 @@ discard block |
||
91 | 91 | <strong><?php esc_html_e('Venue List', 'event_espresso'); ?></strong> |
92 | 92 | <br /> |
93 | 93 | <?php printf( |
94 | - esc_html__( |
|
95 | - 'If you would like to style the look of your venues archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', |
|
96 | - 'event_espresso' |
|
97 | - ), |
|
98 | - '<a href="https://codex.wordpress.org/Post_Type_Templates">', |
|
99 | - '</a>' |
|
100 | - ); ?> |
|
94 | + esc_html__( |
|
95 | + 'If you would like to style the look of your venues archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', |
|
96 | + 'event_espresso' |
|
97 | + ), |
|
98 | + '<a href="https://codex.wordpress.org/Post_Type_Templates">', |
|
99 | + '</a>' |
|
100 | + ); ?> |
|
101 | 101 | <ul> |
102 | 102 | <li style="list-style-type: circle;"> |
103 | 103 | <?php printf( |
104 | - esc_html__( |
|
105 | - 'Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
106 | - 'event_espresso' |
|
107 | - ), |
|
108 | - '<strong>archive-espresso_venues.php</strong>', |
|
109 | - 'wp-content/themes/twenty-fourteen' |
|
110 | - ); ?> |
|
104 | + esc_html__( |
|
105 | + 'Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
106 | + 'event_espresso' |
|
107 | + ), |
|
108 | + '<strong>archive-espresso_venues.php</strong>', |
|
109 | + 'wp-content/themes/twenty-fourteen' |
|
110 | + ); ?> |
|
111 | 111 | </li> |
112 | 112 | <li style="list-style-type: circle;"> |
113 | 113 | <?php printf( |
114 | - esc_html__( |
|
115 | - 'Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
116 | - 'event_espresso' |
|
117 | - ), |
|
118 | - '<strong>single-espresso_venues.php</strong>', |
|
119 | - 'wp-content/themes/twenty-fourteen' |
|
120 | - ); ?> |
|
114 | + esc_html__( |
|
115 | + 'Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
116 | + 'event_espresso' |
|
117 | + ), |
|
118 | + '<strong>single-espresso_venues.php</strong>', |
|
119 | + 'wp-content/themes/twenty-fourteen' |
|
120 | + ); ?> |
|
121 | 121 | </li> |
122 | 122 | </ul> |
123 | 123 | </li> |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
128 | 128 | <br /> |
129 | 129 | <?php esc_html_e( |
130 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
131 | - 'event_espresso' |
|
132 | - ); ?> |
|
130 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
131 | + 'event_espresso' |
|
132 | + ); ?> |
|
133 | 133 | </p> |
134 | 134 | <p> |
135 | 135 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
136 | 136 | <br /> |
137 | 137 | <?php esc_html_e( |
138 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
139 | - 'event_espresso' |
|
140 | - ); ?> |
|
138 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
139 | + 'event_espresso' |
|
140 | + ); ?> |
|
141 | 141 | </p> |
142 | 142 | \ No newline at end of file |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | </p> |
8 | 8 | <p class="ee-attention"> |
9 | 9 | <?php esc_html_e( |
10 | - 'Notice: Your log files may be publicly accessible. Logging should be turned off when its not needed.', |
|
11 | - 'event_espresso' |
|
12 | - ); ?> |
|
10 | + 'Notice: Your log files may be publicly accessible. Logging should be turned off when its not needed.', |
|
11 | + 'event_espresso' |
|
12 | + ); ?> |
|
13 | 13 | </p> |
14 | 14 | <ul> |
15 | 15 | <li> |
16 | 16 | <strong><?php esc_html_e('Enable Remote Logging', 'event_espresso'); ?></strong><br /> |
17 | 17 | <?php esc_html_e( |
18 | - 'Every time a page is accessed on your site, this option will send all Event Espresso registration form data, your server details, and debugging information to a remote server.', |
|
19 | - 'event_espresso' |
|
20 | - ); ?> |
|
18 | + 'Every time a page is accessed on your site, this option will send all Event Espresso registration form data, your server details, and debugging information to a remote server.', |
|
19 | + 'event_espresso' |
|
20 | + ); ?> |
|
21 | 21 | </li> |
22 | 22 | <li> |
23 | 23 | <strong><?php esc_html_e('Remote Logging URL', 'event_espresso'); ?></strong><br /> |
24 | 24 | <?php esc_html_e( |
25 | - 'This option sends all Event Espresso debugging data and get / post variables to the specified URL.', |
|
26 | - 'event_espresso' |
|
27 | - ); ?> |
|
25 | + 'This option sends all Event Espresso debugging data and get / post variables to the specified URL.', |
|
26 | + 'event_espresso' |
|
27 | + ); ?> |
|
28 | 28 | </li> |
29 | 29 | <li> |
30 | 30 | <strong><?php esc_html_e('Send Login Information (Optional)', 'event_espresso'); ?></strong><br /> |
31 | 31 | <?php esc_html_e( |
32 | - 'By using constants in th wp-config.php file, you can send a "key" and "pass" parameters in the remote logging action.', |
|
33 | - 'event_espresso' |
|
34 | - ); ?> |
|
32 | + 'By using constants in th wp-config.php file, you can send a "key" and "pass" parameters in the remote logging action.', |
|
33 | + 'event_espresso' |
|
34 | + ); ?> |
|
35 | 35 | <?php esc_html_e( |
36 | - 'Add the constants below to your wp-config.php file, above the line that says "That\'s all, stop editing! Happy blogging."', |
|
37 | - 'event_espresso' |
|
38 | - ); ?> |
|
36 | + 'Add the constants below to your wp-config.php file, above the line that says "That\'s all, stop editing! Happy blogging."', |
|
37 | + 'event_espresso' |
|
38 | + ); ?> |
|
39 | 39 | <pre> |
40 | 40 | define( 'EELOGGING_PASS', 'YOUR PASSWORD' ); |
41 | 41 | define( 'EELOGGING_KEY', 'YOUR REMOTE KEY' ); |
@@ -48,39 +48,39 @@ discard block |
||
48 | 48 | <ul> |
49 | 49 | <li> |
50 | 50 | <strong><?php esc_html_e( |
51 | - 'Link to Event Espresso in your Registration Page?', |
|
52 | - 'event_espresso' |
|
53 | - ); ?> |
|
51 | + 'Link to Event Espresso in your Registration Page?', |
|
52 | + 'event_espresso' |
|
53 | + ); ?> |
|
54 | 54 | </strong> |
55 | 55 | <br /> |
56 | 56 | <?php esc_html_e( |
57 | - 'Help spread the word about Event Espresso by allowing us to show a small link back to the to Event Espresso website in your registration page.', |
|
58 | - 'event_espresso' |
|
59 | - ); ?> |
|
57 | + 'Help spread the word about Event Espresso by allowing us to show a small link back to the to Event Espresso website in your registration page.', |
|
58 | + 'event_espresso' |
|
59 | + ); ?> |
|
60 | 60 | </li> |
61 | 61 | <li> |
62 | 62 | <strong><?php esc_html_e('Event Espresso Affiliate ID', 'event_espresso'); ?></strong><br /> |
63 | 63 | <?php printf( |
64 | - esc_html__( |
|
65 | - 'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - '<a href="https://eventespresso.com/affiliates/">', |
|
69 | - '</a>' |
|
70 | - ); ?> |
|
64 | + esc_html__( |
|
65 | + 'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + '<a href="https://eventespresso.com/affiliates/">', |
|
69 | + '</a>' |
|
70 | + ); ?> |
|
71 | 71 | </li> |
72 | 72 | </ul> |
73 | 73 | <p> |
74 | 74 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
75 | 75 | <?php esc_html_e( |
76 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
77 | - 'event_espresso' |
|
78 | - ); ?> |
|
76 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
77 | + 'event_espresso' |
|
78 | + ); ?> |
|
79 | 79 | </p> |
80 | 80 | <p> |
81 | 81 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong><br /> |
82 | 82 | <?php esc_html_e( |
83 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
84 | - 'event_espresso' |
|
85 | - ); ?> |
|
83 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
84 | + 'event_espresso' |
|
85 | + ); ?> |
|
86 | 86 | </p> |
@@ -17,1412 +17,1412 @@ |
||
17 | 17 | class General_Settings_Admin_Page extends EE_Admin_Page |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * _question_group |
|
22 | - * holds the specific question group object for the question group details screen |
|
23 | - * |
|
24 | - * @var object |
|
25 | - */ |
|
26 | - protected $_question_group; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * Initialize basic properties. |
|
31 | - */ |
|
32 | - protected function _init_page_props() |
|
33 | - { |
|
34 | - $this->page_slug = GEN_SET_PG_SLUG; |
|
35 | - $this->page_label = GEN_SET_LABEL; |
|
36 | - $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
37 | - $this->_admin_base_path = GEN_SET_ADMIN; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Set ajax hooks |
|
43 | - */ |
|
44 | - protected function _ajax_hooks() |
|
45 | - { |
|
46 | - add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']); |
|
47 | - add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']); |
|
48 | - add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3); |
|
49 | - add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * More page properties initialization. |
|
55 | - */ |
|
56 | - protected function _define_page_props() |
|
57 | - { |
|
58 | - $this->_admin_page_title = GEN_SET_LABEL; |
|
59 | - $this->_labels = [ |
|
60 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
61 | - ]; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Set page routes property. |
|
67 | - */ |
|
68 | - protected function _set_page_routes() |
|
69 | - { |
|
70 | - $this->_page_routes = [ |
|
71 | - |
|
72 | - 'critical_pages' => [ |
|
73 | - 'func' => '_espresso_page_settings', |
|
74 | - 'capability' => 'manage_options', |
|
75 | - ], |
|
76 | - 'update_espresso_page_settings' => [ |
|
77 | - 'func' => '_update_espresso_page_settings', |
|
78 | - 'capability' => 'manage_options', |
|
79 | - 'noheader' => true, |
|
80 | - ], |
|
81 | - 'default' => [ |
|
82 | - 'func' => '_your_organization_settings', |
|
83 | - 'capability' => 'manage_options', |
|
84 | - ], |
|
85 | - |
|
86 | - 'update_your_organization_settings' => [ |
|
87 | - 'func' => '_update_your_organization_settings', |
|
88 | - 'capability' => 'manage_options', |
|
89 | - 'noheader' => true, |
|
90 | - ], |
|
91 | - |
|
92 | - 'admin_option_settings' => [ |
|
93 | - 'func' => '_admin_option_settings', |
|
94 | - 'capability' => 'manage_options', |
|
95 | - ], |
|
96 | - |
|
97 | - 'update_admin_option_settings' => [ |
|
98 | - 'func' => '_update_admin_option_settings', |
|
99 | - 'capability' => 'manage_options', |
|
100 | - 'noheader' => true, |
|
101 | - ], |
|
102 | - |
|
103 | - 'country_settings' => [ |
|
104 | - 'func' => '_country_settings', |
|
105 | - 'capability' => 'manage_options', |
|
106 | - ], |
|
107 | - |
|
108 | - 'update_country_settings' => [ |
|
109 | - 'func' => '_update_country_settings', |
|
110 | - 'capability' => 'manage_options', |
|
111 | - 'noheader' => true, |
|
112 | - ], |
|
113 | - |
|
114 | - 'display_country_settings' => [ |
|
115 | - 'func' => 'display_country_settings', |
|
116 | - 'capability' => 'manage_options', |
|
117 | - 'noheader' => true, |
|
118 | - ], |
|
119 | - |
|
120 | - 'add_new_state' => [ |
|
121 | - 'func' => 'add_new_state', |
|
122 | - 'capability' => 'manage_options', |
|
123 | - 'noheader' => true, |
|
124 | - ], |
|
125 | - |
|
126 | - 'delete_state' => [ |
|
127 | - 'func' => 'delete_state', |
|
128 | - 'capability' => 'manage_options', |
|
129 | - 'noheader' => true, |
|
130 | - ], |
|
131 | - 'privacy_settings' => [ |
|
132 | - 'func' => 'privacySettings', |
|
133 | - 'capability' => 'manage_options', |
|
134 | - ], |
|
135 | - 'update_privacy_settings' => [ |
|
136 | - 'func' => 'updatePrivacySettings', |
|
137 | - 'capability' => 'manage_options', |
|
138 | - 'noheader' => true, |
|
139 | - 'headers_sent_route' => 'privacy_settings', |
|
140 | - ], |
|
141 | - ]; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Set page configuration property |
|
147 | - */ |
|
148 | - protected function _set_page_config() |
|
149 | - { |
|
150 | - $this->_page_config = [ |
|
151 | - 'critical_pages' => [ |
|
152 | - 'nav' => [ |
|
153 | - 'label' => esc_html__('Critical Pages', 'event_espresso'), |
|
154 | - 'order' => 50, |
|
155 | - ], |
|
156 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
157 | - 'help_tabs' => [ |
|
158 | - 'general_settings_critical_pages_help_tab' => [ |
|
159 | - 'title' => esc_html__('Critical Pages', 'event_espresso'), |
|
160 | - 'filename' => 'general_settings_critical_pages', |
|
161 | - ], |
|
162 | - ], |
|
163 | - 'require_nonce' => false, |
|
164 | - ], |
|
165 | - 'default' => [ |
|
166 | - 'nav' => [ |
|
167 | - 'label' => esc_html__('Your Organization', 'event_espresso'), |
|
168 | - 'order' => 20, |
|
169 | - ], |
|
170 | - 'help_tabs' => [ |
|
171 | - 'general_settings_your_organization_help_tab' => [ |
|
172 | - 'title' => esc_html__('Your Organization', 'event_espresso'), |
|
173 | - 'filename' => 'general_settings_your_organization', |
|
174 | - ], |
|
175 | - ], |
|
176 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
177 | - 'require_nonce' => false, |
|
178 | - ], |
|
179 | - 'admin_option_settings' => [ |
|
180 | - 'nav' => [ |
|
181 | - 'label' => esc_html__('Admin Options', 'event_espresso'), |
|
182 | - 'order' => 60, |
|
183 | - ], |
|
184 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
185 | - 'help_tabs' => [ |
|
186 | - 'general_settings_admin_options_help_tab' => [ |
|
187 | - 'title' => esc_html__('Admin Options', 'event_espresso'), |
|
188 | - 'filename' => 'general_settings_admin_options', |
|
189 | - ], |
|
190 | - ], |
|
191 | - 'require_nonce' => false, |
|
192 | - ], |
|
193 | - 'country_settings' => [ |
|
194 | - 'nav' => [ |
|
195 | - 'label' => esc_html__('Countries', 'event_espresso'), |
|
196 | - 'order' => 70, |
|
197 | - ], |
|
198 | - 'help_tabs' => [ |
|
199 | - 'general_settings_countries_help_tab' => [ |
|
200 | - 'title' => esc_html__('Countries', 'event_espresso'), |
|
201 | - 'filename' => 'general_settings_countries', |
|
202 | - ], |
|
203 | - ], |
|
204 | - 'require_nonce' => false, |
|
205 | - ], |
|
206 | - 'privacy_settings' => [ |
|
207 | - 'nav' => [ |
|
208 | - 'label' => esc_html__('Privacy', 'event_espresso'), |
|
209 | - 'order' => 80, |
|
210 | - ], |
|
211 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
212 | - 'require_nonce' => false, |
|
213 | - ], |
|
214 | - ]; |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - protected function _add_screen_options() |
|
219 | - { |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - protected function _add_feature_pointers() |
|
224 | - { |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
230 | - */ |
|
231 | - public function load_scripts_styles() |
|
232 | - { |
|
233 | - // styles |
|
234 | - wp_enqueue_style('espresso-ui-theme'); |
|
235 | - // scripts |
|
236 | - wp_enqueue_script('ee_admin_js'); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * Execute logic running on `admin_init` |
|
242 | - */ |
|
243 | - public function admin_init() |
|
244 | - { |
|
245 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(__( |
|
246 | - 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
247 | - 'event_espresso' |
|
248 | - )); |
|
249 | - EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(__( |
|
250 | - 'An error occurred! Please refresh the page and try again.', |
|
251 | - 'event_espresso' |
|
252 | - )); |
|
253 | - EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(__( |
|
254 | - 'Are you sure you want to delete this State / Province?', |
|
255 | - 'event_espresso' |
|
256 | - )); |
|
257 | - $protocol = is_ssl() ? 'https://' : 'http://'; |
|
258 | - EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
259 | - 'admin-ajax.php?page=espresso_general_settings', |
|
260 | - $protocol |
|
261 | - ); |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - public function admin_notices() |
|
266 | - { |
|
267 | - } |
|
268 | - |
|
269 | - |
|
270 | - public function admin_footer_scripts() |
|
271 | - { |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Enqueue scripts and styles for the default route. |
|
277 | - */ |
|
278 | - public function load_scripts_styles_default() |
|
279 | - { |
|
280 | - // styles |
|
281 | - wp_enqueue_style('thickbox'); |
|
282 | - // scripts |
|
283 | - wp_enqueue_script('media-upload'); |
|
284 | - wp_enqueue_script('thickbox'); |
|
285 | - wp_register_script( |
|
286 | - 'organization_settings', |
|
287 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
288 | - ['jquery', 'media-upload', 'thickbox'], |
|
289 | - EVENT_ESPRESSO_VERSION, |
|
290 | - true |
|
291 | - ); |
|
292 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION); |
|
293 | - wp_enqueue_script('organization_settings'); |
|
294 | - wp_enqueue_style('organization-css'); |
|
295 | - $confirm_image_delete = [ |
|
296 | - 'text' => wp_strip_all_tags( |
|
297 | - __( |
|
298 | - 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
299 | - 'event_espresso' |
|
300 | - ) |
|
301 | - ), |
|
302 | - ]; |
|
303 | - wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * Enqueue scripts and styles for the country settings route. |
|
309 | - */ |
|
310 | - public function load_scripts_styles_country_settings() |
|
311 | - { |
|
312 | - // scripts |
|
313 | - wp_register_script( |
|
314 | - 'gen_settings_countries', |
|
315 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
316 | - ['ee_admin_js'], |
|
317 | - EVENT_ESPRESSO_VERSION, |
|
318 | - true |
|
319 | - ); |
|
320 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION); |
|
321 | - wp_enqueue_script('gen_settings_countries'); |
|
322 | - wp_enqueue_style('organization-css'); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /************* Espresso Pages *************/ |
|
327 | - /** |
|
328 | - * _espresso_page_settings |
|
329 | - * |
|
330 | - * @throws EE_Error |
|
331 | - * @throws DomainException |
|
332 | - * @throws DomainException |
|
333 | - * @throws InvalidDataTypeException |
|
334 | - * @throws InvalidArgumentException |
|
335 | - */ |
|
336 | - protected function _espresso_page_settings() |
|
337 | - { |
|
338 | - // Check to make sure all of the main pages are set up properly, |
|
339 | - // if not create the default pages and display an admin notice |
|
340 | - EEH_Activation::verify_default_pages_exist(); |
|
341 | - $this->_transient_garbage_collection(); |
|
342 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
343 | - $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
344 | - ? EE_Registry::instance()->CFG->core->reg_page_id |
|
345 | - : null; |
|
346 | - $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
347 | - ? get_post(EE_Registry::instance()->CFG->core->reg_page_id) |
|
348 | - : false; |
|
349 | - $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
350 | - ? EE_Registry::instance()->CFG->core->txn_page_id |
|
351 | - : null; |
|
352 | - $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
353 | - ? get_post(EE_Registry::instance()->CFG->core->txn_page_id) |
|
354 | - : false; |
|
355 | - $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
356 | - ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
357 | - : null; |
|
358 | - $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
359 | - ? get_post(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
360 | - : false; |
|
361 | - $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
362 | - ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
363 | - : null; |
|
364 | - $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
365 | - ? get_post(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
366 | - : false; |
|
367 | - $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
368 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
369 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
370 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
371 | - $this->_template_args, |
|
372 | - true |
|
373 | - ); |
|
374 | - $this->display_admin_page_with_sidebar(); |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * Handler for updating espresso page settings. |
|
380 | - * |
|
381 | - * @throws EE_Error |
|
382 | - */ |
|
383 | - protected function _update_espresso_page_settings() |
|
384 | - { |
|
385 | - // capture incoming request data && set page IDs |
|
386 | - EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
387 | - ? absint($this->_req_data['reg_page_id']) |
|
388 | - : EE_Registry::instance()->CFG->core->reg_page_id; |
|
389 | - EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
390 | - ? absint($this->_req_data['txn_page_id']) |
|
391 | - : EE_Registry::instance()->CFG->core->txn_page_id; |
|
392 | - EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
393 | - ? absint($this->_req_data['thank_you_page_id']) |
|
394 | - : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
395 | - EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
396 | - ? absint($this->_req_data['cancel_page_id']) |
|
397 | - : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
398 | - |
|
399 | - EE_Registry::instance()->CFG->core = apply_filters( |
|
400 | - 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
401 | - EE_Registry::instance()->CFG->core, |
|
402 | - $this->_req_data |
|
403 | - ); |
|
404 | - $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso'); |
|
405 | - $this->_redirect_after_action( |
|
406 | - $this->_update_espresso_configuration( |
|
407 | - $what, |
|
408 | - EE_Registry::instance()->CFG->core, |
|
409 | - __FILE__, |
|
410 | - __FUNCTION__, |
|
411 | - __LINE__ |
|
412 | - ), |
|
413 | - $what, |
|
414 | - '', |
|
415 | - [ |
|
416 | - 'action' => 'critical_pages', |
|
417 | - ], |
|
418 | - true |
|
419 | - ); |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - /************* Your Organization *************/ |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * @throws DomainException |
|
428 | - * @throws EE_Error |
|
429 | - * @throws InvalidArgumentException |
|
430 | - * @throws InvalidDataTypeException |
|
431 | - * @throws InvalidInterfaceException |
|
432 | - */ |
|
433 | - protected function _your_organization_settings() |
|
434 | - { |
|
435 | - $this->_template_args['admin_page_content'] = ''; |
|
436 | - try { |
|
437 | - /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */ |
|
438 | - $organization_settings_form = $this->loader->getShared( |
|
439 | - 'EventEspresso\admin_pages\general_settings\OrganizationSettings' |
|
440 | - ); |
|
441 | - $this->_template_args['admin_page_content'] = $organization_settings_form->display(); |
|
442 | - } catch (Exception $e) { |
|
443 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
444 | - } |
|
445 | - $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
446 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
447 | - $this->display_admin_page_with_sidebar(); |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - /** |
|
452 | - * Handler for updating organization settings. |
|
453 | - * |
|
454 | - * @throws EE_Error |
|
455 | - */ |
|
456 | - protected function _update_your_organization_settings() |
|
457 | - { |
|
458 | - try { |
|
459 | - /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */ |
|
460 | - $organization_settings_form = $this->loader->getShared( |
|
461 | - 'EventEspresso\admin_pages\general_settings\OrganizationSettings' |
|
462 | - ); |
|
463 | - $success = $organization_settings_form->process($this->_req_data); |
|
464 | - EE_Registry::instance()->CFG = apply_filters( |
|
465 | - 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
466 | - EE_Registry::instance()->CFG |
|
467 | - ); |
|
468 | - } catch (Exception $e) { |
|
469 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
470 | - $success = false; |
|
471 | - } |
|
472 | - |
|
473 | - if ($success) { |
|
474 | - $success = $this->_update_espresso_configuration( |
|
475 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
476 | - EE_Registry::instance()->CFG, |
|
477 | - __FILE__, |
|
478 | - __FUNCTION__, |
|
479 | - __LINE__ |
|
480 | - ); |
|
481 | - } |
|
482 | - |
|
483 | - $this->_redirect_after_action($success, '', '', ['action' => 'default'], true); |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - |
|
488 | - /************* Admin Options *************/ |
|
489 | - |
|
490 | - |
|
491 | - /** |
|
492 | - * _admin_option_settings |
|
493 | - * |
|
494 | - * @throws EE_Error |
|
495 | - * @throws LogicException |
|
496 | - */ |
|
497 | - protected function _admin_option_settings() |
|
498 | - { |
|
499 | - $this->_template_args['admin_page_content'] = ''; |
|
500 | - try { |
|
501 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
502 | - // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
503 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
504 | - // also need to account for the do_action that was in the old template |
|
505 | - $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
506 | - $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
507 | - } catch (Exception $e) { |
|
508 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
509 | - } |
|
510 | - $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
511 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
512 | - $this->display_admin_page_with_sidebar(); |
|
513 | - } |
|
514 | - |
|
515 | - |
|
516 | - /** |
|
517 | - * _update_admin_option_settings |
|
518 | - * |
|
519 | - * @throws EE_Error |
|
520 | - * @throws InvalidDataTypeException |
|
521 | - * @throws InvalidFormSubmissionException |
|
522 | - * @throws InvalidArgumentException |
|
523 | - * @throws LogicException |
|
524 | - */ |
|
525 | - protected function _update_admin_option_settings() |
|
526 | - { |
|
527 | - try { |
|
528 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
529 | - $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
530 | - EE_Registry::instance()->CFG->admin = apply_filters( |
|
531 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
532 | - EE_Registry::instance()->CFG->admin |
|
533 | - ); |
|
534 | - } catch (Exception $e) { |
|
535 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
536 | - } |
|
537 | - $this->_redirect_after_action( |
|
538 | - apply_filters( |
|
539 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
540 | - $this->_update_espresso_configuration( |
|
541 | - 'Admin Options', |
|
542 | - EE_Registry::instance()->CFG->admin, |
|
543 | - __FILE__, |
|
544 | - __FUNCTION__, |
|
545 | - __LINE__ |
|
546 | - ) |
|
547 | - ), |
|
548 | - 'Admin Options', |
|
549 | - 'updated', |
|
550 | - ['action' => 'admin_option_settings'] |
|
551 | - ); |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - /************* Countries *************/ |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * @return string |
|
560 | - */ |
|
561 | - protected function getCountryIsoForSite() |
|
562 | - { |
|
563 | - return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
564 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
565 | - : 'US'; |
|
566 | - } |
|
567 | - |
|
568 | - |
|
569 | - /** |
|
570 | - * @param string $CNT_ISO |
|
571 | - * @param EE_Country|null $country |
|
572 | - * @return EE_Base_Class|EE_Country |
|
573 | - * @throws EE_Error |
|
574 | - * @throws InvalidArgumentException |
|
575 | - * @throws InvalidDataTypeException |
|
576 | - * @throws InvalidInterfaceException |
|
577 | - * @throws ReflectionException |
|
578 | - */ |
|
579 | - protected function verifyOrGetCountryFromIso($CNT_ISO, EE_Country $country = null) |
|
580 | - { |
|
581 | - /** @var EE_Country $country */ |
|
582 | - return $country instanceof EE_Country && $country->ID() === $CNT_ISO |
|
583 | - ? $country |
|
584 | - : EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - /** |
|
589 | - * Output Country Settings view. |
|
590 | - * |
|
591 | - * @throws DomainException |
|
592 | - * @throws EE_Error |
|
593 | - * @throws InvalidArgumentException |
|
594 | - * @throws InvalidDataTypeException |
|
595 | - * @throws InvalidInterfaceException |
|
596 | - * @throws ReflectionException |
|
597 | - */ |
|
598 | - protected function _country_settings() |
|
599 | - { |
|
600 | - $CNT_ISO_for_site = $this->getCountryIsoForSite(); |
|
601 | - $CNT_ISO = isset($this->_req_data['country']) |
|
602 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
603 | - : $CNT_ISO_for_site; |
|
604 | - |
|
605 | - // load field generator helper |
|
606 | - |
|
607 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
608 | - |
|
609 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
610 | - EE_Question::new_instance( |
|
611 | - [ |
|
612 | - 'QST_ID' => 0, |
|
613 | - 'QST_display_text' => esc_html__('Select Country', 'event_espresso'), |
|
614 | - 'QST_system' => 'admin-country', |
|
615 | - ] |
|
616 | - ), |
|
617 | - EE_Answer::new_instance( |
|
618 | - [ |
|
619 | - 'ANS_ID' => 0, |
|
620 | - 'ANS_value' => $CNT_ISO, |
|
621 | - ] |
|
622 | - ), |
|
623 | - [ |
|
624 | - 'input_id' => 'country', |
|
625 | - 'input_name' => 'country', |
|
626 | - 'input_prefix' => '', |
|
627 | - 'append_qstn_id' => false, |
|
628 | - ] |
|
629 | - ); |
|
630 | - $country = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site); |
|
631 | - add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2); |
|
632 | - add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2); |
|
633 | - $this->_template_args['country_details_settings'] = $this->display_country_settings( |
|
634 | - $country->ID(), |
|
635 | - $country |
|
636 | - ); |
|
637 | - $this->_template_args['country_states_settings'] = $this->display_country_states( |
|
638 | - $country->ID(), |
|
639 | - $country |
|
640 | - ); |
|
641 | - $this->_template_args['CNT_name_for_site'] = $country->name(); |
|
642 | - |
|
643 | - $this->_set_add_edit_form_tags('update_country_settings'); |
|
644 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
645 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
646 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
647 | - $this->_template_args, |
|
648 | - true |
|
649 | - ); |
|
650 | - $this->display_admin_page_with_no_sidebar(); |
|
651 | - } |
|
652 | - |
|
653 | - |
|
654 | - /** |
|
655 | - * @param string $CNT_ISO |
|
656 | - * @param EE_Country|null $country |
|
657 | - * @return string |
|
658 | - * @throws DomainException |
|
659 | - * @throws EE_Error |
|
660 | - * @throws InvalidArgumentException |
|
661 | - * @throws InvalidDataTypeException |
|
662 | - * @throws InvalidInterfaceException |
|
663 | - * @throws ReflectionException |
|
664 | - */ |
|
665 | - public function display_country_settings($CNT_ISO = '', EE_Country $country = null) |
|
666 | - { |
|
667 | - $CNT_ISO_for_site = $this->getCountryIsoForSite(); |
|
668 | - |
|
669 | - $CNT_ISO = isset($this->_req_data['country']) |
|
670 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
671 | - : $CNT_ISO; |
|
672 | - if (! $CNT_ISO) { |
|
673 | - return ''; |
|
674 | - } |
|
675 | - |
|
676 | - // for ajax |
|
677 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
678 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
679 | - add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2); |
|
680 | - add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2); |
|
681 | - $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country); |
|
682 | - $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site; |
|
683 | - $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled; |
|
684 | - |
|
685 | - $country_input_types = [ |
|
686 | - 'CNT_active' => [ |
|
687 | - 'type' => 'RADIO_BTN', |
|
688 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
689 | - 'class' => '', |
|
690 | - 'options' => $this->_yes_no_values, |
|
691 | - 'use_desc_4_label' => true, |
|
692 | - ], |
|
693 | - 'CNT_ISO' => [ |
|
694 | - 'type' => 'TEXT', |
|
695 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
696 | - 'class' => 'small-text', |
|
697 | - ], |
|
698 | - 'CNT_ISO3' => [ |
|
699 | - 'type' => 'TEXT', |
|
700 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
701 | - 'class' => 'small-text', |
|
702 | - ], |
|
703 | - 'RGN_ID' => [ |
|
704 | - 'type' => 'TEXT', |
|
705 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
706 | - 'class' => 'small-text', |
|
707 | - ], |
|
708 | - 'CNT_name' => [ |
|
709 | - 'type' => 'TEXT', |
|
710 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
711 | - 'class' => 'regular-text', |
|
712 | - ], |
|
713 | - 'CNT_cur_code' => [ |
|
714 | - 'type' => 'TEXT', |
|
715 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
716 | - 'class' => 'small-text', |
|
717 | - 'disabled' => $CNT_cur_disabled, |
|
718 | - ], |
|
719 | - 'CNT_cur_single' => [ |
|
720 | - 'type' => 'TEXT', |
|
721 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
722 | - 'class' => 'medium-text', |
|
723 | - 'disabled' => $CNT_cur_disabled, |
|
724 | - ], |
|
725 | - 'CNT_cur_plural' => [ |
|
726 | - 'type' => 'TEXT', |
|
727 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
728 | - 'class' => 'medium-text', |
|
729 | - 'disabled' => $CNT_cur_disabled, |
|
730 | - ], |
|
731 | - 'CNT_cur_sign' => [ |
|
732 | - 'type' => 'TEXT', |
|
733 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
734 | - 'class' => 'small-text', |
|
735 | - 'htmlentities' => false, |
|
736 | - 'disabled' => $CNT_cur_disabled, |
|
737 | - ], |
|
738 | - 'CNT_cur_sign_b4' => [ |
|
739 | - 'type' => 'RADIO_BTN', |
|
740 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
741 | - 'class' => '', |
|
742 | - 'options' => $this->_yes_no_values, |
|
743 | - 'use_desc_4_label' => true, |
|
744 | - 'disabled' => $CNT_cur_disabled, |
|
745 | - ], |
|
746 | - 'CNT_cur_dec_plc' => [ |
|
747 | - 'type' => 'RADIO_BTN', |
|
748 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
749 | - 'class' => '', |
|
750 | - 'options' => [ |
|
751 | - ['id' => 0, 'text' => ''], |
|
752 | - ['id' => 1, 'text' => ''], |
|
753 | - ['id' => 2, 'text' => ''], |
|
754 | - ['id' => 3, 'text' => ''], |
|
755 | - ], |
|
756 | - 'disabled' => $CNT_cur_disabled, |
|
757 | - ], |
|
758 | - 'CNT_cur_dec_mrk' => [ |
|
759 | - 'type' => 'RADIO_BTN', |
|
760 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
761 | - 'class' => '', |
|
762 | - 'options' => [ |
|
763 | - [ |
|
764 | - 'id' => ',', |
|
765 | - 'text' => esc_html__(', (comma)', 'event_espresso'), |
|
766 | - ], |
|
767 | - ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')], |
|
768 | - ], |
|
769 | - 'use_desc_4_label' => true, |
|
770 | - 'disabled' => $CNT_cur_disabled, |
|
771 | - ], |
|
772 | - 'CNT_cur_thsnds' => [ |
|
773 | - 'type' => 'RADIO_BTN', |
|
774 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
775 | - 'class' => '', |
|
776 | - 'options' => [ |
|
777 | - [ |
|
778 | - 'id' => ',', |
|
779 | - 'text' => esc_html__(', (comma)', 'event_espresso'), |
|
780 | - ], |
|
781 | - [ |
|
782 | - 'id' => '.', |
|
783 | - 'text' => esc_html__('. (decimal)', 'event_espresso'), |
|
784 | - ], |
|
785 | - [ |
|
786 | - 'id' => ' ', |
|
787 | - 'text' => esc_html__('(space)', 'event_espresso'), |
|
788 | - ], |
|
789 | - ], |
|
790 | - 'use_desc_4_label' => true, |
|
791 | - 'disabled' => $CNT_cur_disabled, |
|
792 | - ], |
|
793 | - 'CNT_tel_code' => [ |
|
794 | - 'type' => 'TEXT', |
|
795 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
796 | - 'class' => 'small-text', |
|
797 | - ], |
|
798 | - 'CNT_is_EU' => [ |
|
799 | - 'type' => 'RADIO_BTN', |
|
800 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
801 | - 'class' => '', |
|
802 | - 'options' => $this->_yes_no_values, |
|
803 | - 'use_desc_4_label' => true, |
|
804 | - ], |
|
805 | - ]; |
|
806 | - $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
807 | - $country, |
|
808 | - $country_input_types |
|
809 | - ); |
|
810 | - $country_details_settings = EEH_Template::display_template( |
|
811 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
812 | - $this->_template_args, |
|
813 | - true |
|
814 | - ); |
|
815 | - |
|
816 | - if (defined('DOING_AJAX')) { |
|
817 | - $notices = EE_Error::get_notices(false, false, false); |
|
818 | - echo wp_json_encode( |
|
819 | - [ |
|
820 | - 'return_data' => $country_details_settings, |
|
821 | - 'success' => $notices['success'], |
|
822 | - 'errors' => $notices['errors'], |
|
823 | - ] |
|
824 | - ); |
|
825 | - die(); |
|
826 | - } else { |
|
827 | - return $country_details_settings; |
|
828 | - } |
|
829 | - } |
|
830 | - |
|
831 | - |
|
832 | - /** |
|
833 | - * @param string $CNT_ISO |
|
834 | - * @param EE_Country|null $country |
|
835 | - * @return string |
|
836 | - * @throws DomainException |
|
837 | - * @throws EE_Error |
|
838 | - * @throws InvalidArgumentException |
|
839 | - * @throws InvalidDataTypeException |
|
840 | - * @throws InvalidInterfaceException |
|
841 | - * @throws ReflectionException |
|
842 | - */ |
|
843 | - public function display_country_states($CNT_ISO = '', EE_Country $country = null) |
|
844 | - { |
|
845 | - |
|
846 | - $CNT_ISO = isset($this->_req_data['country']) |
|
847 | - ? sanitize_text_field($this->_req_data['country']) |
|
848 | - : $CNT_ISO; |
|
849 | - if (! $CNT_ISO) { |
|
850 | - return ''; |
|
851 | - } |
|
852 | - // for ajax |
|
853 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
854 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
855 | - add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2); |
|
856 | - add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10, 2); |
|
857 | - $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]); |
|
858 | - if (empty($states)) { |
|
859 | - /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */ |
|
860 | - $countrySubRegionDao = $this->loader->getShared( |
|
861 | - 'EventEspresso\core\services\address\CountrySubRegionDao' |
|
862 | - ); |
|
863 | - if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) { |
|
864 | - $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country); |
|
865 | - if ($countrySubRegionDao->saveCountrySubRegions($country)) { |
|
866 | - $states = EEM_State::instance()->get_all_states_for_these_countries( |
|
867 | - [$CNT_ISO => $CNT_ISO] |
|
868 | - ); |
|
869 | - } |
|
870 | - } |
|
871 | - } |
|
872 | - if (is_array($states)) { |
|
873 | - foreach ($states as $STA_ID => $state) { |
|
874 | - if ($state instanceof EE_State) { |
|
875 | - // STA_abbrev STA_name STA_active |
|
876 | - $state_input_types = [ |
|
877 | - 'STA_abbrev' => [ |
|
878 | - 'type' => 'TEXT', |
|
879 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
880 | - 'class' => 'small-text', |
|
881 | - ], |
|
882 | - 'STA_name' => [ |
|
883 | - 'type' => 'TEXT', |
|
884 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
885 | - 'class' => 'regular-text', |
|
886 | - ], |
|
887 | - 'STA_active' => [ |
|
888 | - 'type' => 'RADIO_BTN', |
|
889 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
890 | - 'options' => $this->_yes_no_values, |
|
891 | - 'use_desc_4_label' => true, |
|
892 | - ], |
|
893 | - ]; |
|
894 | - $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
895 | - EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
896 | - $state, |
|
897 | - $state_input_types |
|
898 | - ); |
|
899 | - $query_args = [ |
|
900 | - 'action' => 'delete_state', |
|
901 | - 'STA_ID' => $STA_ID, |
|
902 | - 'CNT_ISO' => $CNT_ISO, |
|
903 | - 'STA_abbrev' => $state->abbrev(), |
|
904 | - ]; |
|
905 | - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
906 | - EE_Admin_Page::add_query_args_and_nonce( |
|
907 | - $query_args, |
|
908 | - GEN_SET_ADMIN_URL |
|
909 | - ); |
|
910 | - } |
|
911 | - } |
|
912 | - } else { |
|
913 | - $this->_template_args['states'] = false; |
|
914 | - } |
|
915 | - |
|
916 | - $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
917 | - ['action' => 'add_new_state'], |
|
918 | - GEN_SET_ADMIN_URL |
|
919 | - ); |
|
920 | - |
|
921 | - $state_details_settings = EEH_Template::display_template( |
|
922 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
923 | - $this->_template_args, |
|
924 | - true |
|
925 | - ); |
|
926 | - |
|
927 | - if (defined('DOING_AJAX')) { |
|
928 | - $notices = EE_Error::get_notices(false, false, false); |
|
929 | - echo wp_json_encode( |
|
930 | - [ |
|
931 | - 'return_data' => $state_details_settings, |
|
932 | - 'success' => $notices['success'], |
|
933 | - 'errors' => $notices['errors'], |
|
934 | - ] |
|
935 | - ); |
|
936 | - die(); |
|
937 | - } else { |
|
938 | - return $state_details_settings; |
|
939 | - } |
|
940 | - } |
|
941 | - |
|
942 | - |
|
943 | - /** |
|
944 | - * add_new_state |
|
945 | - * |
|
946 | - * @access public |
|
947 | - * @return void |
|
948 | - * @throws EE_Error |
|
949 | - * @throws InvalidArgumentException |
|
950 | - * @throws InvalidDataTypeException |
|
951 | - * @throws InvalidInterfaceException |
|
952 | - */ |
|
953 | - public function add_new_state() |
|
954 | - { |
|
955 | - |
|
956 | - $success = true; |
|
957 | - |
|
958 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
959 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
960 | - : false; |
|
961 | - if (! $CNT_ISO) { |
|
962 | - EE_Error::add_error( |
|
963 | - esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
964 | - __FILE__, |
|
965 | - __FUNCTION__, |
|
966 | - __LINE__ |
|
967 | - ); |
|
968 | - $success = false; |
|
969 | - } |
|
970 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
971 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
972 | - : false; |
|
973 | - if (! $STA_abbrev) { |
|
974 | - EE_Error::add_error( |
|
975 | - esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
976 | - __FILE__, |
|
977 | - __FUNCTION__, |
|
978 | - __LINE__ |
|
979 | - ); |
|
980 | - $success = false; |
|
981 | - } |
|
982 | - $STA_name = isset($this->_req_data['STA_name']) |
|
983 | - ? sanitize_text_field($this->_req_data['STA_name']) |
|
984 | - : false; |
|
985 | - if (! $STA_name) { |
|
986 | - EE_Error::add_error( |
|
987 | - esc_html__('No State name or an invalid State name was received.', 'event_espresso'), |
|
988 | - __FILE__, |
|
989 | - __FUNCTION__, |
|
990 | - __LINE__ |
|
991 | - ); |
|
992 | - $success = false; |
|
993 | - } |
|
994 | - |
|
995 | - if ($success) { |
|
996 | - $cols_n_values = [ |
|
997 | - 'CNT_ISO' => $CNT_ISO, |
|
998 | - 'STA_abbrev' => $STA_abbrev, |
|
999 | - 'STA_name' => $STA_name, |
|
1000 | - 'STA_active' => true, |
|
1001 | - ]; |
|
1002 | - $success = EEM_State::instance()->insert($cols_n_values); |
|
1003 | - EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso')); |
|
1004 | - } |
|
1005 | - |
|
1006 | - if (defined('DOING_AJAX')) { |
|
1007 | - $notices = EE_Error::get_notices(false, false, false); |
|
1008 | - echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO])); |
|
1009 | - die(); |
|
1010 | - } else { |
|
1011 | - $this->_redirect_after_action($success, 'State', 'added', ['action' => 'country_settings']); |
|
1012 | - } |
|
1013 | - } |
|
1014 | - |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * @return void |
|
1018 | - * @throws EE_Error |
|
1019 | - * @throws InvalidArgumentException |
|
1020 | - * @throws InvalidDataTypeException |
|
1021 | - * @throws InvalidInterfaceException |
|
1022 | - */ |
|
1023 | - public function delete_state() |
|
1024 | - { |
|
1025 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
1026 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
1027 | - : false; |
|
1028 | - $STA_ID = isset($this->_req_data['STA_ID']) |
|
1029 | - ? sanitize_text_field($this->_req_data['STA_ID']) |
|
1030 | - : false; |
|
1031 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
1032 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
1033 | - : false; |
|
1034 | - if (! $STA_ID) { |
|
1035 | - EE_Error::add_error( |
|
1036 | - esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
1037 | - __FILE__, |
|
1038 | - __FUNCTION__, |
|
1039 | - __LINE__ |
|
1040 | - ); |
|
1041 | - return; |
|
1042 | - } |
|
1043 | - |
|
1044 | - $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
1045 | - if ($success !== false) { |
|
1046 | - do_action( |
|
1047 | - 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
1048 | - $CNT_ISO, |
|
1049 | - $STA_ID, |
|
1050 | - ['STA_abbrev' => $STA_abbrev] |
|
1051 | - ); |
|
1052 | - EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso')); |
|
1053 | - } |
|
1054 | - if (defined('DOING_AJAX')) { |
|
1055 | - $notices = EE_Error::get_notices(false); |
|
1056 | - $notices['return_data'] = true; |
|
1057 | - echo wp_json_encode($notices); |
|
1058 | - die(); |
|
1059 | - } else { |
|
1060 | - $this->_redirect_after_action( |
|
1061 | - $success, |
|
1062 | - 'State', |
|
1063 | - 'deleted', |
|
1064 | - ['action' => 'country_settings'] |
|
1065 | - ); |
|
1066 | - } |
|
1067 | - } |
|
1068 | - |
|
1069 | - |
|
1070 | - /** |
|
1071 | - * _update_country_settings |
|
1072 | - * |
|
1073 | - * @return void |
|
1074 | - * @throws EE_Error |
|
1075 | - * @throws InvalidArgumentException |
|
1076 | - * @throws InvalidDataTypeException |
|
1077 | - * @throws InvalidInterfaceException |
|
1078 | - */ |
|
1079 | - protected function _update_country_settings() |
|
1080 | - { |
|
1081 | - // grab the country ISO code |
|
1082 | - $CNT_ISO = isset($this->_req_data['country']) |
|
1083 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
1084 | - : false; |
|
1085 | - if (! $CNT_ISO) { |
|
1086 | - EE_Error::add_error( |
|
1087 | - esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1088 | - __FILE__, |
|
1089 | - __FUNCTION__, |
|
1090 | - __LINE__ |
|
1091 | - ); |
|
1092 | - |
|
1093 | - return; |
|
1094 | - } |
|
1095 | - $cols_n_values = []; |
|
1096 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
1097 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
1098 | - : false; |
|
1099 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1100 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1101 | - : null; |
|
1102 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1103 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1104 | - : null; |
|
1105 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) { |
|
1106 | - $cols_n_values['CNT_cur_code'] = strtoupper( |
|
1107 | - sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1108 | - ); |
|
1109 | - } |
|
1110 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) { |
|
1111 | - $cols_n_values['CNT_cur_single'] = sanitize_text_field( |
|
1112 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'] |
|
1113 | - ); |
|
1114 | - } |
|
1115 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) { |
|
1116 | - $cols_n_values['CNT_cur_plural'] = sanitize_text_field( |
|
1117 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'] |
|
1118 | - ); |
|
1119 | - } |
|
1120 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) { |
|
1121 | - $cols_n_values['CNT_cur_sign'] = sanitize_text_field( |
|
1122 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'] |
|
1123 | - ); |
|
1124 | - } |
|
1125 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) { |
|
1126 | - $cols_n_values['CNT_cur_sign_b4'] = absint( |
|
1127 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'] |
|
1128 | - ); |
|
1129 | - } |
|
1130 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) { |
|
1131 | - $cols_n_values['CNT_cur_dec_plc'] = absint( |
|
1132 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'] |
|
1133 | - ); |
|
1134 | - } |
|
1135 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) { |
|
1136 | - $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field( |
|
1137 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'] |
|
1138 | - ); |
|
1139 | - } |
|
1140 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) { |
|
1141 | - $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field( |
|
1142 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'] |
|
1143 | - ); |
|
1144 | - } |
|
1145 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1146 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1147 | - : null; |
|
1148 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1149 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1150 | - : false; |
|
1151 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1152 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1153 | - : false; |
|
1154 | - // allow filtering of country data |
|
1155 | - $cols_n_values = apply_filters( |
|
1156 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1157 | - $cols_n_values |
|
1158 | - ); |
|
1159 | - |
|
1160 | - // where values |
|
1161 | - $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]]; |
|
1162 | - // run the update |
|
1163 | - $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1164 | - |
|
1165 | - if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1166 | - // allow filtering of states data |
|
1167 | - $states = apply_filters( |
|
1168 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1169 | - $this->_req_data['states'] |
|
1170 | - ); |
|
1171 | - |
|
1172 | - // loop thru state data ( looks like : states[75][STA_name] ) |
|
1173 | - foreach ($states as $STA_ID => $state) { |
|
1174 | - $cols_n_values = [ |
|
1175 | - 'CNT_ISO' => $CNT_ISO, |
|
1176 | - 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1177 | - 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1178 | - 'STA_active' => (bool) absint($state['STA_active']), |
|
1179 | - ]; |
|
1180 | - // where values |
|
1181 | - $where_cols_n_values = [['STA_ID' => $STA_ID]]; |
|
1182 | - // run the update |
|
1183 | - $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1184 | - if ($success !== false) { |
|
1185 | - do_action( |
|
1186 | - 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1187 | - $CNT_ISO, |
|
1188 | - $STA_ID, |
|
1189 | - $cols_n_values |
|
1190 | - ); |
|
1191 | - } |
|
1192 | - } |
|
1193 | - } |
|
1194 | - // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1195 | - if ( |
|
1196 | - isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1197 | - && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1198 | - ) { |
|
1199 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1200 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
1201 | - } |
|
1202 | - |
|
1203 | - if ($success !== false) { |
|
1204 | - EE_Error::add_success( |
|
1205 | - esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1206 | - ); |
|
1207 | - } |
|
1208 | - $this->_redirect_after_action( |
|
1209 | - $success, |
|
1210 | - '', |
|
1211 | - '', |
|
1212 | - ['action' => 'country_settings', 'country' => $CNT_ISO], |
|
1213 | - true |
|
1214 | - ); |
|
1215 | - } |
|
1216 | - |
|
1217 | - |
|
1218 | - /** |
|
1219 | - * form_form_field_label_wrap |
|
1220 | - * |
|
1221 | - * @param string $label |
|
1222 | - * @return string |
|
1223 | - */ |
|
1224 | - public function country_form_field_label_wrap($label, $required_text) |
|
1225 | - { |
|
1226 | - return ' |
|
20 | + /** |
|
21 | + * _question_group |
|
22 | + * holds the specific question group object for the question group details screen |
|
23 | + * |
|
24 | + * @var object |
|
25 | + */ |
|
26 | + protected $_question_group; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * Initialize basic properties. |
|
31 | + */ |
|
32 | + protected function _init_page_props() |
|
33 | + { |
|
34 | + $this->page_slug = GEN_SET_PG_SLUG; |
|
35 | + $this->page_label = GEN_SET_LABEL; |
|
36 | + $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
37 | + $this->_admin_base_path = GEN_SET_ADMIN; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Set ajax hooks |
|
43 | + */ |
|
44 | + protected function _ajax_hooks() |
|
45 | + { |
|
46 | + add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']); |
|
47 | + add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']); |
|
48 | + add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3); |
|
49 | + add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * More page properties initialization. |
|
55 | + */ |
|
56 | + protected function _define_page_props() |
|
57 | + { |
|
58 | + $this->_admin_page_title = GEN_SET_LABEL; |
|
59 | + $this->_labels = [ |
|
60 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
61 | + ]; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Set page routes property. |
|
67 | + */ |
|
68 | + protected function _set_page_routes() |
|
69 | + { |
|
70 | + $this->_page_routes = [ |
|
71 | + |
|
72 | + 'critical_pages' => [ |
|
73 | + 'func' => '_espresso_page_settings', |
|
74 | + 'capability' => 'manage_options', |
|
75 | + ], |
|
76 | + 'update_espresso_page_settings' => [ |
|
77 | + 'func' => '_update_espresso_page_settings', |
|
78 | + 'capability' => 'manage_options', |
|
79 | + 'noheader' => true, |
|
80 | + ], |
|
81 | + 'default' => [ |
|
82 | + 'func' => '_your_organization_settings', |
|
83 | + 'capability' => 'manage_options', |
|
84 | + ], |
|
85 | + |
|
86 | + 'update_your_organization_settings' => [ |
|
87 | + 'func' => '_update_your_organization_settings', |
|
88 | + 'capability' => 'manage_options', |
|
89 | + 'noheader' => true, |
|
90 | + ], |
|
91 | + |
|
92 | + 'admin_option_settings' => [ |
|
93 | + 'func' => '_admin_option_settings', |
|
94 | + 'capability' => 'manage_options', |
|
95 | + ], |
|
96 | + |
|
97 | + 'update_admin_option_settings' => [ |
|
98 | + 'func' => '_update_admin_option_settings', |
|
99 | + 'capability' => 'manage_options', |
|
100 | + 'noheader' => true, |
|
101 | + ], |
|
102 | + |
|
103 | + 'country_settings' => [ |
|
104 | + 'func' => '_country_settings', |
|
105 | + 'capability' => 'manage_options', |
|
106 | + ], |
|
107 | + |
|
108 | + 'update_country_settings' => [ |
|
109 | + 'func' => '_update_country_settings', |
|
110 | + 'capability' => 'manage_options', |
|
111 | + 'noheader' => true, |
|
112 | + ], |
|
113 | + |
|
114 | + 'display_country_settings' => [ |
|
115 | + 'func' => 'display_country_settings', |
|
116 | + 'capability' => 'manage_options', |
|
117 | + 'noheader' => true, |
|
118 | + ], |
|
119 | + |
|
120 | + 'add_new_state' => [ |
|
121 | + 'func' => 'add_new_state', |
|
122 | + 'capability' => 'manage_options', |
|
123 | + 'noheader' => true, |
|
124 | + ], |
|
125 | + |
|
126 | + 'delete_state' => [ |
|
127 | + 'func' => 'delete_state', |
|
128 | + 'capability' => 'manage_options', |
|
129 | + 'noheader' => true, |
|
130 | + ], |
|
131 | + 'privacy_settings' => [ |
|
132 | + 'func' => 'privacySettings', |
|
133 | + 'capability' => 'manage_options', |
|
134 | + ], |
|
135 | + 'update_privacy_settings' => [ |
|
136 | + 'func' => 'updatePrivacySettings', |
|
137 | + 'capability' => 'manage_options', |
|
138 | + 'noheader' => true, |
|
139 | + 'headers_sent_route' => 'privacy_settings', |
|
140 | + ], |
|
141 | + ]; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Set page configuration property |
|
147 | + */ |
|
148 | + protected function _set_page_config() |
|
149 | + { |
|
150 | + $this->_page_config = [ |
|
151 | + 'critical_pages' => [ |
|
152 | + 'nav' => [ |
|
153 | + 'label' => esc_html__('Critical Pages', 'event_espresso'), |
|
154 | + 'order' => 50, |
|
155 | + ], |
|
156 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
157 | + 'help_tabs' => [ |
|
158 | + 'general_settings_critical_pages_help_tab' => [ |
|
159 | + 'title' => esc_html__('Critical Pages', 'event_espresso'), |
|
160 | + 'filename' => 'general_settings_critical_pages', |
|
161 | + ], |
|
162 | + ], |
|
163 | + 'require_nonce' => false, |
|
164 | + ], |
|
165 | + 'default' => [ |
|
166 | + 'nav' => [ |
|
167 | + 'label' => esc_html__('Your Organization', 'event_espresso'), |
|
168 | + 'order' => 20, |
|
169 | + ], |
|
170 | + 'help_tabs' => [ |
|
171 | + 'general_settings_your_organization_help_tab' => [ |
|
172 | + 'title' => esc_html__('Your Organization', 'event_espresso'), |
|
173 | + 'filename' => 'general_settings_your_organization', |
|
174 | + ], |
|
175 | + ], |
|
176 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
177 | + 'require_nonce' => false, |
|
178 | + ], |
|
179 | + 'admin_option_settings' => [ |
|
180 | + 'nav' => [ |
|
181 | + 'label' => esc_html__('Admin Options', 'event_espresso'), |
|
182 | + 'order' => 60, |
|
183 | + ], |
|
184 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
185 | + 'help_tabs' => [ |
|
186 | + 'general_settings_admin_options_help_tab' => [ |
|
187 | + 'title' => esc_html__('Admin Options', 'event_espresso'), |
|
188 | + 'filename' => 'general_settings_admin_options', |
|
189 | + ], |
|
190 | + ], |
|
191 | + 'require_nonce' => false, |
|
192 | + ], |
|
193 | + 'country_settings' => [ |
|
194 | + 'nav' => [ |
|
195 | + 'label' => esc_html__('Countries', 'event_espresso'), |
|
196 | + 'order' => 70, |
|
197 | + ], |
|
198 | + 'help_tabs' => [ |
|
199 | + 'general_settings_countries_help_tab' => [ |
|
200 | + 'title' => esc_html__('Countries', 'event_espresso'), |
|
201 | + 'filename' => 'general_settings_countries', |
|
202 | + ], |
|
203 | + ], |
|
204 | + 'require_nonce' => false, |
|
205 | + ], |
|
206 | + 'privacy_settings' => [ |
|
207 | + 'nav' => [ |
|
208 | + 'label' => esc_html__('Privacy', 'event_espresso'), |
|
209 | + 'order' => 80, |
|
210 | + ], |
|
211 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
212 | + 'require_nonce' => false, |
|
213 | + ], |
|
214 | + ]; |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + protected function _add_screen_options() |
|
219 | + { |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + protected function _add_feature_pointers() |
|
224 | + { |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
230 | + */ |
|
231 | + public function load_scripts_styles() |
|
232 | + { |
|
233 | + // styles |
|
234 | + wp_enqueue_style('espresso-ui-theme'); |
|
235 | + // scripts |
|
236 | + wp_enqueue_script('ee_admin_js'); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * Execute logic running on `admin_init` |
|
242 | + */ |
|
243 | + public function admin_init() |
|
244 | + { |
|
245 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(__( |
|
246 | + 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
247 | + 'event_espresso' |
|
248 | + )); |
|
249 | + EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(__( |
|
250 | + 'An error occurred! Please refresh the page and try again.', |
|
251 | + 'event_espresso' |
|
252 | + )); |
|
253 | + EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(__( |
|
254 | + 'Are you sure you want to delete this State / Province?', |
|
255 | + 'event_espresso' |
|
256 | + )); |
|
257 | + $protocol = is_ssl() ? 'https://' : 'http://'; |
|
258 | + EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
259 | + 'admin-ajax.php?page=espresso_general_settings', |
|
260 | + $protocol |
|
261 | + ); |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + public function admin_notices() |
|
266 | + { |
|
267 | + } |
|
268 | + |
|
269 | + |
|
270 | + public function admin_footer_scripts() |
|
271 | + { |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Enqueue scripts and styles for the default route. |
|
277 | + */ |
|
278 | + public function load_scripts_styles_default() |
|
279 | + { |
|
280 | + // styles |
|
281 | + wp_enqueue_style('thickbox'); |
|
282 | + // scripts |
|
283 | + wp_enqueue_script('media-upload'); |
|
284 | + wp_enqueue_script('thickbox'); |
|
285 | + wp_register_script( |
|
286 | + 'organization_settings', |
|
287 | + GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
288 | + ['jquery', 'media-upload', 'thickbox'], |
|
289 | + EVENT_ESPRESSO_VERSION, |
|
290 | + true |
|
291 | + ); |
|
292 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION); |
|
293 | + wp_enqueue_script('organization_settings'); |
|
294 | + wp_enqueue_style('organization-css'); |
|
295 | + $confirm_image_delete = [ |
|
296 | + 'text' => wp_strip_all_tags( |
|
297 | + __( |
|
298 | + 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
299 | + 'event_espresso' |
|
300 | + ) |
|
301 | + ), |
|
302 | + ]; |
|
303 | + wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * Enqueue scripts and styles for the country settings route. |
|
309 | + */ |
|
310 | + public function load_scripts_styles_country_settings() |
|
311 | + { |
|
312 | + // scripts |
|
313 | + wp_register_script( |
|
314 | + 'gen_settings_countries', |
|
315 | + GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
316 | + ['ee_admin_js'], |
|
317 | + EVENT_ESPRESSO_VERSION, |
|
318 | + true |
|
319 | + ); |
|
320 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION); |
|
321 | + wp_enqueue_script('gen_settings_countries'); |
|
322 | + wp_enqueue_style('organization-css'); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /************* Espresso Pages *************/ |
|
327 | + /** |
|
328 | + * _espresso_page_settings |
|
329 | + * |
|
330 | + * @throws EE_Error |
|
331 | + * @throws DomainException |
|
332 | + * @throws DomainException |
|
333 | + * @throws InvalidDataTypeException |
|
334 | + * @throws InvalidArgumentException |
|
335 | + */ |
|
336 | + protected function _espresso_page_settings() |
|
337 | + { |
|
338 | + // Check to make sure all of the main pages are set up properly, |
|
339 | + // if not create the default pages and display an admin notice |
|
340 | + EEH_Activation::verify_default_pages_exist(); |
|
341 | + $this->_transient_garbage_collection(); |
|
342 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
343 | + $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
344 | + ? EE_Registry::instance()->CFG->core->reg_page_id |
|
345 | + : null; |
|
346 | + $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
347 | + ? get_post(EE_Registry::instance()->CFG->core->reg_page_id) |
|
348 | + : false; |
|
349 | + $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
350 | + ? EE_Registry::instance()->CFG->core->txn_page_id |
|
351 | + : null; |
|
352 | + $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
353 | + ? get_post(EE_Registry::instance()->CFG->core->txn_page_id) |
|
354 | + : false; |
|
355 | + $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
356 | + ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
357 | + : null; |
|
358 | + $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
359 | + ? get_post(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
360 | + : false; |
|
361 | + $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
362 | + ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
363 | + : null; |
|
364 | + $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
365 | + ? get_post(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
366 | + : false; |
|
367 | + $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
368 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
369 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
370 | + GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
371 | + $this->_template_args, |
|
372 | + true |
|
373 | + ); |
|
374 | + $this->display_admin_page_with_sidebar(); |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * Handler for updating espresso page settings. |
|
380 | + * |
|
381 | + * @throws EE_Error |
|
382 | + */ |
|
383 | + protected function _update_espresso_page_settings() |
|
384 | + { |
|
385 | + // capture incoming request data && set page IDs |
|
386 | + EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
387 | + ? absint($this->_req_data['reg_page_id']) |
|
388 | + : EE_Registry::instance()->CFG->core->reg_page_id; |
|
389 | + EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
390 | + ? absint($this->_req_data['txn_page_id']) |
|
391 | + : EE_Registry::instance()->CFG->core->txn_page_id; |
|
392 | + EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
393 | + ? absint($this->_req_data['thank_you_page_id']) |
|
394 | + : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
395 | + EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
396 | + ? absint($this->_req_data['cancel_page_id']) |
|
397 | + : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
398 | + |
|
399 | + EE_Registry::instance()->CFG->core = apply_filters( |
|
400 | + 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
401 | + EE_Registry::instance()->CFG->core, |
|
402 | + $this->_req_data |
|
403 | + ); |
|
404 | + $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso'); |
|
405 | + $this->_redirect_after_action( |
|
406 | + $this->_update_espresso_configuration( |
|
407 | + $what, |
|
408 | + EE_Registry::instance()->CFG->core, |
|
409 | + __FILE__, |
|
410 | + __FUNCTION__, |
|
411 | + __LINE__ |
|
412 | + ), |
|
413 | + $what, |
|
414 | + '', |
|
415 | + [ |
|
416 | + 'action' => 'critical_pages', |
|
417 | + ], |
|
418 | + true |
|
419 | + ); |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + /************* Your Organization *************/ |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * @throws DomainException |
|
428 | + * @throws EE_Error |
|
429 | + * @throws InvalidArgumentException |
|
430 | + * @throws InvalidDataTypeException |
|
431 | + * @throws InvalidInterfaceException |
|
432 | + */ |
|
433 | + protected function _your_organization_settings() |
|
434 | + { |
|
435 | + $this->_template_args['admin_page_content'] = ''; |
|
436 | + try { |
|
437 | + /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */ |
|
438 | + $organization_settings_form = $this->loader->getShared( |
|
439 | + 'EventEspresso\admin_pages\general_settings\OrganizationSettings' |
|
440 | + ); |
|
441 | + $this->_template_args['admin_page_content'] = $organization_settings_form->display(); |
|
442 | + } catch (Exception $e) { |
|
443 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
444 | + } |
|
445 | + $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
446 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
447 | + $this->display_admin_page_with_sidebar(); |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + /** |
|
452 | + * Handler for updating organization settings. |
|
453 | + * |
|
454 | + * @throws EE_Error |
|
455 | + */ |
|
456 | + protected function _update_your_organization_settings() |
|
457 | + { |
|
458 | + try { |
|
459 | + /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */ |
|
460 | + $organization_settings_form = $this->loader->getShared( |
|
461 | + 'EventEspresso\admin_pages\general_settings\OrganizationSettings' |
|
462 | + ); |
|
463 | + $success = $organization_settings_form->process($this->_req_data); |
|
464 | + EE_Registry::instance()->CFG = apply_filters( |
|
465 | + 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
466 | + EE_Registry::instance()->CFG |
|
467 | + ); |
|
468 | + } catch (Exception $e) { |
|
469 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
470 | + $success = false; |
|
471 | + } |
|
472 | + |
|
473 | + if ($success) { |
|
474 | + $success = $this->_update_espresso_configuration( |
|
475 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
476 | + EE_Registry::instance()->CFG, |
|
477 | + __FILE__, |
|
478 | + __FUNCTION__, |
|
479 | + __LINE__ |
|
480 | + ); |
|
481 | + } |
|
482 | + |
|
483 | + $this->_redirect_after_action($success, '', '', ['action' => 'default'], true); |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + |
|
488 | + /************* Admin Options *************/ |
|
489 | + |
|
490 | + |
|
491 | + /** |
|
492 | + * _admin_option_settings |
|
493 | + * |
|
494 | + * @throws EE_Error |
|
495 | + * @throws LogicException |
|
496 | + */ |
|
497 | + protected function _admin_option_settings() |
|
498 | + { |
|
499 | + $this->_template_args['admin_page_content'] = ''; |
|
500 | + try { |
|
501 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
502 | + // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
503 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
504 | + // also need to account for the do_action that was in the old template |
|
505 | + $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
506 | + $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
507 | + } catch (Exception $e) { |
|
508 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
509 | + } |
|
510 | + $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
511 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
512 | + $this->display_admin_page_with_sidebar(); |
|
513 | + } |
|
514 | + |
|
515 | + |
|
516 | + /** |
|
517 | + * _update_admin_option_settings |
|
518 | + * |
|
519 | + * @throws EE_Error |
|
520 | + * @throws InvalidDataTypeException |
|
521 | + * @throws InvalidFormSubmissionException |
|
522 | + * @throws InvalidArgumentException |
|
523 | + * @throws LogicException |
|
524 | + */ |
|
525 | + protected function _update_admin_option_settings() |
|
526 | + { |
|
527 | + try { |
|
528 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
529 | + $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
530 | + EE_Registry::instance()->CFG->admin = apply_filters( |
|
531 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
532 | + EE_Registry::instance()->CFG->admin |
|
533 | + ); |
|
534 | + } catch (Exception $e) { |
|
535 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
536 | + } |
|
537 | + $this->_redirect_after_action( |
|
538 | + apply_filters( |
|
539 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
540 | + $this->_update_espresso_configuration( |
|
541 | + 'Admin Options', |
|
542 | + EE_Registry::instance()->CFG->admin, |
|
543 | + __FILE__, |
|
544 | + __FUNCTION__, |
|
545 | + __LINE__ |
|
546 | + ) |
|
547 | + ), |
|
548 | + 'Admin Options', |
|
549 | + 'updated', |
|
550 | + ['action' => 'admin_option_settings'] |
|
551 | + ); |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + /************* Countries *************/ |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * @return string |
|
560 | + */ |
|
561 | + protected function getCountryIsoForSite() |
|
562 | + { |
|
563 | + return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
564 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
565 | + : 'US'; |
|
566 | + } |
|
567 | + |
|
568 | + |
|
569 | + /** |
|
570 | + * @param string $CNT_ISO |
|
571 | + * @param EE_Country|null $country |
|
572 | + * @return EE_Base_Class|EE_Country |
|
573 | + * @throws EE_Error |
|
574 | + * @throws InvalidArgumentException |
|
575 | + * @throws InvalidDataTypeException |
|
576 | + * @throws InvalidInterfaceException |
|
577 | + * @throws ReflectionException |
|
578 | + */ |
|
579 | + protected function verifyOrGetCountryFromIso($CNT_ISO, EE_Country $country = null) |
|
580 | + { |
|
581 | + /** @var EE_Country $country */ |
|
582 | + return $country instanceof EE_Country && $country->ID() === $CNT_ISO |
|
583 | + ? $country |
|
584 | + : EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + /** |
|
589 | + * Output Country Settings view. |
|
590 | + * |
|
591 | + * @throws DomainException |
|
592 | + * @throws EE_Error |
|
593 | + * @throws InvalidArgumentException |
|
594 | + * @throws InvalidDataTypeException |
|
595 | + * @throws InvalidInterfaceException |
|
596 | + * @throws ReflectionException |
|
597 | + */ |
|
598 | + protected function _country_settings() |
|
599 | + { |
|
600 | + $CNT_ISO_for_site = $this->getCountryIsoForSite(); |
|
601 | + $CNT_ISO = isset($this->_req_data['country']) |
|
602 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
603 | + : $CNT_ISO_for_site; |
|
604 | + |
|
605 | + // load field generator helper |
|
606 | + |
|
607 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
608 | + |
|
609 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
610 | + EE_Question::new_instance( |
|
611 | + [ |
|
612 | + 'QST_ID' => 0, |
|
613 | + 'QST_display_text' => esc_html__('Select Country', 'event_espresso'), |
|
614 | + 'QST_system' => 'admin-country', |
|
615 | + ] |
|
616 | + ), |
|
617 | + EE_Answer::new_instance( |
|
618 | + [ |
|
619 | + 'ANS_ID' => 0, |
|
620 | + 'ANS_value' => $CNT_ISO, |
|
621 | + ] |
|
622 | + ), |
|
623 | + [ |
|
624 | + 'input_id' => 'country', |
|
625 | + 'input_name' => 'country', |
|
626 | + 'input_prefix' => '', |
|
627 | + 'append_qstn_id' => false, |
|
628 | + ] |
|
629 | + ); |
|
630 | + $country = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site); |
|
631 | + add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2); |
|
632 | + add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2); |
|
633 | + $this->_template_args['country_details_settings'] = $this->display_country_settings( |
|
634 | + $country->ID(), |
|
635 | + $country |
|
636 | + ); |
|
637 | + $this->_template_args['country_states_settings'] = $this->display_country_states( |
|
638 | + $country->ID(), |
|
639 | + $country |
|
640 | + ); |
|
641 | + $this->_template_args['CNT_name_for_site'] = $country->name(); |
|
642 | + |
|
643 | + $this->_set_add_edit_form_tags('update_country_settings'); |
|
644 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
645 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
646 | + GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
647 | + $this->_template_args, |
|
648 | + true |
|
649 | + ); |
|
650 | + $this->display_admin_page_with_no_sidebar(); |
|
651 | + } |
|
652 | + |
|
653 | + |
|
654 | + /** |
|
655 | + * @param string $CNT_ISO |
|
656 | + * @param EE_Country|null $country |
|
657 | + * @return string |
|
658 | + * @throws DomainException |
|
659 | + * @throws EE_Error |
|
660 | + * @throws InvalidArgumentException |
|
661 | + * @throws InvalidDataTypeException |
|
662 | + * @throws InvalidInterfaceException |
|
663 | + * @throws ReflectionException |
|
664 | + */ |
|
665 | + public function display_country_settings($CNT_ISO = '', EE_Country $country = null) |
|
666 | + { |
|
667 | + $CNT_ISO_for_site = $this->getCountryIsoForSite(); |
|
668 | + |
|
669 | + $CNT_ISO = isset($this->_req_data['country']) |
|
670 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
671 | + : $CNT_ISO; |
|
672 | + if (! $CNT_ISO) { |
|
673 | + return ''; |
|
674 | + } |
|
675 | + |
|
676 | + // for ajax |
|
677 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
678 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
679 | + add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2); |
|
680 | + add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2); |
|
681 | + $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country); |
|
682 | + $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site; |
|
683 | + $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled; |
|
684 | + |
|
685 | + $country_input_types = [ |
|
686 | + 'CNT_active' => [ |
|
687 | + 'type' => 'RADIO_BTN', |
|
688 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
689 | + 'class' => '', |
|
690 | + 'options' => $this->_yes_no_values, |
|
691 | + 'use_desc_4_label' => true, |
|
692 | + ], |
|
693 | + 'CNT_ISO' => [ |
|
694 | + 'type' => 'TEXT', |
|
695 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
696 | + 'class' => 'small-text', |
|
697 | + ], |
|
698 | + 'CNT_ISO3' => [ |
|
699 | + 'type' => 'TEXT', |
|
700 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
701 | + 'class' => 'small-text', |
|
702 | + ], |
|
703 | + 'RGN_ID' => [ |
|
704 | + 'type' => 'TEXT', |
|
705 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
706 | + 'class' => 'small-text', |
|
707 | + ], |
|
708 | + 'CNT_name' => [ |
|
709 | + 'type' => 'TEXT', |
|
710 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
711 | + 'class' => 'regular-text', |
|
712 | + ], |
|
713 | + 'CNT_cur_code' => [ |
|
714 | + 'type' => 'TEXT', |
|
715 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
716 | + 'class' => 'small-text', |
|
717 | + 'disabled' => $CNT_cur_disabled, |
|
718 | + ], |
|
719 | + 'CNT_cur_single' => [ |
|
720 | + 'type' => 'TEXT', |
|
721 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
722 | + 'class' => 'medium-text', |
|
723 | + 'disabled' => $CNT_cur_disabled, |
|
724 | + ], |
|
725 | + 'CNT_cur_plural' => [ |
|
726 | + 'type' => 'TEXT', |
|
727 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
728 | + 'class' => 'medium-text', |
|
729 | + 'disabled' => $CNT_cur_disabled, |
|
730 | + ], |
|
731 | + 'CNT_cur_sign' => [ |
|
732 | + 'type' => 'TEXT', |
|
733 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
734 | + 'class' => 'small-text', |
|
735 | + 'htmlentities' => false, |
|
736 | + 'disabled' => $CNT_cur_disabled, |
|
737 | + ], |
|
738 | + 'CNT_cur_sign_b4' => [ |
|
739 | + 'type' => 'RADIO_BTN', |
|
740 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
741 | + 'class' => '', |
|
742 | + 'options' => $this->_yes_no_values, |
|
743 | + 'use_desc_4_label' => true, |
|
744 | + 'disabled' => $CNT_cur_disabled, |
|
745 | + ], |
|
746 | + 'CNT_cur_dec_plc' => [ |
|
747 | + 'type' => 'RADIO_BTN', |
|
748 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
749 | + 'class' => '', |
|
750 | + 'options' => [ |
|
751 | + ['id' => 0, 'text' => ''], |
|
752 | + ['id' => 1, 'text' => ''], |
|
753 | + ['id' => 2, 'text' => ''], |
|
754 | + ['id' => 3, 'text' => ''], |
|
755 | + ], |
|
756 | + 'disabled' => $CNT_cur_disabled, |
|
757 | + ], |
|
758 | + 'CNT_cur_dec_mrk' => [ |
|
759 | + 'type' => 'RADIO_BTN', |
|
760 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
761 | + 'class' => '', |
|
762 | + 'options' => [ |
|
763 | + [ |
|
764 | + 'id' => ',', |
|
765 | + 'text' => esc_html__(', (comma)', 'event_espresso'), |
|
766 | + ], |
|
767 | + ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')], |
|
768 | + ], |
|
769 | + 'use_desc_4_label' => true, |
|
770 | + 'disabled' => $CNT_cur_disabled, |
|
771 | + ], |
|
772 | + 'CNT_cur_thsnds' => [ |
|
773 | + 'type' => 'RADIO_BTN', |
|
774 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
775 | + 'class' => '', |
|
776 | + 'options' => [ |
|
777 | + [ |
|
778 | + 'id' => ',', |
|
779 | + 'text' => esc_html__(', (comma)', 'event_espresso'), |
|
780 | + ], |
|
781 | + [ |
|
782 | + 'id' => '.', |
|
783 | + 'text' => esc_html__('. (decimal)', 'event_espresso'), |
|
784 | + ], |
|
785 | + [ |
|
786 | + 'id' => ' ', |
|
787 | + 'text' => esc_html__('(space)', 'event_espresso'), |
|
788 | + ], |
|
789 | + ], |
|
790 | + 'use_desc_4_label' => true, |
|
791 | + 'disabled' => $CNT_cur_disabled, |
|
792 | + ], |
|
793 | + 'CNT_tel_code' => [ |
|
794 | + 'type' => 'TEXT', |
|
795 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
796 | + 'class' => 'small-text', |
|
797 | + ], |
|
798 | + 'CNT_is_EU' => [ |
|
799 | + 'type' => 'RADIO_BTN', |
|
800 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
801 | + 'class' => '', |
|
802 | + 'options' => $this->_yes_no_values, |
|
803 | + 'use_desc_4_label' => true, |
|
804 | + ], |
|
805 | + ]; |
|
806 | + $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
807 | + $country, |
|
808 | + $country_input_types |
|
809 | + ); |
|
810 | + $country_details_settings = EEH_Template::display_template( |
|
811 | + GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
812 | + $this->_template_args, |
|
813 | + true |
|
814 | + ); |
|
815 | + |
|
816 | + if (defined('DOING_AJAX')) { |
|
817 | + $notices = EE_Error::get_notices(false, false, false); |
|
818 | + echo wp_json_encode( |
|
819 | + [ |
|
820 | + 'return_data' => $country_details_settings, |
|
821 | + 'success' => $notices['success'], |
|
822 | + 'errors' => $notices['errors'], |
|
823 | + ] |
|
824 | + ); |
|
825 | + die(); |
|
826 | + } else { |
|
827 | + return $country_details_settings; |
|
828 | + } |
|
829 | + } |
|
830 | + |
|
831 | + |
|
832 | + /** |
|
833 | + * @param string $CNT_ISO |
|
834 | + * @param EE_Country|null $country |
|
835 | + * @return string |
|
836 | + * @throws DomainException |
|
837 | + * @throws EE_Error |
|
838 | + * @throws InvalidArgumentException |
|
839 | + * @throws InvalidDataTypeException |
|
840 | + * @throws InvalidInterfaceException |
|
841 | + * @throws ReflectionException |
|
842 | + */ |
|
843 | + public function display_country_states($CNT_ISO = '', EE_Country $country = null) |
|
844 | + { |
|
845 | + |
|
846 | + $CNT_ISO = isset($this->_req_data['country']) |
|
847 | + ? sanitize_text_field($this->_req_data['country']) |
|
848 | + : $CNT_ISO; |
|
849 | + if (! $CNT_ISO) { |
|
850 | + return ''; |
|
851 | + } |
|
852 | + // for ajax |
|
853 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
854 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
855 | + add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2); |
|
856 | + add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10, 2); |
|
857 | + $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]); |
|
858 | + if (empty($states)) { |
|
859 | + /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */ |
|
860 | + $countrySubRegionDao = $this->loader->getShared( |
|
861 | + 'EventEspresso\core\services\address\CountrySubRegionDao' |
|
862 | + ); |
|
863 | + if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) { |
|
864 | + $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country); |
|
865 | + if ($countrySubRegionDao->saveCountrySubRegions($country)) { |
|
866 | + $states = EEM_State::instance()->get_all_states_for_these_countries( |
|
867 | + [$CNT_ISO => $CNT_ISO] |
|
868 | + ); |
|
869 | + } |
|
870 | + } |
|
871 | + } |
|
872 | + if (is_array($states)) { |
|
873 | + foreach ($states as $STA_ID => $state) { |
|
874 | + if ($state instanceof EE_State) { |
|
875 | + // STA_abbrev STA_name STA_active |
|
876 | + $state_input_types = [ |
|
877 | + 'STA_abbrev' => [ |
|
878 | + 'type' => 'TEXT', |
|
879 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
880 | + 'class' => 'small-text', |
|
881 | + ], |
|
882 | + 'STA_name' => [ |
|
883 | + 'type' => 'TEXT', |
|
884 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
885 | + 'class' => 'regular-text', |
|
886 | + ], |
|
887 | + 'STA_active' => [ |
|
888 | + 'type' => 'RADIO_BTN', |
|
889 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
890 | + 'options' => $this->_yes_no_values, |
|
891 | + 'use_desc_4_label' => true, |
|
892 | + ], |
|
893 | + ]; |
|
894 | + $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
895 | + EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
896 | + $state, |
|
897 | + $state_input_types |
|
898 | + ); |
|
899 | + $query_args = [ |
|
900 | + 'action' => 'delete_state', |
|
901 | + 'STA_ID' => $STA_ID, |
|
902 | + 'CNT_ISO' => $CNT_ISO, |
|
903 | + 'STA_abbrev' => $state->abbrev(), |
|
904 | + ]; |
|
905 | + $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
906 | + EE_Admin_Page::add_query_args_and_nonce( |
|
907 | + $query_args, |
|
908 | + GEN_SET_ADMIN_URL |
|
909 | + ); |
|
910 | + } |
|
911 | + } |
|
912 | + } else { |
|
913 | + $this->_template_args['states'] = false; |
|
914 | + } |
|
915 | + |
|
916 | + $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
917 | + ['action' => 'add_new_state'], |
|
918 | + GEN_SET_ADMIN_URL |
|
919 | + ); |
|
920 | + |
|
921 | + $state_details_settings = EEH_Template::display_template( |
|
922 | + GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
923 | + $this->_template_args, |
|
924 | + true |
|
925 | + ); |
|
926 | + |
|
927 | + if (defined('DOING_AJAX')) { |
|
928 | + $notices = EE_Error::get_notices(false, false, false); |
|
929 | + echo wp_json_encode( |
|
930 | + [ |
|
931 | + 'return_data' => $state_details_settings, |
|
932 | + 'success' => $notices['success'], |
|
933 | + 'errors' => $notices['errors'], |
|
934 | + ] |
|
935 | + ); |
|
936 | + die(); |
|
937 | + } else { |
|
938 | + return $state_details_settings; |
|
939 | + } |
|
940 | + } |
|
941 | + |
|
942 | + |
|
943 | + /** |
|
944 | + * add_new_state |
|
945 | + * |
|
946 | + * @access public |
|
947 | + * @return void |
|
948 | + * @throws EE_Error |
|
949 | + * @throws InvalidArgumentException |
|
950 | + * @throws InvalidDataTypeException |
|
951 | + * @throws InvalidInterfaceException |
|
952 | + */ |
|
953 | + public function add_new_state() |
|
954 | + { |
|
955 | + |
|
956 | + $success = true; |
|
957 | + |
|
958 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
959 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
960 | + : false; |
|
961 | + if (! $CNT_ISO) { |
|
962 | + EE_Error::add_error( |
|
963 | + esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
964 | + __FILE__, |
|
965 | + __FUNCTION__, |
|
966 | + __LINE__ |
|
967 | + ); |
|
968 | + $success = false; |
|
969 | + } |
|
970 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
971 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
972 | + : false; |
|
973 | + if (! $STA_abbrev) { |
|
974 | + EE_Error::add_error( |
|
975 | + esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
976 | + __FILE__, |
|
977 | + __FUNCTION__, |
|
978 | + __LINE__ |
|
979 | + ); |
|
980 | + $success = false; |
|
981 | + } |
|
982 | + $STA_name = isset($this->_req_data['STA_name']) |
|
983 | + ? sanitize_text_field($this->_req_data['STA_name']) |
|
984 | + : false; |
|
985 | + if (! $STA_name) { |
|
986 | + EE_Error::add_error( |
|
987 | + esc_html__('No State name or an invalid State name was received.', 'event_espresso'), |
|
988 | + __FILE__, |
|
989 | + __FUNCTION__, |
|
990 | + __LINE__ |
|
991 | + ); |
|
992 | + $success = false; |
|
993 | + } |
|
994 | + |
|
995 | + if ($success) { |
|
996 | + $cols_n_values = [ |
|
997 | + 'CNT_ISO' => $CNT_ISO, |
|
998 | + 'STA_abbrev' => $STA_abbrev, |
|
999 | + 'STA_name' => $STA_name, |
|
1000 | + 'STA_active' => true, |
|
1001 | + ]; |
|
1002 | + $success = EEM_State::instance()->insert($cols_n_values); |
|
1003 | + EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso')); |
|
1004 | + } |
|
1005 | + |
|
1006 | + if (defined('DOING_AJAX')) { |
|
1007 | + $notices = EE_Error::get_notices(false, false, false); |
|
1008 | + echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO])); |
|
1009 | + die(); |
|
1010 | + } else { |
|
1011 | + $this->_redirect_after_action($success, 'State', 'added', ['action' => 'country_settings']); |
|
1012 | + } |
|
1013 | + } |
|
1014 | + |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * @return void |
|
1018 | + * @throws EE_Error |
|
1019 | + * @throws InvalidArgumentException |
|
1020 | + * @throws InvalidDataTypeException |
|
1021 | + * @throws InvalidInterfaceException |
|
1022 | + */ |
|
1023 | + public function delete_state() |
|
1024 | + { |
|
1025 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
1026 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
1027 | + : false; |
|
1028 | + $STA_ID = isset($this->_req_data['STA_ID']) |
|
1029 | + ? sanitize_text_field($this->_req_data['STA_ID']) |
|
1030 | + : false; |
|
1031 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
1032 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
1033 | + : false; |
|
1034 | + if (! $STA_ID) { |
|
1035 | + EE_Error::add_error( |
|
1036 | + esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
1037 | + __FILE__, |
|
1038 | + __FUNCTION__, |
|
1039 | + __LINE__ |
|
1040 | + ); |
|
1041 | + return; |
|
1042 | + } |
|
1043 | + |
|
1044 | + $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
1045 | + if ($success !== false) { |
|
1046 | + do_action( |
|
1047 | + 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
1048 | + $CNT_ISO, |
|
1049 | + $STA_ID, |
|
1050 | + ['STA_abbrev' => $STA_abbrev] |
|
1051 | + ); |
|
1052 | + EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso')); |
|
1053 | + } |
|
1054 | + if (defined('DOING_AJAX')) { |
|
1055 | + $notices = EE_Error::get_notices(false); |
|
1056 | + $notices['return_data'] = true; |
|
1057 | + echo wp_json_encode($notices); |
|
1058 | + die(); |
|
1059 | + } else { |
|
1060 | + $this->_redirect_after_action( |
|
1061 | + $success, |
|
1062 | + 'State', |
|
1063 | + 'deleted', |
|
1064 | + ['action' => 'country_settings'] |
|
1065 | + ); |
|
1066 | + } |
|
1067 | + } |
|
1068 | + |
|
1069 | + |
|
1070 | + /** |
|
1071 | + * _update_country_settings |
|
1072 | + * |
|
1073 | + * @return void |
|
1074 | + * @throws EE_Error |
|
1075 | + * @throws InvalidArgumentException |
|
1076 | + * @throws InvalidDataTypeException |
|
1077 | + * @throws InvalidInterfaceException |
|
1078 | + */ |
|
1079 | + protected function _update_country_settings() |
|
1080 | + { |
|
1081 | + // grab the country ISO code |
|
1082 | + $CNT_ISO = isset($this->_req_data['country']) |
|
1083 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
1084 | + : false; |
|
1085 | + if (! $CNT_ISO) { |
|
1086 | + EE_Error::add_error( |
|
1087 | + esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1088 | + __FILE__, |
|
1089 | + __FUNCTION__, |
|
1090 | + __LINE__ |
|
1091 | + ); |
|
1092 | + |
|
1093 | + return; |
|
1094 | + } |
|
1095 | + $cols_n_values = []; |
|
1096 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
1097 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
1098 | + : false; |
|
1099 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1100 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1101 | + : null; |
|
1102 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1103 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1104 | + : null; |
|
1105 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) { |
|
1106 | + $cols_n_values['CNT_cur_code'] = strtoupper( |
|
1107 | + sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1108 | + ); |
|
1109 | + } |
|
1110 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) { |
|
1111 | + $cols_n_values['CNT_cur_single'] = sanitize_text_field( |
|
1112 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'] |
|
1113 | + ); |
|
1114 | + } |
|
1115 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) { |
|
1116 | + $cols_n_values['CNT_cur_plural'] = sanitize_text_field( |
|
1117 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'] |
|
1118 | + ); |
|
1119 | + } |
|
1120 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) { |
|
1121 | + $cols_n_values['CNT_cur_sign'] = sanitize_text_field( |
|
1122 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'] |
|
1123 | + ); |
|
1124 | + } |
|
1125 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) { |
|
1126 | + $cols_n_values['CNT_cur_sign_b4'] = absint( |
|
1127 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'] |
|
1128 | + ); |
|
1129 | + } |
|
1130 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) { |
|
1131 | + $cols_n_values['CNT_cur_dec_plc'] = absint( |
|
1132 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'] |
|
1133 | + ); |
|
1134 | + } |
|
1135 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) { |
|
1136 | + $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field( |
|
1137 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'] |
|
1138 | + ); |
|
1139 | + } |
|
1140 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) { |
|
1141 | + $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field( |
|
1142 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'] |
|
1143 | + ); |
|
1144 | + } |
|
1145 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1146 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1147 | + : null; |
|
1148 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1149 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1150 | + : false; |
|
1151 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1152 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1153 | + : false; |
|
1154 | + // allow filtering of country data |
|
1155 | + $cols_n_values = apply_filters( |
|
1156 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1157 | + $cols_n_values |
|
1158 | + ); |
|
1159 | + |
|
1160 | + // where values |
|
1161 | + $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]]; |
|
1162 | + // run the update |
|
1163 | + $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1164 | + |
|
1165 | + if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1166 | + // allow filtering of states data |
|
1167 | + $states = apply_filters( |
|
1168 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1169 | + $this->_req_data['states'] |
|
1170 | + ); |
|
1171 | + |
|
1172 | + // loop thru state data ( looks like : states[75][STA_name] ) |
|
1173 | + foreach ($states as $STA_ID => $state) { |
|
1174 | + $cols_n_values = [ |
|
1175 | + 'CNT_ISO' => $CNT_ISO, |
|
1176 | + 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1177 | + 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1178 | + 'STA_active' => (bool) absint($state['STA_active']), |
|
1179 | + ]; |
|
1180 | + // where values |
|
1181 | + $where_cols_n_values = [['STA_ID' => $STA_ID]]; |
|
1182 | + // run the update |
|
1183 | + $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1184 | + if ($success !== false) { |
|
1185 | + do_action( |
|
1186 | + 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1187 | + $CNT_ISO, |
|
1188 | + $STA_ID, |
|
1189 | + $cols_n_values |
|
1190 | + ); |
|
1191 | + } |
|
1192 | + } |
|
1193 | + } |
|
1194 | + // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1195 | + if ( |
|
1196 | + isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1197 | + && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1198 | + ) { |
|
1199 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1200 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
1201 | + } |
|
1202 | + |
|
1203 | + if ($success !== false) { |
|
1204 | + EE_Error::add_success( |
|
1205 | + esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1206 | + ); |
|
1207 | + } |
|
1208 | + $this->_redirect_after_action( |
|
1209 | + $success, |
|
1210 | + '', |
|
1211 | + '', |
|
1212 | + ['action' => 'country_settings', 'country' => $CNT_ISO], |
|
1213 | + true |
|
1214 | + ); |
|
1215 | + } |
|
1216 | + |
|
1217 | + |
|
1218 | + /** |
|
1219 | + * form_form_field_label_wrap |
|
1220 | + * |
|
1221 | + * @param string $label |
|
1222 | + * @return string |
|
1223 | + */ |
|
1224 | + public function country_form_field_label_wrap($label, $required_text) |
|
1225 | + { |
|
1226 | + return ' |
|
1227 | 1227 | <tr> |
1228 | 1228 | <th> |
1229 | 1229 | ' . $label . ' |
1230 | 1230 | </th>'; |
1231 | - } |
|
1232 | - |
|
1233 | - |
|
1234 | - /** |
|
1235 | - * form_form_field_input__wrap |
|
1236 | - * |
|
1237 | - * @param string $label |
|
1238 | - * @return string |
|
1239 | - */ |
|
1240 | - public function country_form_field_input__wrap($input, $label) |
|
1241 | - { |
|
1242 | - return ' |
|
1231 | + } |
|
1232 | + |
|
1233 | + |
|
1234 | + /** |
|
1235 | + * form_form_field_input__wrap |
|
1236 | + * |
|
1237 | + * @param string $label |
|
1238 | + * @return string |
|
1239 | + */ |
|
1240 | + public function country_form_field_input__wrap($input, $label) |
|
1241 | + { |
|
1242 | + return ' |
|
1243 | 1243 | <td class="general-settings-country-input-td"> |
1244 | 1244 | ' . $input . ' |
1245 | 1245 | </td> |
1246 | 1246 | </tr>'; |
1247 | - } |
|
1248 | - |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * form_form_field_label_wrap |
|
1252 | - * |
|
1253 | - * @param string $label |
|
1254 | - * @param string $required_text |
|
1255 | - * @return string |
|
1256 | - */ |
|
1257 | - public function state_form_field_label_wrap($label, $required_text) |
|
1258 | - { |
|
1259 | - return $required_text; |
|
1260 | - } |
|
1261 | - |
|
1262 | - |
|
1263 | - /** |
|
1264 | - * form_form_field_input__wrap |
|
1265 | - * |
|
1266 | - * @param string $label |
|
1267 | - * @return string |
|
1268 | - */ |
|
1269 | - public function state_form_field_input__wrap($input, $label) |
|
1270 | - { |
|
1271 | - return ' |
|
1247 | + } |
|
1248 | + |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * form_form_field_label_wrap |
|
1252 | + * |
|
1253 | + * @param string $label |
|
1254 | + * @param string $required_text |
|
1255 | + * @return string |
|
1256 | + */ |
|
1257 | + public function state_form_field_label_wrap($label, $required_text) |
|
1258 | + { |
|
1259 | + return $required_text; |
|
1260 | + } |
|
1261 | + |
|
1262 | + |
|
1263 | + /** |
|
1264 | + * form_form_field_input__wrap |
|
1265 | + * |
|
1266 | + * @param string $label |
|
1267 | + * @return string |
|
1268 | + */ |
|
1269 | + public function state_form_field_input__wrap($input, $label) |
|
1270 | + { |
|
1271 | + return ' |
|
1272 | 1272 | <td class="general-settings-country-state-input-td"> |
1273 | 1273 | ' . $input . ' |
1274 | 1274 | </td>'; |
1275 | - } |
|
1276 | - |
|
1277 | - |
|
1278 | - /***********/ |
|
1279 | - |
|
1280 | - |
|
1281 | - /** |
|
1282 | - * displays edit and view links for critical EE pages |
|
1283 | - * |
|
1284 | - * @param int $ee_page_id |
|
1285 | - * @return string |
|
1286 | - */ |
|
1287 | - public static function edit_view_links($ee_page_id) |
|
1288 | - { |
|
1289 | - $links = '<a href="' |
|
1290 | - . add_query_arg( |
|
1291 | - ['post' => $ee_page_id, 'action' => 'edit'], |
|
1292 | - admin_url('post.php') |
|
1293 | - ) |
|
1294 | - . '" >' |
|
1295 | - . esc_html__('Edit', 'event_espresso') |
|
1296 | - . '</a>'; |
|
1297 | - $links .= ' | '; |
|
1298 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>'; |
|
1299 | - |
|
1300 | - return $links; |
|
1301 | - } |
|
1302 | - |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * displays page and shortcode status for critical EE pages |
|
1306 | - * |
|
1307 | - * @param WP page object $ee_page |
|
1308 | - * @return string |
|
1309 | - */ |
|
1310 | - public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1311 | - { |
|
1312 | - |
|
1313 | - // page status |
|
1314 | - if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1315 | - $pg_colour = 'green'; |
|
1316 | - $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1317 | - } else { |
|
1318 | - $pg_colour = 'red'; |
|
1319 | - $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1320 | - } |
|
1321 | - |
|
1322 | - // shortcode status |
|
1323 | - if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1324 | - $sc_colour = 'green'; |
|
1325 | - $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1326 | - } else { |
|
1327 | - $sc_colour = 'red'; |
|
1328 | - $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1329 | - } |
|
1330 | - |
|
1331 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1332 | - . $pg_status |
|
1333 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1334 | - } |
|
1335 | - |
|
1336 | - |
|
1337 | - /** |
|
1338 | - * generates a dropdown of all parent pages - copied from WP core |
|
1339 | - * |
|
1340 | - * @param int $default |
|
1341 | - * @param int $parent |
|
1342 | - * @param int $level |
|
1343 | - * @param bool $echo |
|
1344 | - * @return string; |
|
1345 | - */ |
|
1346 | - public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0, $echo = true) |
|
1347 | - { |
|
1348 | - global $wpdb; |
|
1349 | - $items = $wpdb->get_results( |
|
1350 | - $wpdb->prepare( |
|
1351 | - "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1352 | - $parent |
|
1353 | - ) |
|
1354 | - ); |
|
1355 | - $output = ''; |
|
1356 | - |
|
1357 | - if ($items) { |
|
1358 | - $level = absint($level); |
|
1359 | - foreach ($items as $item) { |
|
1360 | - $ID = absint($item->ID); |
|
1361 | - $post_title = wp_strip_all_tags($item->post_title); |
|
1362 | - $pad = str_repeat(' ', $level * 3); |
|
1363 | - $option = "\n\t"; |
|
1364 | - $option .= '<option class="level-' . $level . '" '; |
|
1365 | - $option .= 'value="' . $ID . '" '; |
|
1366 | - $option .= $ID === absint($default) ? ' selected="selected"' : ''; |
|
1367 | - $option .= '>'; |
|
1368 | - $option .= "$pad {$post_title}"; |
|
1369 | - $option .= '</option>'; |
|
1370 | - $output .= $option; |
|
1371 | - ob_start(); |
|
1372 | - parent_dropdown($default, $item->ID, $level + 1); |
|
1373 | - $output .= ob_get_clean(); |
|
1374 | - } |
|
1375 | - } |
|
1376 | - if ($echo) { |
|
1377 | - echo $output; |
|
1378 | - return ''; |
|
1379 | - } |
|
1380 | - return $output; |
|
1381 | - } |
|
1382 | - |
|
1383 | - |
|
1384 | - /** |
|
1385 | - * Loads the scripts for the privacy settings form |
|
1386 | - */ |
|
1387 | - public function load_scripts_styles_privacy_settings() |
|
1388 | - { |
|
1389 | - $form_handler = |
|
1390 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1391 | - $form_handler->enqueueStylesAndScripts(); |
|
1392 | - } |
|
1393 | - |
|
1394 | - |
|
1395 | - /** |
|
1396 | - * display the privacy settings form |
|
1397 | - * |
|
1398 | - * @throws EE_Error |
|
1399 | - */ |
|
1400 | - public function privacySettings() |
|
1401 | - { |
|
1402 | - $this->_set_add_edit_form_tags('update_privacy_settings'); |
|
1403 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1404 | - $form_handler = |
|
1405 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1406 | - $this->_template_args['admin_page_content'] = $form_handler->display(); |
|
1407 | - $this->display_admin_page_with_sidebar(); |
|
1408 | - } |
|
1409 | - |
|
1410 | - |
|
1411 | - /** |
|
1412 | - * Update the privacy settings from form data |
|
1413 | - * |
|
1414 | - * @throws EE_Error |
|
1415 | - */ |
|
1416 | - public function updatePrivacySettings() |
|
1417 | - { |
|
1418 | - $form_handler = |
|
1419 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1420 | - $success = $form_handler->process($this->get_request_data()); |
|
1421 | - $this->_redirect_after_action( |
|
1422 | - $success, |
|
1423 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1424 | - 'updated', |
|
1425 | - ['action' => 'privacy_settings'] |
|
1426 | - ); |
|
1427 | - } |
|
1275 | + } |
|
1276 | + |
|
1277 | + |
|
1278 | + /***********/ |
|
1279 | + |
|
1280 | + |
|
1281 | + /** |
|
1282 | + * displays edit and view links for critical EE pages |
|
1283 | + * |
|
1284 | + * @param int $ee_page_id |
|
1285 | + * @return string |
|
1286 | + */ |
|
1287 | + public static function edit_view_links($ee_page_id) |
|
1288 | + { |
|
1289 | + $links = '<a href="' |
|
1290 | + . add_query_arg( |
|
1291 | + ['post' => $ee_page_id, 'action' => 'edit'], |
|
1292 | + admin_url('post.php') |
|
1293 | + ) |
|
1294 | + . '" >' |
|
1295 | + . esc_html__('Edit', 'event_espresso') |
|
1296 | + . '</a>'; |
|
1297 | + $links .= ' | '; |
|
1298 | + $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>'; |
|
1299 | + |
|
1300 | + return $links; |
|
1301 | + } |
|
1302 | + |
|
1303 | + |
|
1304 | + /** |
|
1305 | + * displays page and shortcode status for critical EE pages |
|
1306 | + * |
|
1307 | + * @param WP page object $ee_page |
|
1308 | + * @return string |
|
1309 | + */ |
|
1310 | + public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1311 | + { |
|
1312 | + |
|
1313 | + // page status |
|
1314 | + if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1315 | + $pg_colour = 'green'; |
|
1316 | + $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1317 | + } else { |
|
1318 | + $pg_colour = 'red'; |
|
1319 | + $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1320 | + } |
|
1321 | + |
|
1322 | + // shortcode status |
|
1323 | + if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1324 | + $sc_colour = 'green'; |
|
1325 | + $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1326 | + } else { |
|
1327 | + $sc_colour = 'red'; |
|
1328 | + $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1329 | + } |
|
1330 | + |
|
1331 | + return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1332 | + . $pg_status |
|
1333 | + . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1334 | + } |
|
1335 | + |
|
1336 | + |
|
1337 | + /** |
|
1338 | + * generates a dropdown of all parent pages - copied from WP core |
|
1339 | + * |
|
1340 | + * @param int $default |
|
1341 | + * @param int $parent |
|
1342 | + * @param int $level |
|
1343 | + * @param bool $echo |
|
1344 | + * @return string; |
|
1345 | + */ |
|
1346 | + public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0, $echo = true) |
|
1347 | + { |
|
1348 | + global $wpdb; |
|
1349 | + $items = $wpdb->get_results( |
|
1350 | + $wpdb->prepare( |
|
1351 | + "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1352 | + $parent |
|
1353 | + ) |
|
1354 | + ); |
|
1355 | + $output = ''; |
|
1356 | + |
|
1357 | + if ($items) { |
|
1358 | + $level = absint($level); |
|
1359 | + foreach ($items as $item) { |
|
1360 | + $ID = absint($item->ID); |
|
1361 | + $post_title = wp_strip_all_tags($item->post_title); |
|
1362 | + $pad = str_repeat(' ', $level * 3); |
|
1363 | + $option = "\n\t"; |
|
1364 | + $option .= '<option class="level-' . $level . '" '; |
|
1365 | + $option .= 'value="' . $ID . '" '; |
|
1366 | + $option .= $ID === absint($default) ? ' selected="selected"' : ''; |
|
1367 | + $option .= '>'; |
|
1368 | + $option .= "$pad {$post_title}"; |
|
1369 | + $option .= '</option>'; |
|
1370 | + $output .= $option; |
|
1371 | + ob_start(); |
|
1372 | + parent_dropdown($default, $item->ID, $level + 1); |
|
1373 | + $output .= ob_get_clean(); |
|
1374 | + } |
|
1375 | + } |
|
1376 | + if ($echo) { |
|
1377 | + echo $output; |
|
1378 | + return ''; |
|
1379 | + } |
|
1380 | + return $output; |
|
1381 | + } |
|
1382 | + |
|
1383 | + |
|
1384 | + /** |
|
1385 | + * Loads the scripts for the privacy settings form |
|
1386 | + */ |
|
1387 | + public function load_scripts_styles_privacy_settings() |
|
1388 | + { |
|
1389 | + $form_handler = |
|
1390 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1391 | + $form_handler->enqueueStylesAndScripts(); |
|
1392 | + } |
|
1393 | + |
|
1394 | + |
|
1395 | + /** |
|
1396 | + * display the privacy settings form |
|
1397 | + * |
|
1398 | + * @throws EE_Error |
|
1399 | + */ |
|
1400 | + public function privacySettings() |
|
1401 | + { |
|
1402 | + $this->_set_add_edit_form_tags('update_privacy_settings'); |
|
1403 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1404 | + $form_handler = |
|
1405 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1406 | + $this->_template_args['admin_page_content'] = $form_handler->display(); |
|
1407 | + $this->display_admin_page_with_sidebar(); |
|
1408 | + } |
|
1409 | + |
|
1410 | + |
|
1411 | + /** |
|
1412 | + * Update the privacy settings from form data |
|
1413 | + * |
|
1414 | + * @throws EE_Error |
|
1415 | + */ |
|
1416 | + public function updatePrivacySettings() |
|
1417 | + { |
|
1418 | + $form_handler = |
|
1419 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1420 | + $success = $form_handler->process($this->get_request_data()); |
|
1421 | + $this->_redirect_after_action( |
|
1422 | + $success, |
|
1423 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1424 | + 'updated', |
|
1425 | + ['action' => 'privacy_settings'] |
|
1426 | + ); |
|
1427 | + } |
|
1428 | 1428 | } |
@@ -9,21 +9,21 @@ |
||
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php esc_html_e( |
12 | - 'Specify if registrants should be allowed to attempt additional payments if the original payment is delayed.', |
|
13 | - 'event_espresso' |
|
14 | - ); ?> |
|
12 | + 'Specify if registrants should be allowed to attempt additional payments if the original payment is delayed.', |
|
13 | + 'event_espresso' |
|
14 | + ); ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong><br /> |
18 | 18 | <?php esc_html_e( |
19 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
20 | - 'event_espresso' |
|
21 | - ); ?> |
|
19 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
20 | + 'event_espresso' |
|
21 | + ); ?> |
|
22 | 22 | </p> |
23 | 23 | <p> |
24 | 24 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong><br /> |
25 | 25 | <?php esc_html_e( |
26 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
27 | - 'event_espresso' |
|
28 | - ); ?> |
|
26 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
27 | + 'event_espresso' |
|
28 | + ); ?> |
|
29 | 29 | </p> |
30 | 30 | \ No newline at end of file |
@@ -16,246 +16,246 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * This is used to hold the reports template data which is setup early in the request. |
|
21 | - * |
|
22 | - * @type array |
|
23 | - */ |
|
24 | - protected $_reports_template_data = array(); |
|
25 | - |
|
26 | - /** |
|
27 | - * @Constructor |
|
28 | - * @access public |
|
29 | - * |
|
30 | - * @param bool $routing |
|
31 | - * |
|
32 | - * @return \Extend_Transactions_Admin_Page |
|
33 | - */ |
|
34 | - public function __construct($routing = true) |
|
35 | - { |
|
36 | - parent::__construct($routing); |
|
37 | - define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
38 | - define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
39 | - define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * _extend_page_config |
|
45 | - * |
|
46 | - * @access protected |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - protected function _extend_page_config() |
|
50 | - { |
|
51 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
52 | - |
|
53 | - $new_page_routes = array( |
|
54 | - 'reports' => array( |
|
55 | - 'func' => '_transaction_reports', |
|
56 | - 'capability' => 'ee_read_transactions', |
|
57 | - ), |
|
58 | - ); |
|
59 | - |
|
60 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
61 | - |
|
62 | - $new_page_config = array( |
|
63 | - 'reports' => array( |
|
64 | - 'nav' => array( |
|
65 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
66 | - 'order' => 20, |
|
67 | - ), |
|
68 | - 'help_tabs' => array( |
|
69 | - 'transactions_reports_help_tab' => array( |
|
70 | - 'title' => esc_html__('Transaction Reports', 'event_espresso'), |
|
71 | - 'filename' => 'transactions_reports', |
|
72 | - ), |
|
73 | - ), |
|
74 | - 'require_nonce' => false, |
|
75 | - ), |
|
76 | - ); |
|
77 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * load_scripts_styles_reports |
|
83 | - * |
|
84 | - * @access public |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function load_scripts_styles_reports() |
|
88 | - { |
|
89 | - wp_register_script( |
|
90 | - 'ee-txn-reports-js', |
|
91 | - TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
92 | - array('google-charts'), |
|
93 | - EVENT_ESPRESSO_VERSION, |
|
94 | - true |
|
95 | - ); |
|
96 | - wp_enqueue_script('ee-txn-reports-js'); |
|
97 | - $this->_transaction_reports_js_setup(); |
|
98 | - EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
104 | - * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method. |
|
105 | - */ |
|
106 | - protected function _transaction_reports_js_setup() |
|
107 | - { |
|
108 | - $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report(); |
|
109 | - $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report(); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * _transaction_reports |
|
115 | - * generates Business Reports regarding Transactions |
|
116 | - * |
|
117 | - * @return void |
|
118 | - */ |
|
119 | - protected function _transaction_reports() |
|
120 | - { |
|
121 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
122 | - $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
123 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
124 | - $template_path, |
|
125 | - $this->_reports_template_data, |
|
126 | - true |
|
127 | - ); |
|
128 | - |
|
129 | - // the final template wrapper |
|
130 | - $this->display_admin_page_with_no_sidebar(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * _revenue_per_day_report |
|
136 | - * generates Business Report showing Total Revenue per Day. |
|
137 | - * |
|
138 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
139 | - * |
|
140 | - * @return string |
|
141 | - */ |
|
142 | - private function _revenue_per_day_report($period = '-1 month') |
|
143 | - { |
|
144 | - |
|
145 | - $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
|
146 | - |
|
147 | - $TXN = EEM_Transaction::instance(); |
|
148 | - |
|
149 | - $results = $TXN->get_revenue_per_day_report($period); |
|
150 | - $results = (array) $results; |
|
151 | - $revenue = array(); |
|
152 | - $subtitle = ''; |
|
153 | - |
|
154 | - if ($results) { |
|
155 | - $revenue[] = array( |
|
156 | - esc_html__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), |
|
157 | - esc_html__('Total Revenue', 'event_espresso'), |
|
158 | - ); |
|
159 | - foreach ($results as $result) { |
|
160 | - $revenue[] = array($result->txnDate, (float) $result->revenue); |
|
161 | - } |
|
162 | - |
|
163 | - // setup the date range. |
|
164 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
165 | - $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
166 | - $subtitle = sprintf( |
|
167 | - wp_strip_all_tags( |
|
168 | - _x('For the period: %s to %s', 'Used to give date range', 'event_espresso') |
|
169 | - ), |
|
170 | - $beginning_date->format('Y-m-d'), |
|
171 | - $ending_date->format('Y-m-d') |
|
172 | - ); |
|
173 | - } |
|
174 | - |
|
175 | - $report_title = wp_strip_all_tags(__('Total Revenue per Day', 'event_espresso')); |
|
176 | - |
|
177 | - $report_params = array( |
|
178 | - 'title' => $report_title, |
|
179 | - 'subtitle' => $subtitle, |
|
180 | - 'id' => $report_ID, |
|
181 | - 'revenue' => $revenue, |
|
182 | - 'noResults' => empty($revenue) || count($revenue) === 1, |
|
183 | - 'noTxnMsg' => sprintf( |
|
184 | - wp_strip_all_tags( |
|
185 | - __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso') |
|
186 | - ), |
|
187 | - '<h2>' . $report_title . '</h2><p>', |
|
188 | - '</p>' |
|
189 | - ), |
|
190 | - ); |
|
191 | - wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
192 | - |
|
193 | - return $report_ID; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * _revenue_per_event_report |
|
199 | - * generates Business Report showing total revenue per event. |
|
200 | - * |
|
201 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
202 | - * |
|
203 | - * @return int |
|
204 | - */ |
|
205 | - private function _revenue_per_event_report($period = '-1 month') |
|
206 | - { |
|
207 | - |
|
208 | - $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
|
209 | - |
|
210 | - $TXN = EEM_Transaction::instance(); |
|
211 | - $results = $TXN->get_revenue_per_event_report($period); |
|
212 | - $results = (array) $results; |
|
213 | - $revenue = array(); |
|
214 | - $subtitle = ''; |
|
215 | - |
|
216 | - if ($results) { |
|
217 | - $revenue[] = array( |
|
218 | - esc_html__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), |
|
219 | - esc_html__('Total Revenue', 'event_espresso'), |
|
220 | - ); |
|
221 | - foreach ($results as $result) { |
|
222 | - if ($result->revenue > 1) { |
|
223 | - $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
224 | - $event_name = wp_trim_words($event_name, 5, '...'); |
|
225 | - $revenue[] = array($event_name, (float) $result->revenue); |
|
226 | - } |
|
227 | - } |
|
228 | - |
|
229 | - // setup the date range. |
|
230 | - $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
231 | - $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
232 | - $subtitle = sprintf( |
|
233 | - wp_strip_all_tags( |
|
234 | - _x('For the period: %s to %s', 'Used to give date range', 'event_espresso') |
|
235 | - ), |
|
236 | - $beginning_date->format('Y-m-d'), |
|
237 | - $ending_date->format('Y-m-d') |
|
238 | - ); |
|
239 | - } |
|
240 | - |
|
241 | - $report_title = wp_strip_all_tags(__('Total Revenue per Event', 'event_espresso')); |
|
242 | - |
|
243 | - $report_params = array( |
|
244 | - 'title' => $report_title, |
|
245 | - 'subtitle' => $subtitle, |
|
246 | - 'id' => $report_ID, |
|
247 | - 'revenue' => $revenue, |
|
248 | - 'noResults' => empty($revenue), |
|
249 | - 'noTxnMsg' => sprintf( |
|
250 | - wp_strip_all_tags( |
|
251 | - __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso') |
|
252 | - ), |
|
253 | - '<h2>' . $report_title . '</h2><p>', |
|
254 | - '</p>' |
|
255 | - ), |
|
256 | - ); |
|
257 | - wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
258 | - |
|
259 | - return $report_ID; |
|
260 | - } |
|
19 | + /** |
|
20 | + * This is used to hold the reports template data which is setup early in the request. |
|
21 | + * |
|
22 | + * @type array |
|
23 | + */ |
|
24 | + protected $_reports_template_data = array(); |
|
25 | + |
|
26 | + /** |
|
27 | + * @Constructor |
|
28 | + * @access public |
|
29 | + * |
|
30 | + * @param bool $routing |
|
31 | + * |
|
32 | + * @return \Extend_Transactions_Admin_Page |
|
33 | + */ |
|
34 | + public function __construct($routing = true) |
|
35 | + { |
|
36 | + parent::__construct($routing); |
|
37 | + define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/'); |
|
38 | + define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/'); |
|
39 | + define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/'); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * _extend_page_config |
|
45 | + * |
|
46 | + * @access protected |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + protected function _extend_page_config() |
|
50 | + { |
|
51 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions'; |
|
52 | + |
|
53 | + $new_page_routes = array( |
|
54 | + 'reports' => array( |
|
55 | + 'func' => '_transaction_reports', |
|
56 | + 'capability' => 'ee_read_transactions', |
|
57 | + ), |
|
58 | + ); |
|
59 | + |
|
60 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
61 | + |
|
62 | + $new_page_config = array( |
|
63 | + 'reports' => array( |
|
64 | + 'nav' => array( |
|
65 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
66 | + 'order' => 20, |
|
67 | + ), |
|
68 | + 'help_tabs' => array( |
|
69 | + 'transactions_reports_help_tab' => array( |
|
70 | + 'title' => esc_html__('Transaction Reports', 'event_espresso'), |
|
71 | + 'filename' => 'transactions_reports', |
|
72 | + ), |
|
73 | + ), |
|
74 | + 'require_nonce' => false, |
|
75 | + ), |
|
76 | + ); |
|
77 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * load_scripts_styles_reports |
|
83 | + * |
|
84 | + * @access public |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function load_scripts_styles_reports() |
|
88 | + { |
|
89 | + wp_register_script( |
|
90 | + 'ee-txn-reports-js', |
|
91 | + TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', |
|
92 | + array('google-charts'), |
|
93 | + EVENT_ESPRESSO_VERSION, |
|
94 | + true |
|
95 | + ); |
|
96 | + wp_enqueue_script('ee-txn-reports-js'); |
|
97 | + $this->_transaction_reports_js_setup(); |
|
98 | + EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts(); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
104 | + * Also $this->{$_reports_template_data} property is set for later usage by the _transaction_reports method. |
|
105 | + */ |
|
106 | + protected function _transaction_reports_js_setup() |
|
107 | + { |
|
108 | + $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_day_report(); |
|
109 | + $this->_reports_template_data['admin_reports'][] = $this->_revenue_per_event_report(); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * _transaction_reports |
|
115 | + * generates Business Reports regarding Transactions |
|
116 | + * |
|
117 | + * @return void |
|
118 | + */ |
|
119 | + protected function _transaction_reports() |
|
120 | + { |
|
121 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
122 | + $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
123 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
124 | + $template_path, |
|
125 | + $this->_reports_template_data, |
|
126 | + true |
|
127 | + ); |
|
128 | + |
|
129 | + // the final template wrapper |
|
130 | + $this->display_admin_page_with_no_sidebar(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * _revenue_per_day_report |
|
136 | + * generates Business Report showing Total Revenue per Day. |
|
137 | + * |
|
138 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
139 | + * |
|
140 | + * @return string |
|
141 | + */ |
|
142 | + private function _revenue_per_day_report($period = '-1 month') |
|
143 | + { |
|
144 | + |
|
145 | + $report_ID = 'txn-admin-revenue-per-day-report-dv'; |
|
146 | + |
|
147 | + $TXN = EEM_Transaction::instance(); |
|
148 | + |
|
149 | + $results = $TXN->get_revenue_per_day_report($period); |
|
150 | + $results = (array) $results; |
|
151 | + $revenue = array(); |
|
152 | + $subtitle = ''; |
|
153 | + |
|
154 | + if ($results) { |
|
155 | + $revenue[] = array( |
|
156 | + esc_html__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), |
|
157 | + esc_html__('Total Revenue', 'event_espresso'), |
|
158 | + ); |
|
159 | + foreach ($results as $result) { |
|
160 | + $revenue[] = array($result->txnDate, (float) $result->revenue); |
|
161 | + } |
|
162 | + |
|
163 | + // setup the date range. |
|
164 | + $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
165 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
166 | + $subtitle = sprintf( |
|
167 | + wp_strip_all_tags( |
|
168 | + _x('For the period: %s to %s', 'Used to give date range', 'event_espresso') |
|
169 | + ), |
|
170 | + $beginning_date->format('Y-m-d'), |
|
171 | + $ending_date->format('Y-m-d') |
|
172 | + ); |
|
173 | + } |
|
174 | + |
|
175 | + $report_title = wp_strip_all_tags(__('Total Revenue per Day', 'event_espresso')); |
|
176 | + |
|
177 | + $report_params = array( |
|
178 | + 'title' => $report_title, |
|
179 | + 'subtitle' => $subtitle, |
|
180 | + 'id' => $report_ID, |
|
181 | + 'revenue' => $revenue, |
|
182 | + 'noResults' => empty($revenue) || count($revenue) === 1, |
|
183 | + 'noTxnMsg' => sprintf( |
|
184 | + wp_strip_all_tags( |
|
185 | + __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso') |
|
186 | + ), |
|
187 | + '<h2>' . $report_title . '</h2><p>', |
|
188 | + '</p>' |
|
189 | + ), |
|
190 | + ); |
|
191 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params); |
|
192 | + |
|
193 | + return $report_ID; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * _revenue_per_event_report |
|
199 | + * generates Business Report showing total revenue per event. |
|
200 | + * |
|
201 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
202 | + * |
|
203 | + * @return int |
|
204 | + */ |
|
205 | + private function _revenue_per_event_report($period = '-1 month') |
|
206 | + { |
|
207 | + |
|
208 | + $report_ID = 'txn-admin-revenue-per-event-report-dv'; |
|
209 | + |
|
210 | + $TXN = EEM_Transaction::instance(); |
|
211 | + $results = $TXN->get_revenue_per_event_report($period); |
|
212 | + $results = (array) $results; |
|
213 | + $revenue = array(); |
|
214 | + $subtitle = ''; |
|
215 | + |
|
216 | + if ($results) { |
|
217 | + $revenue[] = array( |
|
218 | + esc_html__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), |
|
219 | + esc_html__('Total Revenue', 'event_espresso'), |
|
220 | + ); |
|
221 | + foreach ($results as $result) { |
|
222 | + if ($result->revenue > 1) { |
|
223 | + $event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8')); |
|
224 | + $event_name = wp_trim_words($event_name, 5, '...'); |
|
225 | + $revenue[] = array($event_name, (float) $result->revenue); |
|
226 | + } |
|
227 | + } |
|
228 | + |
|
229 | + // setup the date range. |
|
230 | + $beginning_date = new DateTime('now' . $period, new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
231 | + $ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone())); |
|
232 | + $subtitle = sprintf( |
|
233 | + wp_strip_all_tags( |
|
234 | + _x('For the period: %s to %s', 'Used to give date range', 'event_espresso') |
|
235 | + ), |
|
236 | + $beginning_date->format('Y-m-d'), |
|
237 | + $ending_date->format('Y-m-d') |
|
238 | + ); |
|
239 | + } |
|
240 | + |
|
241 | + $report_title = wp_strip_all_tags(__('Total Revenue per Event', 'event_espresso')); |
|
242 | + |
|
243 | + $report_params = array( |
|
244 | + 'title' => $report_title, |
|
245 | + 'subtitle' => $subtitle, |
|
246 | + 'id' => $report_ID, |
|
247 | + 'revenue' => $revenue, |
|
248 | + 'noResults' => empty($revenue), |
|
249 | + 'noTxnMsg' => sprintf( |
|
250 | + wp_strip_all_tags( |
|
251 | + __('%sThere is no revenue to report for the last 30 days.%s', 'event_espresso') |
|
252 | + ), |
|
253 | + '<h2>' . $report_title . '</h2><p>', |
|
254 | + '</p>' |
|
255 | + ), |
|
256 | + ); |
|
257 | + wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params); |
|
258 | + |
|
259 | + return $report_ID; |
|
260 | + } |
|
261 | 261 | } |
@@ -13,2525 +13,2525 @@ |
||
13 | 13 | class Transactions_Admin_Page extends EE_Admin_Page |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var EE_Transaction |
|
18 | - */ |
|
19 | - private $_transaction; |
|
20 | - |
|
21 | - /** |
|
22 | - * @var EE_Session |
|
23 | - */ |
|
24 | - private $_session; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var array $_txn_status |
|
28 | - */ |
|
29 | - private static $_txn_status; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var array $_pay_status |
|
33 | - */ |
|
34 | - private static $_pay_status; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var array $_existing_reg_payment_REG_IDs |
|
38 | - */ |
|
39 | - protected $_existing_reg_payment_REG_IDs; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * _init_page_props |
|
44 | - * |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - protected function _init_page_props() |
|
48 | - { |
|
49 | - $this->page_slug = TXN_PG_SLUG; |
|
50 | - $this->page_label = esc_html__('Transactions', 'event_espresso'); |
|
51 | - $this->_admin_base_url = TXN_ADMIN_URL; |
|
52 | - $this->_admin_base_path = TXN_ADMIN; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * _ajax_hooks |
|
58 | - * |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - protected function _ajax_hooks() |
|
62 | - { |
|
63 | - add_action('wp_ajax_espresso_apply_payment', [$this, 'apply_payments_or_refunds']); |
|
64 | - add_action('wp_ajax_espresso_apply_refund', [$this, 'apply_payments_or_refunds']); |
|
65 | - add_action('wp_ajax_espresso_delete_payment', [$this, 'delete_payment']); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * _define_page_props |
|
71 | - * |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - protected function _define_page_props() |
|
75 | - { |
|
76 | - $this->_admin_page_title = $this->page_label; |
|
77 | - $this->_labels = [ |
|
78 | - 'buttons' => [ |
|
79 | - 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
|
80 | - 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
|
81 | - 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
82 | - ], |
|
83 | - ]; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * grab url requests and route them |
|
89 | - * |
|
90 | - * @access private |
|
91 | - * @return void |
|
92 | - * @throws EE_Error |
|
93 | - * @throws InvalidArgumentException |
|
94 | - * @throws InvalidDataTypeException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - */ |
|
97 | - public function _set_page_routes() |
|
98 | - { |
|
99 | - |
|
100 | - $this->_set_transaction_status_array(); |
|
101 | - $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
102 | - |
|
103 | - $this->_page_routes = [ |
|
104 | - |
|
105 | - 'default' => [ |
|
106 | - 'func' => '_transactions_overview_list_table', |
|
107 | - 'capability' => 'ee_read_transactions', |
|
108 | - ], |
|
109 | - |
|
110 | - 'view_transaction' => [ |
|
111 | - 'func' => '_transaction_details', |
|
112 | - 'capability' => 'ee_read_transaction', |
|
113 | - 'obj_id' => $TXN_ID, |
|
114 | - ], |
|
115 | - |
|
116 | - 'send_payment_reminder' => [ |
|
117 | - 'func' => '_send_payment_reminder', |
|
118 | - 'noheader' => true, |
|
119 | - 'capability' => 'ee_send_message', |
|
120 | - ], |
|
121 | - |
|
122 | - 'espresso_apply_payment' => [ |
|
123 | - 'func' => 'apply_payments_or_refunds', |
|
124 | - 'noheader' => true, |
|
125 | - 'capability' => 'ee_edit_payments', |
|
126 | - ], |
|
127 | - |
|
128 | - 'espresso_apply_refund' => [ |
|
129 | - 'func' => 'apply_payments_or_refunds', |
|
130 | - 'noheader' => true, |
|
131 | - 'capability' => 'ee_edit_payments', |
|
132 | - ], |
|
133 | - |
|
134 | - 'espresso_delete_payment' => [ |
|
135 | - 'func' => 'delete_payment', |
|
136 | - 'noheader' => true, |
|
137 | - 'capability' => 'ee_delete_payments', |
|
138 | - ], |
|
139 | - |
|
140 | - 'espresso_recalculate_line_items' => [ |
|
141 | - 'func' => 'recalculateLineItems', |
|
142 | - 'noheader' => true, |
|
143 | - 'capability' => 'ee_edit_payments', |
|
144 | - ], |
|
145 | - |
|
146 | - ]; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - protected function _set_page_config() |
|
151 | - { |
|
152 | - $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
153 | - $this->_page_config = [ |
|
154 | - 'default' => [ |
|
155 | - 'nav' => [ |
|
156 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
157 | - 'order' => 10, |
|
158 | - ], |
|
159 | - 'list_table' => 'EE_Admin_Transactions_List_Table', |
|
160 | - 'help_tabs' => [ |
|
161 | - 'transactions_overview_help_tab' => [ |
|
162 | - 'title' => esc_html__('Transactions Overview', 'event_espresso'), |
|
163 | - 'filename' => 'transactions_overview', |
|
164 | - ], |
|
165 | - 'transactions_overview_table_column_headings_help_tab' => [ |
|
166 | - 'title' => esc_html__('Transactions Table Column Headings', 'event_espresso'), |
|
167 | - 'filename' => 'transactions_overview_table_column_headings', |
|
168 | - ], |
|
169 | - 'transactions_overview_views_filters_help_tab' => [ |
|
170 | - 'title' => esc_html__('Transaction Views & Filters & Search', 'event_espresso'), |
|
171 | - 'filename' => 'transactions_overview_views_filters_search', |
|
172 | - ], |
|
173 | - ], |
|
174 | - /** |
|
175 | - * commented out because currently we are not displaying tips for transaction list table status but this |
|
176 | - * may change in a later iteration so want to keep the code for then. |
|
177 | - */ |
|
178 | - // 'qtips' => array( 'Transactions_List_Table_Tips' ), |
|
179 | - 'require_nonce' => false, |
|
180 | - ], |
|
181 | - 'view_transaction' => [ |
|
182 | - 'nav' => [ |
|
183 | - 'label' => esc_html__('View Transaction', 'event_espresso'), |
|
184 | - 'order' => 5, |
|
185 | - 'url' => $TXN_ID |
|
186 | - ? add_query_arg(['TXN_ID' => $TXN_ID], $this->_current_page_view_url) |
|
187 | - : $this->_admin_base_url, |
|
188 | - 'persistent' => false, |
|
189 | - ], |
|
190 | - 'help_tabs' => [ |
|
191 | - 'transactions_view_transaction_help_tab' => [ |
|
192 | - 'title' => esc_html__('View Transaction', 'event_espresso'), |
|
193 | - 'filename' => 'transactions_view_transaction', |
|
194 | - ], |
|
195 | - 'transactions_view_transaction_transaction_details_table_help_tab' => [ |
|
196 | - 'title' => esc_html__('Transaction Details Table', 'event_espresso'), |
|
197 | - 'filename' => 'transactions_view_transaction_transaction_details_table', |
|
198 | - ], |
|
199 | - 'transactions_view_transaction_attendees_registered_help_tab' => [ |
|
200 | - 'title' => esc_html__('Attendees Registered', 'event_espresso'), |
|
201 | - 'filename' => 'transactions_view_transaction_attendees_registered', |
|
202 | - ], |
|
203 | - 'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => [ |
|
204 | - 'title' => esc_html__('Primary Registrant & Billing Information', 'event_espresso'), |
|
205 | - 'filename' => 'transactions_view_transaction_primary_registrant_billing_information', |
|
206 | - ], |
|
207 | - ], |
|
208 | - 'qtips' => ['Transaction_Details_Tips'], |
|
209 | - 'metaboxes' => ['_transaction_details_metaboxes'], |
|
210 | - |
|
211 | - 'require_nonce' => false, |
|
212 | - ], |
|
213 | - ]; |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * The below methods aren't used by this class currently |
|
219 | - */ |
|
220 | - protected function _add_screen_options() |
|
221 | - { |
|
222 | - // noop |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - protected function _add_feature_pointers() |
|
227 | - { |
|
228 | - // noop |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - public function admin_init() |
|
233 | - { |
|
234 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
235 | - $event_name = $this->request->getRequestParam('event_name'); |
|
236 | - $redirect_from = $this->request->getRequestParam('redirect_from', '', 'url'); |
|
237 | - // IF a registration was JUST added via the admin... |
|
238 | - if ($EVT_ID && $event_name && $redirect_from) { |
|
239 | - // then set a cookie so that we can block any attempts to use |
|
240 | - // the back button as a way to enter another registration. |
|
241 | - setcookie('ee_registration_added', $EVT_ID, time() + WEEK_IN_SECONDS, '/'); |
|
242 | - // and update the global |
|
243 | - $_COOKIE['ee_registration_added'] = $EVT_ID; |
|
244 | - } |
|
245 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__( |
|
246 | - 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
247 | - 'event_espresso' |
|
248 | - ); |
|
249 | - EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__( |
|
250 | - 'An error occurred! Please refresh the page and try again.', |
|
251 | - 'event_espresso' |
|
252 | - ); |
|
253 | - EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
254 | - EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
255 | - EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
256 | - EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__( |
|
257 | - 'This transaction has been overpaid ! Payments Total', |
|
258 | - 'event_espresso' |
|
259 | - ); |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - public function admin_notices() |
|
264 | - { |
|
265 | - // noop |
|
266 | - } |
|
267 | - |
|
268 | - |
|
269 | - public function admin_footer_scripts() |
|
270 | - { |
|
271 | - // noop |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * _set_transaction_status_array |
|
277 | - * sets list of transaction statuses |
|
278 | - * |
|
279 | - * @access private |
|
280 | - * @return void |
|
281 | - * @throws EE_Error |
|
282 | - * @throws InvalidArgumentException |
|
283 | - * @throws InvalidDataTypeException |
|
284 | - * @throws InvalidInterfaceException |
|
285 | - */ |
|
286 | - private function _set_transaction_status_array() |
|
287 | - { |
|
288 | - self::$_txn_status = EEM_Transaction::instance()->status_array(true); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - /** |
|
293 | - * get_transaction_status_array |
|
294 | - * return the transaction status array for wp_list_table |
|
295 | - * |
|
296 | - * @access public |
|
297 | - * @return array |
|
298 | - */ |
|
299 | - public function get_transaction_status_array() |
|
300 | - { |
|
301 | - return self::$_txn_status; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * get list of payment statuses |
|
307 | - * |
|
308 | - * @access private |
|
309 | - * @return void |
|
310 | - * @throws EE_Error |
|
311 | - * @throws InvalidArgumentException |
|
312 | - * @throws InvalidDataTypeException |
|
313 | - * @throws InvalidInterfaceException |
|
314 | - */ |
|
315 | - private function _get_payment_status_array() |
|
316 | - { |
|
317 | - self::$_pay_status = EEM_Payment::instance()->status_array(true); |
|
318 | - $this->_template_args['payment_status'] = self::$_pay_status; |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * _add_screen_options_default |
|
324 | - * |
|
325 | - * @access protected |
|
326 | - * @return void |
|
327 | - * @throws InvalidArgumentException |
|
328 | - * @throws InvalidDataTypeException |
|
329 | - * @throws InvalidInterfaceException |
|
330 | - */ |
|
331 | - protected function _add_screen_options_default() |
|
332 | - { |
|
333 | - $this->_per_page_screen_option(); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * load_scripts_styles |
|
339 | - * |
|
340 | - * @access public |
|
341 | - * @return void |
|
342 | - */ |
|
343 | - public function load_scripts_styles() |
|
344 | - { |
|
345 | - // enqueue style |
|
346 | - wp_register_style( |
|
347 | - 'espresso_txn', |
|
348 | - TXN_ASSETS_URL . 'espresso_transactions_admin.css', |
|
349 | - [], |
|
350 | - EVENT_ESPRESSO_VERSION |
|
351 | - ); |
|
352 | - wp_enqueue_style('espresso_txn'); |
|
353 | - // scripts |
|
354 | - wp_register_script( |
|
355 | - 'espresso_txn', |
|
356 | - TXN_ASSETS_URL . 'espresso_transactions_admin.js', |
|
357 | - [ |
|
358 | - 'ee_admin_js', |
|
359 | - 'ee-datepicker', |
|
360 | - 'jquery-ui-datepicker', |
|
361 | - 'jquery-ui-draggable', |
|
362 | - 'ee-dialog', |
|
363 | - 'ee-accounting', |
|
364 | - 'ee-serialize-full-array', |
|
365 | - ], |
|
366 | - EVENT_ESPRESSO_VERSION, |
|
367 | - true |
|
368 | - ); |
|
369 | - wp_enqueue_script('espresso_txn'); |
|
370 | - } |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * load_scripts_styles_view_transaction |
|
375 | - * |
|
376 | - * @access public |
|
377 | - * @return void |
|
378 | - */ |
|
379 | - public function load_scripts_styles_view_transaction() |
|
380 | - { |
|
381 | - // styles |
|
382 | - wp_enqueue_style('espresso-ui-theme'); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * load_scripts_styles_default |
|
388 | - * |
|
389 | - * @access public |
|
390 | - * @return void |
|
391 | - */ |
|
392 | - public function load_scripts_styles_default() |
|
393 | - { |
|
394 | - // styles |
|
395 | - wp_enqueue_style('espresso-ui-theme'); |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - /** |
|
400 | - * _set_list_table_views_default |
|
401 | - * |
|
402 | - * @access protected |
|
403 | - * @return void |
|
404 | - */ |
|
405 | - protected function _set_list_table_views_default() |
|
406 | - { |
|
407 | - $this->_views = [ |
|
408 | - 'all' => [ |
|
409 | - 'slug' => 'all', |
|
410 | - 'label' => esc_html__('View All Transactions', 'event_espresso'), |
|
411 | - 'count' => 0, |
|
412 | - ], |
|
413 | - 'abandoned' => [ |
|
414 | - 'slug' => 'abandoned', |
|
415 | - 'label' => esc_html__('Abandoned Transactions', 'event_espresso'), |
|
416 | - 'count' => 0, |
|
417 | - ], |
|
418 | - 'incomplete' => [ |
|
419 | - 'slug' => 'incomplete', |
|
420 | - 'label' => esc_html__('Incomplete Transactions', 'event_espresso'), |
|
421 | - 'count' => 0, |
|
422 | - ], |
|
423 | - ]; |
|
424 | - if ( |
|
425 | - /** |
|
426 | - * Filters whether a link to the "Failed Transactions" list table |
|
427 | - * appears on the Transactions Admin Page list table. |
|
428 | - * List display can be turned back on via the following: |
|
429 | - * add_filter( |
|
430 | - * 'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list', |
|
431 | - * '__return_true' |
|
432 | - * ); |
|
433 | - * |
|
434 | - * @param boolean $display_failed_txns_list |
|
435 | - * @param Transactions_Admin_Page $this |
|
436 | - * @since 4.9.70.p |
|
437 | - */ |
|
438 | - apply_filters( |
|
439 | - 'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list', |
|
440 | - false, |
|
441 | - $this |
|
442 | - ) |
|
443 | - ) { |
|
444 | - $this->_views['failed'] = [ |
|
445 | - 'slug' => 'failed', |
|
446 | - 'label' => esc_html__('Failed Transactions', 'event_espresso'), |
|
447 | - 'count' => 0, |
|
448 | - ]; |
|
449 | - } |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * _set_transaction_object |
|
455 | - * This sets the _transaction property for the transaction details screen |
|
456 | - * |
|
457 | - * @access private |
|
458 | - * @return void |
|
459 | - * @throws EE_Error |
|
460 | - * @throws InvalidArgumentException |
|
461 | - * @throws RuntimeException |
|
462 | - * @throws InvalidDataTypeException |
|
463 | - * @throws InvalidInterfaceException |
|
464 | - * @throws ReflectionException |
|
465 | - */ |
|
466 | - private function _set_transaction_object() |
|
467 | - { |
|
468 | - if ($this->_transaction instanceof EE_Transaction) { |
|
469 | - return; |
|
470 | - } //get out we've already set the object |
|
471 | - |
|
472 | - $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
473 | - |
|
474 | - // get transaction object |
|
475 | - $this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
476 | - $this->_session = $this->_transaction instanceof EE_Transaction |
|
477 | - ? $this->_transaction->session_data() |
|
478 | - : null; |
|
479 | - if ($this->_transaction instanceof EE_Transaction) { |
|
480 | - $this->_transaction->verify_abandoned_transaction_status(); |
|
481 | - } |
|
482 | - |
|
483 | - if (! $this->_transaction instanceof EE_Transaction) { |
|
484 | - $error_msg = sprintf( |
|
485 | - esc_html__( |
|
486 | - 'An error occurred and the details for the transaction with the ID # %d could not be retrieved.', |
|
487 | - 'event_espresso' |
|
488 | - ), |
|
489 | - $TXN_ID |
|
490 | - ); |
|
491 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
492 | - } |
|
493 | - } |
|
494 | - |
|
495 | - |
|
496 | - /** |
|
497 | - * _transaction_legend_items |
|
498 | - * |
|
499 | - * @access protected |
|
500 | - * @return array |
|
501 | - * @throws EE_Error |
|
502 | - * @throws InvalidArgumentException |
|
503 | - * @throws ReflectionException |
|
504 | - * @throws InvalidDataTypeException |
|
505 | - * @throws InvalidInterfaceException |
|
506 | - */ |
|
507 | - protected function _transaction_legend_items() |
|
508 | - { |
|
509 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
510 | - $items = []; |
|
511 | - |
|
512 | - if ( |
|
513 | - EE_Registry::instance()->CAP->current_user_can( |
|
514 | - 'ee_read_global_messages', |
|
515 | - 'view_filtered_messages' |
|
516 | - ) |
|
517 | - ) { |
|
518 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
519 | - if ( |
|
520 | - is_array($related_for_icon) |
|
521 | - && isset($related_for_icon['css_class'], $related_for_icon['label']) |
|
522 | - ) { |
|
523 | - $items['view_related_messages'] = [ |
|
524 | - 'class' => $related_for_icon['css_class'], |
|
525 | - 'desc' => $related_for_icon['label'], |
|
526 | - ]; |
|
527 | - } |
|
528 | - } |
|
529 | - |
|
530 | - $items = apply_filters( |
|
531 | - 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
|
532 | - array_merge( |
|
533 | - $items, |
|
534 | - [ |
|
535 | - 'view_details' => [ |
|
536 | - 'class' => 'dashicons dashicons-cart', |
|
537 | - 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
538 | - ], |
|
539 | - 'view_invoice' => [ |
|
540 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
541 | - 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
542 | - ], |
|
543 | - 'view_receipt' => [ |
|
544 | - 'class' => 'dashicons dashicons-media-default', |
|
545 | - 'desc' => esc_html__('View Transaction Receipt', 'event_espresso'), |
|
546 | - ], |
|
547 | - 'view_registration' => [ |
|
548 | - 'class' => 'dashicons dashicons-clipboard', |
|
549 | - 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
550 | - ], |
|
551 | - 'payment_overview_link' => [ |
|
552 | - 'class' => 'dashicons dashicons-money', |
|
553 | - 'desc' => esc_html__('Make Payment on Frontend', 'event_espresso'), |
|
554 | - ], |
|
555 | - ] |
|
556 | - ) |
|
557 | - ); |
|
558 | - |
|
559 | - if ( |
|
560 | - EEH_MSG_Template::is_mt_active('payment_reminder') |
|
561 | - && EE_Registry::instance()->CAP->current_user_can( |
|
562 | - 'ee_send_message', |
|
563 | - 'espresso_transactions_send_payment_reminder' |
|
564 | - ) |
|
565 | - ) { |
|
566 | - $items['send_payment_reminder'] = [ |
|
567 | - 'class' => 'dashicons dashicons-email-alt', |
|
568 | - 'desc' => esc_html__('Send Payment Reminder', 'event_espresso'), |
|
569 | - ]; |
|
570 | - } else { |
|
571 | - $items['blank*'] = [ |
|
572 | - 'class' => '', |
|
573 | - 'desc' => '', |
|
574 | - ]; |
|
575 | - } |
|
576 | - $more_items = apply_filters( |
|
577 | - 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
|
578 | - [ |
|
579 | - 'overpaid' => [ |
|
580 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
581 | - 'desc' => EEH_Template::pretty_status( |
|
582 | - EEM_Transaction::overpaid_status_code, |
|
583 | - false, |
|
584 | - 'sentence' |
|
585 | - ), |
|
586 | - ], |
|
587 | - 'complete' => [ |
|
588 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
589 | - 'desc' => EEH_Template::pretty_status( |
|
590 | - EEM_Transaction::complete_status_code, |
|
591 | - false, |
|
592 | - 'sentence' |
|
593 | - ), |
|
594 | - ], |
|
595 | - 'incomplete' => [ |
|
596 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
597 | - 'desc' => EEH_Template::pretty_status( |
|
598 | - EEM_Transaction::incomplete_status_code, |
|
599 | - false, |
|
600 | - 'sentence' |
|
601 | - ), |
|
602 | - ], |
|
603 | - 'abandoned' => [ |
|
604 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
605 | - 'desc' => EEH_Template::pretty_status( |
|
606 | - EEM_Transaction::abandoned_status_code, |
|
607 | - false, |
|
608 | - 'sentence' |
|
609 | - ), |
|
610 | - ], |
|
611 | - 'failed' => [ |
|
612 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
613 | - 'desc' => EEH_Template::pretty_status( |
|
614 | - EEM_Transaction::failed_status_code, |
|
615 | - false, |
|
616 | - 'sentence' |
|
617 | - ), |
|
618 | - ], |
|
619 | - ] |
|
620 | - ); |
|
621 | - |
|
622 | - return array_merge($items, $more_items); |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - /** |
|
627 | - * _transactions_overview_list_table |
|
628 | - * |
|
629 | - * @access protected |
|
630 | - * @return void |
|
631 | - * @throws DomainException |
|
632 | - * @throws EE_Error |
|
633 | - * @throws InvalidArgumentException |
|
634 | - * @throws InvalidDataTypeException |
|
635 | - * @throws InvalidInterfaceException |
|
636 | - * @throws ReflectionException |
|
637 | - */ |
|
638 | - protected function _transactions_overview_list_table() |
|
639 | - { |
|
640 | - $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
641 | - |
|
642 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
643 | - $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
644 | - $this->_template_args['admin_page_header'] = $event instanceof EE_Event |
|
645 | - ? sprintf( |
|
646 | - esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), |
|
647 | - '<h3>', |
|
648 | - '<a href="' |
|
649 | - . EE_Admin_Page::add_query_args_and_nonce( |
|
650 | - ['action' => 'edit', 'post' => $event->ID()], |
|
651 | - EVENTS_ADMIN_URL |
|
652 | - ) |
|
653 | - . '" title="' |
|
654 | - . esc_attr__('Click to Edit event', 'event_espresso') |
|
655 | - . '">' . $event->name() . '</a>', |
|
656 | - '</h3>' |
|
657 | - ) |
|
658 | - : ''; |
|
659 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
660 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
661 | - } |
|
662 | - |
|
663 | - |
|
664 | - /** |
|
665 | - * _transaction_details |
|
666 | - * generates HTML for the View Transaction Details Admin page |
|
667 | - * |
|
668 | - * @access protected |
|
669 | - * @return void |
|
670 | - * @throws DomainException |
|
671 | - * @throws EE_Error |
|
672 | - * @throws InvalidArgumentException |
|
673 | - * @throws InvalidDataTypeException |
|
674 | - * @throws InvalidInterfaceException |
|
675 | - * @throws RuntimeException |
|
676 | - * @throws ReflectionException |
|
677 | - */ |
|
678 | - protected function _transaction_details() |
|
679 | - { |
|
680 | - do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
681 | - |
|
682 | - $this->_set_transaction_status_array(); |
|
683 | - |
|
684 | - $this->_template_args = []; |
|
685 | - $this->_template_args['transactions_page'] = $this->_wp_page_slug; |
|
686 | - |
|
687 | - $this->_set_transaction_object(); |
|
688 | - |
|
689 | - if (! $this->_transaction instanceof EE_Transaction) { |
|
690 | - return; |
|
691 | - } |
|
692 | - |
|
693 | - $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
|
694 | - $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
695 | - |
|
696 | - $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
|
697 | - $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
698 | - |
|
699 | - $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ]; |
|
700 | - $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
701 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID(); |
|
702 | - |
|
703 | - $this->_template_args['grand_total'] = $this->_transaction->total(); |
|
704 | - $this->_template_args['total_paid'] = $this->_transaction->paid(); |
|
705 | - |
|
706 | - $amount_due = $this->_transaction->total() - $this->_transaction->paid(); |
|
707 | - $this->_template_args['amount_due'] = EEH_Template::format_currency( |
|
708 | - $amount_due, |
|
709 | - true |
|
710 | - ); |
|
711 | - if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
712 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign |
|
713 | - . $this->_template_args['amount_due']; |
|
714 | - } else { |
|
715 | - $this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign; |
|
716 | - } |
|
717 | - $this->_template_args['amount_due_class'] = ''; |
|
718 | - |
|
719 | - if ($this->_transaction->paid() === $this->_transaction->total()) { |
|
720 | - // paid in full |
|
721 | - $this->_template_args['amount_due'] = false; |
|
722 | - } elseif ($this->_transaction->paid() > $this->_transaction->total()) { |
|
723 | - // overpaid |
|
724 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
725 | - } elseif ($this->_transaction->total() > (float) 0) { |
|
726 | - if ($this->_transaction->paid() > (float) 0) { |
|
727 | - // monies owing |
|
728 | - $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
729 | - } elseif ($this->_transaction->paid() === (float) 0) { |
|
730 | - // no payments made yet |
|
731 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
732 | - } |
|
733 | - } elseif ($this->_transaction->total() === (float) 0) { |
|
734 | - // free event |
|
735 | - $this->_template_args['amount_due'] = false; |
|
736 | - } |
|
737 | - |
|
738 | - $payment_method = $this->_transaction->payment_method(); |
|
739 | - |
|
740 | - $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
|
741 | - ? $payment_method->admin_name() |
|
742 | - : esc_html__('Unknown', 'event_espresso'); |
|
743 | - |
|
744 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
745 | - // link back to overview |
|
746 | - $this->_template_args['txn_overview_url'] = $this->request->getServerParam( |
|
747 | - 'HTTP_REFERER', |
|
748 | - TXN_ADMIN_URL |
|
749 | - ); |
|
750 | - |
|
751 | - |
|
752 | - // next link |
|
753 | - $next_txn = $this->_transaction->next( |
|
754 | - null, |
|
755 | - [['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]], |
|
756 | - 'TXN_ID' |
|
757 | - ); |
|
758 | - $this->_template_args['next_transaction'] = $next_txn |
|
759 | - ? $this->_next_link( |
|
760 | - EE_Admin_Page::add_query_args_and_nonce( |
|
761 | - ['action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']], |
|
762 | - TXN_ADMIN_URL |
|
763 | - ), |
|
764 | - 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
765 | - ) |
|
766 | - : ''; |
|
767 | - // previous link |
|
768 | - $previous_txn = $this->_transaction->previous( |
|
769 | - null, |
|
770 | - [['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]], |
|
771 | - 'TXN_ID' |
|
772 | - ); |
|
773 | - $this->_template_args['previous_transaction'] = $previous_txn |
|
774 | - ? $this->_previous_link( |
|
775 | - EE_Admin_Page::add_query_args_and_nonce( |
|
776 | - ['action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']], |
|
777 | - TXN_ADMIN_URL |
|
778 | - ), |
|
779 | - 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
780 | - ) |
|
781 | - : ''; |
|
782 | - |
|
783 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
784 | - $event_name = $this->request->getRequestParam('event_name'); |
|
785 | - $redirect_from = $this->request->getRequestParam('redirect_from', '', 'url'); |
|
786 | - |
|
787 | - // were we just redirected here after adding a new registration ??? |
|
788 | - if ($EVT_ID && $event_name && $redirect_from) { |
|
789 | - if ( |
|
790 | - EE_Registry::instance()->CAP->current_user_can( |
|
791 | - 'ee_edit_registrations', |
|
792 | - 'espresso_registrations_new_registration', |
|
793 | - $EVT_ID |
|
794 | - ) |
|
795 | - ) { |
|
796 | - $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
|
797 | - $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce( |
|
798 | - [ |
|
799 | - 'page' => 'espresso_registrations', |
|
800 | - 'action' => 'new_registration', |
|
801 | - 'return' => 'default', |
|
802 | - 'TXN_ID' => $this->_transaction->ID(), |
|
803 | - 'event_id' => $EVT_ID, |
|
804 | - ], |
|
805 | - REG_ADMIN_URL |
|
806 | - ); |
|
807 | - $this->_admin_page_title .= '">'; |
|
808 | - |
|
809 | - $this->_admin_page_title .= sprintf( |
|
810 | - esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
811 | - htmlentities(urldecode($event_name), ENT_QUOTES, 'UTF-8') |
|
812 | - ); |
|
813 | - $this->_admin_page_title .= '</a>'; |
|
814 | - } |
|
815 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
816 | - } |
|
817 | - // grab messages at the last second |
|
818 | - $this->_template_args['notices'] = EE_Error::get_notices(); |
|
819 | - // path to template |
|
820 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
821 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
|
822 | - $template_path, |
|
823 | - $this->_template_args, |
|
824 | - true |
|
825 | - ); |
|
826 | - |
|
827 | - // the details template wrapper |
|
828 | - $this->display_admin_page_with_sidebar(); |
|
829 | - } |
|
830 | - |
|
831 | - |
|
832 | - /** |
|
833 | - * _transaction_details_metaboxes |
|
834 | - * |
|
835 | - * @access protected |
|
836 | - * @return void |
|
837 | - * @throws EE_Error |
|
838 | - * @throws InvalidArgumentException |
|
839 | - * @throws InvalidDataTypeException |
|
840 | - * @throws InvalidInterfaceException |
|
841 | - * @throws RuntimeException |
|
842 | - * @throws ReflectionException |
|
843 | - */ |
|
844 | - protected function _transaction_details_metaboxes() |
|
845 | - { |
|
846 | - |
|
847 | - $this->_set_transaction_object(); |
|
848 | - |
|
849 | - if (! $this->_transaction instanceof EE_Transaction) { |
|
850 | - return; |
|
851 | - } |
|
852 | - add_meta_box( |
|
853 | - 'edit-txn-details-mbox', |
|
854 | - esc_html__('Transaction Details', 'event_espresso'), |
|
855 | - [$this, 'txn_details_meta_box'], |
|
856 | - $this->_wp_page_slug, |
|
857 | - 'normal', |
|
858 | - 'high' |
|
859 | - ); |
|
860 | - add_meta_box( |
|
861 | - 'edit-txn-attendees-mbox', |
|
862 | - esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
863 | - [$this, 'txn_attendees_meta_box'], |
|
864 | - $this->_wp_page_slug, |
|
865 | - 'normal', |
|
866 | - 'high', |
|
867 | - ['TXN_ID' => $this->_transaction->ID()] |
|
868 | - ); |
|
869 | - add_meta_box( |
|
870 | - 'edit-txn-registrant-mbox', |
|
871 | - esc_html__('Primary Contact', 'event_espresso'), |
|
872 | - [$this, 'txn_registrant_side_meta_box'], |
|
873 | - $this->_wp_page_slug, |
|
874 | - 'side', |
|
875 | - 'high' |
|
876 | - ); |
|
877 | - add_meta_box( |
|
878 | - 'edit-txn-billing-info-mbox', |
|
879 | - esc_html__('Billing Information', 'event_espresso'), |
|
880 | - [$this, 'txn_billing_info_side_meta_box'], |
|
881 | - $this->_wp_page_slug, |
|
882 | - 'side', |
|
883 | - 'high' |
|
884 | - ); |
|
885 | - } |
|
886 | - |
|
887 | - |
|
888 | - /** |
|
889 | - * Callback for transaction actions metabox. |
|
890 | - * |
|
891 | - * @param EE_Transaction|null $transaction |
|
892 | - * @return string |
|
893 | - * @throws DomainException |
|
894 | - * @throws EE_Error |
|
895 | - * @throws InvalidArgumentException |
|
896 | - * @throws InvalidDataTypeException |
|
897 | - * @throws InvalidInterfaceException |
|
898 | - * @throws ReflectionException |
|
899 | - * @throws RuntimeException |
|
900 | - */ |
|
901 | - public function getActionButtons(EE_Transaction $transaction = null) |
|
902 | - { |
|
903 | - $content = ''; |
|
904 | - $actions = []; |
|
905 | - if (! $transaction instanceof EE_Transaction) { |
|
906 | - return $content; |
|
907 | - } |
|
908 | - /** @var EE_Registration $primary_registration */ |
|
909 | - $primary_registration = $transaction->primary_registration(); |
|
910 | - $attendee = $primary_registration instanceof EE_Registration |
|
911 | - ? $primary_registration->attendee() |
|
912 | - : null; |
|
913 | - |
|
914 | - if ( |
|
915 | - $attendee instanceof EE_Attendee |
|
916 | - && EE_Registry::instance()->CAP->current_user_can( |
|
917 | - 'ee_send_message', |
|
918 | - 'espresso_transactions_send_payment_reminder' |
|
919 | - ) |
|
920 | - ) { |
|
921 | - $actions['payment_reminder'] = |
|
922 | - EEH_MSG_Template::is_mt_active('payment_reminder') |
|
923 | - && $this->_transaction->status_ID() !== EEM_Transaction::complete_status_code |
|
924 | - && $this->_transaction->status_ID() !== EEM_Transaction::overpaid_status_code |
|
925 | - ? EEH_Template::get_button_or_link( |
|
926 | - EE_Admin_Page::add_query_args_and_nonce( |
|
927 | - [ |
|
928 | - 'action' => 'send_payment_reminder', |
|
929 | - 'TXN_ID' => $this->_transaction->ID(), |
|
930 | - 'redirect_to' => 'view_transaction', |
|
931 | - ], |
|
932 | - TXN_ADMIN_URL |
|
933 | - ), |
|
934 | - esc_html__(' Send Payment Reminder', 'event_espresso'), |
|
935 | - 'button secondary-button', |
|
936 | - 'dashicons dashicons-email-alt' |
|
937 | - ) |
|
938 | - : ''; |
|
939 | - } |
|
940 | - |
|
941 | - if ( |
|
942 | - EE_Registry::instance()->CAP->current_user_can( |
|
943 | - 'ee_edit_payments', |
|
944 | - 'espresso_transactions_recalculate_line_items' |
|
945 | - ) |
|
946 | - ) { |
|
947 | - $actions['recalculate_line_items'] = EEH_Template::get_button_or_link( |
|
948 | - EE_Admin_Page::add_query_args_and_nonce( |
|
949 | - [ |
|
950 | - 'action' => 'espresso_recalculate_line_items', |
|
951 | - 'TXN_ID' => $this->_transaction->ID(), |
|
952 | - 'redirect_to' => 'view_transaction', |
|
953 | - ], |
|
954 | - TXN_ADMIN_URL |
|
955 | - ), |
|
956 | - esc_html__(' Recalculate Taxes and Total', 'event_espresso'), |
|
957 | - 'button secondary-button', |
|
958 | - 'dashicons dashicons-update' |
|
959 | - ); |
|
960 | - } |
|
961 | - |
|
962 | - if ( |
|
963 | - $primary_registration instanceof EE_Registration |
|
964 | - && EEH_MSG_Template::is_mt_active('receipt') |
|
965 | - ) { |
|
966 | - $actions['receipt'] = EEH_Template::get_button_or_link( |
|
967 | - $primary_registration->receipt_url(), |
|
968 | - esc_html__('View Receipt', 'event_espresso'), |
|
969 | - 'button secondary-button', |
|
970 | - 'dashicons dashicons-media-default' |
|
971 | - ); |
|
972 | - } |
|
973 | - |
|
974 | - if ( |
|
975 | - $primary_registration instanceof EE_Registration |
|
976 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
977 | - ) { |
|
978 | - $actions['invoice'] = EEH_Template::get_button_or_link( |
|
979 | - $primary_registration->invoice_url(), |
|
980 | - esc_html__('View Invoice', 'event_espresso'), |
|
981 | - 'button secondary-button', |
|
982 | - 'dashicons dashicons-media-spreadsheet' |
|
983 | - ); |
|
984 | - } |
|
985 | - $actions = array_filter( |
|
986 | - apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction) |
|
987 | - ); |
|
988 | - if ($actions) { |
|
989 | - $content = '<ul>'; |
|
990 | - $content .= '<li>' . implode('</li><li>', $actions) . '</li>'; |
|
991 | - $content .= '</uL>'; |
|
992 | - } |
|
993 | - return $content; |
|
994 | - } |
|
995 | - |
|
996 | - |
|
997 | - /** |
|
998 | - * txn_details_meta_box |
|
999 | - * generates HTML for the Transaction main meta box |
|
1000 | - * |
|
1001 | - * @return void |
|
1002 | - * @throws DomainException |
|
1003 | - * @throws EE_Error |
|
1004 | - * @throws InvalidArgumentException |
|
1005 | - * @throws InvalidDataTypeException |
|
1006 | - * @throws InvalidInterfaceException |
|
1007 | - * @throws RuntimeException |
|
1008 | - * @throws ReflectionException |
|
1009 | - */ |
|
1010 | - public function txn_details_meta_box() |
|
1011 | - { |
|
1012 | - $this->_set_transaction_object(); |
|
1013 | - $this->_template_args['TXN_ID'] = $this->_transaction->ID(); |
|
1014 | - $this->_template_args['attendee'] = |
|
1015 | - $this->_transaction->primary_registration() instanceof EE_Registration |
|
1016 | - ? $this->_transaction->primary_registration()->attendee() |
|
1017 | - : null; |
|
1018 | - $this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can( |
|
1019 | - 'ee_edit_payments', |
|
1020 | - 'apply_payment_or_refund_from_registration_details' |
|
1021 | - ); |
|
1022 | - $this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can( |
|
1023 | - 'ee_delete_payments', |
|
1024 | - 'delete_payment_from_registration_details' |
|
1025 | - ); |
|
1026 | - |
|
1027 | - // get line table |
|
1028 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
1029 | - $Line_Item_Display = new EE_Line_Item_Display( |
|
1030 | - 'admin_table', |
|
1031 | - 'EE_Admin_Table_Line_Item_Display_Strategy' |
|
1032 | - ); |
|
1033 | - $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( |
|
1034 | - $this->_transaction->total_line_item() |
|
1035 | - ); |
|
1036 | - $this->_template_args['REG_code'] = |
|
1037 | - $this->_transaction->primary_registration() instanceof EE_Registration |
|
1038 | - ? $this->_transaction->primary_registration()->reg_code() |
|
1039 | - : null; |
|
1040 | - // process taxes |
|
1041 | - $taxes = $this->_transaction->line_items([['LIN_type' => EEM_Line_Item::type_tax]]); |
|
1042 | - $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false; |
|
1043 | - |
|
1044 | - $this->_template_args['grand_total'] = EEH_Template::format_currency( |
|
1045 | - $this->_transaction->total(), |
|
1046 | - false, |
|
1047 | - false |
|
1048 | - ); |
|
1049 | - $this->_template_args['grand_raw_total'] = $this->_transaction->total(); |
|
1050 | - $this->_template_args['TXN_status'] = $this->_transaction->status_ID(); |
|
1051 | - |
|
1052 | - // process payment details |
|
1053 | - $payments = $this->_transaction->payments(); |
|
1054 | - if (! empty($payments)) { |
|
1055 | - $this->_template_args['payments'] = $payments; |
|
1056 | - $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
1057 | - } else { |
|
1058 | - $this->_template_args['payments'] = false; |
|
1059 | - $this->_template_args['existing_reg_payments'] = []; |
|
1060 | - } |
|
1061 | - |
|
1062 | - $this->_template_args['edit_payment_url'] = add_query_arg(['action' => 'edit_payment'], TXN_ADMIN_URL); |
|
1063 | - $this->_template_args['delete_payment_url'] = add_query_arg( |
|
1064 | - ['action' => 'espresso_delete_payment'], |
|
1065 | - TXN_ADMIN_URL |
|
1066 | - ); |
|
1067 | - |
|
1068 | - if (isset($txn_details['invoice_number'])) { |
|
1069 | - $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
|
1070 | - $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__( |
|
1071 | - 'Invoice Number', |
|
1072 | - 'event_espresso' |
|
1073 | - ); |
|
1074 | - } |
|
1075 | - |
|
1076 | - $this->_template_args['txn_details']['registration_session']['value'] = |
|
1077 | - $this->_transaction->primary_registration() instanceof EE_Registration |
|
1078 | - ? $this->_transaction->primary_registration()->session_ID() |
|
1079 | - : null; |
|
1080 | - $this->_template_args['txn_details']['registration_session']['label'] = esc_html__( |
|
1081 | - 'Registration Session', |
|
1082 | - 'event_espresso' |
|
1083 | - ); |
|
1084 | - |
|
1085 | - $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) |
|
1086 | - ? $this->_session['ip_address'] |
|
1087 | - : ''; |
|
1088 | - $this->_template_args['txn_details']['ip_address']['label'] = esc_html__( |
|
1089 | - 'Transaction placed from IP', |
|
1090 | - 'event_espresso' |
|
1091 | - ); |
|
1092 | - |
|
1093 | - $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) |
|
1094 | - ? $this->_session['user_agent'] |
|
1095 | - : ''; |
|
1096 | - $this->_template_args['txn_details']['user_agent']['label'] = esc_html__( |
|
1097 | - 'Registrant User Agent', |
|
1098 | - 'event_espresso' |
|
1099 | - ); |
|
1100 | - |
|
1101 | - $reg_steps = '<ul>'; |
|
1102 | - foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
1103 | - if ($reg_step_status === true) { |
|
1104 | - $reg_steps .= '<li style="color:#70cc50">' |
|
1105 | - . sprintf( |
|
1106 | - esc_html__('%1$s : Completed', 'event_espresso'), |
|
1107 | - ucwords(str_replace('_', ' ', $reg_step)) |
|
1108 | - ) |
|
1109 | - . '</li>'; |
|
1110 | - } elseif ($reg_step_status !== false && is_numeric($reg_step_status)) { |
|
1111 | - $reg_steps .= '<li style="color:#2EA2CC">' |
|
1112 | - . sprintf( |
|
1113 | - esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
1114 | - ucwords(str_replace('_', ' ', $reg_step)), |
|
1115 | - date( |
|
1116 | - get_option('date_format') . ' ' . get_option('time_format'), |
|
1117 | - $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1118 | - ) |
|
1119 | - ) |
|
1120 | - . '</li>'; |
|
1121 | - } else { |
|
1122 | - $reg_steps .= '<li style="color:#E76700">' |
|
1123 | - . sprintf( |
|
1124 | - esc_html__('%1$s : Never Initiated', 'event_espresso'), |
|
1125 | - ucwords(str_replace('_', ' ', $reg_step)) |
|
1126 | - ) |
|
1127 | - . '</li>'; |
|
1128 | - } |
|
1129 | - } |
|
1130 | - $reg_steps .= '</ul>'; |
|
1131 | - $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
|
1132 | - $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__( |
|
1133 | - 'Registration Step Progress', |
|
1134 | - 'event_espresso' |
|
1135 | - ); |
|
1136 | - |
|
1137 | - |
|
1138 | - $this->_get_registrations_to_apply_payment_to(); |
|
1139 | - $this->_get_payment_methods($payments); |
|
1140 | - $this->_get_payment_status_array(); |
|
1141 | - $this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction. |
|
1142 | - |
|
1143 | - $this->_template_args['transaction_form_url'] = add_query_arg( |
|
1144 | - [ |
|
1145 | - 'action' => 'edit_transaction', |
|
1146 | - 'process' => 'transaction', |
|
1147 | - ], |
|
1148 | - TXN_ADMIN_URL |
|
1149 | - ); |
|
1150 | - $this->_template_args['apply_payment_form_url'] = add_query_arg( |
|
1151 | - [ |
|
1152 | - 'page' => 'espresso_transactions', |
|
1153 | - 'action' => 'espresso_apply_payment', |
|
1154 | - ], |
|
1155 | - WP_AJAX_URL |
|
1156 | - ); |
|
1157 | - $this->_template_args['delete_payment_form_url'] = add_query_arg( |
|
1158 | - [ |
|
1159 | - 'page' => 'espresso_transactions', |
|
1160 | - 'action' => 'espresso_delete_payment', |
|
1161 | - ], |
|
1162 | - WP_AJAX_URL |
|
1163 | - ); |
|
1164 | - |
|
1165 | - $this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction); |
|
1166 | - |
|
1167 | - // 'espresso_delete_payment_nonce' |
|
1168 | - |
|
1169 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
1170 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1171 | - } |
|
1172 | - |
|
1173 | - |
|
1174 | - /** |
|
1175 | - * _get_registration_payment_IDs |
|
1176 | - * generates an array of Payment IDs and their corresponding Registration IDs |
|
1177 | - * |
|
1178 | - * @access protected |
|
1179 | - * @param EE_Payment[] $payments |
|
1180 | - * @return array |
|
1181 | - * @throws EE_Error |
|
1182 | - * @throws InvalidArgumentException |
|
1183 | - * @throws InvalidDataTypeException |
|
1184 | - * @throws InvalidInterfaceException |
|
1185 | - * @throws ReflectionException |
|
1186 | - */ |
|
1187 | - protected function _get_registration_payment_IDs($payments = []) |
|
1188 | - { |
|
1189 | - $existing_reg_payments = []; |
|
1190 | - // get all reg payments for these payments |
|
1191 | - $reg_payments = EEM_Registration_Payment::instance()->get_all( |
|
1192 | - [ |
|
1193 | - [ |
|
1194 | - 'PAY_ID' => [ |
|
1195 | - 'IN', |
|
1196 | - array_keys($payments), |
|
1197 | - ], |
|
1198 | - ], |
|
1199 | - ] |
|
1200 | - ); |
|
1201 | - if (! empty($reg_payments)) { |
|
1202 | - foreach ($payments as $payment) { |
|
1203 | - if (! $payment instanceof EE_Payment) { |
|
1204 | - continue; |
|
1205 | - } elseif (! isset($existing_reg_payments[ $payment->ID() ])) { |
|
1206 | - $existing_reg_payments[ $payment->ID() ] = []; |
|
1207 | - } |
|
1208 | - foreach ($reg_payments as $reg_payment) { |
|
1209 | - if ( |
|
1210 | - $reg_payment instanceof EE_Registration_Payment |
|
1211 | - && $reg_payment->payment_ID() === $payment->ID() |
|
1212 | - ) { |
|
1213 | - $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID(); |
|
1214 | - } |
|
1215 | - } |
|
1216 | - } |
|
1217 | - } |
|
1218 | - |
|
1219 | - return $existing_reg_payments; |
|
1220 | - } |
|
1221 | - |
|
1222 | - |
|
1223 | - /** |
|
1224 | - * _get_registrations_to_apply_payment_to |
|
1225 | - * generates HTML for displaying a series of checkboxes in the admin payment modal window |
|
1226 | - * which allows the admin to only apply the payment to the specific registrations |
|
1227 | - * |
|
1228 | - * @access protected |
|
1229 | - * @return void |
|
1230 | - * @throws EE_Error |
|
1231 | - * @throws InvalidArgumentException |
|
1232 | - * @throws InvalidDataTypeException |
|
1233 | - * @throws InvalidInterfaceException |
|
1234 | - * @throws ReflectionException |
|
1235 | - */ |
|
1236 | - protected function _get_registrations_to_apply_payment_to() |
|
1237 | - { |
|
1238 | - // we want any registration with an active status (ie: not deleted or cancelled) |
|
1239 | - $query_params = [ |
|
1240 | - [ |
|
1241 | - 'STS_ID' => [ |
|
1242 | - 'IN', |
|
1243 | - [ |
|
1244 | - EEM_Registration::status_id_approved, |
|
1245 | - EEM_Registration::status_id_pending_payment, |
|
1246 | - EEM_Registration::status_id_not_approved, |
|
1247 | - ], |
|
1248 | - ], |
|
1249 | - ], |
|
1250 | - ]; |
|
1251 | - $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
1252 | - '', |
|
1253 | - 'txn-admin-apply-payment-to-registrations-dv', |
|
1254 | - '', |
|
1255 | - 'clear: both; margin: 1.5em 0 0; display: none;' |
|
1256 | - ); |
|
1257 | - $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
1258 | - $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
1259 | - $registrations_to_apply_payment_to .= EEH_HTML::thead( |
|
1260 | - EEH_HTML::tr( |
|
1261 | - EEH_HTML::th(esc_html__('ID', 'event_espresso')) . |
|
1262 | - EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) . |
|
1263 | - EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) . |
|
1264 | - EEH_HTML::th(esc_html__('Event', 'event_espresso')) . |
|
1265 | - EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
1266 | - EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
1267 | - EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
1268 | - ) |
|
1269 | - ); |
|
1270 | - $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
|
1271 | - // get registrations for TXN |
|
1272 | - $registrations = $this->_transaction->registrations($query_params); |
|
1273 | - $existing_reg_payments = $this->_template_args['existing_reg_payments']; |
|
1274 | - foreach ($registrations as $registration) { |
|
1275 | - if ($registration instanceof EE_Registration) { |
|
1276 | - $attendee_name = $registration->attendee() instanceof EE_Attendee |
|
1277 | - ? $registration->attendee()->full_name() |
|
1278 | - : esc_html__('Unknown Attendee', 'event_espresso'); |
|
1279 | - $owing = $registration->final_price() - $registration->paid(); |
|
1280 | - $taxable = $registration->ticket()->taxable() |
|
1281 | - ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>' |
|
1282 | - : ''; |
|
1283 | - $checked = empty($existing_reg_payments) |
|
1284 | - || in_array($registration->ID(), $existing_reg_payments, true) |
|
1285 | - ? ' checked="checked"' |
|
1286 | - : ''; |
|
1287 | - $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
|
1288 | - $registrations_to_apply_payment_to .= EEH_HTML::tr( |
|
1289 | - EEH_HTML::td($registration->ID()) . |
|
1290 | - EEH_HTML::td($attendee_name) . |
|
1291 | - EEH_HTML::td( |
|
1292 | - $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
1293 | - ) . |
|
1294 | - EEH_HTML::td($registration->event_name()) . |
|
1295 | - EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
1296 | - EEH_HTML::td( |
|
1297 | - EEH_Template::format_currency($owing), |
|
1298 | - '', |
|
1299 | - 'txn-admin-payment-owing-td jst-cntr' |
|
1300 | - ) . |
|
1301 | - EEH_HTML::td( |
|
1302 | - '<input type="checkbox" value="' . $registration->ID() |
|
1303 | - . '" name="txn_admin_payment[registrations]"' |
|
1304 | - . $checked . $disabled . '>', |
|
1305 | - '', |
|
1306 | - 'jst-cntr' |
|
1307 | - ), |
|
1308 | - 'apply-payment-registration-row-' . $registration->ID() |
|
1309 | - ); |
|
1310 | - } |
|
1311 | - } |
|
1312 | - $registrations_to_apply_payment_to .= EEH_HTML::tbodyx(); |
|
1313 | - $registrations_to_apply_payment_to .= EEH_HTML::tablex(); |
|
1314 | - $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
1315 | - $registrations_to_apply_payment_to .= EEH_HTML::p( |
|
1316 | - esc_html__( |
|
1317 | - 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', |
|
1318 | - 'event_espresso' |
|
1319 | - ), |
|
1320 | - '', |
|
1321 | - 'clear description' |
|
1322 | - ); |
|
1323 | - $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
1324 | - $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
1325 | - } |
|
1326 | - |
|
1327 | - |
|
1328 | - /** |
|
1329 | - * _get_reg_status_selection |
|
1330 | - * |
|
1331 | - * @return void |
|
1332 | - * @throws EE_Error |
|
1333 | - * @todo this will need to be adjusted either once MER comes along OR we move default reg status to tickets |
|
1334 | - * instead of events. |
|
1335 | - * @access protected |
|
1336 | - */ |
|
1337 | - protected function _get_reg_status_selection() |
|
1338 | - { |
|
1339 | - // first get all possible statuses |
|
1340 | - $statuses = EEM_Registration::reg_status_array([], true); |
|
1341 | - // let's add a "don't change" option. |
|
1342 | - $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
|
1343 | - $status_array = array_merge($status_array, $statuses); |
|
1344 | - $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( |
|
1345 | - 'txn_reg_status_change[reg_status]', |
|
1346 | - $status_array, |
|
1347 | - 'NAN', |
|
1348 | - 'id="txn-admin-payment-reg-status-inp"', |
|
1349 | - 'txn-reg-status-change-reg-status' |
|
1350 | - ); |
|
1351 | - $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( |
|
1352 | - 'delete_txn_reg_status_change[reg_status]', |
|
1353 | - $status_array, |
|
1354 | - 'NAN', |
|
1355 | - 'delete-txn-admin-payment-reg-status-inp', |
|
1356 | - 'delete-txn-reg-status-change-reg-status' |
|
1357 | - ); |
|
1358 | - } |
|
1359 | - |
|
1360 | - |
|
1361 | - /** |
|
1362 | - * _get_payment_methods |
|
1363 | - * Gets all the payment methods available generally, or the ones that are already |
|
1364 | - * selected on these payments (in case their payment methods are no longer active). |
|
1365 | - * Has the side-effect of updating the template args' payment_methods item |
|
1366 | - * |
|
1367 | - * @access private |
|
1368 | - * @param EE_Payment[] to show on this page |
|
1369 | - * @return void |
|
1370 | - * @throws EE_Error |
|
1371 | - * @throws InvalidArgumentException |
|
1372 | - * @throws InvalidDataTypeException |
|
1373 | - * @throws InvalidInterfaceException |
|
1374 | - * @throws ReflectionException |
|
1375 | - */ |
|
1376 | - private function _get_payment_methods($payments = []) |
|
1377 | - { |
|
1378 | - $payment_methods_of_payments = []; |
|
1379 | - foreach ($payments as $payment) { |
|
1380 | - if ($payment instanceof EE_Payment) { |
|
1381 | - $payment_methods_of_payments[] = $payment->ID(); |
|
1382 | - } |
|
1383 | - } |
|
1384 | - if ($payment_methods_of_payments) { |
|
1385 | - $query_args = [ |
|
1386 | - [ |
|
1387 | - 'OR*payment_method_for_payment' => [ |
|
1388 | - 'PMD_ID' => ['IN', $payment_methods_of_payments], |
|
1389 | - 'PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%'], |
|
1390 | - ], |
|
1391 | - ], |
|
1392 | - ]; |
|
1393 | - } else { |
|
1394 | - $query_args = [['PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%']]]; |
|
1395 | - } |
|
1396 | - $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
1397 | - } |
|
1398 | - |
|
1399 | - |
|
1400 | - /** |
|
1401 | - * txn_attendees_meta_box |
|
1402 | - * generates HTML for the Attendees Transaction main meta box |
|
1403 | - * |
|
1404 | - * @access public |
|
1405 | - * @param WP_Post $post |
|
1406 | - * @param array $metabox |
|
1407 | - * @return void |
|
1408 | - * @throws DomainException |
|
1409 | - * @throws EE_Error |
|
1410 | - * @throws InvalidArgumentException |
|
1411 | - * @throws InvalidDataTypeException |
|
1412 | - * @throws InvalidInterfaceException |
|
1413 | - * @throws ReflectionException |
|
1414 | - */ |
|
1415 | - public function txn_attendees_meta_box($post, $metabox = ['args' => []]) |
|
1416 | - { |
|
1417 | - |
|
1418 | - /** @noinspection NonSecureExtractUsageInspection */ |
|
1419 | - extract($metabox['args']); |
|
1420 | - $this->_template_args['post'] = $post; |
|
1421 | - $this->_template_args['event_attendees'] = []; |
|
1422 | - // process items in cart |
|
1423 | - $line_items = $this->_transaction->get_many_related( |
|
1424 | - 'Line_Item', |
|
1425 | - [['LIN_type' => 'line-item']] |
|
1426 | - ); |
|
1427 | - if (! empty($line_items)) { |
|
1428 | - foreach ($line_items as $item) { |
|
1429 | - if ($item instanceof EE_Line_Item) { |
|
1430 | - switch ($item->OBJ_type()) { |
|
1431 | - case 'Event': |
|
1432 | - break; |
|
1433 | - case 'Ticket': |
|
1434 | - $ticket = $item->ticket(); |
|
1435 | - // right now we're only handling tickets here. |
|
1436 | - // Cause its expected that only tickets will have attendees right? |
|
1437 | - if (! $ticket instanceof EE_Ticket) { |
|
1438 | - break; |
|
1439 | - } |
|
1440 | - try { |
|
1441 | - $event_name = $ticket->get_event_name(); |
|
1442 | - } catch (Exception $e) { |
|
1443 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1444 | - $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
1445 | - } |
|
1446 | - $event_name .= ' - ' . $item->name(); |
|
1447 | - $ticket_price = EEH_Template::format_currency($item->unit_price()); |
|
1448 | - // now get all of the registrations for this transaction that use this ticket |
|
1449 | - $registrations = $ticket->registrations( |
|
1450 | - [['TXN_ID' => $this->_transaction->ID()]] |
|
1451 | - ); |
|
1452 | - foreach ($registrations as $registration) { |
|
1453 | - if (! $registration instanceof EE_Registration) { |
|
1454 | - break; |
|
1455 | - } |
|
1456 | - $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID'] |
|
1457 | - = $registration->status_ID(); |
|
1458 | - $this->_template_args['event_attendees'][ $registration->ID() ]['att_num'] |
|
1459 | - = $registration->count(); |
|
1460 | - $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name'] |
|
1461 | - = $event_name; |
|
1462 | - $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price'] |
|
1463 | - = $ticket_price; |
|
1464 | - // attendee info |
|
1465 | - $attendee = $registration->get_first_related('Attendee'); |
|
1466 | - if ($attendee instanceof EE_Attendee) { |
|
1467 | - $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] |
|
1468 | - = $attendee->ID(); |
|
1469 | - $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] |
|
1470 | - = $attendee->full_name(); |
|
1471 | - $this->_template_args['event_attendees'][ $registration->ID() ]['email'] |
|
1472 | - = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name |
|
1473 | - . esc_html__( |
|
1474 | - ' Event', |
|
1475 | - 'event_espresso' |
|
1476 | - ) |
|
1477 | - . '">' . $attendee->email() . '</a>'; |
|
1478 | - $this->_template_args['event_attendees'][ $registration->ID() ]['address'] |
|
1479 | - = EEH_Address::format($attendee, 'inline', false, false); |
|
1480 | - } else { |
|
1481 | - $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = ''; |
|
1482 | - $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = ''; |
|
1483 | - $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = ''; |
|
1484 | - $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = ''; |
|
1485 | - } |
|
1486 | - } |
|
1487 | - break; |
|
1488 | - } |
|
1489 | - } |
|
1490 | - } |
|
1491 | - |
|
1492 | - $this->_template_args['transaction_form_url'] = add_query_arg( |
|
1493 | - [ |
|
1494 | - 'action' => 'edit_transaction', |
|
1495 | - 'process' => 'attendees', |
|
1496 | - ], |
|
1497 | - TXN_ADMIN_URL |
|
1498 | - ); |
|
1499 | - echo EEH_Template::display_template( |
|
1500 | - TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', |
|
1501 | - $this->_template_args, |
|
1502 | - true |
|
1503 | - ); |
|
1504 | - } else { |
|
1505 | - printf( |
|
1506 | - esc_html__( |
|
1507 | - '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', |
|
1508 | - 'event_espresso' |
|
1509 | - ), |
|
1510 | - '<p class="important-notice">', |
|
1511 | - '</p>' |
|
1512 | - ); |
|
1513 | - } |
|
1514 | - } |
|
1515 | - |
|
1516 | - |
|
1517 | - /** |
|
1518 | - * txn_registrant_side_meta_box |
|
1519 | - * generates HTML for the Edit Transaction side meta box |
|
1520 | - * |
|
1521 | - * @access public |
|
1522 | - * @return void |
|
1523 | - * @throws DomainException |
|
1524 | - * @throws EE_Error |
|
1525 | - * @throws InvalidArgumentException |
|
1526 | - * @throws InvalidDataTypeException |
|
1527 | - * @throws InvalidInterfaceException |
|
1528 | - * @throws ReflectionException |
|
1529 | - */ |
|
1530 | - public function txn_registrant_side_meta_box() |
|
1531 | - { |
|
1532 | - $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration |
|
1533 | - ? $this->_transaction->primary_registration()->get_first_related('Attendee') |
|
1534 | - : null; |
|
1535 | - if (! $primary_att instanceof EE_Attendee) { |
|
1536 | - $this->_template_args['no_attendee_message'] = esc_html__( |
|
1537 | - 'There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', |
|
1538 | - 'event_espresso' |
|
1539 | - ); |
|
1540 | - $primary_att = EEM_Attendee::instance()->create_default_object(); |
|
1541 | - } |
|
1542 | - $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1543 | - $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
|
1544 | - $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
|
1545 | - $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1546 | - $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
|
1547 | - $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
1548 | - [ |
|
1549 | - 'action' => 'edit_attendee', |
|
1550 | - 'post' => $primary_att->ID(), |
|
1551 | - ], |
|
1552 | - REG_ADMIN_URL |
|
1553 | - ); |
|
1554 | - // get formatted address for registrant |
|
1555 | - $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
1556 | - echo EEH_Template::display_template( |
|
1557 | - TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', |
|
1558 | - $this->_template_args, |
|
1559 | - true |
|
1560 | - ); |
|
1561 | - } |
|
1562 | - |
|
1563 | - |
|
1564 | - /** |
|
1565 | - * txn_billing_info_side_meta_box |
|
1566 | - * generates HTML for the Edit Transaction side meta box |
|
1567 | - * |
|
1568 | - * @access public |
|
1569 | - * @return void |
|
1570 | - * @throws DomainException |
|
1571 | - * @throws EE_Error |
|
1572 | - * @throws ReflectionException |
|
1573 | - */ |
|
1574 | - public function txn_billing_info_side_meta_box() |
|
1575 | - { |
|
1576 | - |
|
1577 | - $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
|
1578 | - $this->_template_args['billing_form_url'] = add_query_arg( |
|
1579 | - ['action' => 'edit_transaction', 'process' => 'billing'], |
|
1580 | - TXN_ADMIN_URL |
|
1581 | - ); |
|
1582 | - |
|
1583 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1584 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1585 | - } |
|
1586 | - |
|
1587 | - |
|
1588 | - /** |
|
1589 | - * apply_payments_or_refunds |
|
1590 | - * registers a payment or refund made towards a transaction |
|
1591 | - * |
|
1592 | - * @access public |
|
1593 | - * @return void |
|
1594 | - * @throws EE_Error |
|
1595 | - * @throws InvalidArgumentException |
|
1596 | - * @throws ReflectionException |
|
1597 | - * @throws RuntimeException |
|
1598 | - * @throws InvalidDataTypeException |
|
1599 | - * @throws InvalidInterfaceException |
|
1600 | - */ |
|
1601 | - public function apply_payments_or_refunds() |
|
1602 | - { |
|
1603 | - $json_response_data = ['return_data' => false]; |
|
1604 | - $valid_data = $this->_validate_payment_request_data(); |
|
1605 | - $has_access = EE_Registry::instance()->CAP->current_user_can( |
|
1606 | - 'ee_edit_payments', |
|
1607 | - 'apply_payment_or_refund_from_registration_details' |
|
1608 | - ); |
|
1609 | - if (! empty($valid_data) && $has_access) { |
|
1610 | - $PAY_ID = $valid_data['PAY_ID']; |
|
1611 | - // save the new payment |
|
1612 | - $payment = $this->_create_payment_from_request_data($valid_data); |
|
1613 | - // get the TXN for this payment |
|
1614 | - $transaction = $payment->transaction(); |
|
1615 | - // verify transaction |
|
1616 | - if ($transaction instanceof EE_Transaction) { |
|
1617 | - // calculate_total_payments_and_update_status |
|
1618 | - $this->_process_transaction_payments($transaction); |
|
1619 | - $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
1620 | - $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
1621 | - // apply payment to registrations (if applicable) |
|
1622 | - if (! empty($REG_IDs)) { |
|
1623 | - $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
1624 | - $this->_maybe_send_notifications(); |
|
1625 | - // now process status changes for the same registrations |
|
1626 | - $this->_process_registration_status_change($transaction, $REG_IDs); |
|
1627 | - } |
|
1628 | - $this->_maybe_send_notifications($payment); |
|
1629 | - // prepare to render page |
|
1630 | - $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
1631 | - do_action( |
|
1632 | - 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', |
|
1633 | - $transaction, |
|
1634 | - $payment |
|
1635 | - ); |
|
1636 | - } else { |
|
1637 | - EE_Error::add_error( |
|
1638 | - esc_html__( |
|
1639 | - 'A valid Transaction for this payment could not be retrieved.', |
|
1640 | - 'event_espresso' |
|
1641 | - ), |
|
1642 | - __FILE__, |
|
1643 | - __FUNCTION__, |
|
1644 | - __LINE__ |
|
1645 | - ); |
|
1646 | - } |
|
1647 | - } elseif ($has_access) { |
|
1648 | - EE_Error::add_error( |
|
1649 | - esc_html__( |
|
1650 | - 'The payment form data could not be processed. Please try again.', |
|
1651 | - 'event_espresso' |
|
1652 | - ), |
|
1653 | - __FILE__, |
|
1654 | - __FUNCTION__, |
|
1655 | - __LINE__ |
|
1656 | - ); |
|
1657 | - } else { |
|
1658 | - EE_Error::add_error( |
|
1659 | - esc_html__( |
|
1660 | - 'You do not have access to apply payments or refunds to a registration.', |
|
1661 | - 'event_espresso' |
|
1662 | - ), |
|
1663 | - __FILE__, |
|
1664 | - __FUNCTION__, |
|
1665 | - __LINE__ |
|
1666 | - ); |
|
1667 | - } |
|
1668 | - $notices = EE_Error::get_notices( |
|
1669 | - false, |
|
1670 | - false, |
|
1671 | - false |
|
1672 | - ); |
|
1673 | - $this->_template_args = [ |
|
1674 | - 'data' => $json_response_data, |
|
1675 | - 'error' => $notices['errors'], |
|
1676 | - 'success' => $notices['success'], |
|
1677 | - ]; |
|
1678 | - $this->_return_json(); |
|
1679 | - } |
|
1680 | - |
|
1681 | - |
|
1682 | - /** |
|
1683 | - * _validate_payment_request_data |
|
1684 | - * |
|
1685 | - * @return array |
|
1686 | - * @throws EE_Error |
|
1687 | - * @throws InvalidArgumentException |
|
1688 | - * @throws InvalidDataTypeException |
|
1689 | - * @throws InvalidInterfaceException |
|
1690 | - */ |
|
1691 | - protected function _validate_payment_request_data() |
|
1692 | - { |
|
1693 | - if (! $this->request->requestParamIsSet('txn_admin_payment')) { |
|
1694 | - return []; |
|
1695 | - } |
|
1696 | - $payment_form = $this->_generate_payment_form_section(); |
|
1697 | - try { |
|
1698 | - if ($payment_form->was_submitted()) { |
|
1699 | - $payment_form->receive_form_submission(); |
|
1700 | - if (! $payment_form->is_valid()) { |
|
1701 | - $submission_error_messages = []; |
|
1702 | - foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
1703 | - if ($validation_error instanceof EE_Validation_Error) { |
|
1704 | - $form_input = $validation_error->get_form_section(); |
|
1705 | - $submission_error_messages[] = sprintf( |
|
1706 | - _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
1707 | - $form_input instanceof EE_Form_Input_Base ? $form_input->html_label_text() : '', |
|
1708 | - $validation_error->getMessage() |
|
1709 | - ); |
|
1710 | - } |
|
1711 | - } |
|
1712 | - EE_Error::add_error( |
|
1713 | - implode('<br />', $submission_error_messages), |
|
1714 | - __FILE__, |
|
1715 | - __FUNCTION__, |
|
1716 | - __LINE__ |
|
1717 | - ); |
|
1718 | - return []; |
|
1719 | - } |
|
1720 | - } |
|
1721 | - } catch (EE_Error $e) { |
|
1722 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1723 | - return []; |
|
1724 | - } |
|
1725 | - |
|
1726 | - return $payment_form->valid_data(); |
|
1727 | - } |
|
1728 | - |
|
1729 | - |
|
1730 | - /** |
|
1731 | - * _generate_payment_form_section |
|
1732 | - * |
|
1733 | - * @return EE_Form_Section_Proper |
|
1734 | - * @throws EE_Error |
|
1735 | - */ |
|
1736 | - protected function _generate_payment_form_section() |
|
1737 | - { |
|
1738 | - return new EE_Form_Section_Proper( |
|
1739 | - [ |
|
1740 | - 'name' => 'txn_admin_payment', |
|
1741 | - 'subsections' => [ |
|
1742 | - 'PAY_ID' => new EE_Text_Input( |
|
1743 | - [ |
|
1744 | - 'default' => 0, |
|
1745 | - 'required' => false, |
|
1746 | - 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
1747 | - 'validation_strategies' => [new EE_Int_Normalization()], |
|
1748 | - ] |
|
1749 | - ), |
|
1750 | - 'TXN_ID' => new EE_Text_Input( |
|
1751 | - [ |
|
1752 | - 'default' => 0, |
|
1753 | - 'required' => true, |
|
1754 | - 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
1755 | - 'validation_strategies' => [new EE_Int_Normalization()], |
|
1756 | - ] |
|
1757 | - ), |
|
1758 | - 'type' => new EE_Text_Input( |
|
1759 | - [ |
|
1760 | - 'default' => 1, |
|
1761 | - 'required' => true, |
|
1762 | - 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
1763 | - 'validation_strategies' => [new EE_Int_Normalization()], |
|
1764 | - ] |
|
1765 | - ), |
|
1766 | - 'amount' => new EE_Text_Input( |
|
1767 | - [ |
|
1768 | - 'default' => 0, |
|
1769 | - 'required' => true, |
|
1770 | - 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
1771 | - 'validation_strategies' => [new EE_Float_Normalization()], |
|
1772 | - ] |
|
1773 | - ), |
|
1774 | - 'status' => new EE_Text_Input( |
|
1775 | - [ |
|
1776 | - 'default' => EEM_Payment::status_id_approved, |
|
1777 | - 'required' => true, |
|
1778 | - 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
1779 | - ] |
|
1780 | - ), |
|
1781 | - 'PMD_ID' => new EE_Text_Input( |
|
1782 | - [ |
|
1783 | - 'default' => 2, |
|
1784 | - 'required' => true, |
|
1785 | - 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
1786 | - 'validation_strategies' => [new EE_Int_Normalization()], |
|
1787 | - ] |
|
1788 | - ), |
|
1789 | - 'date' => new EE_Text_Input( |
|
1790 | - [ |
|
1791 | - 'default' => time(), |
|
1792 | - 'required' => true, |
|
1793 | - 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
1794 | - ] |
|
1795 | - ), |
|
1796 | - 'txn_id_chq_nmbr' => new EE_Text_Input( |
|
1797 | - [ |
|
1798 | - 'default' => '', |
|
1799 | - 'required' => false, |
|
1800 | - 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
1801 | - 'validation_strategies' => [ |
|
1802 | - new EE_Max_Length_Validation_Strategy( |
|
1803 | - esc_html__('Input too long', 'event_espresso'), |
|
1804 | - 100 |
|
1805 | - ), |
|
1806 | - ], |
|
1807 | - ] |
|
1808 | - ), |
|
1809 | - 'po_number' => new EE_Text_Input( |
|
1810 | - [ |
|
1811 | - 'default' => '', |
|
1812 | - 'required' => false, |
|
1813 | - 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
1814 | - 'validation_strategies' => [ |
|
1815 | - new EE_Max_Length_Validation_Strategy( |
|
1816 | - esc_html__('Input too long', 'event_espresso'), |
|
1817 | - 100 |
|
1818 | - ), |
|
1819 | - ], |
|
1820 | - ] |
|
1821 | - ), |
|
1822 | - 'accounting' => new EE_Text_Input( |
|
1823 | - [ |
|
1824 | - 'default' => '', |
|
1825 | - 'required' => false, |
|
1826 | - 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
1827 | - 'validation_strategies' => [ |
|
1828 | - new EE_Max_Length_Validation_Strategy( |
|
1829 | - esc_html__('Input too long', 'event_espresso'), |
|
1830 | - 100 |
|
1831 | - ), |
|
1832 | - ], |
|
1833 | - ] |
|
1834 | - ), |
|
1835 | - ], |
|
1836 | - ] |
|
1837 | - ); |
|
1838 | - } |
|
1839 | - |
|
1840 | - |
|
1841 | - /** |
|
1842 | - * _create_payment_from_request_data |
|
1843 | - * |
|
1844 | - * @param array $valid_data |
|
1845 | - * @return EE_Payment |
|
1846 | - * @throws EE_Error |
|
1847 | - * @throws InvalidArgumentException |
|
1848 | - * @throws InvalidDataTypeException |
|
1849 | - * @throws InvalidInterfaceException |
|
1850 | - * @throws ReflectionException |
|
1851 | - */ |
|
1852 | - protected function _create_payment_from_request_data($valid_data) |
|
1853 | - { |
|
1854 | - $PAY_ID = $valid_data['PAY_ID']; |
|
1855 | - // get payment amount |
|
1856 | - $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
1857 | - // payments have a type value of 1 and refunds have a type value of -1 |
|
1858 | - // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
|
1859 | - $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
1860 | - // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
|
1861 | - $date = $valid_data['date'] |
|
1862 | - ? preg_replace('/\s+/', ' ', $valid_data['date']) |
|
1863 | - : date('Y-m-d g:i a', current_time('timestamp')); |
|
1864 | - $payment = EE_Payment::new_instance( |
|
1865 | - [ |
|
1866 | - 'TXN_ID' => $valid_data['TXN_ID'], |
|
1867 | - 'STS_ID' => $valid_data['status'], |
|
1868 | - 'PAY_timestamp' => $date, |
|
1869 | - 'PAY_source' => EEM_Payment_Method::scope_admin, |
|
1870 | - 'PMD_ID' => $valid_data['PMD_ID'], |
|
1871 | - 'PAY_amount' => $amount, |
|
1872 | - 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
1873 | - 'PAY_po_number' => $valid_data['po_number'], |
|
1874 | - 'PAY_extra_accntng' => $valid_data['accounting'], |
|
1875 | - 'PAY_details' => $valid_data, |
|
1876 | - 'PAY_ID' => $PAY_ID, |
|
1877 | - ], |
|
1878 | - '', |
|
1879 | - ['Y-m-d', 'g:i a'] |
|
1880 | - ); |
|
1881 | - |
|
1882 | - if (! $payment->save()) { |
|
1883 | - EE_Error::add_error( |
|
1884 | - sprintf( |
|
1885 | - esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
1886 | - $payment->ID() |
|
1887 | - ), |
|
1888 | - __FILE__, |
|
1889 | - __FUNCTION__, |
|
1890 | - __LINE__ |
|
1891 | - ); |
|
1892 | - } |
|
1893 | - |
|
1894 | - return $payment; |
|
1895 | - } |
|
1896 | - |
|
1897 | - |
|
1898 | - /** |
|
1899 | - * _process_transaction_payments |
|
1900 | - * |
|
1901 | - * @param EE_Transaction $transaction |
|
1902 | - * @return void |
|
1903 | - * @throws EE_Error |
|
1904 | - * @throws InvalidArgumentException |
|
1905 | - * @throws ReflectionException |
|
1906 | - * @throws InvalidDataTypeException |
|
1907 | - * @throws InvalidInterfaceException |
|
1908 | - */ |
|
1909 | - protected function _process_transaction_payments(EE_Transaction $transaction) |
|
1910 | - { |
|
1911 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
1912 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1913 | - // update the transaction with this payment |
|
1914 | - if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
1915 | - EE_Error::add_success( |
|
1916 | - esc_html__( |
|
1917 | - 'The payment has been processed successfully.', |
|
1918 | - 'event_espresso' |
|
1919 | - ), |
|
1920 | - __FILE__, |
|
1921 | - __FUNCTION__, |
|
1922 | - __LINE__ |
|
1923 | - ); |
|
1924 | - } else { |
|
1925 | - EE_Error::add_error( |
|
1926 | - esc_html__( |
|
1927 | - 'The payment was processed successfully but the amount paid for the transaction was not updated.', |
|
1928 | - 'event_espresso' |
|
1929 | - ), |
|
1930 | - __FILE__, |
|
1931 | - __FUNCTION__, |
|
1932 | - __LINE__ |
|
1933 | - ); |
|
1934 | - } |
|
1935 | - } |
|
1936 | - |
|
1937 | - |
|
1938 | - /** |
|
1939 | - * _get_REG_IDs_to_apply_payment_to |
|
1940 | - * returns a list of registration IDs that the payment will apply to |
|
1941 | - * |
|
1942 | - * @param EE_Payment $payment |
|
1943 | - * @return array |
|
1944 | - * @throws EE_Error |
|
1945 | - * @throws InvalidArgumentException |
|
1946 | - * @throws InvalidDataTypeException |
|
1947 | - * @throws InvalidInterfaceException |
|
1948 | - * @throws ReflectionException |
|
1949 | - */ |
|
1950 | - protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) |
|
1951 | - { |
|
1952 | - // grab array of IDs for specific registrations to apply changes to |
|
1953 | - $REG_IDs = $this->request->getRequestParam('txn_admin_payment[registrations]', [], 'int', true); |
|
1954 | - // nothing specified ? then get all reg IDs |
|
1955 | - if (empty($REG_IDs)) { |
|
1956 | - $registrations = $payment->transaction()->registrations(); |
|
1957 | - $REG_IDs = ! empty($registrations) |
|
1958 | - ? array_keys($registrations) |
|
1959 | - : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1960 | - } |
|
1961 | - |
|
1962 | - // ensure that REG_IDs are integers and NOT strings |
|
1963 | - return array_map('intval', $REG_IDs); |
|
1964 | - } |
|
1965 | - |
|
1966 | - |
|
1967 | - /** |
|
1968 | - * @return array |
|
1969 | - */ |
|
1970 | - public function existing_reg_payment_REG_IDs() |
|
1971 | - { |
|
1972 | - return $this->_existing_reg_payment_REG_IDs; |
|
1973 | - } |
|
1974 | - |
|
1975 | - |
|
1976 | - /** |
|
1977 | - * @param array $existing_reg_payment_REG_IDs |
|
1978 | - */ |
|
1979 | - public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) |
|
1980 | - { |
|
1981 | - $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
|
1982 | - } |
|
1983 | - |
|
1984 | - |
|
1985 | - /** |
|
1986 | - * _get_existing_reg_payment_REG_IDs |
|
1987 | - * returns a list of registration IDs that the payment is currently related to |
|
1988 | - * as recorded in the database |
|
1989 | - * |
|
1990 | - * @param EE_Payment $payment |
|
1991 | - * @return array |
|
1992 | - * @throws EE_Error |
|
1993 | - * @throws InvalidArgumentException |
|
1994 | - * @throws InvalidDataTypeException |
|
1995 | - * @throws InvalidInterfaceException |
|
1996 | - * @throws ReflectionException |
|
1997 | - */ |
|
1998 | - protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) |
|
1999 | - { |
|
2000 | - if ($this->existing_reg_payment_REG_IDs() === null) { |
|
2001 | - // let's get any existing reg payment records for this payment |
|
2002 | - $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
2003 | - // but we only want the REG IDs, so grab the array keys |
|
2004 | - $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) |
|
2005 | - ? array_keys($existing_reg_payment_REG_IDs) |
|
2006 | - : []; |
|
2007 | - $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
2008 | - } |
|
2009 | - |
|
2010 | - return $this->existing_reg_payment_REG_IDs(); |
|
2011 | - } |
|
2012 | - |
|
2013 | - |
|
2014 | - /** |
|
2015 | - * _remove_existing_registration_payments |
|
2016 | - * this calculates the difference between existing relations |
|
2017 | - * to the supplied payment and the new list registration IDs, |
|
2018 | - * removes any related registrations that no longer apply, |
|
2019 | - * and then updates the registration paid fields |
|
2020 | - * |
|
2021 | - * @param EE_Payment $payment |
|
2022 | - * @param int $PAY_ID |
|
2023 | - * @return bool; |
|
2024 | - * @throws EE_Error |
|
2025 | - * @throws InvalidArgumentException |
|
2026 | - * @throws ReflectionException |
|
2027 | - * @throws InvalidDataTypeException |
|
2028 | - * @throws InvalidInterfaceException |
|
2029 | - */ |
|
2030 | - protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) |
|
2031 | - { |
|
2032 | - // newly created payments will have nothing recorded for $PAY_ID |
|
2033 | - if (absint($PAY_ID) === 0) { |
|
2034 | - return false; |
|
2035 | - } |
|
2036 | - $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
2037 | - if (empty($existing_reg_payment_REG_IDs)) { |
|
2038 | - return false; |
|
2039 | - } |
|
2040 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
2041 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
2042 | - |
|
2043 | - return $transaction_payments->delete_registration_payments_and_update_registrations( |
|
2044 | - $payment, |
|
2045 | - [ |
|
2046 | - [ |
|
2047 | - 'PAY_ID' => $payment->ID(), |
|
2048 | - 'REG_ID' => ['IN', $existing_reg_payment_REG_IDs], |
|
2049 | - ], |
|
2050 | - ] |
|
2051 | - ); |
|
2052 | - } |
|
2053 | - |
|
2054 | - |
|
2055 | - /** |
|
2056 | - * _update_registration_payments |
|
2057 | - * this applies the payments to the selected registrations |
|
2058 | - * but only if they have not already been paid for |
|
2059 | - * |
|
2060 | - * @param EE_Transaction $transaction |
|
2061 | - * @param EE_Payment $payment |
|
2062 | - * @param array $REG_IDs |
|
2063 | - * @return void |
|
2064 | - * @throws EE_Error |
|
2065 | - * @throws InvalidArgumentException |
|
2066 | - * @throws ReflectionException |
|
2067 | - * @throws RuntimeException |
|
2068 | - * @throws InvalidDataTypeException |
|
2069 | - * @throws InvalidInterfaceException |
|
2070 | - */ |
|
2071 | - protected function _update_registration_payments( |
|
2072 | - EE_Transaction $transaction, |
|
2073 | - EE_Payment $payment, |
|
2074 | - $REG_IDs = [] |
|
2075 | - ) { |
|
2076 | - // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
|
2077 | - // so let's do that using our set of REG_IDs from the form |
|
2078 | - $registration_query_where_params = [ |
|
2079 | - 'REG_ID' => ['IN', $REG_IDs], |
|
2080 | - ]; |
|
2081 | - // but add in some conditions regarding payment, |
|
2082 | - // so that we don't apply payments to registrations that are free or have already been paid for |
|
2083 | - // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
|
2084 | - if (! $payment->is_a_refund()) { |
|
2085 | - $registration_query_where_params['REG_final_price'] = ['!=', 0]; |
|
2086 | - $registration_query_where_params['REG_final_price*'] = ['!=', 'REG_paid', true]; |
|
2087 | - } |
|
2088 | - $registrations = $transaction->registrations([$registration_query_where_params]); |
|
2089 | - if (! empty($registrations)) { |
|
2090 | - /** @type EE_Payment_Processor $payment_processor */ |
|
2091 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2092 | - $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
2093 | - } |
|
2094 | - } |
|
2095 | - |
|
2096 | - |
|
2097 | - /** |
|
2098 | - * _process_registration_status_change |
|
2099 | - * This processes requested registration status changes for all the registrations |
|
2100 | - * on a given transaction and (optionally) sends out notifications for the changes. |
|
2101 | - * |
|
2102 | - * @param EE_Transaction $transaction |
|
2103 | - * @param array $REG_IDs |
|
2104 | - * @return bool |
|
2105 | - * @throws EE_Error |
|
2106 | - * @throws InvalidArgumentException |
|
2107 | - * @throws ReflectionException |
|
2108 | - * @throws InvalidDataTypeException |
|
2109 | - * @throws InvalidInterfaceException |
|
2110 | - */ |
|
2111 | - protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = []) |
|
2112 | - { |
|
2113 | - // first if there is no change in status then we get out. |
|
2114 | - $reg_status = $this->request->getRequestParam('txn_reg_status_change[reg_status]', 'NAN'); |
|
2115 | - if ($reg_status === 'NAN') { |
|
2116 | - // no error message, no change requested, just nothing to do man. |
|
2117 | - return false; |
|
2118 | - } |
|
2119 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
2120 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
2121 | - |
|
2122 | - // made it here dude? Oh WOW. K, let's take care of changing the statuses |
|
2123 | - return $transaction_processor->manually_update_registration_statuses( |
|
2124 | - $transaction, |
|
2125 | - $reg_status, |
|
2126 | - [['REG_ID' => ['IN', $REG_IDs]]] |
|
2127 | - ); |
|
2128 | - } |
|
2129 | - |
|
2130 | - |
|
2131 | - /** |
|
2132 | - * _build_payment_json_response |
|
2133 | - * |
|
2134 | - * @access public |
|
2135 | - * @param EE_Payment $payment |
|
2136 | - * @param array $REG_IDs |
|
2137 | - * @param bool | null $delete_txn_reg_status_change |
|
2138 | - * @return array |
|
2139 | - * @throws EE_Error |
|
2140 | - * @throws InvalidArgumentException |
|
2141 | - * @throws InvalidDataTypeException |
|
2142 | - * @throws InvalidInterfaceException |
|
2143 | - * @throws ReflectionException |
|
2144 | - */ |
|
2145 | - protected function _build_payment_json_response( |
|
2146 | - EE_Payment $payment, |
|
2147 | - $REG_IDs = [], |
|
2148 | - $delete_txn_reg_status_change = null |
|
2149 | - ) { |
|
2150 | - // was the payment deleted ? |
|
2151 | - if (is_bool($delete_txn_reg_status_change)) { |
|
2152 | - return [ |
|
2153 | - 'PAY_ID' => $payment->ID(), |
|
2154 | - 'amount' => $payment->amount(), |
|
2155 | - 'total_paid' => $payment->transaction()->paid(), |
|
2156 | - 'txn_status' => $payment->transaction()->status_ID(), |
|
2157 | - 'pay_status' => $payment->STS_ID(), |
|
2158 | - 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
2159 | - 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
|
2160 | - ]; |
|
2161 | - } |
|
2162 | - |
|
2163 | - $this->_get_payment_status_array(); |
|
2164 | - return [ |
|
2165 | - 'amount' => $payment->amount(), |
|
2166 | - 'total_paid' => $payment->transaction()->paid(), |
|
2167 | - 'txn_status' => $payment->transaction()->status_ID(), |
|
2168 | - 'pay_status' => $payment->STS_ID(), |
|
2169 | - 'PAY_ID' => $payment->ID(), |
|
2170 | - 'STS_ID' => $payment->STS_ID(), |
|
2171 | - 'status' => self::$_pay_status[ $payment->STS_ID() ], |
|
2172 | - 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
2173 | - 'method' => strtoupper($payment->source()), |
|
2174 | - 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
|
2175 | - 'gateway' => $payment->payment_method() |
|
2176 | - ? $payment->payment_method()->admin_name() |
|
2177 | - : esc_html__('Unknown', 'event_espresso'), |
|
2178 | - 'gateway_response' => $payment->gateway_response(), |
|
2179 | - 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
|
2180 | - 'po_number' => $payment->po_number(), |
|
2181 | - 'extra_accntng' => $payment->extra_accntng(), |
|
2182 | - 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
2183 | - ]; |
|
2184 | - } |
|
2185 | - |
|
2186 | - |
|
2187 | - /** |
|
2188 | - * delete_payment |
|
2189 | - * delete a payment or refund made towards a transaction |
|
2190 | - * |
|
2191 | - * @access public |
|
2192 | - * @return void |
|
2193 | - * @throws EE_Error |
|
2194 | - * @throws InvalidArgumentException |
|
2195 | - * @throws ReflectionException |
|
2196 | - * @throws InvalidDataTypeException |
|
2197 | - * @throws InvalidInterfaceException |
|
2198 | - */ |
|
2199 | - public function delete_payment() |
|
2200 | - { |
|
2201 | - $json_response_data = ['return_data' => false]; |
|
2202 | - $PAY_ID = $this->request->getRequestParam('delete_txn_admin_payment[PAY_ID]', 0, 'int'); |
|
2203 | - |
|
2204 | - $can_delete = EE_Registry::instance()->CAP->current_user_can( |
|
2205 | - 'ee_delete_payments', |
|
2206 | - 'delete_payment_from_registration_details' |
|
2207 | - ); |
|
2208 | - if ($PAY_ID && $can_delete) { |
|
2209 | - $delete_txn_reg_status_change = $this->request->getRequestParam( |
|
2210 | - 'delete_txn_reg_status_change', |
|
2211 | - false, |
|
2212 | - 'bool' |
|
2213 | - ); |
|
2214 | - $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
2215 | - if ($payment instanceof EE_Payment) { |
|
2216 | - $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
2217 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
2218 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
2219 | - if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
2220 | - $json_response_data['return_data'] = $this->_build_payment_json_response( |
|
2221 | - $payment, |
|
2222 | - $REG_IDs, |
|
2223 | - $delete_txn_reg_status_change |
|
2224 | - ); |
|
2225 | - if ($delete_txn_reg_status_change) { |
|
2226 | - // MAKE sure we also add the delete_txn_req_status_change to the |
|
2227 | - // request data because that's how messages will be looking for it. |
|
2228 | - $this->request->setRequestParam('txn_reg_status_change', $delete_txn_reg_status_change); |
|
2229 | - $this->_maybe_send_notifications(); |
|
2230 | - $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
2231 | - } |
|
2232 | - } |
|
2233 | - } else { |
|
2234 | - EE_Error::add_error( |
|
2235 | - esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
2236 | - __FILE__, |
|
2237 | - __FUNCTION__, |
|
2238 | - __LINE__ |
|
2239 | - ); |
|
2240 | - } |
|
2241 | - } elseif ($can_delete) { |
|
2242 | - EE_Error::add_error( |
|
2243 | - esc_html__( |
|
2244 | - 'A valid Payment ID was not received, therefore payment form data could not be loaded.', |
|
2245 | - 'event_espresso' |
|
2246 | - ), |
|
2247 | - __FILE__, |
|
2248 | - __FUNCTION__, |
|
2249 | - __LINE__ |
|
2250 | - ); |
|
2251 | - } else { |
|
2252 | - EE_Error::add_error( |
|
2253 | - esc_html__( |
|
2254 | - 'You do not have access to delete a payment.', |
|
2255 | - 'event_espresso' |
|
2256 | - ), |
|
2257 | - __FILE__, |
|
2258 | - __FUNCTION__, |
|
2259 | - __LINE__ |
|
2260 | - ); |
|
2261 | - } |
|
2262 | - $notices = EE_Error::get_notices(false, false, false); |
|
2263 | - $this->_template_args = [ |
|
2264 | - 'data' => $json_response_data, |
|
2265 | - 'success' => $notices['success'], |
|
2266 | - 'error' => $notices['errors'], |
|
2267 | - 'attention' => $notices['attention'], |
|
2268 | - ]; |
|
2269 | - $this->_return_json(); |
|
2270 | - } |
|
2271 | - |
|
2272 | - |
|
2273 | - /** |
|
2274 | - * _registration_payment_data_array |
|
2275 | - * adds info for 'owing' and 'paid' for each registration to the json response |
|
2276 | - * |
|
2277 | - * @access protected |
|
2278 | - * @param array $REG_IDs |
|
2279 | - * @return array |
|
2280 | - * @throws EE_Error |
|
2281 | - * @throws InvalidArgumentException |
|
2282 | - * @throws InvalidDataTypeException |
|
2283 | - * @throws InvalidInterfaceException |
|
2284 | - * @throws ReflectionException |
|
2285 | - */ |
|
2286 | - protected function _registration_payment_data_array($REG_IDs) |
|
2287 | - { |
|
2288 | - $registration_payment_data = []; |
|
2289 | - // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
|
2290 | - if (! empty($REG_IDs)) { |
|
2291 | - $registrations = EEM_Registration::instance()->get_all([['REG_ID' => ['IN', $REG_IDs]]]); |
|
2292 | - foreach ($registrations as $registration) { |
|
2293 | - if ($registration instanceof EE_Registration) { |
|
2294 | - $registration_payment_data[ $registration->ID() ] = [ |
|
2295 | - 'paid' => $registration->pretty_paid(), |
|
2296 | - 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
2297 | - ]; |
|
2298 | - } |
|
2299 | - } |
|
2300 | - } |
|
2301 | - |
|
2302 | - return $registration_payment_data; |
|
2303 | - } |
|
2304 | - |
|
2305 | - |
|
2306 | - /** |
|
2307 | - * _maybe_send_notifications |
|
2308 | - * determines whether or not the admin has indicated that notifications should be sent. |
|
2309 | - * If so, will toggle a filter switch for delivering registration notices. |
|
2310 | - * If passed an EE_Payment object, then it will trigger payment notifications instead. |
|
2311 | - * |
|
2312 | - * @access protected |
|
2313 | - * @param EE_Payment | null $payment |
|
2314 | - */ |
|
2315 | - protected function _maybe_send_notifications($payment = null) |
|
2316 | - { |
|
2317 | - switch ($payment instanceof EE_Payment) { |
|
2318 | - // payment notifications |
|
2319 | - case true: |
|
2320 | - if ($this->request->getRequestParam('txn_payments[send_notifications]', false, 'bool')) { |
|
2321 | - $this->_process_payment_notification($payment); |
|
2322 | - } |
|
2323 | - break; |
|
2324 | - // registration notifications |
|
2325 | - case false: |
|
2326 | - if ($this->request->getRequestParam('txn_reg_status_change[send_notifications]', false, 'bool')) { |
|
2327 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
2328 | - } |
|
2329 | - break; |
|
2330 | - } |
|
2331 | - } |
|
2332 | - |
|
2333 | - |
|
2334 | - /** |
|
2335 | - * _send_payment_reminder |
|
2336 | - * generates HTML for the View Transaction Details Admin page |
|
2337 | - * |
|
2338 | - * @access protected |
|
2339 | - * @return void |
|
2340 | - * @throws EE_Error |
|
2341 | - * @throws InvalidArgumentException |
|
2342 | - * @throws InvalidDataTypeException |
|
2343 | - * @throws InvalidInterfaceException |
|
2344 | - */ |
|
2345 | - protected function _send_payment_reminder() |
|
2346 | - { |
|
2347 | - $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
2348 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2349 | - $redirect_to = $this->request->getRequestParam('redirect_to'); |
|
2350 | - $query_args = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : []; |
|
2351 | - do_action( |
|
2352 | - 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
2353 | - $transaction |
|
2354 | - ); |
|
2355 | - $this->_redirect_after_action( |
|
2356 | - false, |
|
2357 | - esc_html__('payment reminder', 'event_espresso'), |
|
2358 | - esc_html__('sent', 'event_espresso'), |
|
2359 | - $query_args, |
|
2360 | - true |
|
2361 | - ); |
|
2362 | - } |
|
2363 | - |
|
2364 | - |
|
2365 | - /** |
|
2366 | - * get_transactions |
|
2367 | - * get transactions for given parameters (used by list table) |
|
2368 | - * |
|
2369 | - * @param int $per_page how many transactions displayed per page |
|
2370 | - * @param boolean $count return the count or objects |
|
2371 | - * @param string $view |
|
2372 | - * @return EE_Transaction[]|int int = count || array of transaction objects |
|
2373 | - * @throws EE_Error |
|
2374 | - * @throws InvalidArgumentException |
|
2375 | - * @throws InvalidDataTypeException |
|
2376 | - * @throws InvalidInterfaceException |
|
2377 | - */ |
|
2378 | - public function get_transactions($per_page, $count = false, $view = '') |
|
2379 | - { |
|
2380 | - $start_date = wp_strip_all_tags( |
|
2381 | - $this->request->getRequestParam('txn-filter-start-date', date('m/d/Y', strtotime('-10 year'))) |
|
2382 | - ); |
|
2383 | - $end_date = wp_strip_all_tags( |
|
2384 | - $this->request->getRequestParam('txn-filter-end-date', date('m/d/Y')) |
|
2385 | - ); |
|
2386 | - |
|
2387 | - // make sure our timestamps start and end right at the boundaries for each day |
|
2388 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
2389 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
2390 | - |
|
2391 | - |
|
2392 | - // convert to timestamps |
|
2393 | - $start_date = strtotime($start_date); |
|
2394 | - $end_date = strtotime($end_date); |
|
2395 | - |
|
2396 | - // makes sure start date is the lowest value and vice versa |
|
2397 | - $start_date = min($start_date, $end_date); |
|
2398 | - $end_date = max($start_date, $end_date); |
|
2399 | - |
|
2400 | - // convert to correct format for query |
|
2401 | - $start_date = EEM_Transaction::instance()->convert_datetime_for_query( |
|
2402 | - 'TXN_timestamp', |
|
2403 | - date('Y-m-d H:i:s', $start_date), |
|
2404 | - 'Y-m-d H:i:s' |
|
2405 | - ); |
|
2406 | - $end_date = EEM_Transaction::instance()->convert_datetime_for_query( |
|
2407 | - 'TXN_timestamp', |
|
2408 | - date('Y-m-d H:i:s', $end_date), |
|
2409 | - 'Y-m-d H:i:s' |
|
2410 | - ); |
|
2411 | - |
|
2412 | - |
|
2413 | - // set orderby |
|
2414 | - $orderby = $this->request->getRequestParam('orderby'); |
|
2415 | - |
|
2416 | - switch ($orderby) { |
|
2417 | - case 'TXN_ID': |
|
2418 | - break; |
|
2419 | - case 'ATT_fname': |
|
2420 | - $orderby = 'Registration.Attendee.ATT_fname'; |
|
2421 | - break; |
|
2422 | - case 'event_name': |
|
2423 | - $orderby = 'Registration.Event.EVT_name'; |
|
2424 | - break; |
|
2425 | - default: // 'TXN_timestamp' |
|
2426 | - $orderby = 'TXN_timestamp'; |
|
2427 | - } |
|
2428 | - |
|
2429 | - $sort = $this->request->getRequestParam('order', 'DESC'); |
|
2430 | - $current_page = $this->request->getRequestParam('paged', 1, 'int'); |
|
2431 | - |
|
2432 | - $per_page = absint($per_page) ? $per_page : 10; |
|
2433 | - $per_page = $this->request->getRequestParam('perpage', $per_page, 'int'); |
|
2434 | - |
|
2435 | - $offset = ($current_page - 1) * $per_page; |
|
2436 | - $limit = [$offset, $per_page]; |
|
2437 | - |
|
2438 | - $_where = [ |
|
2439 | - 'TXN_timestamp' => ['BETWEEN', [$start_date, $end_date]], |
|
2440 | - 'Registration.REG_count' => 1, |
|
2441 | - ]; |
|
2442 | - |
|
2443 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
2444 | - if ($EVT_ID) { |
|
2445 | - $_where['Registration.EVT_ID'] = $EVT_ID; |
|
2446 | - } |
|
2447 | - |
|
2448 | - $search_term = $this->request->getRequestParam('s'); |
|
2449 | - if ($search_term) { |
|
2450 | - $search_term = '%' . $search_term . '%'; |
|
2451 | - $_where['OR'] = [ |
|
2452 | - 'Registration.Event.EVT_name' => ['LIKE', $search_term], |
|
2453 | - 'Registration.Event.EVT_desc' => ['LIKE', $search_term], |
|
2454 | - 'Registration.Event.EVT_short_desc' => ['LIKE', $search_term], |
|
2455 | - 'Registration.Attendee.ATT_full_name' => ['LIKE', $search_term], |
|
2456 | - 'Registration.Attendee.ATT_fname' => ['LIKE', $search_term], |
|
2457 | - 'Registration.Attendee.ATT_lname' => ['LIKE', $search_term], |
|
2458 | - 'Registration.Attendee.ATT_short_bio' => ['LIKE', $search_term], |
|
2459 | - 'Registration.Attendee.ATT_email' => ['LIKE', $search_term], |
|
2460 | - 'Registration.Attendee.ATT_address' => ['LIKE', $search_term], |
|
2461 | - 'Registration.Attendee.ATT_address2' => ['LIKE', $search_term], |
|
2462 | - 'Registration.Attendee.ATT_city' => ['LIKE', $search_term], |
|
2463 | - 'Registration.REG_final_price' => ['LIKE', $search_term], |
|
2464 | - 'Registration.REG_code' => ['LIKE', $search_term], |
|
2465 | - 'Registration.REG_count' => ['LIKE', $search_term], |
|
2466 | - 'Registration.REG_group_size' => ['LIKE', $search_term], |
|
2467 | - 'Registration.Ticket.TKT_name' => ['LIKE', $search_term], |
|
2468 | - 'Registration.Ticket.TKT_description' => ['LIKE', $search_term], |
|
2469 | - 'Payment.PAY_source' => ['LIKE', $search_term], |
|
2470 | - 'Payment.Payment_Method.PMD_name' => ['LIKE', $search_term], |
|
2471 | - 'TXN_session_data' => ['LIKE', $search_term], |
|
2472 | - 'Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_term], |
|
2473 | - ]; |
|
2474 | - } |
|
2475 | - |
|
2476 | - $status = $this->request->getRequestParam('status'); |
|
2477 | - // failed transactions |
|
2478 | - $failed = (! empty($status) && $status === 'failed' && ! $count) || ($count && $view === 'failed'); |
|
2479 | - $abandoned = (! empty($status) && $status === 'abandoned' && ! $count) || ($count && $view === 'abandoned'); |
|
2480 | - $incomplete = (! empty($status) && $status === 'incomplete' && ! $count) || ($count && $view === 'incomplete'); |
|
2481 | - |
|
2482 | - if ($failed) { |
|
2483 | - $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
2484 | - } elseif ($abandoned) { |
|
2485 | - $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
|
2486 | - } elseif ($incomplete) { |
|
2487 | - $_where['STS_ID'] = EEM_Transaction::incomplete_status_code; |
|
2488 | - } else { |
|
2489 | - $_where['STS_ID'] = ['!=', EEM_Transaction::failed_status_code]; |
|
2490 | - $_where['STS_ID*'] = ['!=', EEM_Transaction::abandoned_status_code]; |
|
2491 | - } |
|
2492 | - |
|
2493 | - $query_params = apply_filters( |
|
2494 | - 'FHEE__Transactions_Admin_Page___get_transactions_query_params', |
|
2495 | - [ |
|
2496 | - $_where, |
|
2497 | - 'order_by' => [$orderby => $sort], |
|
2498 | - 'limit' => $limit, |
|
2499 | - 'default_where_conditions' => EEM_Base::default_where_conditions_this_only, |
|
2500 | - ], |
|
2501 | - $this->request->requestParams(), |
|
2502 | - $view, |
|
2503 | - $count |
|
2504 | - ); |
|
2505 | - |
|
2506 | - return $count |
|
2507 | - ? EEM_Transaction::instance()->count([$query_params[0]], 'TXN_ID', true) |
|
2508 | - : EEM_Transaction::instance()->get_all($query_params); |
|
2509 | - } |
|
2510 | - |
|
2511 | - |
|
2512 | - /** |
|
2513 | - * @throws EE_Error |
|
2514 | - * @throws InvalidArgumentException |
|
2515 | - * @throws InvalidDataTypeException |
|
2516 | - * @throws InvalidInterfaceException |
|
2517 | - * @throws ReflectionException |
|
2518 | - * @throws RuntimeException |
|
2519 | - * @since 4.9.79.p |
|
2520 | - */ |
|
2521 | - public function recalculateLineItems() |
|
2522 | - { |
|
2523 | - $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
2524 | - /** @var EE_Transaction $transaction */ |
|
2525 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2526 | - $success = $transaction->recalculateLineItems(); |
|
2527 | - $redirect_to = $this->request->getRequestParam('redirect_to'); |
|
2528 | - $query_args = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : []; |
|
2529 | - $this->_redirect_after_action( |
|
2530 | - $success, |
|
2531 | - esc_html__('Transaction taxes and totals', 'event_espresso'), |
|
2532 | - esc_html__('recalculated', 'event_espresso'), |
|
2533 | - $query_args, |
|
2534 | - true |
|
2535 | - ); |
|
2536 | - } |
|
16 | + /** |
|
17 | + * @var EE_Transaction |
|
18 | + */ |
|
19 | + private $_transaction; |
|
20 | + |
|
21 | + /** |
|
22 | + * @var EE_Session |
|
23 | + */ |
|
24 | + private $_session; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var array $_txn_status |
|
28 | + */ |
|
29 | + private static $_txn_status; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var array $_pay_status |
|
33 | + */ |
|
34 | + private static $_pay_status; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var array $_existing_reg_payment_REG_IDs |
|
38 | + */ |
|
39 | + protected $_existing_reg_payment_REG_IDs; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * _init_page_props |
|
44 | + * |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + protected function _init_page_props() |
|
48 | + { |
|
49 | + $this->page_slug = TXN_PG_SLUG; |
|
50 | + $this->page_label = esc_html__('Transactions', 'event_espresso'); |
|
51 | + $this->_admin_base_url = TXN_ADMIN_URL; |
|
52 | + $this->_admin_base_path = TXN_ADMIN; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * _ajax_hooks |
|
58 | + * |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + protected function _ajax_hooks() |
|
62 | + { |
|
63 | + add_action('wp_ajax_espresso_apply_payment', [$this, 'apply_payments_or_refunds']); |
|
64 | + add_action('wp_ajax_espresso_apply_refund', [$this, 'apply_payments_or_refunds']); |
|
65 | + add_action('wp_ajax_espresso_delete_payment', [$this, 'delete_payment']); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * _define_page_props |
|
71 | + * |
|
72 | + * @return void |
|
73 | + */ |
|
74 | + protected function _define_page_props() |
|
75 | + { |
|
76 | + $this->_admin_page_title = $this->page_label; |
|
77 | + $this->_labels = [ |
|
78 | + 'buttons' => [ |
|
79 | + 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
|
80 | + 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
|
81 | + 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
82 | + ], |
|
83 | + ]; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * grab url requests and route them |
|
89 | + * |
|
90 | + * @access private |
|
91 | + * @return void |
|
92 | + * @throws EE_Error |
|
93 | + * @throws InvalidArgumentException |
|
94 | + * @throws InvalidDataTypeException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + */ |
|
97 | + public function _set_page_routes() |
|
98 | + { |
|
99 | + |
|
100 | + $this->_set_transaction_status_array(); |
|
101 | + $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
102 | + |
|
103 | + $this->_page_routes = [ |
|
104 | + |
|
105 | + 'default' => [ |
|
106 | + 'func' => '_transactions_overview_list_table', |
|
107 | + 'capability' => 'ee_read_transactions', |
|
108 | + ], |
|
109 | + |
|
110 | + 'view_transaction' => [ |
|
111 | + 'func' => '_transaction_details', |
|
112 | + 'capability' => 'ee_read_transaction', |
|
113 | + 'obj_id' => $TXN_ID, |
|
114 | + ], |
|
115 | + |
|
116 | + 'send_payment_reminder' => [ |
|
117 | + 'func' => '_send_payment_reminder', |
|
118 | + 'noheader' => true, |
|
119 | + 'capability' => 'ee_send_message', |
|
120 | + ], |
|
121 | + |
|
122 | + 'espresso_apply_payment' => [ |
|
123 | + 'func' => 'apply_payments_or_refunds', |
|
124 | + 'noheader' => true, |
|
125 | + 'capability' => 'ee_edit_payments', |
|
126 | + ], |
|
127 | + |
|
128 | + 'espresso_apply_refund' => [ |
|
129 | + 'func' => 'apply_payments_or_refunds', |
|
130 | + 'noheader' => true, |
|
131 | + 'capability' => 'ee_edit_payments', |
|
132 | + ], |
|
133 | + |
|
134 | + 'espresso_delete_payment' => [ |
|
135 | + 'func' => 'delete_payment', |
|
136 | + 'noheader' => true, |
|
137 | + 'capability' => 'ee_delete_payments', |
|
138 | + ], |
|
139 | + |
|
140 | + 'espresso_recalculate_line_items' => [ |
|
141 | + 'func' => 'recalculateLineItems', |
|
142 | + 'noheader' => true, |
|
143 | + 'capability' => 'ee_edit_payments', |
|
144 | + ], |
|
145 | + |
|
146 | + ]; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + protected function _set_page_config() |
|
151 | + { |
|
152 | + $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
153 | + $this->_page_config = [ |
|
154 | + 'default' => [ |
|
155 | + 'nav' => [ |
|
156 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
157 | + 'order' => 10, |
|
158 | + ], |
|
159 | + 'list_table' => 'EE_Admin_Transactions_List_Table', |
|
160 | + 'help_tabs' => [ |
|
161 | + 'transactions_overview_help_tab' => [ |
|
162 | + 'title' => esc_html__('Transactions Overview', 'event_espresso'), |
|
163 | + 'filename' => 'transactions_overview', |
|
164 | + ], |
|
165 | + 'transactions_overview_table_column_headings_help_tab' => [ |
|
166 | + 'title' => esc_html__('Transactions Table Column Headings', 'event_espresso'), |
|
167 | + 'filename' => 'transactions_overview_table_column_headings', |
|
168 | + ], |
|
169 | + 'transactions_overview_views_filters_help_tab' => [ |
|
170 | + 'title' => esc_html__('Transaction Views & Filters & Search', 'event_espresso'), |
|
171 | + 'filename' => 'transactions_overview_views_filters_search', |
|
172 | + ], |
|
173 | + ], |
|
174 | + /** |
|
175 | + * commented out because currently we are not displaying tips for transaction list table status but this |
|
176 | + * may change in a later iteration so want to keep the code for then. |
|
177 | + */ |
|
178 | + // 'qtips' => array( 'Transactions_List_Table_Tips' ), |
|
179 | + 'require_nonce' => false, |
|
180 | + ], |
|
181 | + 'view_transaction' => [ |
|
182 | + 'nav' => [ |
|
183 | + 'label' => esc_html__('View Transaction', 'event_espresso'), |
|
184 | + 'order' => 5, |
|
185 | + 'url' => $TXN_ID |
|
186 | + ? add_query_arg(['TXN_ID' => $TXN_ID], $this->_current_page_view_url) |
|
187 | + : $this->_admin_base_url, |
|
188 | + 'persistent' => false, |
|
189 | + ], |
|
190 | + 'help_tabs' => [ |
|
191 | + 'transactions_view_transaction_help_tab' => [ |
|
192 | + 'title' => esc_html__('View Transaction', 'event_espresso'), |
|
193 | + 'filename' => 'transactions_view_transaction', |
|
194 | + ], |
|
195 | + 'transactions_view_transaction_transaction_details_table_help_tab' => [ |
|
196 | + 'title' => esc_html__('Transaction Details Table', 'event_espresso'), |
|
197 | + 'filename' => 'transactions_view_transaction_transaction_details_table', |
|
198 | + ], |
|
199 | + 'transactions_view_transaction_attendees_registered_help_tab' => [ |
|
200 | + 'title' => esc_html__('Attendees Registered', 'event_espresso'), |
|
201 | + 'filename' => 'transactions_view_transaction_attendees_registered', |
|
202 | + ], |
|
203 | + 'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => [ |
|
204 | + 'title' => esc_html__('Primary Registrant & Billing Information', 'event_espresso'), |
|
205 | + 'filename' => 'transactions_view_transaction_primary_registrant_billing_information', |
|
206 | + ], |
|
207 | + ], |
|
208 | + 'qtips' => ['Transaction_Details_Tips'], |
|
209 | + 'metaboxes' => ['_transaction_details_metaboxes'], |
|
210 | + |
|
211 | + 'require_nonce' => false, |
|
212 | + ], |
|
213 | + ]; |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * The below methods aren't used by this class currently |
|
219 | + */ |
|
220 | + protected function _add_screen_options() |
|
221 | + { |
|
222 | + // noop |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + protected function _add_feature_pointers() |
|
227 | + { |
|
228 | + // noop |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + public function admin_init() |
|
233 | + { |
|
234 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
235 | + $event_name = $this->request->getRequestParam('event_name'); |
|
236 | + $redirect_from = $this->request->getRequestParam('redirect_from', '', 'url'); |
|
237 | + // IF a registration was JUST added via the admin... |
|
238 | + if ($EVT_ID && $event_name && $redirect_from) { |
|
239 | + // then set a cookie so that we can block any attempts to use |
|
240 | + // the back button as a way to enter another registration. |
|
241 | + setcookie('ee_registration_added', $EVT_ID, time() + WEEK_IN_SECONDS, '/'); |
|
242 | + // and update the global |
|
243 | + $_COOKIE['ee_registration_added'] = $EVT_ID; |
|
244 | + } |
|
245 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__( |
|
246 | + 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
247 | + 'event_espresso' |
|
248 | + ); |
|
249 | + EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__( |
|
250 | + 'An error occurred! Please refresh the page and try again.', |
|
251 | + 'event_espresso' |
|
252 | + ); |
|
253 | + EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
254 | + EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
255 | + EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
256 | + EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__( |
|
257 | + 'This transaction has been overpaid ! Payments Total', |
|
258 | + 'event_espresso' |
|
259 | + ); |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + public function admin_notices() |
|
264 | + { |
|
265 | + // noop |
|
266 | + } |
|
267 | + |
|
268 | + |
|
269 | + public function admin_footer_scripts() |
|
270 | + { |
|
271 | + // noop |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * _set_transaction_status_array |
|
277 | + * sets list of transaction statuses |
|
278 | + * |
|
279 | + * @access private |
|
280 | + * @return void |
|
281 | + * @throws EE_Error |
|
282 | + * @throws InvalidArgumentException |
|
283 | + * @throws InvalidDataTypeException |
|
284 | + * @throws InvalidInterfaceException |
|
285 | + */ |
|
286 | + private function _set_transaction_status_array() |
|
287 | + { |
|
288 | + self::$_txn_status = EEM_Transaction::instance()->status_array(true); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + /** |
|
293 | + * get_transaction_status_array |
|
294 | + * return the transaction status array for wp_list_table |
|
295 | + * |
|
296 | + * @access public |
|
297 | + * @return array |
|
298 | + */ |
|
299 | + public function get_transaction_status_array() |
|
300 | + { |
|
301 | + return self::$_txn_status; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * get list of payment statuses |
|
307 | + * |
|
308 | + * @access private |
|
309 | + * @return void |
|
310 | + * @throws EE_Error |
|
311 | + * @throws InvalidArgumentException |
|
312 | + * @throws InvalidDataTypeException |
|
313 | + * @throws InvalidInterfaceException |
|
314 | + */ |
|
315 | + private function _get_payment_status_array() |
|
316 | + { |
|
317 | + self::$_pay_status = EEM_Payment::instance()->status_array(true); |
|
318 | + $this->_template_args['payment_status'] = self::$_pay_status; |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * _add_screen_options_default |
|
324 | + * |
|
325 | + * @access protected |
|
326 | + * @return void |
|
327 | + * @throws InvalidArgumentException |
|
328 | + * @throws InvalidDataTypeException |
|
329 | + * @throws InvalidInterfaceException |
|
330 | + */ |
|
331 | + protected function _add_screen_options_default() |
|
332 | + { |
|
333 | + $this->_per_page_screen_option(); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * load_scripts_styles |
|
339 | + * |
|
340 | + * @access public |
|
341 | + * @return void |
|
342 | + */ |
|
343 | + public function load_scripts_styles() |
|
344 | + { |
|
345 | + // enqueue style |
|
346 | + wp_register_style( |
|
347 | + 'espresso_txn', |
|
348 | + TXN_ASSETS_URL . 'espresso_transactions_admin.css', |
|
349 | + [], |
|
350 | + EVENT_ESPRESSO_VERSION |
|
351 | + ); |
|
352 | + wp_enqueue_style('espresso_txn'); |
|
353 | + // scripts |
|
354 | + wp_register_script( |
|
355 | + 'espresso_txn', |
|
356 | + TXN_ASSETS_URL . 'espresso_transactions_admin.js', |
|
357 | + [ |
|
358 | + 'ee_admin_js', |
|
359 | + 'ee-datepicker', |
|
360 | + 'jquery-ui-datepicker', |
|
361 | + 'jquery-ui-draggable', |
|
362 | + 'ee-dialog', |
|
363 | + 'ee-accounting', |
|
364 | + 'ee-serialize-full-array', |
|
365 | + ], |
|
366 | + EVENT_ESPRESSO_VERSION, |
|
367 | + true |
|
368 | + ); |
|
369 | + wp_enqueue_script('espresso_txn'); |
|
370 | + } |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * load_scripts_styles_view_transaction |
|
375 | + * |
|
376 | + * @access public |
|
377 | + * @return void |
|
378 | + */ |
|
379 | + public function load_scripts_styles_view_transaction() |
|
380 | + { |
|
381 | + // styles |
|
382 | + wp_enqueue_style('espresso-ui-theme'); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * load_scripts_styles_default |
|
388 | + * |
|
389 | + * @access public |
|
390 | + * @return void |
|
391 | + */ |
|
392 | + public function load_scripts_styles_default() |
|
393 | + { |
|
394 | + // styles |
|
395 | + wp_enqueue_style('espresso-ui-theme'); |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + /** |
|
400 | + * _set_list_table_views_default |
|
401 | + * |
|
402 | + * @access protected |
|
403 | + * @return void |
|
404 | + */ |
|
405 | + protected function _set_list_table_views_default() |
|
406 | + { |
|
407 | + $this->_views = [ |
|
408 | + 'all' => [ |
|
409 | + 'slug' => 'all', |
|
410 | + 'label' => esc_html__('View All Transactions', 'event_espresso'), |
|
411 | + 'count' => 0, |
|
412 | + ], |
|
413 | + 'abandoned' => [ |
|
414 | + 'slug' => 'abandoned', |
|
415 | + 'label' => esc_html__('Abandoned Transactions', 'event_espresso'), |
|
416 | + 'count' => 0, |
|
417 | + ], |
|
418 | + 'incomplete' => [ |
|
419 | + 'slug' => 'incomplete', |
|
420 | + 'label' => esc_html__('Incomplete Transactions', 'event_espresso'), |
|
421 | + 'count' => 0, |
|
422 | + ], |
|
423 | + ]; |
|
424 | + if ( |
|
425 | + /** |
|
426 | + * Filters whether a link to the "Failed Transactions" list table |
|
427 | + * appears on the Transactions Admin Page list table. |
|
428 | + * List display can be turned back on via the following: |
|
429 | + * add_filter( |
|
430 | + * 'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list', |
|
431 | + * '__return_true' |
|
432 | + * ); |
|
433 | + * |
|
434 | + * @param boolean $display_failed_txns_list |
|
435 | + * @param Transactions_Admin_Page $this |
|
436 | + * @since 4.9.70.p |
|
437 | + */ |
|
438 | + apply_filters( |
|
439 | + 'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list', |
|
440 | + false, |
|
441 | + $this |
|
442 | + ) |
|
443 | + ) { |
|
444 | + $this->_views['failed'] = [ |
|
445 | + 'slug' => 'failed', |
|
446 | + 'label' => esc_html__('Failed Transactions', 'event_espresso'), |
|
447 | + 'count' => 0, |
|
448 | + ]; |
|
449 | + } |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * _set_transaction_object |
|
455 | + * This sets the _transaction property for the transaction details screen |
|
456 | + * |
|
457 | + * @access private |
|
458 | + * @return void |
|
459 | + * @throws EE_Error |
|
460 | + * @throws InvalidArgumentException |
|
461 | + * @throws RuntimeException |
|
462 | + * @throws InvalidDataTypeException |
|
463 | + * @throws InvalidInterfaceException |
|
464 | + * @throws ReflectionException |
|
465 | + */ |
|
466 | + private function _set_transaction_object() |
|
467 | + { |
|
468 | + if ($this->_transaction instanceof EE_Transaction) { |
|
469 | + return; |
|
470 | + } //get out we've already set the object |
|
471 | + |
|
472 | + $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
473 | + |
|
474 | + // get transaction object |
|
475 | + $this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
476 | + $this->_session = $this->_transaction instanceof EE_Transaction |
|
477 | + ? $this->_transaction->session_data() |
|
478 | + : null; |
|
479 | + if ($this->_transaction instanceof EE_Transaction) { |
|
480 | + $this->_transaction->verify_abandoned_transaction_status(); |
|
481 | + } |
|
482 | + |
|
483 | + if (! $this->_transaction instanceof EE_Transaction) { |
|
484 | + $error_msg = sprintf( |
|
485 | + esc_html__( |
|
486 | + 'An error occurred and the details for the transaction with the ID # %d could not be retrieved.', |
|
487 | + 'event_espresso' |
|
488 | + ), |
|
489 | + $TXN_ID |
|
490 | + ); |
|
491 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
492 | + } |
|
493 | + } |
|
494 | + |
|
495 | + |
|
496 | + /** |
|
497 | + * _transaction_legend_items |
|
498 | + * |
|
499 | + * @access protected |
|
500 | + * @return array |
|
501 | + * @throws EE_Error |
|
502 | + * @throws InvalidArgumentException |
|
503 | + * @throws ReflectionException |
|
504 | + * @throws InvalidDataTypeException |
|
505 | + * @throws InvalidInterfaceException |
|
506 | + */ |
|
507 | + protected function _transaction_legend_items() |
|
508 | + { |
|
509 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
510 | + $items = []; |
|
511 | + |
|
512 | + if ( |
|
513 | + EE_Registry::instance()->CAP->current_user_can( |
|
514 | + 'ee_read_global_messages', |
|
515 | + 'view_filtered_messages' |
|
516 | + ) |
|
517 | + ) { |
|
518 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
519 | + if ( |
|
520 | + is_array($related_for_icon) |
|
521 | + && isset($related_for_icon['css_class'], $related_for_icon['label']) |
|
522 | + ) { |
|
523 | + $items['view_related_messages'] = [ |
|
524 | + 'class' => $related_for_icon['css_class'], |
|
525 | + 'desc' => $related_for_icon['label'], |
|
526 | + ]; |
|
527 | + } |
|
528 | + } |
|
529 | + |
|
530 | + $items = apply_filters( |
|
531 | + 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
|
532 | + array_merge( |
|
533 | + $items, |
|
534 | + [ |
|
535 | + 'view_details' => [ |
|
536 | + 'class' => 'dashicons dashicons-cart', |
|
537 | + 'desc' => esc_html__('View Transaction Details', 'event_espresso'), |
|
538 | + ], |
|
539 | + 'view_invoice' => [ |
|
540 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
541 | + 'desc' => esc_html__('View Transaction Invoice', 'event_espresso'), |
|
542 | + ], |
|
543 | + 'view_receipt' => [ |
|
544 | + 'class' => 'dashicons dashicons-media-default', |
|
545 | + 'desc' => esc_html__('View Transaction Receipt', 'event_espresso'), |
|
546 | + ], |
|
547 | + 'view_registration' => [ |
|
548 | + 'class' => 'dashicons dashicons-clipboard', |
|
549 | + 'desc' => esc_html__('View Registration Details', 'event_espresso'), |
|
550 | + ], |
|
551 | + 'payment_overview_link' => [ |
|
552 | + 'class' => 'dashicons dashicons-money', |
|
553 | + 'desc' => esc_html__('Make Payment on Frontend', 'event_espresso'), |
|
554 | + ], |
|
555 | + ] |
|
556 | + ) |
|
557 | + ); |
|
558 | + |
|
559 | + if ( |
|
560 | + EEH_MSG_Template::is_mt_active('payment_reminder') |
|
561 | + && EE_Registry::instance()->CAP->current_user_can( |
|
562 | + 'ee_send_message', |
|
563 | + 'espresso_transactions_send_payment_reminder' |
|
564 | + ) |
|
565 | + ) { |
|
566 | + $items['send_payment_reminder'] = [ |
|
567 | + 'class' => 'dashicons dashicons-email-alt', |
|
568 | + 'desc' => esc_html__('Send Payment Reminder', 'event_espresso'), |
|
569 | + ]; |
|
570 | + } else { |
|
571 | + $items['blank*'] = [ |
|
572 | + 'class' => '', |
|
573 | + 'desc' => '', |
|
574 | + ]; |
|
575 | + } |
|
576 | + $more_items = apply_filters( |
|
577 | + 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
|
578 | + [ |
|
579 | + 'overpaid' => [ |
|
580 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
581 | + 'desc' => EEH_Template::pretty_status( |
|
582 | + EEM_Transaction::overpaid_status_code, |
|
583 | + false, |
|
584 | + 'sentence' |
|
585 | + ), |
|
586 | + ], |
|
587 | + 'complete' => [ |
|
588 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
589 | + 'desc' => EEH_Template::pretty_status( |
|
590 | + EEM_Transaction::complete_status_code, |
|
591 | + false, |
|
592 | + 'sentence' |
|
593 | + ), |
|
594 | + ], |
|
595 | + 'incomplete' => [ |
|
596 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
597 | + 'desc' => EEH_Template::pretty_status( |
|
598 | + EEM_Transaction::incomplete_status_code, |
|
599 | + false, |
|
600 | + 'sentence' |
|
601 | + ), |
|
602 | + ], |
|
603 | + 'abandoned' => [ |
|
604 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
605 | + 'desc' => EEH_Template::pretty_status( |
|
606 | + EEM_Transaction::abandoned_status_code, |
|
607 | + false, |
|
608 | + 'sentence' |
|
609 | + ), |
|
610 | + ], |
|
611 | + 'failed' => [ |
|
612 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
613 | + 'desc' => EEH_Template::pretty_status( |
|
614 | + EEM_Transaction::failed_status_code, |
|
615 | + false, |
|
616 | + 'sentence' |
|
617 | + ), |
|
618 | + ], |
|
619 | + ] |
|
620 | + ); |
|
621 | + |
|
622 | + return array_merge($items, $more_items); |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + /** |
|
627 | + * _transactions_overview_list_table |
|
628 | + * |
|
629 | + * @access protected |
|
630 | + * @return void |
|
631 | + * @throws DomainException |
|
632 | + * @throws EE_Error |
|
633 | + * @throws InvalidArgumentException |
|
634 | + * @throws InvalidDataTypeException |
|
635 | + * @throws InvalidInterfaceException |
|
636 | + * @throws ReflectionException |
|
637 | + */ |
|
638 | + protected function _transactions_overview_list_table() |
|
639 | + { |
|
640 | + $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
|
641 | + |
|
642 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
643 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
644 | + $this->_template_args['admin_page_header'] = $event instanceof EE_Event |
|
645 | + ? sprintf( |
|
646 | + esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), |
|
647 | + '<h3>', |
|
648 | + '<a href="' |
|
649 | + . EE_Admin_Page::add_query_args_and_nonce( |
|
650 | + ['action' => 'edit', 'post' => $event->ID()], |
|
651 | + EVENTS_ADMIN_URL |
|
652 | + ) |
|
653 | + . '" title="' |
|
654 | + . esc_attr__('Click to Edit event', 'event_espresso') |
|
655 | + . '">' . $event->name() . '</a>', |
|
656 | + '</h3>' |
|
657 | + ) |
|
658 | + : ''; |
|
659 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
660 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
661 | + } |
|
662 | + |
|
663 | + |
|
664 | + /** |
|
665 | + * _transaction_details |
|
666 | + * generates HTML for the View Transaction Details Admin page |
|
667 | + * |
|
668 | + * @access protected |
|
669 | + * @return void |
|
670 | + * @throws DomainException |
|
671 | + * @throws EE_Error |
|
672 | + * @throws InvalidArgumentException |
|
673 | + * @throws InvalidDataTypeException |
|
674 | + * @throws InvalidInterfaceException |
|
675 | + * @throws RuntimeException |
|
676 | + * @throws ReflectionException |
|
677 | + */ |
|
678 | + protected function _transaction_details() |
|
679 | + { |
|
680 | + do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
681 | + |
|
682 | + $this->_set_transaction_status_array(); |
|
683 | + |
|
684 | + $this->_template_args = []; |
|
685 | + $this->_template_args['transactions_page'] = $this->_wp_page_slug; |
|
686 | + |
|
687 | + $this->_set_transaction_object(); |
|
688 | + |
|
689 | + if (! $this->_transaction instanceof EE_Transaction) { |
|
690 | + return; |
|
691 | + } |
|
692 | + |
|
693 | + $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
|
694 | + $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
695 | + |
|
696 | + $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
|
697 | + $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
698 | + |
|
699 | + $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ]; |
|
700 | + $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
701 | + $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID(); |
|
702 | + |
|
703 | + $this->_template_args['grand_total'] = $this->_transaction->total(); |
|
704 | + $this->_template_args['total_paid'] = $this->_transaction->paid(); |
|
705 | + |
|
706 | + $amount_due = $this->_transaction->total() - $this->_transaction->paid(); |
|
707 | + $this->_template_args['amount_due'] = EEH_Template::format_currency( |
|
708 | + $amount_due, |
|
709 | + true |
|
710 | + ); |
|
711 | + if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
712 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign |
|
713 | + . $this->_template_args['amount_due']; |
|
714 | + } else { |
|
715 | + $this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign; |
|
716 | + } |
|
717 | + $this->_template_args['amount_due_class'] = ''; |
|
718 | + |
|
719 | + if ($this->_transaction->paid() === $this->_transaction->total()) { |
|
720 | + // paid in full |
|
721 | + $this->_template_args['amount_due'] = false; |
|
722 | + } elseif ($this->_transaction->paid() > $this->_transaction->total()) { |
|
723 | + // overpaid |
|
724 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
725 | + } elseif ($this->_transaction->total() > (float) 0) { |
|
726 | + if ($this->_transaction->paid() > (float) 0) { |
|
727 | + // monies owing |
|
728 | + $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
729 | + } elseif ($this->_transaction->paid() === (float) 0) { |
|
730 | + // no payments made yet |
|
731 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
732 | + } |
|
733 | + } elseif ($this->_transaction->total() === (float) 0) { |
|
734 | + // free event |
|
735 | + $this->_template_args['amount_due'] = false; |
|
736 | + } |
|
737 | + |
|
738 | + $payment_method = $this->_transaction->payment_method(); |
|
739 | + |
|
740 | + $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
|
741 | + ? $payment_method->admin_name() |
|
742 | + : esc_html__('Unknown', 'event_espresso'); |
|
743 | + |
|
744 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
745 | + // link back to overview |
|
746 | + $this->_template_args['txn_overview_url'] = $this->request->getServerParam( |
|
747 | + 'HTTP_REFERER', |
|
748 | + TXN_ADMIN_URL |
|
749 | + ); |
|
750 | + |
|
751 | + |
|
752 | + // next link |
|
753 | + $next_txn = $this->_transaction->next( |
|
754 | + null, |
|
755 | + [['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]], |
|
756 | + 'TXN_ID' |
|
757 | + ); |
|
758 | + $this->_template_args['next_transaction'] = $next_txn |
|
759 | + ? $this->_next_link( |
|
760 | + EE_Admin_Page::add_query_args_and_nonce( |
|
761 | + ['action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']], |
|
762 | + TXN_ADMIN_URL |
|
763 | + ), |
|
764 | + 'dashicons dashicons-arrow-right ee-icon-size-22' |
|
765 | + ) |
|
766 | + : ''; |
|
767 | + // previous link |
|
768 | + $previous_txn = $this->_transaction->previous( |
|
769 | + null, |
|
770 | + [['STS_ID' => ['!=', EEM_Transaction::failed_status_code]]], |
|
771 | + 'TXN_ID' |
|
772 | + ); |
|
773 | + $this->_template_args['previous_transaction'] = $previous_txn |
|
774 | + ? $this->_previous_link( |
|
775 | + EE_Admin_Page::add_query_args_and_nonce( |
|
776 | + ['action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']], |
|
777 | + TXN_ADMIN_URL |
|
778 | + ), |
|
779 | + 'dashicons dashicons-arrow-left ee-icon-size-22' |
|
780 | + ) |
|
781 | + : ''; |
|
782 | + |
|
783 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
784 | + $event_name = $this->request->getRequestParam('event_name'); |
|
785 | + $redirect_from = $this->request->getRequestParam('redirect_from', '', 'url'); |
|
786 | + |
|
787 | + // were we just redirected here after adding a new registration ??? |
|
788 | + if ($EVT_ID && $event_name && $redirect_from) { |
|
789 | + if ( |
|
790 | + EE_Registry::instance()->CAP->current_user_can( |
|
791 | + 'ee_edit_registrations', |
|
792 | + 'espresso_registrations_new_registration', |
|
793 | + $EVT_ID |
|
794 | + ) |
|
795 | + ) { |
|
796 | + $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
|
797 | + $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce( |
|
798 | + [ |
|
799 | + 'page' => 'espresso_registrations', |
|
800 | + 'action' => 'new_registration', |
|
801 | + 'return' => 'default', |
|
802 | + 'TXN_ID' => $this->_transaction->ID(), |
|
803 | + 'event_id' => $EVT_ID, |
|
804 | + ], |
|
805 | + REG_ADMIN_URL |
|
806 | + ); |
|
807 | + $this->_admin_page_title .= '">'; |
|
808 | + |
|
809 | + $this->_admin_page_title .= sprintf( |
|
810 | + esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
811 | + htmlentities(urldecode($event_name), ENT_QUOTES, 'UTF-8') |
|
812 | + ); |
|
813 | + $this->_admin_page_title .= '</a>'; |
|
814 | + } |
|
815 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
816 | + } |
|
817 | + // grab messages at the last second |
|
818 | + $this->_template_args['notices'] = EE_Error::get_notices(); |
|
819 | + // path to template |
|
820 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
821 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template( |
|
822 | + $template_path, |
|
823 | + $this->_template_args, |
|
824 | + true |
|
825 | + ); |
|
826 | + |
|
827 | + // the details template wrapper |
|
828 | + $this->display_admin_page_with_sidebar(); |
|
829 | + } |
|
830 | + |
|
831 | + |
|
832 | + /** |
|
833 | + * _transaction_details_metaboxes |
|
834 | + * |
|
835 | + * @access protected |
|
836 | + * @return void |
|
837 | + * @throws EE_Error |
|
838 | + * @throws InvalidArgumentException |
|
839 | + * @throws InvalidDataTypeException |
|
840 | + * @throws InvalidInterfaceException |
|
841 | + * @throws RuntimeException |
|
842 | + * @throws ReflectionException |
|
843 | + */ |
|
844 | + protected function _transaction_details_metaboxes() |
|
845 | + { |
|
846 | + |
|
847 | + $this->_set_transaction_object(); |
|
848 | + |
|
849 | + if (! $this->_transaction instanceof EE_Transaction) { |
|
850 | + return; |
|
851 | + } |
|
852 | + add_meta_box( |
|
853 | + 'edit-txn-details-mbox', |
|
854 | + esc_html__('Transaction Details', 'event_espresso'), |
|
855 | + [$this, 'txn_details_meta_box'], |
|
856 | + $this->_wp_page_slug, |
|
857 | + 'normal', |
|
858 | + 'high' |
|
859 | + ); |
|
860 | + add_meta_box( |
|
861 | + 'edit-txn-attendees-mbox', |
|
862 | + esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
863 | + [$this, 'txn_attendees_meta_box'], |
|
864 | + $this->_wp_page_slug, |
|
865 | + 'normal', |
|
866 | + 'high', |
|
867 | + ['TXN_ID' => $this->_transaction->ID()] |
|
868 | + ); |
|
869 | + add_meta_box( |
|
870 | + 'edit-txn-registrant-mbox', |
|
871 | + esc_html__('Primary Contact', 'event_espresso'), |
|
872 | + [$this, 'txn_registrant_side_meta_box'], |
|
873 | + $this->_wp_page_slug, |
|
874 | + 'side', |
|
875 | + 'high' |
|
876 | + ); |
|
877 | + add_meta_box( |
|
878 | + 'edit-txn-billing-info-mbox', |
|
879 | + esc_html__('Billing Information', 'event_espresso'), |
|
880 | + [$this, 'txn_billing_info_side_meta_box'], |
|
881 | + $this->_wp_page_slug, |
|
882 | + 'side', |
|
883 | + 'high' |
|
884 | + ); |
|
885 | + } |
|
886 | + |
|
887 | + |
|
888 | + /** |
|
889 | + * Callback for transaction actions metabox. |
|
890 | + * |
|
891 | + * @param EE_Transaction|null $transaction |
|
892 | + * @return string |
|
893 | + * @throws DomainException |
|
894 | + * @throws EE_Error |
|
895 | + * @throws InvalidArgumentException |
|
896 | + * @throws InvalidDataTypeException |
|
897 | + * @throws InvalidInterfaceException |
|
898 | + * @throws ReflectionException |
|
899 | + * @throws RuntimeException |
|
900 | + */ |
|
901 | + public function getActionButtons(EE_Transaction $transaction = null) |
|
902 | + { |
|
903 | + $content = ''; |
|
904 | + $actions = []; |
|
905 | + if (! $transaction instanceof EE_Transaction) { |
|
906 | + return $content; |
|
907 | + } |
|
908 | + /** @var EE_Registration $primary_registration */ |
|
909 | + $primary_registration = $transaction->primary_registration(); |
|
910 | + $attendee = $primary_registration instanceof EE_Registration |
|
911 | + ? $primary_registration->attendee() |
|
912 | + : null; |
|
913 | + |
|
914 | + if ( |
|
915 | + $attendee instanceof EE_Attendee |
|
916 | + && EE_Registry::instance()->CAP->current_user_can( |
|
917 | + 'ee_send_message', |
|
918 | + 'espresso_transactions_send_payment_reminder' |
|
919 | + ) |
|
920 | + ) { |
|
921 | + $actions['payment_reminder'] = |
|
922 | + EEH_MSG_Template::is_mt_active('payment_reminder') |
|
923 | + && $this->_transaction->status_ID() !== EEM_Transaction::complete_status_code |
|
924 | + && $this->_transaction->status_ID() !== EEM_Transaction::overpaid_status_code |
|
925 | + ? EEH_Template::get_button_or_link( |
|
926 | + EE_Admin_Page::add_query_args_and_nonce( |
|
927 | + [ |
|
928 | + 'action' => 'send_payment_reminder', |
|
929 | + 'TXN_ID' => $this->_transaction->ID(), |
|
930 | + 'redirect_to' => 'view_transaction', |
|
931 | + ], |
|
932 | + TXN_ADMIN_URL |
|
933 | + ), |
|
934 | + esc_html__(' Send Payment Reminder', 'event_espresso'), |
|
935 | + 'button secondary-button', |
|
936 | + 'dashicons dashicons-email-alt' |
|
937 | + ) |
|
938 | + : ''; |
|
939 | + } |
|
940 | + |
|
941 | + if ( |
|
942 | + EE_Registry::instance()->CAP->current_user_can( |
|
943 | + 'ee_edit_payments', |
|
944 | + 'espresso_transactions_recalculate_line_items' |
|
945 | + ) |
|
946 | + ) { |
|
947 | + $actions['recalculate_line_items'] = EEH_Template::get_button_or_link( |
|
948 | + EE_Admin_Page::add_query_args_and_nonce( |
|
949 | + [ |
|
950 | + 'action' => 'espresso_recalculate_line_items', |
|
951 | + 'TXN_ID' => $this->_transaction->ID(), |
|
952 | + 'redirect_to' => 'view_transaction', |
|
953 | + ], |
|
954 | + TXN_ADMIN_URL |
|
955 | + ), |
|
956 | + esc_html__(' Recalculate Taxes and Total', 'event_espresso'), |
|
957 | + 'button secondary-button', |
|
958 | + 'dashicons dashicons-update' |
|
959 | + ); |
|
960 | + } |
|
961 | + |
|
962 | + if ( |
|
963 | + $primary_registration instanceof EE_Registration |
|
964 | + && EEH_MSG_Template::is_mt_active('receipt') |
|
965 | + ) { |
|
966 | + $actions['receipt'] = EEH_Template::get_button_or_link( |
|
967 | + $primary_registration->receipt_url(), |
|
968 | + esc_html__('View Receipt', 'event_espresso'), |
|
969 | + 'button secondary-button', |
|
970 | + 'dashicons dashicons-media-default' |
|
971 | + ); |
|
972 | + } |
|
973 | + |
|
974 | + if ( |
|
975 | + $primary_registration instanceof EE_Registration |
|
976 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
977 | + ) { |
|
978 | + $actions['invoice'] = EEH_Template::get_button_or_link( |
|
979 | + $primary_registration->invoice_url(), |
|
980 | + esc_html__('View Invoice', 'event_espresso'), |
|
981 | + 'button secondary-button', |
|
982 | + 'dashicons dashicons-media-spreadsheet' |
|
983 | + ); |
|
984 | + } |
|
985 | + $actions = array_filter( |
|
986 | + apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction) |
|
987 | + ); |
|
988 | + if ($actions) { |
|
989 | + $content = '<ul>'; |
|
990 | + $content .= '<li>' . implode('</li><li>', $actions) . '</li>'; |
|
991 | + $content .= '</uL>'; |
|
992 | + } |
|
993 | + return $content; |
|
994 | + } |
|
995 | + |
|
996 | + |
|
997 | + /** |
|
998 | + * txn_details_meta_box |
|
999 | + * generates HTML for the Transaction main meta box |
|
1000 | + * |
|
1001 | + * @return void |
|
1002 | + * @throws DomainException |
|
1003 | + * @throws EE_Error |
|
1004 | + * @throws InvalidArgumentException |
|
1005 | + * @throws InvalidDataTypeException |
|
1006 | + * @throws InvalidInterfaceException |
|
1007 | + * @throws RuntimeException |
|
1008 | + * @throws ReflectionException |
|
1009 | + */ |
|
1010 | + public function txn_details_meta_box() |
|
1011 | + { |
|
1012 | + $this->_set_transaction_object(); |
|
1013 | + $this->_template_args['TXN_ID'] = $this->_transaction->ID(); |
|
1014 | + $this->_template_args['attendee'] = |
|
1015 | + $this->_transaction->primary_registration() instanceof EE_Registration |
|
1016 | + ? $this->_transaction->primary_registration()->attendee() |
|
1017 | + : null; |
|
1018 | + $this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can( |
|
1019 | + 'ee_edit_payments', |
|
1020 | + 'apply_payment_or_refund_from_registration_details' |
|
1021 | + ); |
|
1022 | + $this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can( |
|
1023 | + 'ee_delete_payments', |
|
1024 | + 'delete_payment_from_registration_details' |
|
1025 | + ); |
|
1026 | + |
|
1027 | + // get line table |
|
1028 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
1029 | + $Line_Item_Display = new EE_Line_Item_Display( |
|
1030 | + 'admin_table', |
|
1031 | + 'EE_Admin_Table_Line_Item_Display_Strategy' |
|
1032 | + ); |
|
1033 | + $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( |
|
1034 | + $this->_transaction->total_line_item() |
|
1035 | + ); |
|
1036 | + $this->_template_args['REG_code'] = |
|
1037 | + $this->_transaction->primary_registration() instanceof EE_Registration |
|
1038 | + ? $this->_transaction->primary_registration()->reg_code() |
|
1039 | + : null; |
|
1040 | + // process taxes |
|
1041 | + $taxes = $this->_transaction->line_items([['LIN_type' => EEM_Line_Item::type_tax]]); |
|
1042 | + $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false; |
|
1043 | + |
|
1044 | + $this->_template_args['grand_total'] = EEH_Template::format_currency( |
|
1045 | + $this->_transaction->total(), |
|
1046 | + false, |
|
1047 | + false |
|
1048 | + ); |
|
1049 | + $this->_template_args['grand_raw_total'] = $this->_transaction->total(); |
|
1050 | + $this->_template_args['TXN_status'] = $this->_transaction->status_ID(); |
|
1051 | + |
|
1052 | + // process payment details |
|
1053 | + $payments = $this->_transaction->payments(); |
|
1054 | + if (! empty($payments)) { |
|
1055 | + $this->_template_args['payments'] = $payments; |
|
1056 | + $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
1057 | + } else { |
|
1058 | + $this->_template_args['payments'] = false; |
|
1059 | + $this->_template_args['existing_reg_payments'] = []; |
|
1060 | + } |
|
1061 | + |
|
1062 | + $this->_template_args['edit_payment_url'] = add_query_arg(['action' => 'edit_payment'], TXN_ADMIN_URL); |
|
1063 | + $this->_template_args['delete_payment_url'] = add_query_arg( |
|
1064 | + ['action' => 'espresso_delete_payment'], |
|
1065 | + TXN_ADMIN_URL |
|
1066 | + ); |
|
1067 | + |
|
1068 | + if (isset($txn_details['invoice_number'])) { |
|
1069 | + $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
|
1070 | + $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__( |
|
1071 | + 'Invoice Number', |
|
1072 | + 'event_espresso' |
|
1073 | + ); |
|
1074 | + } |
|
1075 | + |
|
1076 | + $this->_template_args['txn_details']['registration_session']['value'] = |
|
1077 | + $this->_transaction->primary_registration() instanceof EE_Registration |
|
1078 | + ? $this->_transaction->primary_registration()->session_ID() |
|
1079 | + : null; |
|
1080 | + $this->_template_args['txn_details']['registration_session']['label'] = esc_html__( |
|
1081 | + 'Registration Session', |
|
1082 | + 'event_espresso' |
|
1083 | + ); |
|
1084 | + |
|
1085 | + $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) |
|
1086 | + ? $this->_session['ip_address'] |
|
1087 | + : ''; |
|
1088 | + $this->_template_args['txn_details']['ip_address']['label'] = esc_html__( |
|
1089 | + 'Transaction placed from IP', |
|
1090 | + 'event_espresso' |
|
1091 | + ); |
|
1092 | + |
|
1093 | + $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) |
|
1094 | + ? $this->_session['user_agent'] |
|
1095 | + : ''; |
|
1096 | + $this->_template_args['txn_details']['user_agent']['label'] = esc_html__( |
|
1097 | + 'Registrant User Agent', |
|
1098 | + 'event_espresso' |
|
1099 | + ); |
|
1100 | + |
|
1101 | + $reg_steps = '<ul>'; |
|
1102 | + foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
1103 | + if ($reg_step_status === true) { |
|
1104 | + $reg_steps .= '<li style="color:#70cc50">' |
|
1105 | + . sprintf( |
|
1106 | + esc_html__('%1$s : Completed', 'event_espresso'), |
|
1107 | + ucwords(str_replace('_', ' ', $reg_step)) |
|
1108 | + ) |
|
1109 | + . '</li>'; |
|
1110 | + } elseif ($reg_step_status !== false && is_numeric($reg_step_status)) { |
|
1111 | + $reg_steps .= '<li style="color:#2EA2CC">' |
|
1112 | + . sprintf( |
|
1113 | + esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
1114 | + ucwords(str_replace('_', ' ', $reg_step)), |
|
1115 | + date( |
|
1116 | + get_option('date_format') . ' ' . get_option('time_format'), |
|
1117 | + $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1118 | + ) |
|
1119 | + ) |
|
1120 | + . '</li>'; |
|
1121 | + } else { |
|
1122 | + $reg_steps .= '<li style="color:#E76700">' |
|
1123 | + . sprintf( |
|
1124 | + esc_html__('%1$s : Never Initiated', 'event_espresso'), |
|
1125 | + ucwords(str_replace('_', ' ', $reg_step)) |
|
1126 | + ) |
|
1127 | + . '</li>'; |
|
1128 | + } |
|
1129 | + } |
|
1130 | + $reg_steps .= '</ul>'; |
|
1131 | + $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
|
1132 | + $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__( |
|
1133 | + 'Registration Step Progress', |
|
1134 | + 'event_espresso' |
|
1135 | + ); |
|
1136 | + |
|
1137 | + |
|
1138 | + $this->_get_registrations_to_apply_payment_to(); |
|
1139 | + $this->_get_payment_methods($payments); |
|
1140 | + $this->_get_payment_status_array(); |
|
1141 | + $this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction. |
|
1142 | + |
|
1143 | + $this->_template_args['transaction_form_url'] = add_query_arg( |
|
1144 | + [ |
|
1145 | + 'action' => 'edit_transaction', |
|
1146 | + 'process' => 'transaction', |
|
1147 | + ], |
|
1148 | + TXN_ADMIN_URL |
|
1149 | + ); |
|
1150 | + $this->_template_args['apply_payment_form_url'] = add_query_arg( |
|
1151 | + [ |
|
1152 | + 'page' => 'espresso_transactions', |
|
1153 | + 'action' => 'espresso_apply_payment', |
|
1154 | + ], |
|
1155 | + WP_AJAX_URL |
|
1156 | + ); |
|
1157 | + $this->_template_args['delete_payment_form_url'] = add_query_arg( |
|
1158 | + [ |
|
1159 | + 'page' => 'espresso_transactions', |
|
1160 | + 'action' => 'espresso_delete_payment', |
|
1161 | + ], |
|
1162 | + WP_AJAX_URL |
|
1163 | + ); |
|
1164 | + |
|
1165 | + $this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction); |
|
1166 | + |
|
1167 | + // 'espresso_delete_payment_nonce' |
|
1168 | + |
|
1169 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
1170 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1171 | + } |
|
1172 | + |
|
1173 | + |
|
1174 | + /** |
|
1175 | + * _get_registration_payment_IDs |
|
1176 | + * generates an array of Payment IDs and their corresponding Registration IDs |
|
1177 | + * |
|
1178 | + * @access protected |
|
1179 | + * @param EE_Payment[] $payments |
|
1180 | + * @return array |
|
1181 | + * @throws EE_Error |
|
1182 | + * @throws InvalidArgumentException |
|
1183 | + * @throws InvalidDataTypeException |
|
1184 | + * @throws InvalidInterfaceException |
|
1185 | + * @throws ReflectionException |
|
1186 | + */ |
|
1187 | + protected function _get_registration_payment_IDs($payments = []) |
|
1188 | + { |
|
1189 | + $existing_reg_payments = []; |
|
1190 | + // get all reg payments for these payments |
|
1191 | + $reg_payments = EEM_Registration_Payment::instance()->get_all( |
|
1192 | + [ |
|
1193 | + [ |
|
1194 | + 'PAY_ID' => [ |
|
1195 | + 'IN', |
|
1196 | + array_keys($payments), |
|
1197 | + ], |
|
1198 | + ], |
|
1199 | + ] |
|
1200 | + ); |
|
1201 | + if (! empty($reg_payments)) { |
|
1202 | + foreach ($payments as $payment) { |
|
1203 | + if (! $payment instanceof EE_Payment) { |
|
1204 | + continue; |
|
1205 | + } elseif (! isset($existing_reg_payments[ $payment->ID() ])) { |
|
1206 | + $existing_reg_payments[ $payment->ID() ] = []; |
|
1207 | + } |
|
1208 | + foreach ($reg_payments as $reg_payment) { |
|
1209 | + if ( |
|
1210 | + $reg_payment instanceof EE_Registration_Payment |
|
1211 | + && $reg_payment->payment_ID() === $payment->ID() |
|
1212 | + ) { |
|
1213 | + $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID(); |
|
1214 | + } |
|
1215 | + } |
|
1216 | + } |
|
1217 | + } |
|
1218 | + |
|
1219 | + return $existing_reg_payments; |
|
1220 | + } |
|
1221 | + |
|
1222 | + |
|
1223 | + /** |
|
1224 | + * _get_registrations_to_apply_payment_to |
|
1225 | + * generates HTML for displaying a series of checkboxes in the admin payment modal window |
|
1226 | + * which allows the admin to only apply the payment to the specific registrations |
|
1227 | + * |
|
1228 | + * @access protected |
|
1229 | + * @return void |
|
1230 | + * @throws EE_Error |
|
1231 | + * @throws InvalidArgumentException |
|
1232 | + * @throws InvalidDataTypeException |
|
1233 | + * @throws InvalidInterfaceException |
|
1234 | + * @throws ReflectionException |
|
1235 | + */ |
|
1236 | + protected function _get_registrations_to_apply_payment_to() |
|
1237 | + { |
|
1238 | + // we want any registration with an active status (ie: not deleted or cancelled) |
|
1239 | + $query_params = [ |
|
1240 | + [ |
|
1241 | + 'STS_ID' => [ |
|
1242 | + 'IN', |
|
1243 | + [ |
|
1244 | + EEM_Registration::status_id_approved, |
|
1245 | + EEM_Registration::status_id_pending_payment, |
|
1246 | + EEM_Registration::status_id_not_approved, |
|
1247 | + ], |
|
1248 | + ], |
|
1249 | + ], |
|
1250 | + ]; |
|
1251 | + $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
1252 | + '', |
|
1253 | + 'txn-admin-apply-payment-to-registrations-dv', |
|
1254 | + '', |
|
1255 | + 'clear: both; margin: 1.5em 0 0; display: none;' |
|
1256 | + ); |
|
1257 | + $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
1258 | + $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
1259 | + $registrations_to_apply_payment_to .= EEH_HTML::thead( |
|
1260 | + EEH_HTML::tr( |
|
1261 | + EEH_HTML::th(esc_html__('ID', 'event_espresso')) . |
|
1262 | + EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) . |
|
1263 | + EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) . |
|
1264 | + EEH_HTML::th(esc_html__('Event', 'event_espresso')) . |
|
1265 | + EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
1266 | + EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') . |
|
1267 | + EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
1268 | + ) |
|
1269 | + ); |
|
1270 | + $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
|
1271 | + // get registrations for TXN |
|
1272 | + $registrations = $this->_transaction->registrations($query_params); |
|
1273 | + $existing_reg_payments = $this->_template_args['existing_reg_payments']; |
|
1274 | + foreach ($registrations as $registration) { |
|
1275 | + if ($registration instanceof EE_Registration) { |
|
1276 | + $attendee_name = $registration->attendee() instanceof EE_Attendee |
|
1277 | + ? $registration->attendee()->full_name() |
|
1278 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
1279 | + $owing = $registration->final_price() - $registration->paid(); |
|
1280 | + $taxable = $registration->ticket()->taxable() |
|
1281 | + ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>' |
|
1282 | + : ''; |
|
1283 | + $checked = empty($existing_reg_payments) |
|
1284 | + || in_array($registration->ID(), $existing_reg_payments, true) |
|
1285 | + ? ' checked="checked"' |
|
1286 | + : ''; |
|
1287 | + $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
|
1288 | + $registrations_to_apply_payment_to .= EEH_HTML::tr( |
|
1289 | + EEH_HTML::td($registration->ID()) . |
|
1290 | + EEH_HTML::td($attendee_name) . |
|
1291 | + EEH_HTML::td( |
|
1292 | + $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
1293 | + ) . |
|
1294 | + EEH_HTML::td($registration->event_name()) . |
|
1295 | + EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') . |
|
1296 | + EEH_HTML::td( |
|
1297 | + EEH_Template::format_currency($owing), |
|
1298 | + '', |
|
1299 | + 'txn-admin-payment-owing-td jst-cntr' |
|
1300 | + ) . |
|
1301 | + EEH_HTML::td( |
|
1302 | + '<input type="checkbox" value="' . $registration->ID() |
|
1303 | + . '" name="txn_admin_payment[registrations]"' |
|
1304 | + . $checked . $disabled . '>', |
|
1305 | + '', |
|
1306 | + 'jst-cntr' |
|
1307 | + ), |
|
1308 | + 'apply-payment-registration-row-' . $registration->ID() |
|
1309 | + ); |
|
1310 | + } |
|
1311 | + } |
|
1312 | + $registrations_to_apply_payment_to .= EEH_HTML::tbodyx(); |
|
1313 | + $registrations_to_apply_payment_to .= EEH_HTML::tablex(); |
|
1314 | + $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
1315 | + $registrations_to_apply_payment_to .= EEH_HTML::p( |
|
1316 | + esc_html__( |
|
1317 | + 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', |
|
1318 | + 'event_espresso' |
|
1319 | + ), |
|
1320 | + '', |
|
1321 | + 'clear description' |
|
1322 | + ); |
|
1323 | + $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
|
1324 | + $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
1325 | + } |
|
1326 | + |
|
1327 | + |
|
1328 | + /** |
|
1329 | + * _get_reg_status_selection |
|
1330 | + * |
|
1331 | + * @return void |
|
1332 | + * @throws EE_Error |
|
1333 | + * @todo this will need to be adjusted either once MER comes along OR we move default reg status to tickets |
|
1334 | + * instead of events. |
|
1335 | + * @access protected |
|
1336 | + */ |
|
1337 | + protected function _get_reg_status_selection() |
|
1338 | + { |
|
1339 | + // first get all possible statuses |
|
1340 | + $statuses = EEM_Registration::reg_status_array([], true); |
|
1341 | + // let's add a "don't change" option. |
|
1342 | + $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
|
1343 | + $status_array = array_merge($status_array, $statuses); |
|
1344 | + $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( |
|
1345 | + 'txn_reg_status_change[reg_status]', |
|
1346 | + $status_array, |
|
1347 | + 'NAN', |
|
1348 | + 'id="txn-admin-payment-reg-status-inp"', |
|
1349 | + 'txn-reg-status-change-reg-status' |
|
1350 | + ); |
|
1351 | + $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( |
|
1352 | + 'delete_txn_reg_status_change[reg_status]', |
|
1353 | + $status_array, |
|
1354 | + 'NAN', |
|
1355 | + 'delete-txn-admin-payment-reg-status-inp', |
|
1356 | + 'delete-txn-reg-status-change-reg-status' |
|
1357 | + ); |
|
1358 | + } |
|
1359 | + |
|
1360 | + |
|
1361 | + /** |
|
1362 | + * _get_payment_methods |
|
1363 | + * Gets all the payment methods available generally, or the ones that are already |
|
1364 | + * selected on these payments (in case their payment methods are no longer active). |
|
1365 | + * Has the side-effect of updating the template args' payment_methods item |
|
1366 | + * |
|
1367 | + * @access private |
|
1368 | + * @param EE_Payment[] to show on this page |
|
1369 | + * @return void |
|
1370 | + * @throws EE_Error |
|
1371 | + * @throws InvalidArgumentException |
|
1372 | + * @throws InvalidDataTypeException |
|
1373 | + * @throws InvalidInterfaceException |
|
1374 | + * @throws ReflectionException |
|
1375 | + */ |
|
1376 | + private function _get_payment_methods($payments = []) |
|
1377 | + { |
|
1378 | + $payment_methods_of_payments = []; |
|
1379 | + foreach ($payments as $payment) { |
|
1380 | + if ($payment instanceof EE_Payment) { |
|
1381 | + $payment_methods_of_payments[] = $payment->ID(); |
|
1382 | + } |
|
1383 | + } |
|
1384 | + if ($payment_methods_of_payments) { |
|
1385 | + $query_args = [ |
|
1386 | + [ |
|
1387 | + 'OR*payment_method_for_payment' => [ |
|
1388 | + 'PMD_ID' => ['IN', $payment_methods_of_payments], |
|
1389 | + 'PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%'], |
|
1390 | + ], |
|
1391 | + ], |
|
1392 | + ]; |
|
1393 | + } else { |
|
1394 | + $query_args = [['PMD_scope' => ['LIKE', '%' . EEM_Payment_Method::scope_admin . '%']]]; |
|
1395 | + } |
|
1396 | + $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
1397 | + } |
|
1398 | + |
|
1399 | + |
|
1400 | + /** |
|
1401 | + * txn_attendees_meta_box |
|
1402 | + * generates HTML for the Attendees Transaction main meta box |
|
1403 | + * |
|
1404 | + * @access public |
|
1405 | + * @param WP_Post $post |
|
1406 | + * @param array $metabox |
|
1407 | + * @return void |
|
1408 | + * @throws DomainException |
|
1409 | + * @throws EE_Error |
|
1410 | + * @throws InvalidArgumentException |
|
1411 | + * @throws InvalidDataTypeException |
|
1412 | + * @throws InvalidInterfaceException |
|
1413 | + * @throws ReflectionException |
|
1414 | + */ |
|
1415 | + public function txn_attendees_meta_box($post, $metabox = ['args' => []]) |
|
1416 | + { |
|
1417 | + |
|
1418 | + /** @noinspection NonSecureExtractUsageInspection */ |
|
1419 | + extract($metabox['args']); |
|
1420 | + $this->_template_args['post'] = $post; |
|
1421 | + $this->_template_args['event_attendees'] = []; |
|
1422 | + // process items in cart |
|
1423 | + $line_items = $this->_transaction->get_many_related( |
|
1424 | + 'Line_Item', |
|
1425 | + [['LIN_type' => 'line-item']] |
|
1426 | + ); |
|
1427 | + if (! empty($line_items)) { |
|
1428 | + foreach ($line_items as $item) { |
|
1429 | + if ($item instanceof EE_Line_Item) { |
|
1430 | + switch ($item->OBJ_type()) { |
|
1431 | + case 'Event': |
|
1432 | + break; |
|
1433 | + case 'Ticket': |
|
1434 | + $ticket = $item->ticket(); |
|
1435 | + // right now we're only handling tickets here. |
|
1436 | + // Cause its expected that only tickets will have attendees right? |
|
1437 | + if (! $ticket instanceof EE_Ticket) { |
|
1438 | + break; |
|
1439 | + } |
|
1440 | + try { |
|
1441 | + $event_name = $ticket->get_event_name(); |
|
1442 | + } catch (Exception $e) { |
|
1443 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1444 | + $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
1445 | + } |
|
1446 | + $event_name .= ' - ' . $item->name(); |
|
1447 | + $ticket_price = EEH_Template::format_currency($item->unit_price()); |
|
1448 | + // now get all of the registrations for this transaction that use this ticket |
|
1449 | + $registrations = $ticket->registrations( |
|
1450 | + [['TXN_ID' => $this->_transaction->ID()]] |
|
1451 | + ); |
|
1452 | + foreach ($registrations as $registration) { |
|
1453 | + if (! $registration instanceof EE_Registration) { |
|
1454 | + break; |
|
1455 | + } |
|
1456 | + $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID'] |
|
1457 | + = $registration->status_ID(); |
|
1458 | + $this->_template_args['event_attendees'][ $registration->ID() ]['att_num'] |
|
1459 | + = $registration->count(); |
|
1460 | + $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name'] |
|
1461 | + = $event_name; |
|
1462 | + $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price'] |
|
1463 | + = $ticket_price; |
|
1464 | + // attendee info |
|
1465 | + $attendee = $registration->get_first_related('Attendee'); |
|
1466 | + if ($attendee instanceof EE_Attendee) { |
|
1467 | + $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] |
|
1468 | + = $attendee->ID(); |
|
1469 | + $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] |
|
1470 | + = $attendee->full_name(); |
|
1471 | + $this->_template_args['event_attendees'][ $registration->ID() ]['email'] |
|
1472 | + = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name |
|
1473 | + . esc_html__( |
|
1474 | + ' Event', |
|
1475 | + 'event_espresso' |
|
1476 | + ) |
|
1477 | + . '">' . $attendee->email() . '</a>'; |
|
1478 | + $this->_template_args['event_attendees'][ $registration->ID() ]['address'] |
|
1479 | + = EEH_Address::format($attendee, 'inline', false, false); |
|
1480 | + } else { |
|
1481 | + $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = ''; |
|
1482 | + $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = ''; |
|
1483 | + $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = ''; |
|
1484 | + $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = ''; |
|
1485 | + } |
|
1486 | + } |
|
1487 | + break; |
|
1488 | + } |
|
1489 | + } |
|
1490 | + } |
|
1491 | + |
|
1492 | + $this->_template_args['transaction_form_url'] = add_query_arg( |
|
1493 | + [ |
|
1494 | + 'action' => 'edit_transaction', |
|
1495 | + 'process' => 'attendees', |
|
1496 | + ], |
|
1497 | + TXN_ADMIN_URL |
|
1498 | + ); |
|
1499 | + echo EEH_Template::display_template( |
|
1500 | + TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', |
|
1501 | + $this->_template_args, |
|
1502 | + true |
|
1503 | + ); |
|
1504 | + } else { |
|
1505 | + printf( |
|
1506 | + esc_html__( |
|
1507 | + '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', |
|
1508 | + 'event_espresso' |
|
1509 | + ), |
|
1510 | + '<p class="important-notice">', |
|
1511 | + '</p>' |
|
1512 | + ); |
|
1513 | + } |
|
1514 | + } |
|
1515 | + |
|
1516 | + |
|
1517 | + /** |
|
1518 | + * txn_registrant_side_meta_box |
|
1519 | + * generates HTML for the Edit Transaction side meta box |
|
1520 | + * |
|
1521 | + * @access public |
|
1522 | + * @return void |
|
1523 | + * @throws DomainException |
|
1524 | + * @throws EE_Error |
|
1525 | + * @throws InvalidArgumentException |
|
1526 | + * @throws InvalidDataTypeException |
|
1527 | + * @throws InvalidInterfaceException |
|
1528 | + * @throws ReflectionException |
|
1529 | + */ |
|
1530 | + public function txn_registrant_side_meta_box() |
|
1531 | + { |
|
1532 | + $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration |
|
1533 | + ? $this->_transaction->primary_registration()->get_first_related('Attendee') |
|
1534 | + : null; |
|
1535 | + if (! $primary_att instanceof EE_Attendee) { |
|
1536 | + $this->_template_args['no_attendee_message'] = esc_html__( |
|
1537 | + 'There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', |
|
1538 | + 'event_espresso' |
|
1539 | + ); |
|
1540 | + $primary_att = EEM_Attendee::instance()->create_default_object(); |
|
1541 | + } |
|
1542 | + $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1543 | + $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
|
1544 | + $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
|
1545 | + $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1546 | + $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
|
1547 | + $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
1548 | + [ |
|
1549 | + 'action' => 'edit_attendee', |
|
1550 | + 'post' => $primary_att->ID(), |
|
1551 | + ], |
|
1552 | + REG_ADMIN_URL |
|
1553 | + ); |
|
1554 | + // get formatted address for registrant |
|
1555 | + $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
1556 | + echo EEH_Template::display_template( |
|
1557 | + TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', |
|
1558 | + $this->_template_args, |
|
1559 | + true |
|
1560 | + ); |
|
1561 | + } |
|
1562 | + |
|
1563 | + |
|
1564 | + /** |
|
1565 | + * txn_billing_info_side_meta_box |
|
1566 | + * generates HTML for the Edit Transaction side meta box |
|
1567 | + * |
|
1568 | + * @access public |
|
1569 | + * @return void |
|
1570 | + * @throws DomainException |
|
1571 | + * @throws EE_Error |
|
1572 | + * @throws ReflectionException |
|
1573 | + */ |
|
1574 | + public function txn_billing_info_side_meta_box() |
|
1575 | + { |
|
1576 | + |
|
1577 | + $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
|
1578 | + $this->_template_args['billing_form_url'] = add_query_arg( |
|
1579 | + ['action' => 'edit_transaction', 'process' => 'billing'], |
|
1580 | + TXN_ADMIN_URL |
|
1581 | + ); |
|
1582 | + |
|
1583 | + $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1584 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1585 | + } |
|
1586 | + |
|
1587 | + |
|
1588 | + /** |
|
1589 | + * apply_payments_or_refunds |
|
1590 | + * registers a payment or refund made towards a transaction |
|
1591 | + * |
|
1592 | + * @access public |
|
1593 | + * @return void |
|
1594 | + * @throws EE_Error |
|
1595 | + * @throws InvalidArgumentException |
|
1596 | + * @throws ReflectionException |
|
1597 | + * @throws RuntimeException |
|
1598 | + * @throws InvalidDataTypeException |
|
1599 | + * @throws InvalidInterfaceException |
|
1600 | + */ |
|
1601 | + public function apply_payments_or_refunds() |
|
1602 | + { |
|
1603 | + $json_response_data = ['return_data' => false]; |
|
1604 | + $valid_data = $this->_validate_payment_request_data(); |
|
1605 | + $has_access = EE_Registry::instance()->CAP->current_user_can( |
|
1606 | + 'ee_edit_payments', |
|
1607 | + 'apply_payment_or_refund_from_registration_details' |
|
1608 | + ); |
|
1609 | + if (! empty($valid_data) && $has_access) { |
|
1610 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1611 | + // save the new payment |
|
1612 | + $payment = $this->_create_payment_from_request_data($valid_data); |
|
1613 | + // get the TXN for this payment |
|
1614 | + $transaction = $payment->transaction(); |
|
1615 | + // verify transaction |
|
1616 | + if ($transaction instanceof EE_Transaction) { |
|
1617 | + // calculate_total_payments_and_update_status |
|
1618 | + $this->_process_transaction_payments($transaction); |
|
1619 | + $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
1620 | + $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
1621 | + // apply payment to registrations (if applicable) |
|
1622 | + if (! empty($REG_IDs)) { |
|
1623 | + $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
1624 | + $this->_maybe_send_notifications(); |
|
1625 | + // now process status changes for the same registrations |
|
1626 | + $this->_process_registration_status_change($transaction, $REG_IDs); |
|
1627 | + } |
|
1628 | + $this->_maybe_send_notifications($payment); |
|
1629 | + // prepare to render page |
|
1630 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
1631 | + do_action( |
|
1632 | + 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', |
|
1633 | + $transaction, |
|
1634 | + $payment |
|
1635 | + ); |
|
1636 | + } else { |
|
1637 | + EE_Error::add_error( |
|
1638 | + esc_html__( |
|
1639 | + 'A valid Transaction for this payment could not be retrieved.', |
|
1640 | + 'event_espresso' |
|
1641 | + ), |
|
1642 | + __FILE__, |
|
1643 | + __FUNCTION__, |
|
1644 | + __LINE__ |
|
1645 | + ); |
|
1646 | + } |
|
1647 | + } elseif ($has_access) { |
|
1648 | + EE_Error::add_error( |
|
1649 | + esc_html__( |
|
1650 | + 'The payment form data could not be processed. Please try again.', |
|
1651 | + 'event_espresso' |
|
1652 | + ), |
|
1653 | + __FILE__, |
|
1654 | + __FUNCTION__, |
|
1655 | + __LINE__ |
|
1656 | + ); |
|
1657 | + } else { |
|
1658 | + EE_Error::add_error( |
|
1659 | + esc_html__( |
|
1660 | + 'You do not have access to apply payments or refunds to a registration.', |
|
1661 | + 'event_espresso' |
|
1662 | + ), |
|
1663 | + __FILE__, |
|
1664 | + __FUNCTION__, |
|
1665 | + __LINE__ |
|
1666 | + ); |
|
1667 | + } |
|
1668 | + $notices = EE_Error::get_notices( |
|
1669 | + false, |
|
1670 | + false, |
|
1671 | + false |
|
1672 | + ); |
|
1673 | + $this->_template_args = [ |
|
1674 | + 'data' => $json_response_data, |
|
1675 | + 'error' => $notices['errors'], |
|
1676 | + 'success' => $notices['success'], |
|
1677 | + ]; |
|
1678 | + $this->_return_json(); |
|
1679 | + } |
|
1680 | + |
|
1681 | + |
|
1682 | + /** |
|
1683 | + * _validate_payment_request_data |
|
1684 | + * |
|
1685 | + * @return array |
|
1686 | + * @throws EE_Error |
|
1687 | + * @throws InvalidArgumentException |
|
1688 | + * @throws InvalidDataTypeException |
|
1689 | + * @throws InvalidInterfaceException |
|
1690 | + */ |
|
1691 | + protected function _validate_payment_request_data() |
|
1692 | + { |
|
1693 | + if (! $this->request->requestParamIsSet('txn_admin_payment')) { |
|
1694 | + return []; |
|
1695 | + } |
|
1696 | + $payment_form = $this->_generate_payment_form_section(); |
|
1697 | + try { |
|
1698 | + if ($payment_form->was_submitted()) { |
|
1699 | + $payment_form->receive_form_submission(); |
|
1700 | + if (! $payment_form->is_valid()) { |
|
1701 | + $submission_error_messages = []; |
|
1702 | + foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
1703 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1704 | + $form_input = $validation_error->get_form_section(); |
|
1705 | + $submission_error_messages[] = sprintf( |
|
1706 | + _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
1707 | + $form_input instanceof EE_Form_Input_Base ? $form_input->html_label_text() : '', |
|
1708 | + $validation_error->getMessage() |
|
1709 | + ); |
|
1710 | + } |
|
1711 | + } |
|
1712 | + EE_Error::add_error( |
|
1713 | + implode('<br />', $submission_error_messages), |
|
1714 | + __FILE__, |
|
1715 | + __FUNCTION__, |
|
1716 | + __LINE__ |
|
1717 | + ); |
|
1718 | + return []; |
|
1719 | + } |
|
1720 | + } |
|
1721 | + } catch (EE_Error $e) { |
|
1722 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1723 | + return []; |
|
1724 | + } |
|
1725 | + |
|
1726 | + return $payment_form->valid_data(); |
|
1727 | + } |
|
1728 | + |
|
1729 | + |
|
1730 | + /** |
|
1731 | + * _generate_payment_form_section |
|
1732 | + * |
|
1733 | + * @return EE_Form_Section_Proper |
|
1734 | + * @throws EE_Error |
|
1735 | + */ |
|
1736 | + protected function _generate_payment_form_section() |
|
1737 | + { |
|
1738 | + return new EE_Form_Section_Proper( |
|
1739 | + [ |
|
1740 | + 'name' => 'txn_admin_payment', |
|
1741 | + 'subsections' => [ |
|
1742 | + 'PAY_ID' => new EE_Text_Input( |
|
1743 | + [ |
|
1744 | + 'default' => 0, |
|
1745 | + 'required' => false, |
|
1746 | + 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
1747 | + 'validation_strategies' => [new EE_Int_Normalization()], |
|
1748 | + ] |
|
1749 | + ), |
|
1750 | + 'TXN_ID' => new EE_Text_Input( |
|
1751 | + [ |
|
1752 | + 'default' => 0, |
|
1753 | + 'required' => true, |
|
1754 | + 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
1755 | + 'validation_strategies' => [new EE_Int_Normalization()], |
|
1756 | + ] |
|
1757 | + ), |
|
1758 | + 'type' => new EE_Text_Input( |
|
1759 | + [ |
|
1760 | + 'default' => 1, |
|
1761 | + 'required' => true, |
|
1762 | + 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
1763 | + 'validation_strategies' => [new EE_Int_Normalization()], |
|
1764 | + ] |
|
1765 | + ), |
|
1766 | + 'amount' => new EE_Text_Input( |
|
1767 | + [ |
|
1768 | + 'default' => 0, |
|
1769 | + 'required' => true, |
|
1770 | + 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
1771 | + 'validation_strategies' => [new EE_Float_Normalization()], |
|
1772 | + ] |
|
1773 | + ), |
|
1774 | + 'status' => new EE_Text_Input( |
|
1775 | + [ |
|
1776 | + 'default' => EEM_Payment::status_id_approved, |
|
1777 | + 'required' => true, |
|
1778 | + 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
1779 | + ] |
|
1780 | + ), |
|
1781 | + 'PMD_ID' => new EE_Text_Input( |
|
1782 | + [ |
|
1783 | + 'default' => 2, |
|
1784 | + 'required' => true, |
|
1785 | + 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
1786 | + 'validation_strategies' => [new EE_Int_Normalization()], |
|
1787 | + ] |
|
1788 | + ), |
|
1789 | + 'date' => new EE_Text_Input( |
|
1790 | + [ |
|
1791 | + 'default' => time(), |
|
1792 | + 'required' => true, |
|
1793 | + 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
1794 | + ] |
|
1795 | + ), |
|
1796 | + 'txn_id_chq_nmbr' => new EE_Text_Input( |
|
1797 | + [ |
|
1798 | + 'default' => '', |
|
1799 | + 'required' => false, |
|
1800 | + 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
1801 | + 'validation_strategies' => [ |
|
1802 | + new EE_Max_Length_Validation_Strategy( |
|
1803 | + esc_html__('Input too long', 'event_espresso'), |
|
1804 | + 100 |
|
1805 | + ), |
|
1806 | + ], |
|
1807 | + ] |
|
1808 | + ), |
|
1809 | + 'po_number' => new EE_Text_Input( |
|
1810 | + [ |
|
1811 | + 'default' => '', |
|
1812 | + 'required' => false, |
|
1813 | + 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
1814 | + 'validation_strategies' => [ |
|
1815 | + new EE_Max_Length_Validation_Strategy( |
|
1816 | + esc_html__('Input too long', 'event_espresso'), |
|
1817 | + 100 |
|
1818 | + ), |
|
1819 | + ], |
|
1820 | + ] |
|
1821 | + ), |
|
1822 | + 'accounting' => new EE_Text_Input( |
|
1823 | + [ |
|
1824 | + 'default' => '', |
|
1825 | + 'required' => false, |
|
1826 | + 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
1827 | + 'validation_strategies' => [ |
|
1828 | + new EE_Max_Length_Validation_Strategy( |
|
1829 | + esc_html__('Input too long', 'event_espresso'), |
|
1830 | + 100 |
|
1831 | + ), |
|
1832 | + ], |
|
1833 | + ] |
|
1834 | + ), |
|
1835 | + ], |
|
1836 | + ] |
|
1837 | + ); |
|
1838 | + } |
|
1839 | + |
|
1840 | + |
|
1841 | + /** |
|
1842 | + * _create_payment_from_request_data |
|
1843 | + * |
|
1844 | + * @param array $valid_data |
|
1845 | + * @return EE_Payment |
|
1846 | + * @throws EE_Error |
|
1847 | + * @throws InvalidArgumentException |
|
1848 | + * @throws InvalidDataTypeException |
|
1849 | + * @throws InvalidInterfaceException |
|
1850 | + * @throws ReflectionException |
|
1851 | + */ |
|
1852 | + protected function _create_payment_from_request_data($valid_data) |
|
1853 | + { |
|
1854 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1855 | + // get payment amount |
|
1856 | + $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
1857 | + // payments have a type value of 1 and refunds have a type value of -1 |
|
1858 | + // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
|
1859 | + $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
1860 | + // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
|
1861 | + $date = $valid_data['date'] |
|
1862 | + ? preg_replace('/\s+/', ' ', $valid_data['date']) |
|
1863 | + : date('Y-m-d g:i a', current_time('timestamp')); |
|
1864 | + $payment = EE_Payment::new_instance( |
|
1865 | + [ |
|
1866 | + 'TXN_ID' => $valid_data['TXN_ID'], |
|
1867 | + 'STS_ID' => $valid_data['status'], |
|
1868 | + 'PAY_timestamp' => $date, |
|
1869 | + 'PAY_source' => EEM_Payment_Method::scope_admin, |
|
1870 | + 'PMD_ID' => $valid_data['PMD_ID'], |
|
1871 | + 'PAY_amount' => $amount, |
|
1872 | + 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
1873 | + 'PAY_po_number' => $valid_data['po_number'], |
|
1874 | + 'PAY_extra_accntng' => $valid_data['accounting'], |
|
1875 | + 'PAY_details' => $valid_data, |
|
1876 | + 'PAY_ID' => $PAY_ID, |
|
1877 | + ], |
|
1878 | + '', |
|
1879 | + ['Y-m-d', 'g:i a'] |
|
1880 | + ); |
|
1881 | + |
|
1882 | + if (! $payment->save()) { |
|
1883 | + EE_Error::add_error( |
|
1884 | + sprintf( |
|
1885 | + esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
1886 | + $payment->ID() |
|
1887 | + ), |
|
1888 | + __FILE__, |
|
1889 | + __FUNCTION__, |
|
1890 | + __LINE__ |
|
1891 | + ); |
|
1892 | + } |
|
1893 | + |
|
1894 | + return $payment; |
|
1895 | + } |
|
1896 | + |
|
1897 | + |
|
1898 | + /** |
|
1899 | + * _process_transaction_payments |
|
1900 | + * |
|
1901 | + * @param EE_Transaction $transaction |
|
1902 | + * @return void |
|
1903 | + * @throws EE_Error |
|
1904 | + * @throws InvalidArgumentException |
|
1905 | + * @throws ReflectionException |
|
1906 | + * @throws InvalidDataTypeException |
|
1907 | + * @throws InvalidInterfaceException |
|
1908 | + */ |
|
1909 | + protected function _process_transaction_payments(EE_Transaction $transaction) |
|
1910 | + { |
|
1911 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
1912 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1913 | + // update the transaction with this payment |
|
1914 | + if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
1915 | + EE_Error::add_success( |
|
1916 | + esc_html__( |
|
1917 | + 'The payment has been processed successfully.', |
|
1918 | + 'event_espresso' |
|
1919 | + ), |
|
1920 | + __FILE__, |
|
1921 | + __FUNCTION__, |
|
1922 | + __LINE__ |
|
1923 | + ); |
|
1924 | + } else { |
|
1925 | + EE_Error::add_error( |
|
1926 | + esc_html__( |
|
1927 | + 'The payment was processed successfully but the amount paid for the transaction was not updated.', |
|
1928 | + 'event_espresso' |
|
1929 | + ), |
|
1930 | + __FILE__, |
|
1931 | + __FUNCTION__, |
|
1932 | + __LINE__ |
|
1933 | + ); |
|
1934 | + } |
|
1935 | + } |
|
1936 | + |
|
1937 | + |
|
1938 | + /** |
|
1939 | + * _get_REG_IDs_to_apply_payment_to |
|
1940 | + * returns a list of registration IDs that the payment will apply to |
|
1941 | + * |
|
1942 | + * @param EE_Payment $payment |
|
1943 | + * @return array |
|
1944 | + * @throws EE_Error |
|
1945 | + * @throws InvalidArgumentException |
|
1946 | + * @throws InvalidDataTypeException |
|
1947 | + * @throws InvalidInterfaceException |
|
1948 | + * @throws ReflectionException |
|
1949 | + */ |
|
1950 | + protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) |
|
1951 | + { |
|
1952 | + // grab array of IDs for specific registrations to apply changes to |
|
1953 | + $REG_IDs = $this->request->getRequestParam('txn_admin_payment[registrations]', [], 'int', true); |
|
1954 | + // nothing specified ? then get all reg IDs |
|
1955 | + if (empty($REG_IDs)) { |
|
1956 | + $registrations = $payment->transaction()->registrations(); |
|
1957 | + $REG_IDs = ! empty($registrations) |
|
1958 | + ? array_keys($registrations) |
|
1959 | + : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1960 | + } |
|
1961 | + |
|
1962 | + // ensure that REG_IDs are integers and NOT strings |
|
1963 | + return array_map('intval', $REG_IDs); |
|
1964 | + } |
|
1965 | + |
|
1966 | + |
|
1967 | + /** |
|
1968 | + * @return array |
|
1969 | + */ |
|
1970 | + public function existing_reg_payment_REG_IDs() |
|
1971 | + { |
|
1972 | + return $this->_existing_reg_payment_REG_IDs; |
|
1973 | + } |
|
1974 | + |
|
1975 | + |
|
1976 | + /** |
|
1977 | + * @param array $existing_reg_payment_REG_IDs |
|
1978 | + */ |
|
1979 | + public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) |
|
1980 | + { |
|
1981 | + $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
|
1982 | + } |
|
1983 | + |
|
1984 | + |
|
1985 | + /** |
|
1986 | + * _get_existing_reg_payment_REG_IDs |
|
1987 | + * returns a list of registration IDs that the payment is currently related to |
|
1988 | + * as recorded in the database |
|
1989 | + * |
|
1990 | + * @param EE_Payment $payment |
|
1991 | + * @return array |
|
1992 | + * @throws EE_Error |
|
1993 | + * @throws InvalidArgumentException |
|
1994 | + * @throws InvalidDataTypeException |
|
1995 | + * @throws InvalidInterfaceException |
|
1996 | + * @throws ReflectionException |
|
1997 | + */ |
|
1998 | + protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) |
|
1999 | + { |
|
2000 | + if ($this->existing_reg_payment_REG_IDs() === null) { |
|
2001 | + // let's get any existing reg payment records for this payment |
|
2002 | + $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
2003 | + // but we only want the REG IDs, so grab the array keys |
|
2004 | + $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) |
|
2005 | + ? array_keys($existing_reg_payment_REG_IDs) |
|
2006 | + : []; |
|
2007 | + $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
2008 | + } |
|
2009 | + |
|
2010 | + return $this->existing_reg_payment_REG_IDs(); |
|
2011 | + } |
|
2012 | + |
|
2013 | + |
|
2014 | + /** |
|
2015 | + * _remove_existing_registration_payments |
|
2016 | + * this calculates the difference between existing relations |
|
2017 | + * to the supplied payment and the new list registration IDs, |
|
2018 | + * removes any related registrations that no longer apply, |
|
2019 | + * and then updates the registration paid fields |
|
2020 | + * |
|
2021 | + * @param EE_Payment $payment |
|
2022 | + * @param int $PAY_ID |
|
2023 | + * @return bool; |
|
2024 | + * @throws EE_Error |
|
2025 | + * @throws InvalidArgumentException |
|
2026 | + * @throws ReflectionException |
|
2027 | + * @throws InvalidDataTypeException |
|
2028 | + * @throws InvalidInterfaceException |
|
2029 | + */ |
|
2030 | + protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) |
|
2031 | + { |
|
2032 | + // newly created payments will have nothing recorded for $PAY_ID |
|
2033 | + if (absint($PAY_ID) === 0) { |
|
2034 | + return false; |
|
2035 | + } |
|
2036 | + $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
2037 | + if (empty($existing_reg_payment_REG_IDs)) { |
|
2038 | + return false; |
|
2039 | + } |
|
2040 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
2041 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
2042 | + |
|
2043 | + return $transaction_payments->delete_registration_payments_and_update_registrations( |
|
2044 | + $payment, |
|
2045 | + [ |
|
2046 | + [ |
|
2047 | + 'PAY_ID' => $payment->ID(), |
|
2048 | + 'REG_ID' => ['IN', $existing_reg_payment_REG_IDs], |
|
2049 | + ], |
|
2050 | + ] |
|
2051 | + ); |
|
2052 | + } |
|
2053 | + |
|
2054 | + |
|
2055 | + /** |
|
2056 | + * _update_registration_payments |
|
2057 | + * this applies the payments to the selected registrations |
|
2058 | + * but only if they have not already been paid for |
|
2059 | + * |
|
2060 | + * @param EE_Transaction $transaction |
|
2061 | + * @param EE_Payment $payment |
|
2062 | + * @param array $REG_IDs |
|
2063 | + * @return void |
|
2064 | + * @throws EE_Error |
|
2065 | + * @throws InvalidArgumentException |
|
2066 | + * @throws ReflectionException |
|
2067 | + * @throws RuntimeException |
|
2068 | + * @throws InvalidDataTypeException |
|
2069 | + * @throws InvalidInterfaceException |
|
2070 | + */ |
|
2071 | + protected function _update_registration_payments( |
|
2072 | + EE_Transaction $transaction, |
|
2073 | + EE_Payment $payment, |
|
2074 | + $REG_IDs = [] |
|
2075 | + ) { |
|
2076 | + // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
|
2077 | + // so let's do that using our set of REG_IDs from the form |
|
2078 | + $registration_query_where_params = [ |
|
2079 | + 'REG_ID' => ['IN', $REG_IDs], |
|
2080 | + ]; |
|
2081 | + // but add in some conditions regarding payment, |
|
2082 | + // so that we don't apply payments to registrations that are free or have already been paid for |
|
2083 | + // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
|
2084 | + if (! $payment->is_a_refund()) { |
|
2085 | + $registration_query_where_params['REG_final_price'] = ['!=', 0]; |
|
2086 | + $registration_query_where_params['REG_final_price*'] = ['!=', 'REG_paid', true]; |
|
2087 | + } |
|
2088 | + $registrations = $transaction->registrations([$registration_query_where_params]); |
|
2089 | + if (! empty($registrations)) { |
|
2090 | + /** @type EE_Payment_Processor $payment_processor */ |
|
2091 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2092 | + $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
2093 | + } |
|
2094 | + } |
|
2095 | + |
|
2096 | + |
|
2097 | + /** |
|
2098 | + * _process_registration_status_change |
|
2099 | + * This processes requested registration status changes for all the registrations |
|
2100 | + * on a given transaction and (optionally) sends out notifications for the changes. |
|
2101 | + * |
|
2102 | + * @param EE_Transaction $transaction |
|
2103 | + * @param array $REG_IDs |
|
2104 | + * @return bool |
|
2105 | + * @throws EE_Error |
|
2106 | + * @throws InvalidArgumentException |
|
2107 | + * @throws ReflectionException |
|
2108 | + * @throws InvalidDataTypeException |
|
2109 | + * @throws InvalidInterfaceException |
|
2110 | + */ |
|
2111 | + protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = []) |
|
2112 | + { |
|
2113 | + // first if there is no change in status then we get out. |
|
2114 | + $reg_status = $this->request->getRequestParam('txn_reg_status_change[reg_status]', 'NAN'); |
|
2115 | + if ($reg_status === 'NAN') { |
|
2116 | + // no error message, no change requested, just nothing to do man. |
|
2117 | + return false; |
|
2118 | + } |
|
2119 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
2120 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
2121 | + |
|
2122 | + // made it here dude? Oh WOW. K, let's take care of changing the statuses |
|
2123 | + return $transaction_processor->manually_update_registration_statuses( |
|
2124 | + $transaction, |
|
2125 | + $reg_status, |
|
2126 | + [['REG_ID' => ['IN', $REG_IDs]]] |
|
2127 | + ); |
|
2128 | + } |
|
2129 | + |
|
2130 | + |
|
2131 | + /** |
|
2132 | + * _build_payment_json_response |
|
2133 | + * |
|
2134 | + * @access public |
|
2135 | + * @param EE_Payment $payment |
|
2136 | + * @param array $REG_IDs |
|
2137 | + * @param bool | null $delete_txn_reg_status_change |
|
2138 | + * @return array |
|
2139 | + * @throws EE_Error |
|
2140 | + * @throws InvalidArgumentException |
|
2141 | + * @throws InvalidDataTypeException |
|
2142 | + * @throws InvalidInterfaceException |
|
2143 | + * @throws ReflectionException |
|
2144 | + */ |
|
2145 | + protected function _build_payment_json_response( |
|
2146 | + EE_Payment $payment, |
|
2147 | + $REG_IDs = [], |
|
2148 | + $delete_txn_reg_status_change = null |
|
2149 | + ) { |
|
2150 | + // was the payment deleted ? |
|
2151 | + if (is_bool($delete_txn_reg_status_change)) { |
|
2152 | + return [ |
|
2153 | + 'PAY_ID' => $payment->ID(), |
|
2154 | + 'amount' => $payment->amount(), |
|
2155 | + 'total_paid' => $payment->transaction()->paid(), |
|
2156 | + 'txn_status' => $payment->transaction()->status_ID(), |
|
2157 | + 'pay_status' => $payment->STS_ID(), |
|
2158 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
2159 | + 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
|
2160 | + ]; |
|
2161 | + } |
|
2162 | + |
|
2163 | + $this->_get_payment_status_array(); |
|
2164 | + return [ |
|
2165 | + 'amount' => $payment->amount(), |
|
2166 | + 'total_paid' => $payment->transaction()->paid(), |
|
2167 | + 'txn_status' => $payment->transaction()->status_ID(), |
|
2168 | + 'pay_status' => $payment->STS_ID(), |
|
2169 | + 'PAY_ID' => $payment->ID(), |
|
2170 | + 'STS_ID' => $payment->STS_ID(), |
|
2171 | + 'status' => self::$_pay_status[ $payment->STS_ID() ], |
|
2172 | + 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
2173 | + 'method' => strtoupper($payment->source()), |
|
2174 | + 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
|
2175 | + 'gateway' => $payment->payment_method() |
|
2176 | + ? $payment->payment_method()->admin_name() |
|
2177 | + : esc_html__('Unknown', 'event_espresso'), |
|
2178 | + 'gateway_response' => $payment->gateway_response(), |
|
2179 | + 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
|
2180 | + 'po_number' => $payment->po_number(), |
|
2181 | + 'extra_accntng' => $payment->extra_accntng(), |
|
2182 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
2183 | + ]; |
|
2184 | + } |
|
2185 | + |
|
2186 | + |
|
2187 | + /** |
|
2188 | + * delete_payment |
|
2189 | + * delete a payment or refund made towards a transaction |
|
2190 | + * |
|
2191 | + * @access public |
|
2192 | + * @return void |
|
2193 | + * @throws EE_Error |
|
2194 | + * @throws InvalidArgumentException |
|
2195 | + * @throws ReflectionException |
|
2196 | + * @throws InvalidDataTypeException |
|
2197 | + * @throws InvalidInterfaceException |
|
2198 | + */ |
|
2199 | + public function delete_payment() |
|
2200 | + { |
|
2201 | + $json_response_data = ['return_data' => false]; |
|
2202 | + $PAY_ID = $this->request->getRequestParam('delete_txn_admin_payment[PAY_ID]', 0, 'int'); |
|
2203 | + |
|
2204 | + $can_delete = EE_Registry::instance()->CAP->current_user_can( |
|
2205 | + 'ee_delete_payments', |
|
2206 | + 'delete_payment_from_registration_details' |
|
2207 | + ); |
|
2208 | + if ($PAY_ID && $can_delete) { |
|
2209 | + $delete_txn_reg_status_change = $this->request->getRequestParam( |
|
2210 | + 'delete_txn_reg_status_change', |
|
2211 | + false, |
|
2212 | + 'bool' |
|
2213 | + ); |
|
2214 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
2215 | + if ($payment instanceof EE_Payment) { |
|
2216 | + $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
2217 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
2218 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
2219 | + if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
2220 | + $json_response_data['return_data'] = $this->_build_payment_json_response( |
|
2221 | + $payment, |
|
2222 | + $REG_IDs, |
|
2223 | + $delete_txn_reg_status_change |
|
2224 | + ); |
|
2225 | + if ($delete_txn_reg_status_change) { |
|
2226 | + // MAKE sure we also add the delete_txn_req_status_change to the |
|
2227 | + // request data because that's how messages will be looking for it. |
|
2228 | + $this->request->setRequestParam('txn_reg_status_change', $delete_txn_reg_status_change); |
|
2229 | + $this->_maybe_send_notifications(); |
|
2230 | + $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
2231 | + } |
|
2232 | + } |
|
2233 | + } else { |
|
2234 | + EE_Error::add_error( |
|
2235 | + esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
2236 | + __FILE__, |
|
2237 | + __FUNCTION__, |
|
2238 | + __LINE__ |
|
2239 | + ); |
|
2240 | + } |
|
2241 | + } elseif ($can_delete) { |
|
2242 | + EE_Error::add_error( |
|
2243 | + esc_html__( |
|
2244 | + 'A valid Payment ID was not received, therefore payment form data could not be loaded.', |
|
2245 | + 'event_espresso' |
|
2246 | + ), |
|
2247 | + __FILE__, |
|
2248 | + __FUNCTION__, |
|
2249 | + __LINE__ |
|
2250 | + ); |
|
2251 | + } else { |
|
2252 | + EE_Error::add_error( |
|
2253 | + esc_html__( |
|
2254 | + 'You do not have access to delete a payment.', |
|
2255 | + 'event_espresso' |
|
2256 | + ), |
|
2257 | + __FILE__, |
|
2258 | + __FUNCTION__, |
|
2259 | + __LINE__ |
|
2260 | + ); |
|
2261 | + } |
|
2262 | + $notices = EE_Error::get_notices(false, false, false); |
|
2263 | + $this->_template_args = [ |
|
2264 | + 'data' => $json_response_data, |
|
2265 | + 'success' => $notices['success'], |
|
2266 | + 'error' => $notices['errors'], |
|
2267 | + 'attention' => $notices['attention'], |
|
2268 | + ]; |
|
2269 | + $this->_return_json(); |
|
2270 | + } |
|
2271 | + |
|
2272 | + |
|
2273 | + /** |
|
2274 | + * _registration_payment_data_array |
|
2275 | + * adds info for 'owing' and 'paid' for each registration to the json response |
|
2276 | + * |
|
2277 | + * @access protected |
|
2278 | + * @param array $REG_IDs |
|
2279 | + * @return array |
|
2280 | + * @throws EE_Error |
|
2281 | + * @throws InvalidArgumentException |
|
2282 | + * @throws InvalidDataTypeException |
|
2283 | + * @throws InvalidInterfaceException |
|
2284 | + * @throws ReflectionException |
|
2285 | + */ |
|
2286 | + protected function _registration_payment_data_array($REG_IDs) |
|
2287 | + { |
|
2288 | + $registration_payment_data = []; |
|
2289 | + // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
|
2290 | + if (! empty($REG_IDs)) { |
|
2291 | + $registrations = EEM_Registration::instance()->get_all([['REG_ID' => ['IN', $REG_IDs]]]); |
|
2292 | + foreach ($registrations as $registration) { |
|
2293 | + if ($registration instanceof EE_Registration) { |
|
2294 | + $registration_payment_data[ $registration->ID() ] = [ |
|
2295 | + 'paid' => $registration->pretty_paid(), |
|
2296 | + 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
2297 | + ]; |
|
2298 | + } |
|
2299 | + } |
|
2300 | + } |
|
2301 | + |
|
2302 | + return $registration_payment_data; |
|
2303 | + } |
|
2304 | + |
|
2305 | + |
|
2306 | + /** |
|
2307 | + * _maybe_send_notifications |
|
2308 | + * determines whether or not the admin has indicated that notifications should be sent. |
|
2309 | + * If so, will toggle a filter switch for delivering registration notices. |
|
2310 | + * If passed an EE_Payment object, then it will trigger payment notifications instead. |
|
2311 | + * |
|
2312 | + * @access protected |
|
2313 | + * @param EE_Payment | null $payment |
|
2314 | + */ |
|
2315 | + protected function _maybe_send_notifications($payment = null) |
|
2316 | + { |
|
2317 | + switch ($payment instanceof EE_Payment) { |
|
2318 | + // payment notifications |
|
2319 | + case true: |
|
2320 | + if ($this->request->getRequestParam('txn_payments[send_notifications]', false, 'bool')) { |
|
2321 | + $this->_process_payment_notification($payment); |
|
2322 | + } |
|
2323 | + break; |
|
2324 | + // registration notifications |
|
2325 | + case false: |
|
2326 | + if ($this->request->getRequestParam('txn_reg_status_change[send_notifications]', false, 'bool')) { |
|
2327 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
2328 | + } |
|
2329 | + break; |
|
2330 | + } |
|
2331 | + } |
|
2332 | + |
|
2333 | + |
|
2334 | + /** |
|
2335 | + * _send_payment_reminder |
|
2336 | + * generates HTML for the View Transaction Details Admin page |
|
2337 | + * |
|
2338 | + * @access protected |
|
2339 | + * @return void |
|
2340 | + * @throws EE_Error |
|
2341 | + * @throws InvalidArgumentException |
|
2342 | + * @throws InvalidDataTypeException |
|
2343 | + * @throws InvalidInterfaceException |
|
2344 | + */ |
|
2345 | + protected function _send_payment_reminder() |
|
2346 | + { |
|
2347 | + $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
2348 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2349 | + $redirect_to = $this->request->getRequestParam('redirect_to'); |
|
2350 | + $query_args = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : []; |
|
2351 | + do_action( |
|
2352 | + 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
2353 | + $transaction |
|
2354 | + ); |
|
2355 | + $this->_redirect_after_action( |
|
2356 | + false, |
|
2357 | + esc_html__('payment reminder', 'event_espresso'), |
|
2358 | + esc_html__('sent', 'event_espresso'), |
|
2359 | + $query_args, |
|
2360 | + true |
|
2361 | + ); |
|
2362 | + } |
|
2363 | + |
|
2364 | + |
|
2365 | + /** |
|
2366 | + * get_transactions |
|
2367 | + * get transactions for given parameters (used by list table) |
|
2368 | + * |
|
2369 | + * @param int $per_page how many transactions displayed per page |
|
2370 | + * @param boolean $count return the count or objects |
|
2371 | + * @param string $view |
|
2372 | + * @return EE_Transaction[]|int int = count || array of transaction objects |
|
2373 | + * @throws EE_Error |
|
2374 | + * @throws InvalidArgumentException |
|
2375 | + * @throws InvalidDataTypeException |
|
2376 | + * @throws InvalidInterfaceException |
|
2377 | + */ |
|
2378 | + public function get_transactions($per_page, $count = false, $view = '') |
|
2379 | + { |
|
2380 | + $start_date = wp_strip_all_tags( |
|
2381 | + $this->request->getRequestParam('txn-filter-start-date', date('m/d/Y', strtotime('-10 year'))) |
|
2382 | + ); |
|
2383 | + $end_date = wp_strip_all_tags( |
|
2384 | + $this->request->getRequestParam('txn-filter-end-date', date('m/d/Y')) |
|
2385 | + ); |
|
2386 | + |
|
2387 | + // make sure our timestamps start and end right at the boundaries for each day |
|
2388 | + $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
2389 | + $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
2390 | + |
|
2391 | + |
|
2392 | + // convert to timestamps |
|
2393 | + $start_date = strtotime($start_date); |
|
2394 | + $end_date = strtotime($end_date); |
|
2395 | + |
|
2396 | + // makes sure start date is the lowest value and vice versa |
|
2397 | + $start_date = min($start_date, $end_date); |
|
2398 | + $end_date = max($start_date, $end_date); |
|
2399 | + |
|
2400 | + // convert to correct format for query |
|
2401 | + $start_date = EEM_Transaction::instance()->convert_datetime_for_query( |
|
2402 | + 'TXN_timestamp', |
|
2403 | + date('Y-m-d H:i:s', $start_date), |
|
2404 | + 'Y-m-d H:i:s' |
|
2405 | + ); |
|
2406 | + $end_date = EEM_Transaction::instance()->convert_datetime_for_query( |
|
2407 | + 'TXN_timestamp', |
|
2408 | + date('Y-m-d H:i:s', $end_date), |
|
2409 | + 'Y-m-d H:i:s' |
|
2410 | + ); |
|
2411 | + |
|
2412 | + |
|
2413 | + // set orderby |
|
2414 | + $orderby = $this->request->getRequestParam('orderby'); |
|
2415 | + |
|
2416 | + switch ($orderby) { |
|
2417 | + case 'TXN_ID': |
|
2418 | + break; |
|
2419 | + case 'ATT_fname': |
|
2420 | + $orderby = 'Registration.Attendee.ATT_fname'; |
|
2421 | + break; |
|
2422 | + case 'event_name': |
|
2423 | + $orderby = 'Registration.Event.EVT_name'; |
|
2424 | + break; |
|
2425 | + default: // 'TXN_timestamp' |
|
2426 | + $orderby = 'TXN_timestamp'; |
|
2427 | + } |
|
2428 | + |
|
2429 | + $sort = $this->request->getRequestParam('order', 'DESC'); |
|
2430 | + $current_page = $this->request->getRequestParam('paged', 1, 'int'); |
|
2431 | + |
|
2432 | + $per_page = absint($per_page) ? $per_page : 10; |
|
2433 | + $per_page = $this->request->getRequestParam('perpage', $per_page, 'int'); |
|
2434 | + |
|
2435 | + $offset = ($current_page - 1) * $per_page; |
|
2436 | + $limit = [$offset, $per_page]; |
|
2437 | + |
|
2438 | + $_where = [ |
|
2439 | + 'TXN_timestamp' => ['BETWEEN', [$start_date, $end_date]], |
|
2440 | + 'Registration.REG_count' => 1, |
|
2441 | + ]; |
|
2442 | + |
|
2443 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
2444 | + if ($EVT_ID) { |
|
2445 | + $_where['Registration.EVT_ID'] = $EVT_ID; |
|
2446 | + } |
|
2447 | + |
|
2448 | + $search_term = $this->request->getRequestParam('s'); |
|
2449 | + if ($search_term) { |
|
2450 | + $search_term = '%' . $search_term . '%'; |
|
2451 | + $_where['OR'] = [ |
|
2452 | + 'Registration.Event.EVT_name' => ['LIKE', $search_term], |
|
2453 | + 'Registration.Event.EVT_desc' => ['LIKE', $search_term], |
|
2454 | + 'Registration.Event.EVT_short_desc' => ['LIKE', $search_term], |
|
2455 | + 'Registration.Attendee.ATT_full_name' => ['LIKE', $search_term], |
|
2456 | + 'Registration.Attendee.ATT_fname' => ['LIKE', $search_term], |
|
2457 | + 'Registration.Attendee.ATT_lname' => ['LIKE', $search_term], |
|
2458 | + 'Registration.Attendee.ATT_short_bio' => ['LIKE', $search_term], |
|
2459 | + 'Registration.Attendee.ATT_email' => ['LIKE', $search_term], |
|
2460 | + 'Registration.Attendee.ATT_address' => ['LIKE', $search_term], |
|
2461 | + 'Registration.Attendee.ATT_address2' => ['LIKE', $search_term], |
|
2462 | + 'Registration.Attendee.ATT_city' => ['LIKE', $search_term], |
|
2463 | + 'Registration.REG_final_price' => ['LIKE', $search_term], |
|
2464 | + 'Registration.REG_code' => ['LIKE', $search_term], |
|
2465 | + 'Registration.REG_count' => ['LIKE', $search_term], |
|
2466 | + 'Registration.REG_group_size' => ['LIKE', $search_term], |
|
2467 | + 'Registration.Ticket.TKT_name' => ['LIKE', $search_term], |
|
2468 | + 'Registration.Ticket.TKT_description' => ['LIKE', $search_term], |
|
2469 | + 'Payment.PAY_source' => ['LIKE', $search_term], |
|
2470 | + 'Payment.Payment_Method.PMD_name' => ['LIKE', $search_term], |
|
2471 | + 'TXN_session_data' => ['LIKE', $search_term], |
|
2472 | + 'Payment.PAY_txn_id_chq_nmbr' => ['LIKE', $search_term], |
|
2473 | + ]; |
|
2474 | + } |
|
2475 | + |
|
2476 | + $status = $this->request->getRequestParam('status'); |
|
2477 | + // failed transactions |
|
2478 | + $failed = (! empty($status) && $status === 'failed' && ! $count) || ($count && $view === 'failed'); |
|
2479 | + $abandoned = (! empty($status) && $status === 'abandoned' && ! $count) || ($count && $view === 'abandoned'); |
|
2480 | + $incomplete = (! empty($status) && $status === 'incomplete' && ! $count) || ($count && $view === 'incomplete'); |
|
2481 | + |
|
2482 | + if ($failed) { |
|
2483 | + $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
2484 | + } elseif ($abandoned) { |
|
2485 | + $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
|
2486 | + } elseif ($incomplete) { |
|
2487 | + $_where['STS_ID'] = EEM_Transaction::incomplete_status_code; |
|
2488 | + } else { |
|
2489 | + $_where['STS_ID'] = ['!=', EEM_Transaction::failed_status_code]; |
|
2490 | + $_where['STS_ID*'] = ['!=', EEM_Transaction::abandoned_status_code]; |
|
2491 | + } |
|
2492 | + |
|
2493 | + $query_params = apply_filters( |
|
2494 | + 'FHEE__Transactions_Admin_Page___get_transactions_query_params', |
|
2495 | + [ |
|
2496 | + $_where, |
|
2497 | + 'order_by' => [$orderby => $sort], |
|
2498 | + 'limit' => $limit, |
|
2499 | + 'default_where_conditions' => EEM_Base::default_where_conditions_this_only, |
|
2500 | + ], |
|
2501 | + $this->request->requestParams(), |
|
2502 | + $view, |
|
2503 | + $count |
|
2504 | + ); |
|
2505 | + |
|
2506 | + return $count |
|
2507 | + ? EEM_Transaction::instance()->count([$query_params[0]], 'TXN_ID', true) |
|
2508 | + : EEM_Transaction::instance()->get_all($query_params); |
|
2509 | + } |
|
2510 | + |
|
2511 | + |
|
2512 | + /** |
|
2513 | + * @throws EE_Error |
|
2514 | + * @throws InvalidArgumentException |
|
2515 | + * @throws InvalidDataTypeException |
|
2516 | + * @throws InvalidInterfaceException |
|
2517 | + * @throws ReflectionException |
|
2518 | + * @throws RuntimeException |
|
2519 | + * @since 4.9.79.p |
|
2520 | + */ |
|
2521 | + public function recalculateLineItems() |
|
2522 | + { |
|
2523 | + $TXN_ID = $this->request->getRequestParam('TXN_ID', 0, 'int'); |
|
2524 | + /** @var EE_Transaction $transaction */ |
|
2525 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2526 | + $success = $transaction->recalculateLineItems(); |
|
2527 | + $redirect_to = $this->request->getRequestParam('redirect_to'); |
|
2528 | + $query_args = $redirect_to ? ['action' => $redirect_to, 'TXN_ID' => $TXN_ID,] : []; |
|
2529 | + $this->_redirect_after_action( |
|
2530 | + $success, |
|
2531 | + esc_html__('Transaction taxes and totals', 'event_espresso'), |
|
2532 | + esc_html__('recalculated', 'event_espresso'), |
|
2533 | + $query_args, |
|
2534 | + true |
|
2535 | + ); |
|
2536 | + } |
|
2537 | 2537 | } |