diff --git a/CHANGELOG.md b/CHANGELOG.md index d906983d815..32549065df0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Releases +### [5.0.12] + +#### Added + - [Add Yesterday View to Registrations Admin List Table (#971)](https://github.com/eventespresso/cafe/pull/971) + +#### Fixed + - [Fix Admin UI Styles (#902)](https://github.com/eventespresso/cafe/pull/902) + - [Fix Transaction Admin Payment Currency Formatting (#931)](https://github.com/eventespresso/cafe/pull/931) + - [Don't Duplicate Default Prices When Duplicating Event (#932)](https://github.com/eventespresso/cafe/pull/932) + - [Fix or Suppress PHP 8.2 Warnings (#936)](https://github.com/eventespresso/cafe/pull/936) + - [Add Class Loader for EE_Transaction_Processor (#950)](https://github.com/eventespresso/cafe/pull/950) + - [Fix Registrations Report CSV Question Order (#946)](https://github.com/eventespresso/cafe/pull/946) + - [Add Styes for Multi-Select Inputs (#943)](https://github.com/eventespresso/cafe/pull/943) + - [Fix Promotions Tax Line Items (#851)](https://github.com/eventespresso/cafe/pull/851) + - [Fix PHP 8.2 Warnings III (#968)](https://github.com/eventespresso/cafe/pull/968) + - [Relax Onsite Gateway URL Prop Type (#964)](https://github.com/eventespresso/cafe/pull/964) + +#### Changed + - [BM 5.0.11 changes (#926)](https://github.com/eventespresso/cafe/pull/926) + - [Refactor Maintenance Mode (#852)](https://github.com/eventespresso/cafe/pull/852) + - [Refactor Cron Jobs (#853)](https://github.com/eventespresso/cafe/pull/853) + - [Double Varchar Size for Extra Join Model IDs (#939)](https://github.com/eventespresso/cafe/pull/939) + - [Dont Map Meta Caps if Cap is NULL (#938)](https://github.com/eventespresso/cafe/pull/938) + - [Optimize DB Table Indexes (#949)](https://github.com/eventespresso/cafe/pull/949) + - [Reduce the number of queries used when multiple datetimes are assigned to a ticket (#955)](https://github.com/eventespresso/cafe/pull/955) + - [Add New Feature Flags Admin UI (Barista#1269) (#957)](https://github.com/eventespresso/cafe/pull/957) + - [Fix RTE Button Active State Styles (Barista#1242) (#958)](https://github.com/eventespresso/cafe/pull/958) + - [Fix Required Ticket Sort Order in EDTR (Barista#1244) (#959)](https://github.com/eventespresso/cafe/pull/959) + - [Fix or Suppress PHP 8.2 Warnings Part II (#947)](https://github.com/eventespresso/cafe/pull/947) + - [Add credit card parameter for E2E tests for PayPal Commerce (Barista#1273) (#961)](https://github.com/eventespresso/cafe/pull/961) + - [More query optimizations (#962)](https://github.com/eventespresso/cafe/pull/962) + - [Increase Query Limit to 250 (Barista#1274) (#972)](https://github.com/eventespresso/cafe/pull/972) + - [Undo Changes Made to Cron Jobs in #853 (#967)](https://github.com/eventespresso/cafe/pull/967) + - [Increase GQL Query Limit to 250 (#969)](https://github.com/eventespresso/cafe/pull/969) + + + ### [5.0.11] #### Added diff --git a/PaymentMethods/Manager.php b/PaymentMethods/Manager.php index 83dd42104ff..7b6c2aceaf0 100644 --- a/PaymentMethods/Manager.php +++ b/PaymentMethods/Manager.php @@ -5,10 +5,10 @@ use EE_Error; use EE_Payment_Method; use EEM_Payment_Method; +use EventEspresso\core\domain\services\database\DbStatus; use EventEspresso\core\services\loaders\LoaderFactory; use EventEspresso\core\services\request\RequestInterface; use ReflectionException; -use EE_Maintenance_Mode; /** * Class EventEspresso\PaymentMethods\Manager @@ -25,9 +25,9 @@ class Manager * List of PMs that can be replaced with PP Commerce. * ['payment method name' => 'settings option'] * - * @var $pms_can_hide + * @var array $pms_can_hide */ - protected static $pms_can_hide = [ + protected static array $pms_can_hide = [ 'paypal_express' => 'api_username', 'paypal_pro' => 'api_username', 'aim' => 'login_id', @@ -39,7 +39,7 @@ class Manager */ public function __construct() { - if (! EE_Maintenance_Mode::instance()->models_can_query()) { + if (DbStatus::isOffline()) { return; } $this->loadPaymentMethods(); diff --git a/PaymentMethods/PayPalCommerce/modules/EED_PayPalCommerce.module.php b/PaymentMethods/PayPalCommerce/modules/EED_PayPalCommerce.module.php index e60fbbc0e4b..94743a6f185 100644 --- a/PaymentMethods/PayPalCommerce/modules/EED_PayPalCommerce.module.php +++ b/PaymentMethods/PayPalCommerce/modules/EED_PayPalCommerce.module.php @@ -1,5 +1,6 @@ models_can_query()) { + if (DbStatus::isOnline()) { // Create an Order. add_action('wp_ajax_eeaPpCreateOrder', [__CLASS__, 'createOrderRequest']); add_action('wp_ajax_nopriv_eeaPpCreateOrder', [__CLASS__, 'createOrderRequest']); diff --git a/PaymentMethods/PayPalCommerce/modules/EED_PayPalOnboard.module.php b/PaymentMethods/PayPalCommerce/modules/EED_PayPalOnboard.module.php index 7cde0d83789..3f0f6e3cfdb 100644 --- a/PaymentMethods/PayPalCommerce/modules/EED_PayPalOnboard.module.php +++ b/PaymentMethods/PayPalCommerce/modules/EED_PayPalOnboard.module.php @@ -1,5 +1,6 @@ models_can_query()) { + if (DbStatus::isOnline()) { // Get onboarding URL. add_action('wp_ajax_eeaPpGetOnboardingUrl', [__CLASS__, 'getOnboardingUrl']); // Get the seller access token. diff --git a/admin_pages/about/About_Admin_Page.core.php b/admin_pages/about/About_Admin_Page.core.php index 78be09e08ba..d40aa7bfeb5 100644 --- a/admin_pages/about/About_Admin_Page.core.php +++ b/admin_pages/about/About_Admin_Page.core.php @@ -1,5 +1,7 @@ level() != EE_Maintenance_Mode::level_2_complete_maintenance ? $this->_get_started_steps() : FALSE; + /*$steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::STATUS_FULL_SITE ? $this->_get_started_steps() : FALSE; $steps = $steps !== FALSE ? $steps : ''; $this->_admin_page_title = sprintf( esc_html__('Welcome to Event Espresso %s', 'event_espresso'), EVENT_ESPRESSO_VERSION ); $settings_message = $steps; @@ -168,8 +170,7 @@ protected function _overview() $this->display_about_admin_page();*/ // Copied from _whats_new() - $steps = EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance - ? $this->_get_started_steps() : false; + $steps = DbStatus::isOnline() ? $this->_get_started_steps() : false; $steps = $steps !== false ? $steps : ''; $this->_admin_page_title = sprintf( esc_html__('Welcome to Event Espresso %s', 'event_espresso'), diff --git a/admin_pages/about/templates/ee4-overview.template.php b/admin_pages/about/templates/ee4-overview.template.php index e09be928b61..629e63b21c8 100644 --- a/admin_pages/about/templates/ee4-overview.template.php +++ b/admin_pages/about/templates/ee4-overview.template.php @@ -1,7 +1,9 @@ level() == EE_Maintenance_Mode::level_2_complete_maintenance) { +if (MaintenanceStatus::isFullSite()) { ?>
'; $notice .= sprintf( esc_html__( diff --git a/admin_pages/maintenance/templates/ee_migration_page.template.php b/admin_pages/maintenance/templates/ee_migration_page.template.php index 157d295325e..4995f21276b 100644 --- a/admin_pages/maintenance/templates/ee_migration_page.template.php +++ b/admin_pages/maintenance/templates/ee_migration_page.template.php @@ -1,5 +1,8 @@ level(); +$m_mode_active = MaintenanceStatus::isNotDisabled(); if ($show_backup_db_text) { ?>
@@ -283,12 +279,7 @@ name="maintenance_mode_level" type='radio' value="0" - + />
' . $item->message_type_obj()->description . '
'; } @@ -173,9 +176,8 @@ public function column_description($item) * @param EE_Message_Template_Group $item * @return string * @throws EE_Error - * @throws ReflectionException */ - public function column_messenger($item) + public function column_messenger(EE_Message_Template_Group $item): string { // Return the name contents return sprintf( @@ -194,10 +196,10 @@ public function column_messenger($item) * @throws EE_Error * @throws ReflectionException */ - public function column_recipients($item) + public function column_recipients(EE_Message_Template_Group $item): string { // Return the name contents - return $this->_get_context_links($item) . $this->row_actions($this->_get_actions_for_messenger_column($item)); + return $this->_get_context_links($item); } @@ -208,7 +210,7 @@ public function column_recipients($item) * @return string message_type name * @throws EE_Error */ - public function column_message_type($item) + public function column_message_type(EE_Message_Template_Group $item): string { return ucwords($item->message_type_obj()->label['singular']); } @@ -220,8 +222,9 @@ public function column_message_type($item) * @param bool $global * @return string * @throws EE_Error + * @throws ReflectionException */ - protected function _get_messengers_dropdown_filter($global = true) + protected function _get_messengers_dropdown_filter(bool $global = true): string { $messenger_options = []; $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( @@ -254,8 +257,9 @@ protected function _get_messengers_dropdown_filter($global = true) * @param bool $global * @return string * @throws EE_Error + * @throws ReflectionException */ - protected function _get_message_types_dropdown_filter($global = true) + protected function _get_message_types_dropdown_filter(bool $global = true): string { $message_type_options = []; $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( @@ -290,7 +294,7 @@ protected function _get_message_types_dropdown_filter($global = true) * @throws EE_Error * @throws ReflectionException */ - protected function _get_edit_url(EE_Message_Template_Group $item) + protected function _get_edit_url(EE_Message_Template_Group $item): string { $edit_url = ''; // edit link but only if item isn't trashed. @@ -322,7 +326,7 @@ protected function _get_edit_url(EE_Message_Template_Group $item) * @throws EE_Error * @throws ReflectionException */ - protected function _get_context_links(EE_Message_Template_Group $item) + protected function _get_context_links(EE_Message_Template_Group $item): string { // first check if we even show the context links or not. if ( @@ -341,11 +345,11 @@ protected function _get_context_links(EE_Message_Template_Group $item) $context_templates = $item->context_templates(); foreach ($context_templates as $context => $template_fields) { $mtp_to = ! empty($template_fields['to']) - && $template_fields['to'] instanceof EE_Message_Template + && $template_fields['to'] instanceof EE_Message_Template ? $template_fields['to']->get('MTP_content') : null; $inactive_class = (empty($mtp_to) && ! empty($template_fields['to'])) - || ! $item->is_context_active($context) + || ! $item->is_context_active($context) ? ' mtp-inactive' : ''; $context_title = ucwords($c_configs[ $context ]['label']); @@ -357,15 +361,15 @@ protected function _get_context_links(EE_Message_Template_Group $item) ], EE_MSG_ADMIN_URL ); - $label = sprintf( + $label = sprintf( esc_attr__('Edit message content for the %1$s', 'event_espresso'), $context_title ); $context_array[] = 'message_type()}-{$context}-edit-link{$inactive_class}" . ' ee-aria-tooltip"' - . ' aria-label="' . $label . '">' - . $context_title - . ''; + . ' class="' . "{$item->message_type()}-{$context}-edit-link{$inactive_class}" . ' ee-aria-tooltip"' + . ' aria-label="' . $label . '">' + . $context_title + . ''; } return implode(' | ', $context_array); @@ -380,7 +384,7 @@ protected function _get_context_links(EE_Message_Template_Group $item) * @param EE_Message_Template_Group $item * @return array */ - protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) + protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item): array { return []; } diff --git a/admin_pages/payments/Payment_Log_Admin_List_Table.class.php b/admin_pages/payments/Payment_Log_Admin_List_Table.class.php index 5f301bbf7d1..99f2e6b93ff 100644 --- a/admin_pages/payments/Payment_Log_Admin_List_Table.class.php +++ b/admin_pages/payments/Payment_Log_Admin_List_Table.class.php @@ -14,7 +14,7 @@ class Payment_Log_Admin_List_Table extends EE_Admin_List_Table /** * @var Payments_Admin_Page $_admin_page */ - protected $_admin_page; + protected EE_Admin_Page $_admin_page; /** diff --git a/admin_pages/payments/Payments_Admin_Page_Init.core.php b/admin_pages/payments/Payments_Admin_Page_Init.core.php index a1a2439d79c..4df59d99a3d 100644 --- a/admin_pages/payments/Payments_Admin_Page_Init.core.php +++ b/admin_pages/payments/Payments_Admin_Page_Init.core.php @@ -1,6 +1,7 @@ models_can_query() + DbStatus::isOffline() || ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table()) ) { return; diff --git a/admin_pages/registration_form/Registration_Form_Questions_Admin_List_Table.class.php b/admin_pages/registration_form/Registration_Form_Questions_Admin_List_Table.class.php index 51dd1d753e4..af720280973 100644 --- a/admin_pages/registration_form/Registration_Form_Questions_Admin_List_Table.class.php +++ b/admin_pages/registration_form/Registration_Form_Questions_Admin_List_Table.class.php @@ -18,7 +18,7 @@ class Registration_Form_Questions_Admin_List_Table extends EE_Admin_List_Table /** * @var Registration_Form_Admin_Page $_admin_page */ - protected $_admin_page; + protected EE_Admin_Page $_admin_page; /** * @var RegFormListTableUserCapabilities diff --git a/admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php b/admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php index 668577f7a49..b725706ded3 100644 --- a/admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php +++ b/admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php @@ -15,7 +15,7 @@ class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table /** * @var Registrations_Admin_Page */ - protected $_admin_page; + protected EE_Admin_Page $_admin_page; /** diff --git a/admin_pages/registrations/EE_Registrations_List_Table.class.php b/admin_pages/registrations/EE_Registrations_List_Table.class.php index 8c600256d79..92c45b9e474 100644 --- a/admin_pages/registrations/EE_Registrations_List_Table.class.php +++ b/admin_pages/registrations/EE_Registrations_List_Table.class.php @@ -5,6 +5,7 @@ use EventEspresso\core\exceptions\EntityNotFoundException; use EventEspresso\core\exceptions\InvalidDataTypeException; use EventEspresso\core\exceptions\InvalidInterfaceException; +use EventEspresso\core\services\request\DataType; /** * Registrations Table class @@ -18,17 +19,11 @@ class EE_Registrations_List_Table extends EE_Admin_List_Table /** * @var Registrations_Admin_Page */ - protected $_admin_page; + protected EE_Admin_Page $_admin_page; - /** - * @var RegistrationsListTableUserCapabilities - */ - protected $caps_handler; + protected RegistrationsListTableUserCapabilities $caps_handler; - /** - * @var array - */ - private $_status; + private array $_status; /** * An array of transaction details for the related transaction to the registration being processed. @@ -36,7 +31,7 @@ class EE_Registrations_List_Table extends EE_Admin_List_Table * * @var array */ - protected $_transaction_details = []; + protected array $_transaction_details = []; /** * An array of event details for the related event to the registration being processed. @@ -44,7 +39,9 @@ class EE_Registrations_List_Table extends EE_Admin_List_Table * * @var array */ - protected $_event_details = []; + protected array $_event_details = []; + + private int $EVT_ID = 0; /** @@ -53,15 +50,16 @@ class EE_Registrations_List_Table extends EE_Admin_List_Table public function __construct(Registrations_Admin_Page $admin_page) { $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP); - $req_data = $admin_page->get_request_data(); - if (! empty($req_data['event_id'])) { + parent::__construct($admin_page); + $this->EVT_ID = $this->request->getRequestParam('event_id', 0, DataType::INTEGER); + $req_data = $admin_page->get_request_data(); + if ($this->EVT_ID) { $extra_query_args = []; foreach ($admin_page->get_views() as $view_details) { - $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']]; + $extra_query_args[ $view_details['slug'] ] = ['event_id' => $this->EVT_ID]; } $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); } - parent::__construct($admin_page); $this->_status = $this->_admin_page->get_registration_status_array(); } @@ -69,6 +67,7 @@ public function __construct(Registrations_Admin_Page $admin_page) /** * @return void * @throws EE_Error + * @throws ReflectionException */ protected function _setup_data() { @@ -82,8 +81,8 @@ protected function _setup_data() */ protected function _set_properties() { - $return_url = $this->getReturnUrl(); - $req_data = $this->_admin_page->get_request_data(); + $return_url = $this->getReturnUrl(); + $req_data = $this->_admin_page->get_request_data(); $this->_wp_list_args = [ 'singular' => esc_html__('registration', 'event_espresso'), @@ -92,14 +91,12 @@ protected function _set_properties() 'screen' => $this->_admin_page->get_current_screen()->id, ]; - $EVT_ID = isset($req_data['event_id']) ? (int) $req_data['event_id'] : 0; - $DTT_ID = $req_data['DTT_ID'] ?? 0; $DTT_ID = $req_data['datetime_id'] ?? $DTT_ID; $DTT_ID = (int) $DTT_ID; - if ($EVT_ID) { - $this->_columns = [ + if ($this->EVT_ID) { + $this->_columns = [ 'cb' => '', // Render a checkbox instead of text 'id' => esc_html__('ID', 'event_espresso'), 'ATT_fname' => esc_html__('Name', 'event_espresso'), @@ -112,7 +109,7 @@ protected function _set_properties() 'actions' => $this->actionsColumnHeader(), ]; } else { - $this->_columns = [ + $this->_columns = [ 'cb' => '', // Render a checkbox instead of text 'id' => esc_html__('ID', 'event_espresso'), 'ATT_fname' => esc_html__('Name', 'event_espresso'), @@ -125,7 +122,7 @@ protected function _set_properties() ]; } - $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $req_data, $EVT_ID, $DTT_ID); + $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $req_data, $this->EVT_ID, $DTT_ID); if (! empty($csv_report)) { $this->_bottom_buttons['csv_reg_report'] = $csv_report; } @@ -182,16 +179,12 @@ protected function _get_row_class($item): string */ protected function _set_related_details(EE_Registration $registration) { - $transaction = $registration->get_first_related('Transaction'); - $status = $transaction instanceof EE_Transaction - ? $transaction->status_ID() - : EEM_Transaction::failed_status_code; + $transaction = $registration->transaction(); + $status = $transaction->status_ID(); $this->_transaction_details = [ 'transaction' => $transaction, 'status' => $status, - 'id' => $transaction instanceof EE_Transaction - ? $transaction->ID() - : 0, + 'id' => $transaction->ID(), 'title_attr' => sprintf( esc_html__('View Transaction Details (%s)', 'event_espresso'), EEH_Template::pretty_status($status, false, 'sentence') @@ -229,9 +222,9 @@ protected function _get_table_filters() $filters = []; // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as // methods. - $cur_date = $this->_req_data['month_range'] ?? ''; - $cur_category = $this->_req_data['EVT_CAT'] ?? -1; - $reg_status = $this->_req_data['_reg_status'] ?? ''; + $cur_date = $this->request->getRequestParam('month_range', ''); + $cur_category = $this->request->getRequestParam('EVT_CAT', -1, DataType::INTEGER); + $reg_status = $this->request->getRequestParam('_reg_status', ''); $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); $status = []; @@ -243,14 +236,16 @@ protected function _get_table_filters() $filters[] = EEH_Form_Fields::select_input( '_reg_status', $status, - isset($this->_req_data['_reg_status']) - ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) - : '' + $reg_status ? strtoupper($reg_status) : '' ); } foreach (['event_id', 'datetime_id', 'ticket_id'] as $filter_key) { - if (isset($this->_req_data[ $filter_key ])) { - $filters[] = EEH_Form_Fields::hidden_input($filter_key, $this->_req_data[ $filter_key ], 'reg_' . $filter_key); + if ($this->request->requestParamIsSet($filter_key)) { + $filters[] = EEH_Form_Fields::hidden_input( + $filter_key, + $this->request->getRequestParam($filter_key), + 'reg_' . $filter_key + ); } } return $filters; @@ -267,9 +262,10 @@ protected function _get_table_filters() */ protected function _add_view_counts() { - $this->_views['all']['count'] = $this->_total_registrations(); - $this->_views['month']['count'] = $this->_total_registrations_this_month(); - $this->_views['today']['count'] = $this->_total_registrations_today(); + $this->_views['all']['count'] = $this->_total_registrations(); + $this->_views['today']['count'] = $this->_total_registrations_today(); + $this->_views['yesterday']['count'] = $this->totalRegistrationsYesterday(); + $this->_views['month']['count'] = $this->_total_registrations_this_month(); if ($this->caps_handler->userCanTrashRegistrations()) { $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); $this->_views['trash']['count'] = $this->_total_registrations('trash'); @@ -286,11 +282,8 @@ protected function _add_view_counts() protected function _total_registrations(string $view = ''): int { $_where = []; - $EVT_ID = isset($this->_req_data['event_id']) - ? absint($this->_req_data['event_id']) - : false; - if ($EVT_ID) { - $_where['EVT_ID'] = $EVT_ID; + if ($this->EVT_ID) { + $_where['EVT_ID'] = $this->EVT_ID; } switch ($view) { case 'trash': @@ -312,37 +305,14 @@ protected function _total_registrations(string $view = ''): int */ protected function _total_registrations_this_month(): int { - $EVT_ID = isset($this->_req_data['event_id']) - ? absint($this->_req_data['event_id']) - : false; - $_where = $EVT_ID - ? ['EVT_ID' => $EVT_ID] - : []; - $this_year_r = date('Y', current_time('timestamp')); - $time_start = ' 00:00:00'; - $time_end = ' 23:59:59'; - $this_month_r = date('m', current_time('timestamp')); - $days_this_month = date('t', current_time('timestamp')); - // setup date query. - $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( - 'REG_date', - $this_year_r . '-' . $this_month_r . '-01' . $time_start, - 'Y-m-d H:i:s' - ); - $end_string = EEM_Registration::instance()->convert_datetime_for_query( - 'REG_date', - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . $time_end, - 'Y-m-d H:i:s' - ); - $_where['REG_date'] = [ - 'BETWEEN', - [ - $beginning_string, - $end_string, - ], - ]; - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; - return EEM_Registration::instance()->count([$_where]); + $current_time = current_time('timestamp'); + $year_and_month = date('Y-m', $current_time); + $days_in_month = date('t', $current_time); + + $start_date = "$year_and_month-01"; + $end_date = "$year_and_month-$days_in_month"; + + return $this->totalRegistrationsForDateRange($start_date, $end_date); } @@ -353,32 +323,54 @@ protected function _total_registrations_this_month(): int */ protected function _total_registrations_today(): int { - $EVT_ID = isset($this->_req_data['event_id']) - ? absint($this->_req_data['event_id']) - : false; - $_where = $EVT_ID - ? ['EVT_ID' => $EVT_ID] - : []; - $current_date = date('Y-m-d', current_time('timestamp')); - $time_start = ' 00:00:00'; - $time_end = ' 23:59:59'; - $_where['REG_date'] = [ - 'BETWEEN', - [ - EEM_Registration::instance()->convert_datetime_for_query( - 'REG_date', - $current_date . $time_start, - 'Y-m-d H:i:s' - ), - EEM_Registration::instance()->convert_datetime_for_query( - 'REG_date', - $current_date . $time_end, - 'Y-m-d H:i:s' - ), + $today = date('Y-m-d', current_time('timestamp')); + return $this->totalRegistrationsForDateRange($today, $today); + } + + + /** + * @return int + * @throws EE_Error + * @throws ReflectionException + */ + protected function totalRegistrationsYesterday(): int + { + $yesterday = date('Y-m-d', current_time('timestamp') - DAY_IN_SECONDS); + return $this->totalRegistrationsForDateRange($yesterday, $yesterday); + } + + + /** + * @param string $start_date earlier date string in format 'Y-m-d' + * @param string $end_date later date string in format 'Y-m-d' + * @return int + * @throws EE_Error + * @throws ReflectionException + */ + private function totalRegistrationsForDateRange(string $start_date, string $end_date): int + { + $where = [ + 'REG_date' => [ + 'BETWEEN', + [ + EEM_Registration::instance()->convert_datetime_for_query( + 'REG_date', + "$start_date 00:00:00", + 'Y-m-d H:i:s' + ), + EEM_Registration::instance()->convert_datetime_for_query( + 'REG_date', + "$end_date 23:59:59", + 'Y-m-d H:i:s' + ), + ], ], + 'STS_ID' => ['!=', EEM_Registration::status_id_incomplete], ]; - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; - return EEM_Registration::instance()->count([$_where]); + if ($this->EVT_ID) { + $where['EVT_ID'] = $this->EVT_ID; + } + return EEM_Registration::instance()->count([$where]); } @@ -395,10 +387,8 @@ public function column_cb($item): string { /** checkbox/lock **/ $REG_ID = $item->ID(); - $transaction = $item->get_first_related('Transaction'); - $payment_count = $transaction instanceof EE_Transaction - ? $transaction->count_related('Payment') - : 0; + $transaction = $item->transaction(); + $payment_count = $transaction->count_related('Payment'); $content = ''; $content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item) @@ -447,7 +437,6 @@ public function column_id(EE_Registration $registration): string */ public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string { - $status = esc_attr($registration->status_ID()); $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); $prime_reg_star = $registration->count() === 1 @@ -457,10 +446,10 @@ public function column_ATT_fname(EE_Registration $registration, bool $prep_conte $group_count = ' ' . sprintf( - esc_html__('(%1$s / %2$s)', 'event_espresso'), - $registration->count(), - $registration->group_size() - ) . ' + esc_html__('(%1$s / %2$s)', 'event_espresso'), + $registration->count(), + $registration->group_size() + ) . ' '; $content = ' @@ -469,20 +458,20 @@ public function column_ATT_fname(EE_Registration $registration, bool $prep_conte class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip" > ' . $this->viewRegistrationLink($registration, $status) - . $prime_reg_star - . $group_count . ' + . $prime_reg_star + . $group_count . ' ' . sprintf( - esc_html__('Reg Code: %s', 'event_espresso'), - $registration->get('REG_code') - ) . ' + esc_html__('Reg Code: %s', 'event_espresso'), + $registration->get('REG_code') + ) . ' '; $url_params = ['_REG_ID' => $registration->ID()]; - if (isset($this->_req_data['event_id'])) { - $url_params['event_id'] = $registration->event_ID(); + if ($this->EVT_ID) { + $url_params['event_id'] = $this->EVT_ID; } // trash/restore/delete actions $actions = $this->trashRegistrationLink($registration, $url_params); @@ -508,12 +497,12 @@ public function column__REG_date(EE_Registration $registration, bool $prep_conte // Build row actions $content = $this->caps_handler->userCanViewTransaction() ? '' - . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a') - . '' + . $this->viewTransactionUrl() + . '" aria-label="' + . esc_attr($this->_transaction_details['title_attr']) + . '">' + . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a') + . '' : $registration->get_i18n_datetime('REG_date'); return $prep_content ? $this->columnContent('_REG_date', $content) : $content; @@ -532,13 +521,13 @@ public function column__REG_date(EE_Registration $registration, bool $prep_conte public function column_event_name(EE_Registration $registration): string { $this->_set_related_details($registration); - $EVT_ID = $registration->event_ID(); - $event_name = $registration->event_name(); - $event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso'); - $event_name = wp_trim_words($event_name, 30, '...'); - $edit_event = $this->editEventLink($EVT_ID, $event_name); + $EVT_ID = $registration->event_ID(); + $event_name = $registration->event_name(); + $event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso'); + $event_name = wp_trim_words($event_name, 30, '...'); + $edit_event = $this->editEventLink($EVT_ID, $event_name); $actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name); - $content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); + $content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); return $this->columnContent('event_name', $content); } @@ -620,11 +609,16 @@ public function column_ATT_email(EE_Registration $registration): string /** * @param EE_Registration $registration * @return string + * @throws EE_Error + * @throws ReflectionException */ public function column__REG_count(EE_Registration $registration): string { - $content = - sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size()); + $content = sprintf( + esc_html__('%1$s / %2$s', 'event_espresso'), + $registration->count(), + $registration->group_size() + ); return $this->columnContent('_REG_count', $content); } @@ -637,10 +631,9 @@ public function column__REG_count(EE_Registration $registration): string */ public function column_PRC_amount(EE_Registration $registration): string { - $ticket = $registration->ticket(); - $req_data = $this->_admin_page->get_request_data(); + $ticket = $registration->ticket(); - $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket + $content = $this->EVT_ID && $ticket instanceof EE_Ticket ? '