@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | <div class="ee-layout-stack"> |
| 38 | 38 | <h3 class="newsletter-send-form-title extreme-text"> |
| 39 | 39 | <?php |
| 40 | - printf( |
|
| 41 | - esc_html__('Sending batch message to %s people...', 'event_espresso'), |
|
| 42 | - '[NUMPEOPLE]' |
|
| 43 | - ); ?> |
|
| 40 | + printf( |
|
| 41 | + esc_html__('Sending batch message to %s people...', 'event_espresso'), |
|
| 42 | + '[NUMPEOPLE]' |
|
| 43 | + ); ?> |
|
| 44 | 44 | </h3> |
| 45 | 45 | <label for="batch-message-template-selector"> |
| 46 | 46 | <?php esc_html_e('Select Template:', 'event_espresso'); ?> |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | > |
| 70 | 70 | <button class='ee-mini-modal-close-btn js-close-list-trigger' |
| 71 | 71 | aria-label="<?php esc_html_e( |
| 72 | - 'close shortcode selector', |
|
| 73 | - 'event_espresso' |
|
| 74 | - ); ?>" |
|
| 72 | + 'close shortcode selector', |
|
| 73 | + 'event_espresso' |
|
| 74 | + ); ?>" |
|
| 75 | 75 | > |
| 76 | 76 | <span class='dashicons dashicons-no'></span> |
| 77 | 77 | </button> |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | > |
| 113 | 113 | <button class='ee-mini-modal-close-btn js-close-list-trigger' |
| 114 | 114 | aria-label="<?php esc_html_e( |
| 115 | - 'close shortcode selector', |
|
| 116 | - 'event_espresso' |
|
| 117 | - ); ?>" |
|
| 115 | + 'close shortcode selector', |
|
| 116 | + 'event_espresso' |
|
| 117 | + ); ?>" |
|
| 118 | 118 | > |
| 119 | 119 | <span class='dashicons dashicons-no'></span> |
| 120 | 120 | </button> |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | > |
| 156 | 156 | <button class='ee-mini-modal-close-btn js-close-list-trigger' |
| 157 | 157 | aria-label="<?php esc_html_e( |
| 158 | - 'close shortcode selector', |
|
| 159 | - 'event_espresso' |
|
| 160 | - ); ?>" |
|
| 158 | + 'close shortcode selector', |
|
| 159 | + 'event_espresso' |
|
| 160 | + ); ?>" |
|
| 161 | 161 | > |
| 162 | 162 | <span class='dashicons dashicons-no'></span> |
| 163 | 163 | </button> |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | <?php esc_html_e('"content" field:', 'event_espresso'); ?> |
| 169 | 169 | </h4> |
| 170 | 170 | <?php echo wp_kses( |
| 171 | - $shortcodes['[NEWSLETTER_CONTENT]'], |
|
| 172 | - AllowedTags::getAllowedTags() |
|
| 173 | - ); ?> |
|
| 171 | + $shortcodes['[NEWSLETTER_CONTENT]'], |
|
| 172 | + AllowedTags::getAllowedTags() |
|
| 173 | + ); ?> |
|
| 174 | 174 | </div> |
| 175 | 175 | </div> |
| 176 | 176 | </div> |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | name="<?php echo esc_attr($form_nonce_name); ?>" |
| 199 | 199 | value="<?php echo esc_attr($form_nonce); ?>"> |
| 200 | 200 | <input type="hidden" name="redirect_back_to" value="<?php |
| 201 | - echo esc_attr($redirect_back_to); ?>"> |
|
| 201 | + echo esc_attr($redirect_back_to); ?>"> |
|
| 202 | 202 | <input type="hidden" |
| 203 | 203 | id="get_newsletter_form_content_nonce" |
| 204 | 204 | name="get_newsletter_form_content_nonce" |
@@ -16,231 +16,231 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class EE_Event_Registrations_List_Table extends EE_Admin_List_Table |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @var Extend_Registrations_Admin_Page |
|
| 21 | - */ |
|
| 22 | - protected EE_Admin_Page $_admin_page; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
| 26 | - */ |
|
| 27 | - protected DatetimesForEventCheckIn $datetimes_for_event; |
|
| 28 | - |
|
| 29 | - protected ?DatetimesForEventCheckIn $datetimes_for_current_row = null; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The DTT_ID if the current view has a specified datetime. |
|
| 33 | - */ |
|
| 34 | - protected int $datetime_id = 0; |
|
| 35 | - |
|
| 36 | - protected ?EE_Datetime $datetime = null; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * The event ID if one is specified in the request |
|
| 40 | - */ |
|
| 41 | - protected int $event_id = 0; |
|
| 42 | - |
|
| 43 | - protected ?EE_Event $event = null; |
|
| 44 | - |
|
| 45 | - protected bool $hide_expired = false; |
|
| 46 | - |
|
| 47 | - protected bool $hide_upcoming = false; |
|
| 48 | - |
|
| 49 | - protected array $_status = []; |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * EE_Event_Registrations_List_Table constructor. |
|
| 54 | - * |
|
| 55 | - * @param Registrations_Admin_Page $admin_page |
|
| 56 | - * @throws EE_Error |
|
| 57 | - * @throws ReflectionException |
|
| 58 | - */ |
|
| 59 | - public function __construct($admin_page) |
|
| 60 | - { |
|
| 61 | - parent::__construct($admin_page); |
|
| 62 | - $this->resolveRequestVars(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @throws EE_Error |
|
| 68 | - * @throws ReflectionException |
|
| 69 | - * @since 5.0.0.p |
|
| 70 | - */ |
|
| 71 | - private function resolveRequestVars() |
|
| 72 | - { |
|
| 73 | - $this->event_id = $this->request->getRequestParam('event_id', 0, 'int'); |
|
| 74 | - $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id); |
|
| 75 | - // if we're filtering for a specific event and it only has one datetime, then grab its ID |
|
| 76 | - $this->datetime = $this->datetimes_for_event->getOneDatetimeForEvent(); |
|
| 77 | - $this->datetime_id = $this->datetime instanceof EE_Datetime ? $this->datetime->ID() : 0; |
|
| 78 | - // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ) |
|
| 79 | - $this->datetime_id = $this->request->getRequestParam( |
|
| 80 | - 'DTT_ID', |
|
| 81 | - $this->datetime_id, |
|
| 82 | - 'int' |
|
| 83 | - ); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @throws EE_Error |
|
| 89 | - * @throws ReflectionException |
|
| 90 | - */ |
|
| 91 | - protected function _setup_data() |
|
| 92 | - { |
|
| 93 | - $this->_data = $this->_view !== 'trash' |
|
| 94 | - ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
| 95 | - : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
| 96 | - |
|
| 97 | - $this->_all_data_count = $this->_view !== 'trash' |
|
| 98 | - ? $this->_admin_page->get_event_attendees($this->_per_page, true) |
|
| 99 | - : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @throws ReflectionException |
|
| 105 | - * @throws EE_Error |
|
| 106 | - */ |
|
| 107 | - protected function _set_properties() |
|
| 108 | - { |
|
| 109 | - $return_url = $this->getReturnUrl(); |
|
| 110 | - |
|
| 111 | - $this->_wp_list_args = [ |
|
| 112 | - 'singular' => esc_html__('registrant', 'event_espresso'), |
|
| 113 | - 'plural' => esc_html__('registrants', 'event_espresso'), |
|
| 114 | - 'ajax' => true, |
|
| 115 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 116 | - ]; |
|
| 117 | - $columns = []; |
|
| 118 | - |
|
| 119 | - $this->_columns = [ |
|
| 120 | - '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
| 121 | - 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
| 122 | - 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
| 123 | - 'Event' => esc_html__('Event', 'event_espresso'), |
|
| 124 | - 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
| 125 | - '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
| 126 | - 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 127 | - 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
| 128 | - ]; |
|
| 129 | - // Add/remove columns when an event has been selected |
|
| 130 | - if (! empty($this->event_id)) { |
|
| 131 | - // Render a checkbox column |
|
| 132 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 133 | - $this->_has_checkbox_column = true; |
|
| 134 | - // Remove the 'Event' column |
|
| 135 | - unset($this->_columns['Event']); |
|
| 136 | - $this->setBottomButtons(); |
|
| 137 | - } |
|
| 138 | - $this->_columns = array_merge($columns, $this->_columns); |
|
| 139 | - $this->_primary_column = '_REG_att_checked_in'; |
|
| 140 | - |
|
| 141 | - $csv_report = RegistrationsCsvReportParams::getRequestParams( |
|
| 142 | - $return_url, |
|
| 143 | - $this->_req_data, |
|
| 144 | - $this->event_id, |
|
| 145 | - $this->datetime_id |
|
| 146 | - ); |
|
| 147 | - if (! empty($csv_report)) { |
|
| 148 | - $this->_bottom_buttons['csv_reg_report'] = $csv_report; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - $this->_sortable_columns = [ |
|
| 152 | - /** |
|
| 153 | - * Allows users to change the default sort if they wish. |
|
| 154 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 155 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 156 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 157 | - * for a specific list table you can use the provided reference to this object instance. |
|
| 158 | - */ |
|
| 159 | - 'ATT_name' => [ |
|
| 160 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 161 | - true, |
|
| 162 | - $this, |
|
| 163 | - ] |
|
| 164 | - ? ['ATT_lname' => true] |
|
| 165 | - : ['ATT_fname' => true], |
|
| 166 | - 'Event' => ['Event.EVT_name' => false], |
|
| 167 | - ]; |
|
| 168 | - $this->_hidden_columns = []; |
|
| 169 | - $this->event = EEM_Event::instance()->get_one_by_ID($this->event_id); |
|
| 170 | - if ($this->event instanceof EE_Event) { |
|
| 171 | - $this->datetimes_for_event = DatetimesForEventCheckIn::fromEvent($this->event); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @param EE_Registration $item |
|
| 178 | - * @return string |
|
| 179 | - */ |
|
| 180 | - protected function _get_row_class($item): string |
|
| 181 | - { |
|
| 182 | - $class = parent::_get_row_class($item); |
|
| 183 | - if ($this->_has_checkbox_column) { |
|
| 184 | - $class .= ' has-checkbox-column'; |
|
| 185 | - } |
|
| 186 | - return $class; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @return array |
|
| 192 | - * @throws EE_Error |
|
| 193 | - * @throws ReflectionException |
|
| 194 | - */ |
|
| 195 | - protected function _get_table_filters() |
|
| 196 | - { |
|
| 197 | - $filters = []; |
|
| 198 | - $this->hide_expired = $this->request->getRequestParam('hide_expired', false, 'bool'); |
|
| 199 | - $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, 'bool'); |
|
| 200 | - $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
|
| 201 | - $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
|
| 202 | - // get datetimes for ALL active events (note possible capability restrictions) |
|
| 203 | - $events = $this->datetimes_for_event->getAllEvents(); |
|
| 204 | - $event_options[] = [ |
|
| 205 | - 'id' => 0, |
|
| 206 | - 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
|
| 207 | - ]; |
|
| 208 | - foreach ($events as $event) { |
|
| 209 | - // any registrations for this event? |
|
| 210 | - if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
| 211 | - continue; |
|
| 212 | - } |
|
| 213 | - $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
|
| 214 | - $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : ''; |
|
| 215 | - |
|
| 216 | - $event_options[] = [ |
|
| 217 | - 'id' => $event->ID(), |
|
| 218 | - 'text' => apply_filters( |
|
| 219 | - 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
| 220 | - $event->name(), |
|
| 221 | - $event |
|
| 222 | - ), |
|
| 223 | - 'class' => $expired_class . $upcoming_class, |
|
| 224 | - ]; |
|
| 225 | - if ($event->ID() === $this->event_id) { |
|
| 226 | - $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
|
| 227 | - $hide_expired_checked = $expired_class === '' ? $hide_expired_checked : ''; |
|
| 228 | - $this->hide_upcoming = $upcoming_class === '' ? $this->hide_upcoming : false; |
|
| 229 | - $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : ''; |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - $select_class = $this->hide_expired ? 'ee-hide-expired-events' : ''; |
|
| 234 | - $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : ''; |
|
| 235 | - $select_input = EEH_Form_Fields::select_input( |
|
| 236 | - 'event_id', |
|
| 237 | - $event_options, |
|
| 238 | - $this->event_id, |
|
| 239 | - '', |
|
| 240 | - $select_class |
|
| 241 | - ); |
|
| 242 | - |
|
| 243 | - $filters[] = ' |
|
| 19 | + /** |
|
| 20 | + * @var Extend_Registrations_Admin_Page |
|
| 21 | + */ |
|
| 22 | + protected EE_Admin_Page $_admin_page; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
| 26 | + */ |
|
| 27 | + protected DatetimesForEventCheckIn $datetimes_for_event; |
|
| 28 | + |
|
| 29 | + protected ?DatetimesForEventCheckIn $datetimes_for_current_row = null; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The DTT_ID if the current view has a specified datetime. |
|
| 33 | + */ |
|
| 34 | + protected int $datetime_id = 0; |
|
| 35 | + |
|
| 36 | + protected ?EE_Datetime $datetime = null; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * The event ID if one is specified in the request |
|
| 40 | + */ |
|
| 41 | + protected int $event_id = 0; |
|
| 42 | + |
|
| 43 | + protected ?EE_Event $event = null; |
|
| 44 | + |
|
| 45 | + protected bool $hide_expired = false; |
|
| 46 | + |
|
| 47 | + protected bool $hide_upcoming = false; |
|
| 48 | + |
|
| 49 | + protected array $_status = []; |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * EE_Event_Registrations_List_Table constructor. |
|
| 54 | + * |
|
| 55 | + * @param Registrations_Admin_Page $admin_page |
|
| 56 | + * @throws EE_Error |
|
| 57 | + * @throws ReflectionException |
|
| 58 | + */ |
|
| 59 | + public function __construct($admin_page) |
|
| 60 | + { |
|
| 61 | + parent::__construct($admin_page); |
|
| 62 | + $this->resolveRequestVars(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @throws EE_Error |
|
| 68 | + * @throws ReflectionException |
|
| 69 | + * @since 5.0.0.p |
|
| 70 | + */ |
|
| 71 | + private function resolveRequestVars() |
|
| 72 | + { |
|
| 73 | + $this->event_id = $this->request->getRequestParam('event_id', 0, 'int'); |
|
| 74 | + $this->datetimes_for_event = DatetimesForEventCheckIn::fromEventID($this->event_id); |
|
| 75 | + // if we're filtering for a specific event and it only has one datetime, then grab its ID |
|
| 76 | + $this->datetime = $this->datetimes_for_event->getOneDatetimeForEvent(); |
|
| 77 | + $this->datetime_id = $this->datetime instanceof EE_Datetime ? $this->datetime->ID() : 0; |
|
| 78 | + // else check the request, but use the above as the default (and hope they match if BOTH exist, LOLZ) |
|
| 79 | + $this->datetime_id = $this->request->getRequestParam( |
|
| 80 | + 'DTT_ID', |
|
| 81 | + $this->datetime_id, |
|
| 82 | + 'int' |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @throws EE_Error |
|
| 89 | + * @throws ReflectionException |
|
| 90 | + */ |
|
| 91 | + protected function _setup_data() |
|
| 92 | + { |
|
| 93 | + $this->_data = $this->_view !== 'trash' |
|
| 94 | + ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
| 95 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
| 96 | + |
|
| 97 | + $this->_all_data_count = $this->_view !== 'trash' |
|
| 98 | + ? $this->_admin_page->get_event_attendees($this->_per_page, true) |
|
| 99 | + : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @throws ReflectionException |
|
| 105 | + * @throws EE_Error |
|
| 106 | + */ |
|
| 107 | + protected function _set_properties() |
|
| 108 | + { |
|
| 109 | + $return_url = $this->getReturnUrl(); |
|
| 110 | + |
|
| 111 | + $this->_wp_list_args = [ |
|
| 112 | + 'singular' => esc_html__('registrant', 'event_espresso'), |
|
| 113 | + 'plural' => esc_html__('registrants', 'event_espresso'), |
|
| 114 | + 'ajax' => true, |
|
| 115 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 116 | + ]; |
|
| 117 | + $columns = []; |
|
| 118 | + |
|
| 119 | + $this->_columns = [ |
|
| 120 | + '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
| 121 | + 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
| 122 | + 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
| 123 | + 'Event' => esc_html__('Event', 'event_espresso'), |
|
| 124 | + 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
| 125 | + '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
| 126 | + 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 127 | + 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
| 128 | + ]; |
|
| 129 | + // Add/remove columns when an event has been selected |
|
| 130 | + if (! empty($this->event_id)) { |
|
| 131 | + // Render a checkbox column |
|
| 132 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 133 | + $this->_has_checkbox_column = true; |
|
| 134 | + // Remove the 'Event' column |
|
| 135 | + unset($this->_columns['Event']); |
|
| 136 | + $this->setBottomButtons(); |
|
| 137 | + } |
|
| 138 | + $this->_columns = array_merge($columns, $this->_columns); |
|
| 139 | + $this->_primary_column = '_REG_att_checked_in'; |
|
| 140 | + |
|
| 141 | + $csv_report = RegistrationsCsvReportParams::getRequestParams( |
|
| 142 | + $return_url, |
|
| 143 | + $this->_req_data, |
|
| 144 | + $this->event_id, |
|
| 145 | + $this->datetime_id |
|
| 146 | + ); |
|
| 147 | + if (! empty($csv_report)) { |
|
| 148 | + $this->_bottom_buttons['csv_reg_report'] = $csv_report; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + $this->_sortable_columns = [ |
|
| 152 | + /** |
|
| 153 | + * Allows users to change the default sort if they wish. |
|
| 154 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 155 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 156 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 157 | + * for a specific list table you can use the provided reference to this object instance. |
|
| 158 | + */ |
|
| 159 | + 'ATT_name' => [ |
|
| 160 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 161 | + true, |
|
| 162 | + $this, |
|
| 163 | + ] |
|
| 164 | + ? ['ATT_lname' => true] |
|
| 165 | + : ['ATT_fname' => true], |
|
| 166 | + 'Event' => ['Event.EVT_name' => false], |
|
| 167 | + ]; |
|
| 168 | + $this->_hidden_columns = []; |
|
| 169 | + $this->event = EEM_Event::instance()->get_one_by_ID($this->event_id); |
|
| 170 | + if ($this->event instanceof EE_Event) { |
|
| 171 | + $this->datetimes_for_event = DatetimesForEventCheckIn::fromEvent($this->event); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @param EE_Registration $item |
|
| 178 | + * @return string |
|
| 179 | + */ |
|
| 180 | + protected function _get_row_class($item): string |
|
| 181 | + { |
|
| 182 | + $class = parent::_get_row_class($item); |
|
| 183 | + if ($this->_has_checkbox_column) { |
|
| 184 | + $class .= ' has-checkbox-column'; |
|
| 185 | + } |
|
| 186 | + return $class; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @return array |
|
| 192 | + * @throws EE_Error |
|
| 193 | + * @throws ReflectionException |
|
| 194 | + */ |
|
| 195 | + protected function _get_table_filters() |
|
| 196 | + { |
|
| 197 | + $filters = []; |
|
| 198 | + $this->hide_expired = $this->request->getRequestParam('hide_expired', false, 'bool'); |
|
| 199 | + $this->hide_upcoming = $this->request->getRequestParam('hide_upcoming', false, 'bool'); |
|
| 200 | + $hide_expired_checked = $this->hide_expired ? 'checked' : ''; |
|
| 201 | + $hide_upcoming_checked = $this->hide_upcoming ? 'checked' : ''; |
|
| 202 | + // get datetimes for ALL active events (note possible capability restrictions) |
|
| 203 | + $events = $this->datetimes_for_event->getAllEvents(); |
|
| 204 | + $event_options[] = [ |
|
| 205 | + 'id' => 0, |
|
| 206 | + 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
|
| 207 | + ]; |
|
| 208 | + foreach ($events as $event) { |
|
| 209 | + // any registrations for this event? |
|
| 210 | + if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
| 211 | + continue; |
|
| 212 | + } |
|
| 213 | + $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
|
| 214 | + $upcoming_class = $event->is_upcoming() ? ' ee-upcoming-event' : ''; |
|
| 215 | + |
|
| 216 | + $event_options[] = [ |
|
| 217 | + 'id' => $event->ID(), |
|
| 218 | + 'text' => apply_filters( |
|
| 219 | + 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
| 220 | + $event->name(), |
|
| 221 | + $event |
|
| 222 | + ), |
|
| 223 | + 'class' => $expired_class . $upcoming_class, |
|
| 224 | + ]; |
|
| 225 | + if ($event->ID() === $this->event_id) { |
|
| 226 | + $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
|
| 227 | + $hide_expired_checked = $expired_class === '' ? $hide_expired_checked : ''; |
|
| 228 | + $this->hide_upcoming = $upcoming_class === '' ? $this->hide_upcoming : false; |
|
| 229 | + $hide_upcoming_checked = $upcoming_class === '' ? $hide_upcoming_checked : ''; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + $select_class = $this->hide_expired ? 'ee-hide-expired-events' : ''; |
|
| 234 | + $select_class .= $this->hide_upcoming ? ' ee-hide-upcoming-events' : ''; |
|
| 235 | + $select_input = EEH_Form_Fields::select_input( |
|
| 236 | + 'event_id', |
|
| 237 | + $event_options, |
|
| 238 | + $this->event_id, |
|
| 239 | + '', |
|
| 240 | + $select_class |
|
| 241 | + ); |
|
| 242 | + |
|
| 243 | + $filters[] = ' |
|
| 244 | 244 | <div class="ee-event-filter__wrapper"> |
| 245 | 245 | <label class="ee-event-filter-main-label"> |
| 246 | 246 | ' . esc_html__('Check-in Status for', 'event_espresso') . ' |
@@ -250,435 +250,435 @@ discard block |
||
| 250 | 250 | <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label> |
| 251 | 251 | ' . $select_input . ' |
| 252 | 252 | </span>'; |
| 253 | - // DTT datetimes filter |
|
| 254 | - $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent( |
|
| 255 | - $hide_upcoming_checked === 'checked' |
|
| 256 | - ); |
|
| 257 | - if (count($datetimes_for_event) > 1) { |
|
| 258 | - $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso'); |
|
| 259 | - foreach ($datetimes_for_event as $datetime) { |
|
| 260 | - if ($datetime instanceof EE_Datetime) { |
|
| 261 | - $datetime_string = $datetime->name(); |
|
| 262 | - $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
| 263 | - $datetime_string .= $datetime->date_and_time_range(); |
|
| 264 | - $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
|
| 265 | - $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
|
| 266 | - $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
|
| 267 | - // now put it all together |
|
| 268 | - $datetimes[ $datetime->ID() ] = $datetime_string; |
|
| 269 | - } |
|
| 270 | - } |
|
| 271 | - $filters[] = ' |
|
| 253 | + // DTT datetimes filter |
|
| 254 | + $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent( |
|
| 255 | + $hide_upcoming_checked === 'checked' |
|
| 256 | + ); |
|
| 257 | + if (count($datetimes_for_event) > 1) { |
|
| 258 | + $datetimes[0] = esc_html__(' - select a datetime - ', 'event_espresso'); |
|
| 259 | + foreach ($datetimes_for_event as $datetime) { |
|
| 260 | + if ($datetime instanceof EE_Datetime) { |
|
| 261 | + $datetime_string = $datetime->name(); |
|
| 262 | + $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
| 263 | + $datetime_string .= $datetime->date_and_time_range(); |
|
| 264 | + $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
|
| 265 | + $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
|
| 266 | + $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
|
| 267 | + // now put it all together |
|
| 268 | + $datetimes[ $datetime->ID() ] = $datetime_string; |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | + $filters[] = ' |
|
| 272 | 272 | <span class="ee-datetime-selector"> |
| 273 | 273 | <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label> |
| 274 | 274 | ' . EEH_Form_Fields::select_input( |
| 275 | - 'DTT_ID', |
|
| 276 | - $datetimes, |
|
| 277 | - $this->datetime_id |
|
| 278 | - ) . ' |
|
| 275 | + 'DTT_ID', |
|
| 276 | + $datetimes, |
|
| 277 | + $this->datetime_id |
|
| 278 | + ) . ' |
|
| 279 | 279 | </span>'; |
| 280 | - } |
|
| 281 | - $filters[] = ' |
|
| 280 | + } |
|
| 281 | + $filters[] = ' |
|
| 282 | 282 | <span class="ee-hide-upcoming-check"> |
| 283 | 283 | <label for="js-ee-hide-upcoming-events"> |
| 284 | 284 | <input type="checkbox" id="js-ee-hide-upcoming-events" name="hide_upcoming" ' |
| 285 | - . $hide_upcoming_checked |
|
| 286 | - . '> |
|
| 285 | + . $hide_upcoming_checked |
|
| 286 | + . '> |
|
| 287 | 287 | ' |
| 288 | - . esc_html__('Hide Upcoming Events', 'event_espresso') |
|
| 289 | - . ' |
|
| 288 | + . esc_html__('Hide Upcoming Events', 'event_espresso') |
|
| 289 | + . ' |
|
| 290 | 290 | </label> |
| 291 | 291 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" |
| 292 | 292 | aria-label="' |
| 293 | - . esc_html__( |
|
| 294 | - 'Will not display events with start dates in the future (ie: have not yet begun)', |
|
| 295 | - 'event_espresso' |
|
| 296 | - ) . '" |
|
| 293 | + . esc_html__( |
|
| 294 | + 'Will not display events with start dates in the future (ie: have not yet begun)', |
|
| 295 | + 'event_espresso' |
|
| 296 | + ) . '" |
|
| 297 | 297 | ></span> |
| 298 | 298 | </span> |
| 299 | 299 | <span class="ee-hide-expired-check"> |
| 300 | 300 | <label for="js-ee-hide-expired-events"> |
| 301 | 301 | <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" ' |
| 302 | - . $hide_expired_checked |
|
| 303 | - . '> |
|
| 302 | + . $hide_expired_checked |
|
| 303 | + . '> |
|
| 304 | 304 | ' . esc_html__('Hide Expired Events', 'event_espresso') . ' |
| 305 | 305 | </label> |
| 306 | 306 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" |
| 307 | 307 | aria-label="' |
| 308 | - . esc_html__( |
|
| 309 | - 'Will not display events with end dates in the past (ie: have already finished)', |
|
| 310 | - 'event_espresso' |
|
| 311 | - ) |
|
| 312 | - . '" |
|
| 308 | + . esc_html__( |
|
| 309 | + 'Will not display events with end dates in the past (ie: have already finished)', |
|
| 310 | + 'event_espresso' |
|
| 311 | + ) |
|
| 312 | + . '" |
|
| 313 | 313 | ></span> |
| 314 | 314 | </span> |
| 315 | 315 | </div> |
| 316 | 316 | </div>'; |
| 317 | - return $filters; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * @throws EE_Error |
|
| 323 | - * @throws ReflectionException |
|
| 324 | - */ |
|
| 325 | - protected function _add_view_counts() |
|
| 326 | - { |
|
| 327 | - $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * @return int |
|
| 333 | - * @throws EE_Error |
|
| 334 | - * @throws ReflectionException |
|
| 335 | - */ |
|
| 336 | - protected function _get_total_event_attendees(): int |
|
| 337 | - { |
|
| 338 | - $query_params = []; |
|
| 339 | - if ($this->event_id) { |
|
| 340 | - $query_params[0]['EVT_ID'] = $this->event_id; |
|
| 341 | - } |
|
| 342 | - // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
| 343 | - if ($this->datetime_id) { |
|
| 344 | - $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id; |
|
| 345 | - } |
|
| 346 | - $status_ids_array = apply_filters( |
|
| 347 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 348 | - [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved] |
|
| 349 | - ); |
|
| 350 | - $query_params[0]['STS_ID'] = ['IN', $status_ids_array]; |
|
| 351 | - return EEM_Registration::instance()->count($query_params); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * @param EE_Registration $item |
|
| 357 | - * @return string |
|
| 358 | - * @throws EE_Error |
|
| 359 | - * @throws ReflectionException |
|
| 360 | - */ |
|
| 361 | - public function column_cb($item): string |
|
| 362 | - { |
|
| 363 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * column_REG_att_checked_in |
|
| 369 | - * |
|
| 370 | - * @param EE_Registration $registration |
|
| 371 | - * @return string |
|
| 372 | - * @throws EE_Error |
|
| 373 | - * @throws InvalidArgumentException |
|
| 374 | - * @throws InvalidDataTypeException |
|
| 375 | - * @throws InvalidInterfaceException |
|
| 376 | - * @throws ReflectionException |
|
| 377 | - */ |
|
| 378 | - public function column__REG_att_checked_in(EE_Registration $registration): string |
|
| 379 | - { |
|
| 380 | - // we need a local variable for the datetime for each row |
|
| 381 | - // (so that we don't pollute state for the entire table) |
|
| 382 | - // so let's try to get it from the registration's event |
|
| 383 | - $DTT_ID = $this->datetime_id; |
|
| 384 | - if (! $DTT_ID) { |
|
| 385 | - $reg_ticket_datetimes = $registration->ticket()->datetimes(); |
|
| 386 | - if (count($reg_ticket_datetimes) === 1) { |
|
| 387 | - $reg_ticket_datetime = reset($reg_ticket_datetimes); |
|
| 388 | - $DTT_ID = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0; |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - if (! $DTT_ID) { |
|
| 393 | - $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration); |
|
| 394 | - $datetime = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID); |
|
| 395 | - $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
| 399 | - $registration, |
|
| 400 | - $DTT_ID |
|
| 401 | - ); |
|
| 402 | - |
|
| 403 | - $aria_label = $checkin_status_dashicon->ariaLabel(); |
|
| 404 | - $dashicon_class = $checkin_status_dashicon->cssClasses(); |
|
| 405 | - $attributes = ' onClick="return false"'; |
|
| 406 | - $button_class = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box'; |
|
| 407 | - |
|
| 408 | - if ( |
|
| 409 | - $DTT_ID |
|
| 410 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 411 | - 'ee_edit_checkin', |
|
| 412 | - 'espresso_registrations_toggle_checkin_status', |
|
| 413 | - $registration->ID() |
|
| 414 | - ) |
|
| 415 | - ) { |
|
| 416 | - // overwrite the disabled attribute with data attributes for performing checkin |
|
| 417 | - $attributes = 'data-_regid="' . $registration->ID() . '"'; |
|
| 418 | - $attributes .= ' data-dttid="' . $DTT_ID . '"'; |
|
| 419 | - $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"'; |
|
| 420 | - $button_class .= ' clickable trigger-checkin'; |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - $content = ' |
|
| 317 | + return $filters; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * @throws EE_Error |
|
| 323 | + * @throws ReflectionException |
|
| 324 | + */ |
|
| 325 | + protected function _add_view_counts() |
|
| 326 | + { |
|
| 327 | + $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * @return int |
|
| 333 | + * @throws EE_Error |
|
| 334 | + * @throws ReflectionException |
|
| 335 | + */ |
|
| 336 | + protected function _get_total_event_attendees(): int |
|
| 337 | + { |
|
| 338 | + $query_params = []; |
|
| 339 | + if ($this->event_id) { |
|
| 340 | + $query_params[0]['EVT_ID'] = $this->event_id; |
|
| 341 | + } |
|
| 342 | + // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
| 343 | + if ($this->datetime_id) { |
|
| 344 | + $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id; |
|
| 345 | + } |
|
| 346 | + $status_ids_array = apply_filters( |
|
| 347 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 348 | + [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved] |
|
| 349 | + ); |
|
| 350 | + $query_params[0]['STS_ID'] = ['IN', $status_ids_array]; |
|
| 351 | + return EEM_Registration::instance()->count($query_params); |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * @param EE_Registration $item |
|
| 357 | + * @return string |
|
| 358 | + * @throws EE_Error |
|
| 359 | + * @throws ReflectionException |
|
| 360 | + */ |
|
| 361 | + public function column_cb($item): string |
|
| 362 | + { |
|
| 363 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * column_REG_att_checked_in |
|
| 369 | + * |
|
| 370 | + * @param EE_Registration $registration |
|
| 371 | + * @return string |
|
| 372 | + * @throws EE_Error |
|
| 373 | + * @throws InvalidArgumentException |
|
| 374 | + * @throws InvalidDataTypeException |
|
| 375 | + * @throws InvalidInterfaceException |
|
| 376 | + * @throws ReflectionException |
|
| 377 | + */ |
|
| 378 | + public function column__REG_att_checked_in(EE_Registration $registration): string |
|
| 379 | + { |
|
| 380 | + // we need a local variable for the datetime for each row |
|
| 381 | + // (so that we don't pollute state for the entire table) |
|
| 382 | + // so let's try to get it from the registration's event |
|
| 383 | + $DTT_ID = $this->datetime_id; |
|
| 384 | + if (! $DTT_ID) { |
|
| 385 | + $reg_ticket_datetimes = $registration->ticket()->datetimes(); |
|
| 386 | + if (count($reg_ticket_datetimes) === 1) { |
|
| 387 | + $reg_ticket_datetime = reset($reg_ticket_datetimes); |
|
| 388 | + $DTT_ID = $reg_ticket_datetime instanceof EE_Datetime ? $reg_ticket_datetime->ID() : 0; |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + if (! $DTT_ID) { |
|
| 393 | + $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration); |
|
| 394 | + $datetime = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID); |
|
| 395 | + $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
| 399 | + $registration, |
|
| 400 | + $DTT_ID |
|
| 401 | + ); |
|
| 402 | + |
|
| 403 | + $aria_label = $checkin_status_dashicon->ariaLabel(); |
|
| 404 | + $dashicon_class = $checkin_status_dashicon->cssClasses(); |
|
| 405 | + $attributes = ' onClick="return false"'; |
|
| 406 | + $button_class = 'button button--secondary button--icon-only ee-aria-tooltip ee-aria-tooltip--big-box'; |
|
| 407 | + |
|
| 408 | + if ( |
|
| 409 | + $DTT_ID |
|
| 410 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 411 | + 'ee_edit_checkin', |
|
| 412 | + 'espresso_registrations_toggle_checkin_status', |
|
| 413 | + $registration->ID() |
|
| 414 | + ) |
|
| 415 | + ) { |
|
| 416 | + // overwrite the disabled attribute with data attributes for performing checkin |
|
| 417 | + $attributes = 'data-_regid="' . $registration->ID() . '"'; |
|
| 418 | + $attributes .= ' data-dttid="' . $DTT_ID . '"'; |
|
| 419 | + $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"'; |
|
| 420 | + $button_class .= ' clickable trigger-checkin'; |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + $content = ' |
|
| 424 | 424 | <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '> |
| 425 | 425 | <span class="' . $dashicon_class . '" ></span> |
| 426 | 426 | </button> |
| 427 | 427 | <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>'; |
| 428 | - return $this->columnContent('_REG_att_checked_in', $content, 'center'); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - /** |
|
| 433 | - * @param EE_Registration $registration |
|
| 434 | - * @return string |
|
| 435 | - * @throws EE_Error |
|
| 436 | - * @throws ReflectionException |
|
| 437 | - */ |
|
| 438 | - public function column_ATT_name(EE_Registration $registration): string |
|
| 439 | - { |
|
| 440 | - $attendee = $registration->attendee(); |
|
| 441 | - if (! $attendee instanceof EE_Attendee) { |
|
| 442 | - return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
| 443 | - } |
|
| 444 | - // edit attendee link |
|
| 445 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 446 | - ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
| 447 | - REG_ADMIN_URL |
|
| 448 | - ); |
|
| 449 | - $name_link = ' |
|
| 428 | + return $this->columnContent('_REG_att_checked_in', $content, 'center'); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + /** |
|
| 433 | + * @param EE_Registration $registration |
|
| 434 | + * @return string |
|
| 435 | + * @throws EE_Error |
|
| 436 | + * @throws ReflectionException |
|
| 437 | + */ |
|
| 438 | + public function column_ATT_name(EE_Registration $registration): string |
|
| 439 | + { |
|
| 440 | + $attendee = $registration->attendee(); |
|
| 441 | + if (! $attendee instanceof EE_Attendee) { |
|
| 442 | + return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
| 443 | + } |
|
| 444 | + // edit attendee link |
|
| 445 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 446 | + ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
| 447 | + REG_ADMIN_URL |
|
| 448 | + ); |
|
| 449 | + $name_link = ' |
|
| 450 | 450 | <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" |
| 451 | 451 | aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '"> |
| 452 | 452 | </span>'; |
| 453 | - $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
| 454 | - 'ee_edit_contacts', |
|
| 455 | - 'espresso_registrations_edit_attendee' |
|
| 456 | - ) |
|
| 457 | - ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__( |
|
| 458 | - 'View Registration Details', |
|
| 459 | - 'event_espresso' |
|
| 460 | - ) . '">' |
|
| 461 | - . $registration->attendee()->full_name() |
|
| 462 | - . '</a>' |
|
| 463 | - : $registration->attendee()->full_name(); |
|
| 464 | - $name_link .= $registration->count() === 1 |
|
| 465 | - ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
|
| 466 | - : ''; |
|
| 467 | - // add group details |
|
| 468 | - $name_link .= ' ' . sprintf( |
|
| 469 | - esc_html__('(%s of %s)', 'event_espresso'), |
|
| 470 | - $registration->count(), |
|
| 471 | - $registration->group_size() |
|
| 472 | - ); |
|
| 473 | - // add regcode |
|
| 474 | - $link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 475 | - ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
| 476 | - REG_ADMIN_URL |
|
| 477 | - ); |
|
| 478 | - $name_link .= '<br>'; |
|
| 479 | - $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
| 480 | - 'ee_read_registration', |
|
| 481 | - 'view_registration', |
|
| 482 | - $registration->ID() |
|
| 483 | - ) |
|
| 484 | - ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__( |
|
| 485 | - 'View Registration Details', |
|
| 486 | - 'event_espresso' |
|
| 487 | - ) . '">' |
|
| 488 | - . $registration->reg_code() |
|
| 489 | - . '</a>' |
|
| 490 | - : $registration->reg_code(); |
|
| 491 | - |
|
| 492 | - $actions = []; |
|
| 493 | - if ( |
|
| 494 | - $this->datetime_id |
|
| 495 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 496 | - 'ee_read_checkins', |
|
| 497 | - 'espresso_registrations_registration_checkins' |
|
| 498 | - ) |
|
| 499 | - ) { |
|
| 500 | - $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 501 | - ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id], |
|
| 502 | - REG_ADMIN_URL |
|
| 503 | - ); |
|
| 504 | - // get the timestamps for this registration's checkins, related to the selected datetime |
|
| 505 | - /** @var EE_Checkin[] $checkins */ |
|
| 506 | - $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]); |
|
| 507 | - if (! empty($checkins)) { |
|
| 508 | - // get the last timestamp |
|
| 509 | - $last_checkin = end($checkins); |
|
| 510 | - // get timestamp string |
|
| 511 | - $timestamp_string = $last_checkin->get_datetime('CHK_timestamp'); |
|
| 512 | - $actions['checkin'] = ' |
|
| 453 | + $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
| 454 | + 'ee_edit_contacts', |
|
| 455 | + 'espresso_registrations_edit_attendee' |
|
| 456 | + ) |
|
| 457 | + ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__( |
|
| 458 | + 'View Registration Details', |
|
| 459 | + 'event_espresso' |
|
| 460 | + ) . '">' |
|
| 461 | + . $registration->attendee()->full_name() |
|
| 462 | + . '</a>' |
|
| 463 | + : $registration->attendee()->full_name(); |
|
| 464 | + $name_link .= $registration->count() === 1 |
|
| 465 | + ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
|
| 466 | + : ''; |
|
| 467 | + // add group details |
|
| 468 | + $name_link .= ' ' . sprintf( |
|
| 469 | + esc_html__('(%s of %s)', 'event_espresso'), |
|
| 470 | + $registration->count(), |
|
| 471 | + $registration->group_size() |
|
| 472 | + ); |
|
| 473 | + // add regcode |
|
| 474 | + $link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 475 | + ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
|
| 476 | + REG_ADMIN_URL |
|
| 477 | + ); |
|
| 478 | + $name_link .= '<br>'; |
|
| 479 | + $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
| 480 | + 'ee_read_registration', |
|
| 481 | + 'view_registration', |
|
| 482 | + $registration->ID() |
|
| 483 | + ) |
|
| 484 | + ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__( |
|
| 485 | + 'View Registration Details', |
|
| 486 | + 'event_espresso' |
|
| 487 | + ) . '">' |
|
| 488 | + . $registration->reg_code() |
|
| 489 | + . '</a>' |
|
| 490 | + : $registration->reg_code(); |
|
| 491 | + |
|
| 492 | + $actions = []; |
|
| 493 | + if ( |
|
| 494 | + $this->datetime_id |
|
| 495 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 496 | + 'ee_read_checkins', |
|
| 497 | + 'espresso_registrations_registration_checkins' |
|
| 498 | + ) |
|
| 499 | + ) { |
|
| 500 | + $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 501 | + ['action' => 'registration_checkins', '_REG_ID' => $registration->ID(), 'DTT_ID' => $this->datetime_id], |
|
| 502 | + REG_ADMIN_URL |
|
| 503 | + ); |
|
| 504 | + // get the timestamps for this registration's checkins, related to the selected datetime |
|
| 505 | + /** @var EE_Checkin[] $checkins */ |
|
| 506 | + $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]); |
|
| 507 | + if (! empty($checkins)) { |
|
| 508 | + // get the last timestamp |
|
| 509 | + $last_checkin = end($checkins); |
|
| 510 | + // get timestamp string |
|
| 511 | + $timestamp_string = $last_checkin->get_datetime('CHK_timestamp'); |
|
| 512 | + $actions['checkin'] = ' |
|
| 513 | 513 | <a class="ee-aria-tooltip" |
| 514 | 514 | href="' . $checkin_list_url . '" |
| 515 | 515 | aria-label="' . esc_attr__( |
| 516 | - 'View this registrant\'s check-ins/checkouts for the datetime', |
|
| 517 | - 'event_espresso' |
|
| 518 | - ) . '" |
|
| 516 | + 'View this registrant\'s check-ins/checkouts for the datetime', |
|
| 517 | + 'event_espresso' |
|
| 518 | + ) . '" |
|
| 519 | 519 | > |
| 520 | 520 | ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . ' |
| 521 | 521 | </a>'; |
| 522 | - } |
|
| 523 | - } |
|
| 524 | - $content = (! empty($this->datetime_id) && ! empty($checkins)) |
|
| 525 | - ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
| 526 | - : $name_link; |
|
| 527 | - return $this->columnContent('ATT_name', $content); |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - |
|
| 531 | - /** |
|
| 532 | - * @param EE_Registration $registration |
|
| 533 | - * @return string |
|
| 534 | - * @throws EE_Error |
|
| 535 | - * @throws EE_Error |
|
| 536 | - * @throws ReflectionException |
|
| 537 | - */ |
|
| 538 | - public function column_ATT_email(EE_Registration $registration): string |
|
| 539 | - { |
|
| 540 | - $attendee = $registration->attendee(); |
|
| 541 | - $content = $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
| 542 | - return $this->columnContent('ATT_email', $content); |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * @param EE_Registration $registration |
|
| 548 | - * @return string |
|
| 549 | - * @throws EE_Error |
|
| 550 | - * @throws ReflectionException |
|
| 551 | - */ |
|
| 552 | - public function column_Event(EE_Registration $registration): string |
|
| 553 | - { |
|
| 554 | - try { |
|
| 555 | - $event = $this->event instanceof EE_Event ? $this->event : $registration->event(); |
|
| 556 | - $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 557 | - ['action' => 'event_registrations', 'event_id' => $event->ID()], |
|
| 558 | - REG_ADMIN_URL |
|
| 559 | - ); |
|
| 560 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 561 | - 'ee_read_checkins', |
|
| 562 | - 'espresso_registrations_registration_checkins' |
|
| 563 | - ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="' |
|
| 564 | - . esc_attr__( |
|
| 565 | - 'View Checkins for this Event', |
|
| 566 | - 'event_espresso' |
|
| 567 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 568 | - } catch (EntityNotFoundException $e) { |
|
| 569 | - $content = esc_html__('Unknown', 'event_espresso'); |
|
| 570 | - } |
|
| 571 | - return $this->columnContent('Event', $content); |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * @param EE_Registration $registration |
|
| 577 | - * @return string |
|
| 578 | - * @throws EE_Error |
|
| 579 | - * @throws ReflectionException |
|
| 580 | - */ |
|
| 581 | - public function column_PRC_name(EE_Registration $registration): string |
|
| 582 | - { |
|
| 583 | - $content = $registration->ticket() instanceof EE_Ticket |
|
| 584 | - ? $registration->ticket()->name() |
|
| 585 | - . '<span class="ee-entity--id">(ID:' . $registration->ticket()->ID() . ')</span>' |
|
| 586 | - : esc_html__( |
|
| 587 | - "Unknown", |
|
| 588 | - "event_espresso" |
|
| 589 | - ); |
|
| 590 | - return $this->columnContent('PRC_name', $content); |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - |
|
| 594 | - /** |
|
| 595 | - * column_REG_final_price |
|
| 596 | - * |
|
| 597 | - * @param EE_Registration $registration |
|
| 598 | - * @return string |
|
| 599 | - * @throws EE_Error |
|
| 600 | - * @throws ReflectionException |
|
| 601 | - */ |
|
| 602 | - public function column__REG_final_price(EE_Registration $registration): string |
|
| 603 | - { |
|
| 604 | - return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end'); |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - |
|
| 608 | - /** |
|
| 609 | - * column_TXN_paid |
|
| 610 | - * |
|
| 611 | - * @param EE_Registration $registration |
|
| 612 | - * @return string |
|
| 613 | - * @throws EE_Error |
|
| 614 | - * @throws ReflectionException |
|
| 615 | - */ |
|
| 616 | - public function column_TXN_paid(EE_Registration $registration): string |
|
| 617 | - { |
|
| 618 | - $content = ''; |
|
| 619 | - if ($registration->count() === 1) { |
|
| 620 | - if ($registration->transaction()->paid() >= $registration->transaction()->total()) { |
|
| 621 | - return '<div class="dashicons dashicons-yes green-icon"></div>'; |
|
| 622 | - } else { |
|
| 623 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 624 | - ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()], |
|
| 625 | - TXN_ADMIN_URL |
|
| 626 | - ); |
|
| 627 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 628 | - 'ee_read_transaction', |
|
| 629 | - 'espresso_transactions_view_transaction' |
|
| 630 | - ) ? ' |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + $content = (! empty($this->datetime_id) && ! empty($checkins)) |
|
| 525 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
| 526 | + : $name_link; |
|
| 527 | + return $this->columnContent('ATT_name', $content); |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + |
|
| 531 | + /** |
|
| 532 | + * @param EE_Registration $registration |
|
| 533 | + * @return string |
|
| 534 | + * @throws EE_Error |
|
| 535 | + * @throws EE_Error |
|
| 536 | + * @throws ReflectionException |
|
| 537 | + */ |
|
| 538 | + public function column_ATT_email(EE_Registration $registration): string |
|
| 539 | + { |
|
| 540 | + $attendee = $registration->attendee(); |
|
| 541 | + $content = $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
| 542 | + return $this->columnContent('ATT_email', $content); |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * @param EE_Registration $registration |
|
| 548 | + * @return string |
|
| 549 | + * @throws EE_Error |
|
| 550 | + * @throws ReflectionException |
|
| 551 | + */ |
|
| 552 | + public function column_Event(EE_Registration $registration): string |
|
| 553 | + { |
|
| 554 | + try { |
|
| 555 | + $event = $this->event instanceof EE_Event ? $this->event : $registration->event(); |
|
| 556 | + $checkin_link_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 557 | + ['action' => 'event_registrations', 'event_id' => $event->ID()], |
|
| 558 | + REG_ADMIN_URL |
|
| 559 | + ); |
|
| 560 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 561 | + 'ee_read_checkins', |
|
| 562 | + 'espresso_registrations_registration_checkins' |
|
| 563 | + ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="' |
|
| 564 | + . esc_attr__( |
|
| 565 | + 'View Checkins for this Event', |
|
| 566 | + 'event_espresso' |
|
| 567 | + ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 568 | + } catch (EntityNotFoundException $e) { |
|
| 569 | + $content = esc_html__('Unknown', 'event_espresso'); |
|
| 570 | + } |
|
| 571 | + return $this->columnContent('Event', $content); |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * @param EE_Registration $registration |
|
| 577 | + * @return string |
|
| 578 | + * @throws EE_Error |
|
| 579 | + * @throws ReflectionException |
|
| 580 | + */ |
|
| 581 | + public function column_PRC_name(EE_Registration $registration): string |
|
| 582 | + { |
|
| 583 | + $content = $registration->ticket() instanceof EE_Ticket |
|
| 584 | + ? $registration->ticket()->name() |
|
| 585 | + . '<span class="ee-entity--id">(ID:' . $registration->ticket()->ID() . ')</span>' |
|
| 586 | + : esc_html__( |
|
| 587 | + "Unknown", |
|
| 588 | + "event_espresso" |
|
| 589 | + ); |
|
| 590 | + return $this->columnContent('PRC_name', $content); |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + |
|
| 594 | + /** |
|
| 595 | + * column_REG_final_price |
|
| 596 | + * |
|
| 597 | + * @param EE_Registration $registration |
|
| 598 | + * @return string |
|
| 599 | + * @throws EE_Error |
|
| 600 | + * @throws ReflectionException |
|
| 601 | + */ |
|
| 602 | + public function column__REG_final_price(EE_Registration $registration): string |
|
| 603 | + { |
|
| 604 | + return $this->columnContent('_REG_final_price', $registration->pretty_final_price(), 'end'); |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + |
|
| 608 | + /** |
|
| 609 | + * column_TXN_paid |
|
| 610 | + * |
|
| 611 | + * @param EE_Registration $registration |
|
| 612 | + * @return string |
|
| 613 | + * @throws EE_Error |
|
| 614 | + * @throws ReflectionException |
|
| 615 | + */ |
|
| 616 | + public function column_TXN_paid(EE_Registration $registration): string |
|
| 617 | + { |
|
| 618 | + $content = ''; |
|
| 619 | + if ($registration->count() === 1) { |
|
| 620 | + if ($registration->transaction()->paid() >= $registration->transaction()->total()) { |
|
| 621 | + return '<div class="dashicons dashicons-yes green-icon"></div>'; |
|
| 622 | + } else { |
|
| 623 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 624 | + ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()], |
|
| 625 | + TXN_ADMIN_URL |
|
| 626 | + ); |
|
| 627 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 628 | + 'ee_read_transaction', |
|
| 629 | + 'espresso_transactions_view_transaction' |
|
| 630 | + ) ? ' |
|
| 631 | 631 | <a class="ee-aria-tooltip ee-status-color--' |
| 632 | - . $registration->transaction()->status_ID() |
|
| 633 | - . '" href="' |
|
| 634 | - . $view_txn_lnk_url |
|
| 635 | - . '" aria-label="' |
|
| 636 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 637 | - . '"> |
|
| 632 | + . $registration->transaction()->status_ID() |
|
| 633 | + . '" href="' |
|
| 634 | + . $view_txn_lnk_url |
|
| 635 | + . '" aria-label="' |
|
| 636 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 637 | + . '"> |
|
| 638 | 638 | ' |
| 639 | - . $registration->transaction()->pretty_paid() |
|
| 640 | - . ' |
|
| 639 | + . $registration->transaction()->pretty_paid() |
|
| 640 | + . ' |
|
| 641 | 641 | </a> |
| 642 | 642 | ' : $registration->transaction()->pretty_paid(); |
| 643 | - } |
|
| 644 | - } |
|
| 645 | - return $this->columnContent('TXN_paid', $content, 'end'); |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - |
|
| 649 | - /** |
|
| 650 | - * column_TXN_total |
|
| 651 | - * |
|
| 652 | - * @param EE_Registration $registration |
|
| 653 | - * @return string |
|
| 654 | - * @throws EE_Error |
|
| 655 | - * @throws ReflectionException |
|
| 656 | - */ |
|
| 657 | - public function column_TXN_total(EE_Registration $registration): string |
|
| 658 | - { |
|
| 659 | - $content = ''; |
|
| 660 | - $txn = $registration->transaction(); |
|
| 661 | - $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL); |
|
| 662 | - if ($registration->get('REG_count') === 1) { |
|
| 663 | - $line_total_obj = $txn->total_line_item(); |
|
| 664 | - $txn_total = $line_total_obj instanceof EE_Line_Item |
|
| 665 | - ? $line_total_obj->get_pretty('LIN_total') |
|
| 666 | - : esc_html__( |
|
| 667 | - 'View Transaction', |
|
| 668 | - 'event_espresso' |
|
| 669 | - ); |
|
| 670 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 671 | - 'ee_read_transaction', |
|
| 672 | - 'espresso_transactions_view_transaction' |
|
| 673 | - ) ? '<a class="ee-aria-tooltip" href="' |
|
| 674 | - . $view_txn_url |
|
| 675 | - . '" aria-label="' |
|
| 676 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 677 | - . '">' |
|
| 678 | - . $txn_total |
|
| 679 | - . '</a>' |
|
| 680 | - : $txn_total; |
|
| 681 | - } |
|
| 682 | - return $this->columnContent('TXN_total', $content, 'end'); |
|
| 683 | - } |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + return $this->columnContent('TXN_paid', $content, 'end'); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + |
|
| 649 | + /** |
|
| 650 | + * column_TXN_total |
|
| 651 | + * |
|
| 652 | + * @param EE_Registration $registration |
|
| 653 | + * @return string |
|
| 654 | + * @throws EE_Error |
|
| 655 | + * @throws ReflectionException |
|
| 656 | + */ |
|
| 657 | + public function column_TXN_total(EE_Registration $registration): string |
|
| 658 | + { |
|
| 659 | + $content = ''; |
|
| 660 | + $txn = $registration->transaction(); |
|
| 661 | + $view_txn_url = add_query_arg(['action' => 'view_transaction', 'TXN_ID' => $txn->ID()], TXN_ADMIN_URL); |
|
| 662 | + if ($registration->get('REG_count') === 1) { |
|
| 663 | + $line_total_obj = $txn->total_line_item(); |
|
| 664 | + $txn_total = $line_total_obj instanceof EE_Line_Item |
|
| 665 | + ? $line_total_obj->get_pretty('LIN_total') |
|
| 666 | + : esc_html__( |
|
| 667 | + 'View Transaction', |
|
| 668 | + 'event_espresso' |
|
| 669 | + ); |
|
| 670 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 671 | + 'ee_read_transaction', |
|
| 672 | + 'espresso_transactions_view_transaction' |
|
| 673 | + ) ? '<a class="ee-aria-tooltip" href="' |
|
| 674 | + . $view_txn_url |
|
| 675 | + . '" aria-label="' |
|
| 676 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 677 | + . '">' |
|
| 678 | + . $txn_total |
|
| 679 | + . '</a>' |
|
| 680 | + : $txn_total; |
|
| 681 | + } |
|
| 682 | + return $this->columnContent('TXN_total', $content, 'end'); |
|
| 683 | + } |
|
| 684 | 684 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | 'ajax' => true, |
| 115 | 115 | 'screen' => $this->_admin_page->get_current_screen()->id, |
| 116 | 116 | ]; |
| 117 | - $columns = []; |
|
| 117 | + $columns = []; |
|
| 118 | 118 | |
| 119 | 119 | $this->_columns = [ |
| 120 | 120 | '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | 'TXN_total' => esc_html__('Total', 'event_espresso'), |
| 128 | 128 | ]; |
| 129 | 129 | // Add/remove columns when an event has been selected |
| 130 | - if (! empty($this->event_id)) { |
|
| 130 | + if ( ! empty($this->event_id)) { |
|
| 131 | 131 | // Render a checkbox column |
| 132 | 132 | $columns['cb'] = '<input type="checkbox" />'; |
| 133 | 133 | $this->_has_checkbox_column = true; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $this->event_id, |
| 145 | 145 | $this->datetime_id |
| 146 | 146 | ); |
| 147 | - if (! empty($csv_report)) { |
|
| 147 | + if ( ! empty($csv_report)) { |
|
| 148 | 148 | $this->_bottom_buttons['csv_reg_report'] = $csv_report; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | ]; |
| 208 | 208 | foreach ($events as $event) { |
| 209 | 209 | // any registrations for this event? |
| 210 | - if (! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
| 210 | + if ( ! $event instanceof EE_Event/* || ! $event->get_count_of_all_registrations()*/) { |
|
| 211 | 211 | continue; |
| 212 | 212 | } |
| 213 | 213 | $expired_class = $event->is_expired() ? 'ee-expired-event' : ''; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $event->name(), |
| 221 | 221 | $event |
| 222 | 222 | ), |
| 223 | - 'class' => $expired_class . $upcoming_class, |
|
| 223 | + 'class' => $expired_class.$upcoming_class, |
|
| 224 | 224 | ]; |
| 225 | 225 | if ($event->ID() === $this->event_id) { |
| 226 | 226 | $this->hide_expired = $expired_class === '' ? $this->hide_expired : false; |
@@ -243,12 +243,12 @@ discard block |
||
| 243 | 243 | $filters[] = ' |
| 244 | 244 | <div class="ee-event-filter__wrapper"> |
| 245 | 245 | <label class="ee-event-filter-main-label"> |
| 246 | - ' . esc_html__('Check-in Status for', 'event_espresso') . ' |
|
| 246 | + ' . esc_html__('Check-in Status for', 'event_espresso').' |
|
| 247 | 247 | </label> |
| 248 | 248 | <div class="ee-event-filter ee-status-outline ee-status-bg--info"> |
| 249 | 249 | <span class="ee-event-selector"> |
| 250 | - <label for="event_id">' . esc_html__('Event', 'event_espresso') . '</label> |
|
| 251 | - ' . $select_input . ' |
|
| 250 | + <label for="event_id">' . esc_html__('Event', 'event_espresso').'</label> |
|
| 251 | + ' . $select_input.' |
|
| 252 | 252 | </span>'; |
| 253 | 253 | // DTT datetimes filter |
| 254 | 254 | $datetimes_for_event = $this->datetimes_for_event->getAllDatetimesForEvent( |
@@ -259,23 +259,23 @@ discard block |
||
| 259 | 259 | foreach ($datetimes_for_event as $datetime) { |
| 260 | 260 | if ($datetime instanceof EE_Datetime) { |
| 261 | 261 | $datetime_string = $datetime->name(); |
| 262 | - $datetime_string = ! empty($datetime_string) ? $datetime_string . ': ' : ''; |
|
| 262 | + $datetime_string = ! empty($datetime_string) ? $datetime_string.': ' : ''; |
|
| 263 | 263 | $datetime_string .= $datetime->date_and_time_range(); |
| 264 | 264 | $datetime_string .= $datetime->is_active() ? ' ∗' : ''; |
| 265 | 265 | $datetime_string .= $datetime->is_expired() ? ' «' : ''; |
| 266 | 266 | $datetime_string .= $datetime->is_upcoming() ? ' »' : ''; |
| 267 | 267 | // now put it all together |
| 268 | - $datetimes[ $datetime->ID() ] = $datetime_string; |
|
| 268 | + $datetimes[$datetime->ID()] = $datetime_string; |
|
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | $filters[] = ' |
| 272 | 272 | <span class="ee-datetime-selector"> |
| 273 | - <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso') . '</label> |
|
| 273 | + <label for="DTT_ID">' . esc_html__('Datetime', 'event_espresso').'</label> |
|
| 274 | 274 | ' . EEH_Form_Fields::select_input( |
| 275 | 275 | 'DTT_ID', |
| 276 | 276 | $datetimes, |
| 277 | 277 | $this->datetime_id |
| 278 | - ) . ' |
|
| 278 | + ).' |
|
| 279 | 279 | </span>'; |
| 280 | 280 | } |
| 281 | 281 | $filters[] = ' |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | . esc_html__( |
| 294 | 294 | 'Will not display events with start dates in the future (ie: have not yet begun)', |
| 295 | 295 | 'event_espresso' |
| 296 | - ) . '" |
|
| 296 | + ).'" |
|
| 297 | 297 | ></span> |
| 298 | 298 | </span> |
| 299 | 299 | <span class="ee-hide-expired-check"> |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | <input type="checkbox" id="js-ee-hide-expired-events" name="hide_expired" ' |
| 302 | 302 | . $hide_expired_checked |
| 303 | 303 | . '> |
| 304 | - ' . esc_html__('Hide Expired Events', 'event_espresso') . ' |
|
| 304 | + ' . esc_html__('Hide Expired Events', 'event_espresso').' |
|
| 305 | 305 | </label> |
| 306 | 306 | <span class="ee-help-btn dashicons dashicons-editor-help ee-aria-tooltip" |
| 307 | 307 | aria-label="' |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | if ($this->datetime_id) { |
| 344 | 344 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $this->datetime_id; |
| 345 | 345 | } |
| 346 | - $status_ids_array = apply_filters( |
|
| 346 | + $status_ids_array = apply_filters( |
|
| 347 | 347 | 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
| 348 | 348 | [EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved] |
| 349 | 349 | ); |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | // (so that we don't pollute state for the entire table) |
| 382 | 382 | // so let's try to get it from the registration's event |
| 383 | 383 | $DTT_ID = $this->datetime_id; |
| 384 | - if (! $DTT_ID) { |
|
| 384 | + if ( ! $DTT_ID) { |
|
| 385 | 385 | $reg_ticket_datetimes = $registration->ticket()->datetimes(); |
| 386 | 386 | if (count($reg_ticket_datetimes) === 1) { |
| 387 | 387 | $reg_ticket_datetime = reset($reg_ticket_datetimes); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - if (! $DTT_ID) { |
|
| 392 | + if ( ! $DTT_ID) { |
|
| 393 | 393 | $this->datetimes_for_current_row = DatetimesForEventCheckIn::fromRegistration($registration); |
| 394 | 394 | $datetime = $this->datetimes_for_current_row->getOneDatetimeForEvent($DTT_ID); |
| 395 | 395 | $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
@@ -414,17 +414,17 @@ discard block |
||
| 414 | 414 | ) |
| 415 | 415 | ) { |
| 416 | 416 | // overwrite the disabled attribute with data attributes for performing checkin |
| 417 | - $attributes = 'data-_regid="' . $registration->ID() . '"'; |
|
| 418 | - $attributes .= ' data-dttid="' . $DTT_ID . '"'; |
|
| 419 | - $attributes .= ' data-nonce="' . wp_create_nonce('checkin_nonce') . '"'; |
|
| 417 | + $attributes = 'data-_regid="'.$registration->ID().'"'; |
|
| 418 | + $attributes .= ' data-dttid="'.$DTT_ID.'"'; |
|
| 419 | + $attributes .= ' data-nonce="'.wp_create_nonce('checkin_nonce').'"'; |
|
| 420 | 420 | $button_class .= ' clickable trigger-checkin'; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $content = ' |
| 424 | - <button aria-label="' . $aria_label . '" class="' . $button_class . '" ' . $attributes . '> |
|
| 425 | - <span class="' . $dashicon_class . '" ></span> |
|
| 424 | + <button aria-label="' . $aria_label.'" class="'.$button_class.'" '.$attributes.'> |
|
| 425 | + <span class="' . $dashicon_class.'" ></span> |
|
| 426 | 426 | </button> |
| 427 | - <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration) . '</span>'; |
|
| 427 | + <span class="show-on-mobile-view-only">' . $this->column_ATT_name($registration).'</span>'; |
|
| 428 | 428 | return $this->columnContent('_REG_att_checked_in', $content, 'center'); |
| 429 | 429 | } |
| 430 | 430 | |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | public function column_ATT_name(EE_Registration $registration): string |
| 439 | 439 | { |
| 440 | 440 | $attendee = $registration->attendee(); |
| 441 | - if (! $attendee instanceof EE_Attendee) { |
|
| 441 | + if ( ! $attendee instanceof EE_Attendee) { |
|
| 442 | 442 | return esc_html__('No contact record for this registration.', 'event_espresso'); |
| 443 | 443 | } |
| 444 | 444 | // edit attendee link |
@@ -446,32 +446,32 @@ discard block |
||
| 446 | 446 | ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
| 447 | 447 | REG_ADMIN_URL |
| 448 | 448 | ); |
| 449 | - $name_link = ' |
|
| 450 | - <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" |
|
| 451 | - aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '"> |
|
| 449 | + $name_link = ' |
|
| 450 | + <span class="ee-status-dot ee-status-bg--' . esc_attr($registration->status_ID()).' ee-aria-tooltip" |
|
| 451 | + aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence').'"> |
|
| 452 | 452 | </span>'; |
| 453 | - $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
| 453 | + $name_link .= EE_Registry::instance()->CAP->current_user_can( |
|
| 454 | 454 | 'ee_edit_contacts', |
| 455 | 455 | 'espresso_registrations_edit_attendee' |
| 456 | 456 | ) |
| 457 | - ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__( |
|
| 457 | + ? '<a class="ee-aria-tooltip" href="'.$edit_lnk_url.'" aria-label="'.esc_attr__( |
|
| 458 | 458 | 'View Registration Details', |
| 459 | 459 | 'event_espresso' |
| 460 | - ) . '">' |
|
| 460 | + ).'">' |
|
| 461 | 461 | . $registration->attendee()->full_name() |
| 462 | 462 | . '</a>' |
| 463 | 463 | : $registration->attendee()->full_name(); |
| 464 | - $name_link .= $registration->count() === 1 |
|
| 464 | + $name_link .= $registration->count() === 1 |
|
| 465 | 465 | ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
| 466 | 466 | : ''; |
| 467 | 467 | // add group details |
| 468 | - $name_link .= ' ' . sprintf( |
|
| 468 | + $name_link .= ' '.sprintf( |
|
| 469 | 469 | esc_html__('(%s of %s)', 'event_espresso'), |
| 470 | 470 | $registration->count(), |
| 471 | 471 | $registration->group_size() |
| 472 | 472 | ); |
| 473 | 473 | // add regcode |
| 474 | - $link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 474 | + $link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 475 | 475 | ['action' => 'view_registration', '_REG_ID' => $registration->ID()], |
| 476 | 476 | REG_ADMIN_URL |
| 477 | 477 | ); |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | 'view_registration', |
| 482 | 482 | $registration->ID() |
| 483 | 483 | ) |
| 484 | - ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__( |
|
| 484 | + ? '<a class="ee-aria-tooltip" href="'.$link.'" aria-label="'.esc_attr__( |
|
| 485 | 485 | 'View Registration Details', |
| 486 | 486 | 'event_espresso' |
| 487 | - ) . '">' |
|
| 487 | + ).'">' |
|
| 488 | 488 | . $registration->reg_code() |
| 489 | 489 | . '</a>' |
| 490 | 490 | : $registration->reg_code(); |
@@ -504,24 +504,24 @@ discard block |
||
| 504 | 504 | // get the timestamps for this registration's checkins, related to the selected datetime |
| 505 | 505 | /** @var EE_Checkin[] $checkins */ |
| 506 | 506 | $checkins = $registration->get_many_related('Checkin', [['DTT_ID' => $this->datetime_id]]); |
| 507 | - if (! empty($checkins)) { |
|
| 507 | + if ( ! empty($checkins)) { |
|
| 508 | 508 | // get the last timestamp |
| 509 | 509 | $last_checkin = end($checkins); |
| 510 | 510 | // get timestamp string |
| 511 | 511 | $timestamp_string = $last_checkin->get_datetime('CHK_timestamp'); |
| 512 | 512 | $actions['checkin'] = ' |
| 513 | 513 | <a class="ee-aria-tooltip" |
| 514 | - href="' . $checkin_list_url . '" |
|
| 514 | + href="' . $checkin_list_url.'" |
|
| 515 | 515 | aria-label="' . esc_attr__( |
| 516 | 516 | 'View this registrant\'s check-ins/checkouts for the datetime', |
| 517 | 517 | 'event_espresso' |
| 518 | - ) . '" |
|
| 518 | + ).'" |
|
| 519 | 519 | > |
| 520 | - ' . $last_checkin->getCheckInText() . ': ' . $timestamp_string . ' |
|
| 520 | + ' . $last_checkin->getCheckInText().': '.$timestamp_string.' |
|
| 521 | 521 | </a>'; |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | - $content = (! empty($this->datetime_id) && ! empty($checkins)) |
|
| 524 | + $content = ( ! empty($this->datetime_id) && ! empty($checkins)) |
|
| 525 | 525 | ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
| 526 | 526 | : $name_link; |
| 527 | 527 | return $this->columnContent('ATT_name', $content); |
@@ -557,14 +557,14 @@ discard block |
||
| 557 | 557 | ['action' => 'event_registrations', 'event_id' => $event->ID()], |
| 558 | 558 | REG_ADMIN_URL |
| 559 | 559 | ); |
| 560 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 560 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 561 | 561 | 'ee_read_checkins', |
| 562 | 562 | 'espresso_registrations_registration_checkins' |
| 563 | - ) ? '<a class="ee-aria-tooltip" href="' . $checkin_link_url . '" aria-label="' |
|
| 563 | + ) ? '<a class="ee-aria-tooltip" href="'.$checkin_link_url.'" aria-label="' |
|
| 564 | 564 | . esc_attr__( |
| 565 | 565 | 'View Checkins for this Event', |
| 566 | 566 | 'event_espresso' |
| 567 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 567 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
| 568 | 568 | } catch (EntityNotFoundException $e) { |
| 569 | 569 | $content = esc_html__('Unknown', 'event_espresso'); |
| 570 | 570 | } |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | { |
| 583 | 583 | $content = $registration->ticket() instanceof EE_Ticket |
| 584 | 584 | ? $registration->ticket()->name() |
| 585 | - . '<span class="ee-entity--id">(ID:' . $registration->ticket()->ID() . ')</span>' |
|
| 585 | + . '<span class="ee-entity--id">(ID:'.$registration->ticket()->ID().')</span>' |
|
| 586 | 586 | : esc_html__( |
| 587 | 587 | "Unknown", |
| 588 | 588 | "event_espresso" |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | ['action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()], |
| 625 | 625 | TXN_ADMIN_URL |
| 626 | 626 | ); |
| 627 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 627 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 628 | 628 | 'ee_read_transaction', |
| 629 | 629 | 'espresso_transactions_view_transaction' |
| 630 | 630 | ) ? ' |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | 'View Transaction', |
| 668 | 668 | 'event_espresso' |
| 669 | 669 | ); |
| 670 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 670 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
| 671 | 671 | 'ee_read_transaction', |
| 672 | 672 | 'espresso_transactions_view_transaction' |
| 673 | 673 | ) ? '<a class="ee-aria-tooltip" href="' |
@@ -16,1296 +16,1296 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Extend_Events_Admin_Page extends Events_Admin_Page |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Extend_Events_Admin_Page constructor. |
|
| 21 | - * |
|
| 22 | - * @param bool $routing |
|
| 23 | - * @throws ReflectionException |
|
| 24 | - */ |
|
| 25 | - public function __construct($routing = true) |
|
| 26 | - { |
|
| 27 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
| 28 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
| 29 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
| 30 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
| 31 | - } |
|
| 32 | - parent::__construct($routing); |
|
| 33 | - $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - protected function _set_page_config() |
|
| 38 | - { |
|
| 39 | - parent::_set_page_config(); |
|
| 40 | - |
|
| 41 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
| 42 | - // is there an evt_id in the request? |
|
| 43 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 44 | - $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
| 45 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
| 46 | - $new_page_routes = [ |
|
| 47 | - 'duplicate_event' => [ |
|
| 48 | - 'func' => '_duplicate_event', |
|
| 49 | - 'capability' => 'ee_edit_event', |
|
| 50 | - 'obj_id' => $EVT_ID, |
|
| 51 | - 'noheader' => true, |
|
| 52 | - ], |
|
| 53 | - 'import_page' => [ |
|
| 54 | - 'func' => '_import_page', |
|
| 55 | - 'capability' => 'import', |
|
| 56 | - ], |
|
| 57 | - 'import' => [ |
|
| 58 | - 'func' => '_import_events', |
|
| 59 | - 'capability' => 'import', |
|
| 60 | - 'noheader' => true, |
|
| 61 | - ], |
|
| 62 | - 'import_events' => [ |
|
| 63 | - 'func' => '_import_events', |
|
| 64 | - 'capability' => 'import', |
|
| 65 | - 'noheader' => true, |
|
| 66 | - ], |
|
| 67 | - 'export_events' => [ |
|
| 68 | - 'func' => '_events_export', |
|
| 69 | - 'capability' => 'export', |
|
| 70 | - 'noheader' => true, |
|
| 71 | - ], |
|
| 72 | - 'export_categories' => [ |
|
| 73 | - 'func' => '_categories_export', |
|
| 74 | - 'capability' => 'export', |
|
| 75 | - 'noheader' => true, |
|
| 76 | - ], |
|
| 77 | - 'sample_export_file' => [ |
|
| 78 | - 'func' => '_sample_export_file', |
|
| 79 | - 'capability' => 'export', |
|
| 80 | - 'noheader' => true, |
|
| 81 | - ], |
|
| 82 | - 'update_template_settings' => [ |
|
| 83 | - 'func' => '_update_template_settings', |
|
| 84 | - 'capability' => 'manage_options', |
|
| 85 | - 'noheader' => true, |
|
| 86 | - ], |
|
| 87 | - 'ticket_list_table' => [ |
|
| 88 | - 'func' => '_tickets_overview_list_table', |
|
| 89 | - 'capability' => 'ee_read_default_tickets', |
|
| 90 | - ], |
|
| 91 | - ]; |
|
| 92 | - $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
| 93 | - $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
| 94 | - // don't load these meta boxes if using the advanced editor |
|
| 95 | - if ( |
|
| 96 | - ! $this->admin_config->useAdvancedEditor() |
|
| 97 | - || ! $this->feature->allowed('use_default_ticket_manager') |
|
| 98 | - ) { |
|
| 99 | - $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
| 100 | - $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
| 101 | - |
|
| 102 | - $legacy_editor_page_routes = [ |
|
| 103 | - 'trash_ticket' => [ |
|
| 104 | - 'func' => '_trash_or_restore_ticket', |
|
| 105 | - 'capability' => 'ee_delete_default_ticket', |
|
| 106 | - 'obj_id' => $TKT_ID, |
|
| 107 | - 'noheader' => true, |
|
| 108 | - 'args' => ['trash' => true], |
|
| 109 | - ], |
|
| 110 | - 'trash_tickets' => [ |
|
| 111 | - 'func' => '_trash_or_restore_ticket', |
|
| 112 | - 'capability' => 'ee_delete_default_tickets', |
|
| 113 | - 'noheader' => true, |
|
| 114 | - 'args' => ['trash' => true], |
|
| 115 | - ], |
|
| 116 | - 'restore_ticket' => [ |
|
| 117 | - 'func' => '_trash_or_restore_ticket', |
|
| 118 | - 'capability' => 'ee_delete_default_ticket', |
|
| 119 | - 'obj_id' => $TKT_ID, |
|
| 120 | - 'noheader' => true, |
|
| 121 | - ], |
|
| 122 | - 'restore_tickets' => [ |
|
| 123 | - 'func' => '_trash_or_restore_ticket', |
|
| 124 | - 'capability' => 'ee_delete_default_tickets', |
|
| 125 | - 'noheader' => true, |
|
| 126 | - ], |
|
| 127 | - 'delete_ticket' => [ |
|
| 128 | - 'func' => '_delete_ticket', |
|
| 129 | - 'capability' => 'ee_delete_default_ticket', |
|
| 130 | - 'obj_id' => $TKT_ID, |
|
| 131 | - 'noheader' => true, |
|
| 132 | - ], |
|
| 133 | - 'delete_tickets' => [ |
|
| 134 | - 'func' => '_delete_ticket', |
|
| 135 | - 'capability' => 'ee_delete_default_tickets', |
|
| 136 | - 'noheader' => true, |
|
| 137 | - ], |
|
| 138 | - ]; |
|
| 139 | - $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 143 | - // partial route/config override |
|
| 144 | - $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
| 145 | - $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
| 146 | - |
|
| 147 | - // add default tickets tab and template settings nav tabs (note union at end) |
|
| 148 | - $this->_page_config = [ |
|
| 149 | - 'ticket_list_table' => [ |
|
| 150 | - 'nav' => [ |
|
| 151 | - 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
| 152 | - 'icon' => 'dashicons-tickets-alt', |
|
| 153 | - 'order' => 60, |
|
| 154 | - ], |
|
| 155 | - 'list_table' => 'Tickets_List_Table', |
|
| 156 | - 'require_nonce' => false, |
|
| 157 | - ], |
|
| 158 | - 'template_settings' => [ |
|
| 159 | - 'nav' => [ |
|
| 160 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 161 | - 'icon' => 'dashicons-layout', |
|
| 162 | - 'order' => 30, |
|
| 163 | - ], |
|
| 164 | - 'metaboxes' => array_merge( |
|
| 165 | - ['_publish_post_box'], |
|
| 166 | - $this->_default_espresso_metaboxes |
|
| 167 | - ), |
|
| 168 | - 'help_tabs' => [ |
|
| 169 | - 'general_settings_templates_help_tab' => [ |
|
| 170 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 171 | - 'filename' => 'general_settings_templates', |
|
| 172 | - ], |
|
| 173 | - ], |
|
| 174 | - 'require_nonce' => false, |
|
| 175 | - ], |
|
| 176 | - ] + $this->_page_config; |
|
| 177 | - |
|
| 178 | - // add filters and actions |
|
| 179 | - // modifying _views |
|
| 180 | - add_filter( |
|
| 181 | - 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
| 182 | - [$this, 'add_additional_datetime_button'], |
|
| 183 | - 10, |
|
| 184 | - 2 |
|
| 185 | - ); |
|
| 186 | - add_filter( |
|
| 187 | - 'FHEE_event_datetime_metabox_clone_button_template', |
|
| 188 | - [$this, 'add_datetime_clone_button'], |
|
| 189 | - 10, |
|
| 190 | - 2 |
|
| 191 | - ); |
|
| 192 | - add_filter( |
|
| 193 | - 'FHEE_event_datetime_metabox_timezones_template', |
|
| 194 | - [$this, 'datetime_timezones_template'], |
|
| 195 | - 10, |
|
| 196 | - 2 |
|
| 197 | - ); |
|
| 198 | - // filters for event list table |
|
| 199 | - add_filter( |
|
| 200 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 201 | - [$this, 'extra_list_table_actions'], |
|
| 202 | - 10, |
|
| 203 | - 2 |
|
| 204 | - ); |
|
| 205 | - // legend item |
|
| 206 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']); |
|
| 207 | - add_action('admin_init', [$this, 'admin_init']); |
|
| 208 | - // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
|
| 209 | - add_filter('get_sample_permalink_html', [DuplicateEventButton::class, 'addButton'], 8, 4); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * admin_init |
|
| 215 | - */ |
|
| 216 | - public function admin_init() |
|
| 217 | - { |
|
| 218 | - EE_Registry::$i18n_js_strings = array_merge( |
|
| 219 | - EE_Registry::$i18n_js_strings, |
|
| 220 | - [ |
|
| 221 | - 'image_confirm' => esc_html__( |
|
| 222 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 223 | - 'event_espresso' |
|
| 224 | - ), |
|
| 225 | - 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
| 226 | - 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
| 227 | - 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
| 228 | - 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
| 229 | - 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
| 230 | - ] |
|
| 231 | - ); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * Add per page screen options to the default ticket list table view. |
|
| 237 | - * |
|
| 238 | - * @throws InvalidArgumentException |
|
| 239 | - * @throws InvalidDataTypeException |
|
| 240 | - * @throws InvalidInterfaceException |
|
| 241 | - */ |
|
| 242 | - protected function _add_screen_options_ticket_list_table() |
|
| 243 | - { |
|
| 244 | - $this->_per_page_screen_option(); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @param string $return the current html |
|
| 250 | - * @param int $id the post id for the page |
|
| 251 | - * @param string|null $new_title What the title is |
|
| 252 | - * @param string|null $new_slug what the slug is |
|
| 253 | - * @return string |
|
| 254 | - * @deprecated 5.0.0.p |
|
| 255 | - */ |
|
| 256 | - public function extra_permalink_field_buttons( |
|
| 257 | - string $return, |
|
| 258 | - int $id, |
|
| 259 | - ?string $new_title, |
|
| 260 | - ?string $new_slug |
|
| 261 | - ): string { |
|
| 262 | - $return = DuplicateEventButton::addButton($return, $id, $new_title, $new_slug); |
|
| 263 | - return TicketSelectorShortcodeButton::addButton($return, $id, $new_title, $new_slug); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Set the list table views for the default ticket list table view. |
|
| 269 | - */ |
|
| 270 | - public function _set_list_table_views_ticket_list_table() |
|
| 271 | - { |
|
| 272 | - $this->_views = [ |
|
| 273 | - 'all' => [ |
|
| 274 | - 'slug' => 'all', |
|
| 275 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 276 | - 'count' => 0, |
|
| 277 | - 'bulk_action' => [ |
|
| 278 | - 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 279 | - ], |
|
| 280 | - ], |
|
| 281 | - 'trashed' => [ |
|
| 282 | - 'slug' => 'trashed', |
|
| 283 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 284 | - 'count' => 0, |
|
| 285 | - 'bulk_action' => [ |
|
| 286 | - 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 287 | - 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 288 | - ], |
|
| 289 | - ], |
|
| 290 | - ]; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * Enqueue scripts and styles for the event editor. |
|
| 296 | - */ |
|
| 297 | - public function load_scripts_styles_edit() |
|
| 298 | - { |
|
| 299 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
| 300 | - wp_register_script( |
|
| 301 | - 'ee-event-editor-heartbeat', |
|
| 302 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
| 303 | - ['ee_admin_js', 'heartbeat'], |
|
| 304 | - EVENT_ESPRESSO_VERSION, |
|
| 305 | - true |
|
| 306 | - ); |
|
| 307 | - wp_enqueue_script('ee-accounting'); |
|
| 308 | - wp_enqueue_script('ee-event-editor-heartbeat'); |
|
| 309 | - } |
|
| 310 | - wp_enqueue_script('event_editor_js'); |
|
| 311 | - wp_register_style( |
|
| 312 | - 'event-editor-css', |
|
| 313 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 314 | - ['ee-admin-css'], |
|
| 315 | - EVENT_ESPRESSO_VERSION |
|
| 316 | - ); |
|
| 317 | - wp_enqueue_style('event-editor-css'); |
|
| 318 | - // styles |
|
| 319 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * Sets the views for the default list table view. |
|
| 325 | - * |
|
| 326 | - * @throws EE_Error |
|
| 327 | - * @throws ReflectionException |
|
| 328 | - */ |
|
| 329 | - protected function _set_list_table_views_default() |
|
| 330 | - { |
|
| 331 | - parent::_set_list_table_views_default(); |
|
| 332 | - $new_views = [ |
|
| 333 | - 'today' => [ |
|
| 334 | - 'slug' => 'today', |
|
| 335 | - 'label' => esc_html__('Today', 'event_espresso'), |
|
| 336 | - 'count' => $this->total_events_today(), |
|
| 337 | - 'bulk_action' => [ |
|
| 338 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 339 | - ], |
|
| 340 | - ], |
|
| 341 | - 'month' => [ |
|
| 342 | - 'slug' => 'month', |
|
| 343 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 344 | - 'count' => $this->total_events_this_month(), |
|
| 345 | - 'bulk_action' => [ |
|
| 346 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 347 | - ], |
|
| 348 | - ], |
|
| 349 | - ]; |
|
| 350 | - $this->_views = array_merge($this->_views, $new_views); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * Returns the extra action links for the default list table view. |
|
| 356 | - * |
|
| 357 | - * @param array $action_links |
|
| 358 | - * @param EE_Event $event |
|
| 359 | - * @return array |
|
| 360 | - * @throws EE_Error |
|
| 361 | - * @throws ReflectionException |
|
| 362 | - */ |
|
| 363 | - public function extra_list_table_actions(array $action_links, EE_Event $event): array |
|
| 364 | - { |
|
| 365 | - if ( |
|
| 366 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 367 | - 'ee_read_registrations', |
|
| 368 | - 'espresso_registrations_reports', |
|
| 369 | - $event->ID() |
|
| 370 | - ) |
|
| 371 | - ) { |
|
| 372 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 373 | - [ |
|
| 374 | - 'action' => 'reports', |
|
| 375 | - 'EVT_ID' => $event->ID(), |
|
| 376 | - ], |
|
| 377 | - REG_ADMIN_URL |
|
| 378 | - ); |
|
| 379 | - |
|
| 380 | - $action_links[] = ' |
|
| 19 | + /** |
|
| 20 | + * Extend_Events_Admin_Page constructor. |
|
| 21 | + * |
|
| 22 | + * @param bool $routing |
|
| 23 | + * @throws ReflectionException |
|
| 24 | + */ |
|
| 25 | + public function __construct($routing = true) |
|
| 26 | + { |
|
| 27 | + if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
| 28 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
| 29 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
| 30 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
| 31 | + } |
|
| 32 | + parent::__construct($routing); |
|
| 33 | + $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + protected function _set_page_config() |
|
| 38 | + { |
|
| 39 | + parent::_set_page_config(); |
|
| 40 | + |
|
| 41 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
| 42 | + // is there an evt_id in the request? |
|
| 43 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 44 | + $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
|
| 45 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
| 46 | + $new_page_routes = [ |
|
| 47 | + 'duplicate_event' => [ |
|
| 48 | + 'func' => '_duplicate_event', |
|
| 49 | + 'capability' => 'ee_edit_event', |
|
| 50 | + 'obj_id' => $EVT_ID, |
|
| 51 | + 'noheader' => true, |
|
| 52 | + ], |
|
| 53 | + 'import_page' => [ |
|
| 54 | + 'func' => '_import_page', |
|
| 55 | + 'capability' => 'import', |
|
| 56 | + ], |
|
| 57 | + 'import' => [ |
|
| 58 | + 'func' => '_import_events', |
|
| 59 | + 'capability' => 'import', |
|
| 60 | + 'noheader' => true, |
|
| 61 | + ], |
|
| 62 | + 'import_events' => [ |
|
| 63 | + 'func' => '_import_events', |
|
| 64 | + 'capability' => 'import', |
|
| 65 | + 'noheader' => true, |
|
| 66 | + ], |
|
| 67 | + 'export_events' => [ |
|
| 68 | + 'func' => '_events_export', |
|
| 69 | + 'capability' => 'export', |
|
| 70 | + 'noheader' => true, |
|
| 71 | + ], |
|
| 72 | + 'export_categories' => [ |
|
| 73 | + 'func' => '_categories_export', |
|
| 74 | + 'capability' => 'export', |
|
| 75 | + 'noheader' => true, |
|
| 76 | + ], |
|
| 77 | + 'sample_export_file' => [ |
|
| 78 | + 'func' => '_sample_export_file', |
|
| 79 | + 'capability' => 'export', |
|
| 80 | + 'noheader' => true, |
|
| 81 | + ], |
|
| 82 | + 'update_template_settings' => [ |
|
| 83 | + 'func' => '_update_template_settings', |
|
| 84 | + 'capability' => 'manage_options', |
|
| 85 | + 'noheader' => true, |
|
| 86 | + ], |
|
| 87 | + 'ticket_list_table' => [ |
|
| 88 | + 'func' => '_tickets_overview_list_table', |
|
| 89 | + 'capability' => 'ee_read_default_tickets', |
|
| 90 | + ], |
|
| 91 | + ]; |
|
| 92 | + $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
| 93 | + $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
| 94 | + // don't load these meta boxes if using the advanced editor |
|
| 95 | + if ( |
|
| 96 | + ! $this->admin_config->useAdvancedEditor() |
|
| 97 | + || ! $this->feature->allowed('use_default_ticket_manager') |
|
| 98 | + ) { |
|
| 99 | + $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
| 100 | + $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
| 101 | + |
|
| 102 | + $legacy_editor_page_routes = [ |
|
| 103 | + 'trash_ticket' => [ |
|
| 104 | + 'func' => '_trash_or_restore_ticket', |
|
| 105 | + 'capability' => 'ee_delete_default_ticket', |
|
| 106 | + 'obj_id' => $TKT_ID, |
|
| 107 | + 'noheader' => true, |
|
| 108 | + 'args' => ['trash' => true], |
|
| 109 | + ], |
|
| 110 | + 'trash_tickets' => [ |
|
| 111 | + 'func' => '_trash_or_restore_ticket', |
|
| 112 | + 'capability' => 'ee_delete_default_tickets', |
|
| 113 | + 'noheader' => true, |
|
| 114 | + 'args' => ['trash' => true], |
|
| 115 | + ], |
|
| 116 | + 'restore_ticket' => [ |
|
| 117 | + 'func' => '_trash_or_restore_ticket', |
|
| 118 | + 'capability' => 'ee_delete_default_ticket', |
|
| 119 | + 'obj_id' => $TKT_ID, |
|
| 120 | + 'noheader' => true, |
|
| 121 | + ], |
|
| 122 | + 'restore_tickets' => [ |
|
| 123 | + 'func' => '_trash_or_restore_ticket', |
|
| 124 | + 'capability' => 'ee_delete_default_tickets', |
|
| 125 | + 'noheader' => true, |
|
| 126 | + ], |
|
| 127 | + 'delete_ticket' => [ |
|
| 128 | + 'func' => '_delete_ticket', |
|
| 129 | + 'capability' => 'ee_delete_default_ticket', |
|
| 130 | + 'obj_id' => $TKT_ID, |
|
| 131 | + 'noheader' => true, |
|
| 132 | + ], |
|
| 133 | + 'delete_tickets' => [ |
|
| 134 | + 'func' => '_delete_ticket', |
|
| 135 | + 'capability' => 'ee_delete_default_tickets', |
|
| 136 | + 'noheader' => true, |
|
| 137 | + ], |
|
| 138 | + ]; |
|
| 139 | + $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 143 | + // partial route/config override |
|
| 144 | + $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
| 145 | + $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
| 146 | + |
|
| 147 | + // add default tickets tab and template settings nav tabs (note union at end) |
|
| 148 | + $this->_page_config = [ |
|
| 149 | + 'ticket_list_table' => [ |
|
| 150 | + 'nav' => [ |
|
| 151 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
| 152 | + 'icon' => 'dashicons-tickets-alt', |
|
| 153 | + 'order' => 60, |
|
| 154 | + ], |
|
| 155 | + 'list_table' => 'Tickets_List_Table', |
|
| 156 | + 'require_nonce' => false, |
|
| 157 | + ], |
|
| 158 | + 'template_settings' => [ |
|
| 159 | + 'nav' => [ |
|
| 160 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 161 | + 'icon' => 'dashicons-layout', |
|
| 162 | + 'order' => 30, |
|
| 163 | + ], |
|
| 164 | + 'metaboxes' => array_merge( |
|
| 165 | + ['_publish_post_box'], |
|
| 166 | + $this->_default_espresso_metaboxes |
|
| 167 | + ), |
|
| 168 | + 'help_tabs' => [ |
|
| 169 | + 'general_settings_templates_help_tab' => [ |
|
| 170 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 171 | + 'filename' => 'general_settings_templates', |
|
| 172 | + ], |
|
| 173 | + ], |
|
| 174 | + 'require_nonce' => false, |
|
| 175 | + ], |
|
| 176 | + ] + $this->_page_config; |
|
| 177 | + |
|
| 178 | + // add filters and actions |
|
| 179 | + // modifying _views |
|
| 180 | + add_filter( |
|
| 181 | + 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
| 182 | + [$this, 'add_additional_datetime_button'], |
|
| 183 | + 10, |
|
| 184 | + 2 |
|
| 185 | + ); |
|
| 186 | + add_filter( |
|
| 187 | + 'FHEE_event_datetime_metabox_clone_button_template', |
|
| 188 | + [$this, 'add_datetime_clone_button'], |
|
| 189 | + 10, |
|
| 190 | + 2 |
|
| 191 | + ); |
|
| 192 | + add_filter( |
|
| 193 | + 'FHEE_event_datetime_metabox_timezones_template', |
|
| 194 | + [$this, 'datetime_timezones_template'], |
|
| 195 | + 10, |
|
| 196 | + 2 |
|
| 197 | + ); |
|
| 198 | + // filters for event list table |
|
| 199 | + add_filter( |
|
| 200 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 201 | + [$this, 'extra_list_table_actions'], |
|
| 202 | + 10, |
|
| 203 | + 2 |
|
| 204 | + ); |
|
| 205 | + // legend item |
|
| 206 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']); |
|
| 207 | + add_action('admin_init', [$this, 'admin_init']); |
|
| 208 | + // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
|
| 209 | + add_filter('get_sample_permalink_html', [DuplicateEventButton::class, 'addButton'], 8, 4); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * admin_init |
|
| 215 | + */ |
|
| 216 | + public function admin_init() |
|
| 217 | + { |
|
| 218 | + EE_Registry::$i18n_js_strings = array_merge( |
|
| 219 | + EE_Registry::$i18n_js_strings, |
|
| 220 | + [ |
|
| 221 | + 'image_confirm' => esc_html__( |
|
| 222 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 223 | + 'event_espresso' |
|
| 224 | + ), |
|
| 225 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
| 226 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
| 227 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
| 228 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
| 229 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
| 230 | + ] |
|
| 231 | + ); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * Add per page screen options to the default ticket list table view. |
|
| 237 | + * |
|
| 238 | + * @throws InvalidArgumentException |
|
| 239 | + * @throws InvalidDataTypeException |
|
| 240 | + * @throws InvalidInterfaceException |
|
| 241 | + */ |
|
| 242 | + protected function _add_screen_options_ticket_list_table() |
|
| 243 | + { |
|
| 244 | + $this->_per_page_screen_option(); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param string $return the current html |
|
| 250 | + * @param int $id the post id for the page |
|
| 251 | + * @param string|null $new_title What the title is |
|
| 252 | + * @param string|null $new_slug what the slug is |
|
| 253 | + * @return string |
|
| 254 | + * @deprecated 5.0.0.p |
|
| 255 | + */ |
|
| 256 | + public function extra_permalink_field_buttons( |
|
| 257 | + string $return, |
|
| 258 | + int $id, |
|
| 259 | + ?string $new_title, |
|
| 260 | + ?string $new_slug |
|
| 261 | + ): string { |
|
| 262 | + $return = DuplicateEventButton::addButton($return, $id, $new_title, $new_slug); |
|
| 263 | + return TicketSelectorShortcodeButton::addButton($return, $id, $new_title, $new_slug); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Set the list table views for the default ticket list table view. |
|
| 269 | + */ |
|
| 270 | + public function _set_list_table_views_ticket_list_table() |
|
| 271 | + { |
|
| 272 | + $this->_views = [ |
|
| 273 | + 'all' => [ |
|
| 274 | + 'slug' => 'all', |
|
| 275 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 276 | + 'count' => 0, |
|
| 277 | + 'bulk_action' => [ |
|
| 278 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 279 | + ], |
|
| 280 | + ], |
|
| 281 | + 'trashed' => [ |
|
| 282 | + 'slug' => 'trashed', |
|
| 283 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 284 | + 'count' => 0, |
|
| 285 | + 'bulk_action' => [ |
|
| 286 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 287 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 288 | + ], |
|
| 289 | + ], |
|
| 290 | + ]; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * Enqueue scripts and styles for the event editor. |
|
| 296 | + */ |
|
| 297 | + public function load_scripts_styles_edit() |
|
| 298 | + { |
|
| 299 | + if (! $this->admin_config->useAdvancedEditor()) { |
|
| 300 | + wp_register_script( |
|
| 301 | + 'ee-event-editor-heartbeat', |
|
| 302 | + EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
| 303 | + ['ee_admin_js', 'heartbeat'], |
|
| 304 | + EVENT_ESPRESSO_VERSION, |
|
| 305 | + true |
|
| 306 | + ); |
|
| 307 | + wp_enqueue_script('ee-accounting'); |
|
| 308 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
| 309 | + } |
|
| 310 | + wp_enqueue_script('event_editor_js'); |
|
| 311 | + wp_register_style( |
|
| 312 | + 'event-editor-css', |
|
| 313 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 314 | + ['ee-admin-css'], |
|
| 315 | + EVENT_ESPRESSO_VERSION |
|
| 316 | + ); |
|
| 317 | + wp_enqueue_style('event-editor-css'); |
|
| 318 | + // styles |
|
| 319 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + |
|
| 323 | + /** |
|
| 324 | + * Sets the views for the default list table view. |
|
| 325 | + * |
|
| 326 | + * @throws EE_Error |
|
| 327 | + * @throws ReflectionException |
|
| 328 | + */ |
|
| 329 | + protected function _set_list_table_views_default() |
|
| 330 | + { |
|
| 331 | + parent::_set_list_table_views_default(); |
|
| 332 | + $new_views = [ |
|
| 333 | + 'today' => [ |
|
| 334 | + 'slug' => 'today', |
|
| 335 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
| 336 | + 'count' => $this->total_events_today(), |
|
| 337 | + 'bulk_action' => [ |
|
| 338 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 339 | + ], |
|
| 340 | + ], |
|
| 341 | + 'month' => [ |
|
| 342 | + 'slug' => 'month', |
|
| 343 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 344 | + 'count' => $this->total_events_this_month(), |
|
| 345 | + 'bulk_action' => [ |
|
| 346 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 347 | + ], |
|
| 348 | + ], |
|
| 349 | + ]; |
|
| 350 | + $this->_views = array_merge($this->_views, $new_views); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Returns the extra action links for the default list table view. |
|
| 356 | + * |
|
| 357 | + * @param array $action_links |
|
| 358 | + * @param EE_Event $event |
|
| 359 | + * @return array |
|
| 360 | + * @throws EE_Error |
|
| 361 | + * @throws ReflectionException |
|
| 362 | + */ |
|
| 363 | + public function extra_list_table_actions(array $action_links, EE_Event $event): array |
|
| 364 | + { |
|
| 365 | + if ( |
|
| 366 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 367 | + 'ee_read_registrations', |
|
| 368 | + 'espresso_registrations_reports', |
|
| 369 | + $event->ID() |
|
| 370 | + ) |
|
| 371 | + ) { |
|
| 372 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 373 | + [ |
|
| 374 | + 'action' => 'reports', |
|
| 375 | + 'EVT_ID' => $event->ID(), |
|
| 376 | + ], |
|
| 377 | + REG_ADMIN_URL |
|
| 378 | + ); |
|
| 379 | + |
|
| 380 | + $action_links[] = ' |
|
| 381 | 381 | <a href="' . $reports_link . '" |
| 382 | 382 | aria-label="' . esc_attr__('View Report', 'event_espresso') . '" |
| 383 | 383 | class="ee-aria-tooltip button button--icon-only" |
| 384 | 384 | > |
| 385 | 385 | <span class="dashicons dashicons-chart-bar"></span> |
| 386 | 386 | </a>'; |
| 387 | - } |
|
| 388 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 389 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 390 | - $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
| 391 | - 'see_notifications_for', |
|
| 392 | - null, |
|
| 393 | - ['EVT_ID' => $event->ID()] |
|
| 394 | - ); |
|
| 395 | - } |
|
| 396 | - return $action_links; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * @param $items |
|
| 402 | - * @return mixed |
|
| 403 | - */ |
|
| 404 | - public function additional_legend_items($items) |
|
| 405 | - { |
|
| 406 | - if ( |
|
| 407 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 408 | - 'ee_read_registrations', |
|
| 409 | - 'espresso_registrations_reports' |
|
| 410 | - ) |
|
| 411 | - ) { |
|
| 412 | - $items['reports'] = [ |
|
| 413 | - 'class' => 'dashicons dashicons-chart-bar', |
|
| 414 | - 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
| 415 | - ]; |
|
| 416 | - } |
|
| 417 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 418 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 419 | - // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset |
|
| 420 | - // (can only use numeric offsets when treating strings as arrays) |
|
| 421 | - if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) { |
|
| 422 | - $items['view_related_messages'] = [ |
|
| 423 | - 'class' => $related_for_icon['css_class'], |
|
| 424 | - 'desc' => $related_for_icon['label'], |
|
| 425 | - ]; |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - return $items; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - /** |
|
| 433 | - * This is the callback method for the duplicate event route |
|
| 434 | - * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
| 435 | - * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
| 436 | - * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
| 437 | - * After duplication the redirect is to the new event edit page. |
|
| 438 | - * |
|
| 439 | - * @return void |
|
| 440 | - * @throws EE_Error If EE_Event is not available with given ID |
|
| 441 | - * @throws ReflectionException |
|
| 442 | - * @access protected |
|
| 443 | - */ |
|
| 444 | - protected function _duplicate_event() |
|
| 445 | - { |
|
| 446 | - // first make sure the ID for the event is in the request. |
|
| 447 | - // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
| 448 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 449 | - if (! $EVT_ID) { |
|
| 450 | - EE_Error::add_error( |
|
| 451 | - esc_html__( |
|
| 452 | - 'In order to duplicate an event an Event ID is required. None was given.', |
|
| 453 | - 'event_espresso' |
|
| 454 | - ), |
|
| 455 | - __FILE__, |
|
| 456 | - __FUNCTION__, |
|
| 457 | - __LINE__ |
|
| 458 | - ); |
|
| 459 | - $this->_redirect_after_action(false, '', '', [], true); |
|
| 460 | - return; |
|
| 461 | - } |
|
| 462 | - // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
| 463 | - $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 464 | - if (! $orig_event instanceof EE_Event) { |
|
| 465 | - throw new EE_Error( |
|
| 466 | - sprintf( |
|
| 467 | - esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
| 468 | - $EVT_ID |
|
| 469 | - ) |
|
| 470 | - ); |
|
| 471 | - } |
|
| 472 | - // k now let's clone the $orig_event before getting relations |
|
| 473 | - $new_event = clone $orig_event; |
|
| 474 | - // original datetimes |
|
| 475 | - $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
| 476 | - // other original relations |
|
| 477 | - $orig_ven = $orig_event->get_many_related('Venue'); |
|
| 478 | - // reset the ID and modify other details to make it clear this is a dupe |
|
| 479 | - $new_event->set('EVT_ID', 0); |
|
| 480 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
| 481 | - $new_event->set('EVT_name', $new_name); |
|
| 482 | - $new_event->set( |
|
| 483 | - 'EVT_slug', |
|
| 484 | - wp_unique_post_slug( |
|
| 485 | - sanitize_title($orig_event->name()), |
|
| 486 | - 0, |
|
| 487 | - 'publish', |
|
| 488 | - 'espresso_events', |
|
| 489 | - 0 |
|
| 490 | - ) |
|
| 491 | - ); |
|
| 492 | - $new_event->set('status', 'draft'); |
|
| 493 | - // duplicate discussion settings |
|
| 494 | - $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
| 495 | - $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
| 496 | - // save the new event |
|
| 497 | - $new_event->save(); |
|
| 498 | - // venues |
|
| 499 | - foreach ($orig_ven as $ven) { |
|
| 500 | - $new_event->_add_relation_to($ven, 'Venue'); |
|
| 501 | - } |
|
| 502 | - $new_event->save(); |
|
| 503 | - // now we need to get the question group relations and handle that |
|
| 504 | - // first primary question groups |
|
| 505 | - $orig_primary_qgs = $orig_event->get_many_related( |
|
| 506 | - 'Question_Group', |
|
| 507 | - [['Event_Question_Group.EQG_primary' => true]] |
|
| 508 | - ); |
|
| 509 | - if (! empty($orig_primary_qgs)) { |
|
| 510 | - foreach ($orig_primary_qgs as $obj) { |
|
| 511 | - if ($obj instanceof EE_Question_Group) { |
|
| 512 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - // next additional attendee question groups |
|
| 517 | - $orig_additional_qgs = $orig_event->get_many_related( |
|
| 518 | - 'Question_Group', |
|
| 519 | - [['Event_Question_Group.EQG_additional' => true]] |
|
| 520 | - ); |
|
| 521 | - if (! empty($orig_additional_qgs)) { |
|
| 522 | - foreach ($orig_additional_qgs as $obj) { |
|
| 523 | - if ($obj instanceof EE_Question_Group) { |
|
| 524 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - $new_event->save(); |
|
| 530 | - |
|
| 531 | - // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
| 532 | - $cloned_tickets = []; |
|
| 533 | - foreach ($orig_datetimes as $orig_dtt) { |
|
| 534 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
| 535 | - continue; |
|
| 536 | - } |
|
| 537 | - $new_dtt = clone $orig_dtt; |
|
| 538 | - $orig_tickets = $orig_dtt->tickets(); |
|
| 539 | - // save new dtt then add to event |
|
| 540 | - $new_dtt->set('DTT_ID', 0); |
|
| 541 | - $new_dtt->set('DTT_sold', 0); |
|
| 542 | - $new_dtt->set_reserved(0); |
|
| 543 | - $new_dtt->save(); |
|
| 544 | - $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
| 545 | - $new_event->save(); |
|
| 546 | - // now let's get the ticket relations setup. |
|
| 547 | - foreach ((array) $orig_tickets as $orig_ticket) { |
|
| 548 | - // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
| 549 | - if (! $orig_ticket instanceof EE_Ticket) { |
|
| 550 | - continue; |
|
| 551 | - } |
|
| 552 | - // is this ticket archived? If it is then let's skip |
|
| 553 | - if ($orig_ticket->get('TKT_deleted')) { |
|
| 554 | - continue; |
|
| 555 | - } |
|
| 556 | - // does this original ticket already exist in the clone_tickets cache? |
|
| 557 | - // If so we'll just use the new ticket from it. |
|
| 558 | - if (isset($cloned_tickets[ $orig_ticket->ID() ])) { |
|
| 559 | - $new_ticket = $cloned_tickets[ $orig_ticket->ID() ]; |
|
| 560 | - } else { |
|
| 561 | - $new_ticket = clone $orig_ticket; |
|
| 562 | - // get relations on the $orig_ticket that we need to set up. |
|
| 563 | - $orig_prices = $orig_ticket->prices(); |
|
| 564 | - $new_ticket->set('TKT_ID', 0); |
|
| 565 | - $new_ticket->set('TKT_sold', 0); |
|
| 566 | - $new_ticket->set('TKT_reserved', 0); |
|
| 567 | - // make sure new ticket has ID. |
|
| 568 | - $new_ticket->save(); |
|
| 569 | - // price relations on new ticket need to be setup. |
|
| 570 | - foreach ($orig_prices as $orig_price) { |
|
| 571 | - // don't clone default prices, just add a relation |
|
| 572 | - if ($orig_price->is_default()) { |
|
| 573 | - $new_ticket->_add_relation_to($orig_price, 'Price'); |
|
| 574 | - $new_ticket->save(); |
|
| 575 | - continue; |
|
| 576 | - } |
|
| 577 | - $new_price = clone $orig_price; |
|
| 578 | - $new_price->set('PRC_ID', 0); |
|
| 579 | - $new_price->save(); |
|
| 580 | - $new_ticket->_add_relation_to($new_price, 'Price'); |
|
| 581 | - } |
|
| 582 | - $new_ticket->save(); |
|
| 583 | - |
|
| 584 | - do_action( |
|
| 585 | - 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
| 586 | - $orig_ticket, |
|
| 587 | - $new_ticket, |
|
| 588 | - $orig_prices, |
|
| 589 | - $orig_event, |
|
| 590 | - $orig_dtt, |
|
| 591 | - $new_dtt |
|
| 592 | - ); |
|
| 593 | - $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket; |
|
| 594 | - } |
|
| 595 | - // k now we can add the new ticket as a relation to the new datetime |
|
| 596 | - // and make sure it's added to our cached $cloned_tickets array |
|
| 597 | - // for use with later datetimes that have the same ticket. |
|
| 598 | - $new_dtt->_add_relation_to($new_ticket, 'Ticket'); |
|
| 599 | - } |
|
| 600 | - $new_dtt->save(); |
|
| 601 | - } |
|
| 602 | - // clone taxonomy information |
|
| 603 | - $taxonomies_to_clone_with = apply_filters( |
|
| 604 | - 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
| 605 | - ['espresso_event_categories', 'espresso_event_type', 'post_tag'] |
|
| 606 | - ); |
|
| 607 | - // get terms for original event (notice) |
|
| 608 | - $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
| 609 | - // loop through terms and add them to new event. |
|
| 610 | - foreach ($orig_terms as $term) { |
|
| 611 | - wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - // duplicate other core WP_Post items for this event. |
|
| 615 | - // post thumbnail (feature image). |
|
| 616 | - $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
| 617 | - if ($feature_image_id) { |
|
| 618 | - update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
| 619 | - } |
|
| 620 | - |
|
| 621 | - // duplicate page_template setting |
|
| 622 | - $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
| 623 | - if ($page_template) { |
|
| 624 | - update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
| 628 | - // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
| 629 | - if ($new_event->ID()) { |
|
| 630 | - $redirect_args = [ |
|
| 631 | - 'post' => $new_event->ID(), |
|
| 632 | - 'action' => 'edit', |
|
| 633 | - ]; |
|
| 634 | - EE_Error::add_success( |
|
| 635 | - esc_html__( |
|
| 636 | - 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
| 637 | - 'event_espresso' |
|
| 638 | - ) |
|
| 639 | - ); |
|
| 640 | - } else { |
|
| 641 | - $redirect_args = [ |
|
| 642 | - 'action' => 'default', |
|
| 643 | - ]; |
|
| 644 | - EE_Error::add_error( |
|
| 645 | - esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
| 646 | - __FILE__, |
|
| 647 | - __FUNCTION__, |
|
| 648 | - __LINE__ |
|
| 649 | - ); |
|
| 650 | - } |
|
| 651 | - $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - |
|
| 655 | - /** |
|
| 656 | - * Generates output for the import page. |
|
| 657 | - * |
|
| 658 | - * @throws EE_Error |
|
| 659 | - */ |
|
| 660 | - protected function _import_page() |
|
| 661 | - { |
|
| 662 | - $title = esc_html__('Import', 'event_espresso'); |
|
| 663 | - $intro = esc_html__( |
|
| 664 | - 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
| 665 | - 'event_espresso' |
|
| 666 | - ); |
|
| 667 | - |
|
| 668 | - $form_url = EVENTS_ADMIN_URL; |
|
| 669 | - $action = 'import_events'; |
|
| 670 | - $type = 'csv'; |
|
| 671 | - |
|
| 672 | - $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
| 673 | - $title, |
|
| 674 | - $intro, |
|
| 675 | - $form_url, |
|
| 676 | - $action, |
|
| 677 | - $type |
|
| 678 | - ); |
|
| 679 | - |
|
| 680 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 681 | - ['action' => 'sample_export_file'], |
|
| 682 | - $this->_admin_base_url |
|
| 683 | - ); |
|
| 684 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 685 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
| 686 | - $this->_template_args, |
|
| 687 | - true |
|
| 688 | - ); |
|
| 689 | - $this->display_admin_page_with_sidebar(); |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * _import_events |
|
| 695 | - * This handles displaying the screen and running imports for importing events. |
|
| 696 | - * |
|
| 697 | - * @return void |
|
| 698 | - * @throws EE_Error |
|
| 699 | - */ |
|
| 700 | - protected function _import_events() |
|
| 701 | - { |
|
| 702 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
| 703 | - $success = EE_Import::instance()->import(); |
|
| 704 | - $this->_redirect_after_action( |
|
| 705 | - $success, |
|
| 706 | - esc_html__('Import File', 'event_espresso'), |
|
| 707 | - 'ran', |
|
| 708 | - ['action' => 'import_page'], |
|
| 709 | - true |
|
| 710 | - ); |
|
| 711 | - } |
|
| 712 | - |
|
| 713 | - |
|
| 714 | - /** |
|
| 715 | - * _events_export |
|
| 716 | - * Will export all (or just the given event) to a Excel compatible file. |
|
| 717 | - * |
|
| 718 | - * @access protected |
|
| 719 | - * @return void |
|
| 720 | - */ |
|
| 721 | - protected function _events_export() |
|
| 722 | - { |
|
| 723 | - $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 724 | - $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int'); |
|
| 725 | - $this->request->mergeRequestParams( |
|
| 726 | - [ |
|
| 727 | - 'export' => 'report', |
|
| 728 | - 'action' => 'all_event_data', |
|
| 729 | - 'EVT_ID' => $EVT_ID, |
|
| 730 | - ] |
|
| 731 | - ); |
|
| 732 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 733 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 734 | - $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
| 735 | - $EE_Export->export(); |
|
| 736 | - } |
|
| 737 | - } |
|
| 738 | - |
|
| 739 | - |
|
| 740 | - /** |
|
| 741 | - * handle category exports() |
|
| 742 | - * |
|
| 743 | - * @return void |
|
| 744 | - */ |
|
| 745 | - protected function _categories_export() |
|
| 746 | - { |
|
| 747 | - $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
| 748 | - $this->request->mergeRequestParams( |
|
| 749 | - [ |
|
| 750 | - 'export' => 'report', |
|
| 751 | - 'action' => 'categories', |
|
| 752 | - 'EVT_ID' => $EVT_ID, |
|
| 753 | - ] |
|
| 754 | - ); |
|
| 755 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 756 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 757 | - $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
| 758 | - $EE_Export->export(); |
|
| 759 | - } |
|
| 760 | - } |
|
| 761 | - |
|
| 762 | - |
|
| 763 | - /** |
|
| 764 | - * Creates a sample CSV file for importing |
|
| 765 | - */ |
|
| 766 | - protected function _sample_export_file() |
|
| 767 | - { |
|
| 768 | - $EE_Export = EE_Export::instance(); |
|
| 769 | - if ($EE_Export instanceof EE_Export) { |
|
| 770 | - $EE_Export->export(); |
|
| 771 | - } |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - |
|
| 775 | - /************* Template Settings *************/ |
|
| 776 | - /** |
|
| 777 | - * Generates template settings page output |
|
| 778 | - * |
|
| 779 | - * @throws DomainException |
|
| 780 | - * @throws EE_Error |
|
| 781 | - * @throws InvalidArgumentException |
|
| 782 | - * @throws InvalidDataTypeException |
|
| 783 | - * @throws InvalidInterfaceException |
|
| 784 | - */ |
|
| 785 | - protected function _template_settings() |
|
| 786 | - { |
|
| 787 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
| 788 | - /** |
|
| 789 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
| 790 | - * from General_Settings_Admin_Page to here. |
|
| 791 | - */ |
|
| 792 | - $this->_template_args = apply_filters( |
|
| 793 | - 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
| 794 | - $this->_template_args |
|
| 795 | - ); |
|
| 796 | - $this->_set_add_edit_form_tags('update_template_settings'); |
|
| 797 | - $this->_set_publish_post_box_vars(); |
|
| 798 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 799 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
| 800 | - $this->_template_args, |
|
| 801 | - true |
|
| 802 | - ); |
|
| 803 | - $this->display_admin_page_with_sidebar(); |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - |
|
| 807 | - /** |
|
| 808 | - * Handler for updating template settings. |
|
| 809 | - * |
|
| 810 | - * @throws EE_Error |
|
| 811 | - */ |
|
| 812 | - protected function _update_template_settings() |
|
| 813 | - { |
|
| 814 | - /** |
|
| 815 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
| 816 | - * from General_Settings_Admin_Page to here. |
|
| 817 | - */ |
|
| 818 | - EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
| 819 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
| 820 | - EE_Registry::instance()->CFG->template_settings, |
|
| 821 | - $this->request->requestParams() |
|
| 822 | - ); |
|
| 823 | - // update custom post type slugs and detect if we need to flush rewrite rules |
|
| 824 | - $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
| 825 | - |
|
| 826 | - $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug'); |
|
| 827 | - |
|
| 828 | - EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug |
|
| 829 | - ? EEH_URL::slugify($event_cpt_slug, 'events') |
|
| 830 | - : EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
| 831 | - |
|
| 832 | - $what = esc_html__('Template Settings', 'event_espresso'); |
|
| 833 | - $success = $this->_update_espresso_configuration( |
|
| 834 | - $what, |
|
| 835 | - EE_Registry::instance()->CFG->template_settings, |
|
| 836 | - __FILE__, |
|
| 837 | - __FUNCTION__, |
|
| 838 | - __LINE__ |
|
| 839 | - ); |
|
| 840 | - if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) { |
|
| 841 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
| 842 | - $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
| 843 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
| 844 | - ); |
|
| 845 | - $rewrite_rules->flush(); |
|
| 846 | - } |
|
| 847 | - $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - |
|
| 851 | - /** |
|
| 852 | - * _premium_event_editor_meta_boxes |
|
| 853 | - * add all metaboxes related to the event_editor |
|
| 854 | - * |
|
| 855 | - * @access protected |
|
| 856 | - * @return void |
|
| 857 | - * @throws EE_Error |
|
| 858 | - * @throws ReflectionException |
|
| 859 | - */ |
|
| 860 | - protected function _premium_event_editor_meta_boxes() |
|
| 861 | - { |
|
| 862 | - $this->verify_cpt_object(); |
|
| 863 | - // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
| 864 | - if ( |
|
| 865 | - ! $this->admin_config->useAdvancedEditor() |
|
| 866 | - || ! $this->feature->allowed('use_reg_options_meta_box') |
|
| 867 | - ) { |
|
| 868 | - $this->addMetaBox( |
|
| 869 | - 'espresso_event_editor_event_options', |
|
| 870 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
| 871 | - [$this, 'registration_options_meta_box'], |
|
| 872 | - $this->page_slug, |
|
| 873 | - 'side', |
|
| 874 | - 'core' |
|
| 875 | - ); |
|
| 876 | - } |
|
| 877 | - } |
|
| 878 | - |
|
| 879 | - |
|
| 880 | - /** |
|
| 881 | - * override caf metabox |
|
| 882 | - * |
|
| 883 | - * @return void |
|
| 884 | - * @throws EE_Error |
|
| 885 | - * @throws ReflectionException |
|
| 886 | - */ |
|
| 887 | - public function registration_options_meta_box() |
|
| 888 | - { |
|
| 889 | - $yes_no_values = [ |
|
| 890 | - ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
|
| 891 | - ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
|
| 892 | - ]; |
|
| 893 | - |
|
| 894 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 895 | - [ |
|
| 896 | - EEM_Registration::status_id_cancelled, |
|
| 897 | - EEM_Registration::status_id_declined, |
|
| 898 | - EEM_Registration::status_id_incomplete, |
|
| 899 | - EEM_Registration::status_id_wait_list, |
|
| 900 | - ], |
|
| 901 | - true |
|
| 902 | - ); |
|
| 903 | - |
|
| 904 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 905 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
| 906 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 907 | - |
|
| 908 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 909 | - 'default_reg_status', |
|
| 910 | - $default_reg_status_values, |
|
| 911 | - $this->_cpt_model_obj->default_registration_status(), |
|
| 912 | - '', |
|
| 913 | - 'ee-input-width--reg', |
|
| 914 | - false |
|
| 915 | - ); |
|
| 916 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 917 | - 'display_desc', |
|
| 918 | - $yes_no_values, |
|
| 919 | - $this->_cpt_model_obj->display_description() |
|
| 920 | - ); |
|
| 921 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 922 | - 'display_ticket_selector', |
|
| 923 | - $yes_no_values, |
|
| 924 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
| 925 | - '', |
|
| 926 | - 'ee-input-width--small', |
|
| 927 | - false |
|
| 928 | - ); |
|
| 929 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 930 | - 'EVT_default_registration_status', |
|
| 931 | - $default_reg_status_values, |
|
| 932 | - $this->_cpt_model_obj->default_registration_status(), |
|
| 933 | - '', |
|
| 934 | - 'ee-input-width--reg', |
|
| 935 | - false |
|
| 936 | - ); |
|
| 937 | - $template_args['additional_registration_options'] = apply_filters( |
|
| 938 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 939 | - '', |
|
| 940 | - $template_args, |
|
| 941 | - $yes_no_values, |
|
| 942 | - $default_reg_status_values |
|
| 943 | - ); |
|
| 944 | - EEH_Template::display_template( |
|
| 945 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 946 | - $template_args |
|
| 947 | - ); |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - |
|
| 951 | - |
|
| 952 | - /** |
|
| 953 | - * wp_list_table_mods for caf |
|
| 954 | - * ============================ |
|
| 955 | - */ |
|
| 956 | - |
|
| 957 | - |
|
| 958 | - /** |
|
| 959 | - * espresso_event_months_dropdown |
|
| 960 | - * |
|
| 961 | - * @deprecatd 5.0.0.p |
|
| 962 | - * @access public |
|
| 963 | - * @return string dropdown listing month/year selections for events. |
|
| 964 | - * @throws EE_Error |
|
| 965 | - */ |
|
| 966 | - public function espresso_event_months_dropdown(): string |
|
| 967 | - { |
|
| 968 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
| 969 | - // Note we need to include any other filters that are set! |
|
| 970 | - return EEH_Form_Fields::generate_event_months_dropdown( |
|
| 971 | - $this->request->getRequestParam('month_range'), |
|
| 972 | - $this->request->getRequestParam('status'), |
|
| 973 | - $this->request->getRequestParam('EVT_CAT', 0, 'int'), |
|
| 974 | - $this->request->getRequestParam('active_status') |
|
| 975 | - ); |
|
| 976 | - } |
|
| 977 | - |
|
| 978 | - |
|
| 979 | - /** |
|
| 980 | - * returns a list of "active" statuses on the event |
|
| 981 | - * |
|
| 982 | - * @deprecatd 5.0.0.p |
|
| 983 | - * @param string $current_value whatever the current active status is |
|
| 984 | - * @return string |
|
| 985 | - */ |
|
| 986 | - public function active_status_dropdown(string $current_value = ''): string |
|
| 987 | - { |
|
| 988 | - $select_name = 'active_status'; |
|
| 989 | - $values = [ |
|
| 990 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
| 991 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
| 992 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
| 993 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
| 994 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
| 995 | - ]; |
|
| 996 | - |
|
| 997 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value); |
|
| 998 | - } |
|
| 999 | - |
|
| 1000 | - |
|
| 1001 | - /** |
|
| 1002 | - * returns a list of "venues" |
|
| 1003 | - * |
|
| 1004 | - * @deprecatd 5.0.0.p |
|
| 1005 | - * @param string $current_value whatever the current active status is |
|
| 1006 | - * @return string |
|
| 1007 | - * @throws EE_Error |
|
| 1008 | - * @throws ReflectionException |
|
| 1009 | - */ |
|
| 1010 | - protected function venuesDropdown(string $current_value = ''): string |
|
| 1011 | - { |
|
| 1012 | - $values = ['' => esc_html__('All Venues', 'event_espresso')]; |
|
| 1013 | - // populate the list of venues. |
|
| 1014 | - $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
|
| 1015 | - |
|
| 1016 | - foreach ($venues as $venue) { |
|
| 1017 | - $values[ $venue->ID() ] = $venue->name(); |
|
| 1018 | - } |
|
| 1019 | - |
|
| 1020 | - return EEH_Form_Fields::select_input('venue', $values, $current_value); |
|
| 1021 | - } |
|
| 1022 | - |
|
| 1023 | - |
|
| 1024 | - /** |
|
| 1025 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
| 1026 | - * |
|
| 1027 | - * @deprecatd 5.0.0.p |
|
| 1028 | - * @access public |
|
| 1029 | - * @return string html |
|
| 1030 | - * @throws EE_Error |
|
| 1031 | - * @throws ReflectionException |
|
| 1032 | - */ |
|
| 1033 | - public function category_dropdown(): string |
|
| 1034 | - { |
|
| 1035 | - return EEH_Form_Fields::generate_event_category_dropdown( |
|
| 1036 | - $this->request->getRequestParam('EVT_CAT', -1, 'int') |
|
| 1037 | - ); |
|
| 1038 | - } |
|
| 1039 | - |
|
| 1040 | - |
|
| 1041 | - /** |
|
| 1042 | - * get total number of events today |
|
| 1043 | - * |
|
| 1044 | - * @access public |
|
| 1045 | - * @return int |
|
| 1046 | - * @throws EE_Error |
|
| 1047 | - * @throws InvalidArgumentException |
|
| 1048 | - * @throws InvalidDataTypeException |
|
| 1049 | - * @throws InvalidInterfaceException |
|
| 1050 | - * @throws ReflectionException |
|
| 1051 | - */ |
|
| 1052 | - public function total_events_today(): int |
|
| 1053 | - { |
|
| 1054 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1055 | - 'DTT_EVT_start', |
|
| 1056 | - date('Y-m-d') . ' 00:00:00', |
|
| 1057 | - 'Y-m-d H:i:s', |
|
| 1058 | - 'UTC' |
|
| 1059 | - ); |
|
| 1060 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1061 | - 'DTT_EVT_start', |
|
| 1062 | - date('Y-m-d') . ' 23:59:59', |
|
| 1063 | - 'Y-m-d H:i:s', |
|
| 1064 | - 'UTC' |
|
| 1065 | - ); |
|
| 1066 | - $where = [ |
|
| 1067 | - 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
| 1068 | - ]; |
|
| 1069 | - return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
| 1070 | - } |
|
| 1071 | - |
|
| 1072 | - |
|
| 1073 | - /** |
|
| 1074 | - * get total number of events this month |
|
| 1075 | - * |
|
| 1076 | - * @access public |
|
| 1077 | - * @return int |
|
| 1078 | - * @throws EE_Error |
|
| 1079 | - * @throws InvalidArgumentException |
|
| 1080 | - * @throws InvalidDataTypeException |
|
| 1081 | - * @throws InvalidInterfaceException |
|
| 1082 | - * @throws ReflectionException |
|
| 1083 | - */ |
|
| 1084 | - public function total_events_this_month(): int |
|
| 1085 | - { |
|
| 1086 | - // Dates |
|
| 1087 | - $this_year_r = date('Y'); |
|
| 1088 | - $this_month_r = date('m'); |
|
| 1089 | - $days_this_month = date('t'); |
|
| 1090 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1091 | - 'DTT_EVT_start', |
|
| 1092 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
| 1093 | - 'Y-m-d H:i:s', |
|
| 1094 | - 'UTC' |
|
| 1095 | - ); |
|
| 1096 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1097 | - 'DTT_EVT_start', |
|
| 1098 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
| 1099 | - 'Y-m-d H:i:s', |
|
| 1100 | - 'UTC' |
|
| 1101 | - ); |
|
| 1102 | - $where = [ |
|
| 1103 | - 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
| 1104 | - ]; |
|
| 1105 | - return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - |
|
| 1109 | - /** DEFAULT TICKETS STUFF **/ |
|
| 1110 | - |
|
| 1111 | - /** |
|
| 1112 | - * Output default tickets list table view. |
|
| 1113 | - * |
|
| 1114 | - * @throws EE_Error |
|
| 1115 | - */ |
|
| 1116 | - public function _tickets_overview_list_table() |
|
| 1117 | - { |
|
| 1118 | - if ( |
|
| 1119 | - $this->admin_config->useAdvancedEditor() |
|
| 1120 | - && $this->feature->allowed('use_default_ticket_manager') |
|
| 1121 | - ) { |
|
| 1122 | - // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
| 1123 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 1124 | - EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php', |
|
| 1125 | - [], |
|
| 1126 | - true |
|
| 1127 | - ); |
|
| 1128 | - $this->display_admin_page_with_no_sidebar(); |
|
| 1129 | - } else { |
|
| 1130 | - $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
| 1131 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1132 | - } |
|
| 1133 | - } |
|
| 1134 | - |
|
| 1135 | - |
|
| 1136 | - /** |
|
| 1137 | - * @param int $per_page |
|
| 1138 | - * @param bool $count |
|
| 1139 | - * @param bool $trashed |
|
| 1140 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
| 1141 | - * @throws EE_Error |
|
| 1142 | - * @throws ReflectionException |
|
| 1143 | - */ |
|
| 1144 | - public function get_default_tickets(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
| 1145 | - { |
|
| 1146 | - $orderby = $this->request->getRequestParam('orderby', 'TKT_name'); |
|
| 1147 | - $order = $this->request->getRequestParam('order', 'ASC'); |
|
| 1148 | - switch ($orderby) { |
|
| 1149 | - case 'TKT_name': |
|
| 1150 | - $orderby = ['TKT_name' => $order]; |
|
| 1151 | - break; |
|
| 1152 | - case 'TKT_price': |
|
| 1153 | - $orderby = ['TKT_price' => $order]; |
|
| 1154 | - break; |
|
| 1155 | - case 'TKT_uses': |
|
| 1156 | - $orderby = ['TKT_uses' => $order]; |
|
| 1157 | - break; |
|
| 1158 | - case 'TKT_min': |
|
| 1159 | - $orderby = ['TKT_min' => $order]; |
|
| 1160 | - break; |
|
| 1161 | - case 'TKT_max': |
|
| 1162 | - $orderby = ['TKT_max' => $order]; |
|
| 1163 | - break; |
|
| 1164 | - case 'TKT_qty': |
|
| 1165 | - $orderby = ['TKT_qty' => $order]; |
|
| 1166 | - break; |
|
| 1167 | - } |
|
| 1168 | - |
|
| 1169 | - $current_page = $this->request->getRequestParam('paged', 1, 'int'); |
|
| 1170 | - $per_page = $this->request->getRequestParam('perpage', $per_page, 'int'); |
|
| 1171 | - $offset = ($current_page - 1) * $per_page; |
|
| 1172 | - |
|
| 1173 | - $where = [ |
|
| 1174 | - 'TKT_is_default' => 1, |
|
| 1175 | - 'TKT_deleted' => $trashed, |
|
| 1176 | - ]; |
|
| 1177 | - |
|
| 1178 | - $search_term = $this->request->getRequestParam('s'); |
|
| 1179 | - if ($search_term) { |
|
| 1180 | - $search_term = '%' . $search_term . '%'; |
|
| 1181 | - $where['OR'] = [ |
|
| 1182 | - 'TKT_name' => ['LIKE', $search_term], |
|
| 1183 | - 'TKT_description' => ['LIKE', $search_term], |
|
| 1184 | - ]; |
|
| 1185 | - } |
|
| 1186 | - |
|
| 1187 | - return $count |
|
| 1188 | - ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where]) |
|
| 1189 | - : EEM_Ticket::instance()->get_all_deleted_and_undeleted( |
|
| 1190 | - [ |
|
| 1191 | - $where, |
|
| 1192 | - 'order_by' => $orderby, |
|
| 1193 | - 'limit' => [$offset, $per_page], |
|
| 1194 | - 'group_by' => 'TKT_ID', |
|
| 1195 | - ] |
|
| 1196 | - ); |
|
| 1197 | - } |
|
| 1198 | - |
|
| 1199 | - |
|
| 1200 | - /** |
|
| 1201 | - * @param bool $trash |
|
| 1202 | - * @throws EE_Error |
|
| 1203 | - * @throws InvalidArgumentException |
|
| 1204 | - * @throws InvalidDataTypeException |
|
| 1205 | - * @throws InvalidInterfaceException |
|
| 1206 | - * @throws ReflectionException |
|
| 1207 | - */ |
|
| 1208 | - protected function _trash_or_restore_ticket(bool $trash = false) |
|
| 1209 | - { |
|
| 1210 | - $success = 1; |
|
| 1211 | - $TKT = EEM_Ticket::instance(); |
|
| 1212 | - // checkboxes? |
|
| 1213 | - $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
| 1214 | - if (! empty($checkboxes)) { |
|
| 1215 | - // if array has more than one element then success message should be plural |
|
| 1216 | - $success = count($checkboxes) > 1 ? 2 : 1; |
|
| 1217 | - // cycle thru the boxes |
|
| 1218 | - foreach ($checkboxes as $TKT_ID => $value) { |
|
| 1219 | - if ($trash) { |
|
| 1220 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1221 | - $success = 0; |
|
| 1222 | - } |
|
| 1223 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1224 | - $success = 0; |
|
| 1225 | - } |
|
| 1226 | - } |
|
| 1227 | - } else { |
|
| 1228 | - // grab single id and trash |
|
| 1229 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
| 1230 | - if ($trash) { |
|
| 1231 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1232 | - $success = 0; |
|
| 1233 | - } |
|
| 1234 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1235 | - $success = 0; |
|
| 1236 | - } |
|
| 1237 | - } |
|
| 1238 | - $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
| 1239 | - $query_args = [ |
|
| 1240 | - 'action' => 'ticket_list_table', |
|
| 1241 | - 'status' => $trash ? '' : 'trashed', |
|
| 1242 | - ]; |
|
| 1243 | - $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
| 1244 | - } |
|
| 1245 | - |
|
| 1246 | - |
|
| 1247 | - /** |
|
| 1248 | - * Handles trashing default ticket. |
|
| 1249 | - * |
|
| 1250 | - * @throws EE_Error |
|
| 1251 | - * @throws ReflectionException |
|
| 1252 | - */ |
|
| 1253 | - protected function _delete_ticket() |
|
| 1254 | - { |
|
| 1255 | - $success = 1; |
|
| 1256 | - // checkboxes? |
|
| 1257 | - $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
| 1258 | - if (! empty($checkboxes)) { |
|
| 1259 | - // if array has more than one element then success message should be plural |
|
| 1260 | - $success = count($checkboxes) > 1 ? 2 : 1; |
|
| 1261 | - // cycle thru the boxes |
|
| 1262 | - foreach ($checkboxes as $TKT_ID => $value) { |
|
| 1263 | - // delete |
|
| 1264 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1265 | - $success = 0; |
|
| 1266 | - } |
|
| 1267 | - } |
|
| 1268 | - } else { |
|
| 1269 | - // grab single id and trash |
|
| 1270 | - $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
| 1271 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1272 | - $success = 0; |
|
| 1273 | - } |
|
| 1274 | - } |
|
| 1275 | - $action_desc = 'deleted'; |
|
| 1276 | - $query_args = [ |
|
| 1277 | - 'action' => 'ticket_list_table', |
|
| 1278 | - 'status' => 'trashed', |
|
| 1279 | - ]; |
|
| 1280 | - // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
| 1281 | - if ( |
|
| 1282 | - EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
| 1283 | - [['TKT_is_default' => 1]], |
|
| 1284 | - 'TKT_ID', |
|
| 1285 | - true |
|
| 1286 | - ) |
|
| 1287 | - ) { |
|
| 1288 | - $query_args = []; |
|
| 1289 | - } |
|
| 1290 | - $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
| 1291 | - } |
|
| 1292 | - |
|
| 1293 | - |
|
| 1294 | - /** |
|
| 1295 | - * @param int $TKT_ID |
|
| 1296 | - * @return bool|int |
|
| 1297 | - * @throws EE_Error |
|
| 1298 | - * @throws ReflectionException |
|
| 1299 | - */ |
|
| 1300 | - protected function _delete_the_ticket(int $TKT_ID) |
|
| 1301 | - { |
|
| 1302 | - $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
| 1303 | - if (! $ticket instanceof EE_Ticket) { |
|
| 1304 | - return false; |
|
| 1305 | - } |
|
| 1306 | - $ticket->_remove_relations('Datetime'); |
|
| 1307 | - // delete all related prices first |
|
| 1308 | - $ticket->delete_related_permanently('Price'); |
|
| 1309 | - return $ticket->delete_permanently(); |
|
| 1310 | - } |
|
| 387 | + } |
|
| 388 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 389 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 390 | + $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
| 391 | + 'see_notifications_for', |
|
| 392 | + null, |
|
| 393 | + ['EVT_ID' => $event->ID()] |
|
| 394 | + ); |
|
| 395 | + } |
|
| 396 | + return $action_links; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * @param $items |
|
| 402 | + * @return mixed |
|
| 403 | + */ |
|
| 404 | + public function additional_legend_items($items) |
|
| 405 | + { |
|
| 406 | + if ( |
|
| 407 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 408 | + 'ee_read_registrations', |
|
| 409 | + 'espresso_registrations_reports' |
|
| 410 | + ) |
|
| 411 | + ) { |
|
| 412 | + $items['reports'] = [ |
|
| 413 | + 'class' => 'dashicons dashicons-chart-bar', |
|
| 414 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
| 415 | + ]; |
|
| 416 | + } |
|
| 417 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 418 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 419 | + // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset |
|
| 420 | + // (can only use numeric offsets when treating strings as arrays) |
|
| 421 | + if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) { |
|
| 422 | + $items['view_related_messages'] = [ |
|
| 423 | + 'class' => $related_for_icon['css_class'], |
|
| 424 | + 'desc' => $related_for_icon['label'], |
|
| 425 | + ]; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + return $items; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + /** |
|
| 433 | + * This is the callback method for the duplicate event route |
|
| 434 | + * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
| 435 | + * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
| 436 | + * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
| 437 | + * After duplication the redirect is to the new event edit page. |
|
| 438 | + * |
|
| 439 | + * @return void |
|
| 440 | + * @throws EE_Error If EE_Event is not available with given ID |
|
| 441 | + * @throws ReflectionException |
|
| 442 | + * @access protected |
|
| 443 | + */ |
|
| 444 | + protected function _duplicate_event() |
|
| 445 | + { |
|
| 446 | + // first make sure the ID for the event is in the request. |
|
| 447 | + // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
| 448 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 449 | + if (! $EVT_ID) { |
|
| 450 | + EE_Error::add_error( |
|
| 451 | + esc_html__( |
|
| 452 | + 'In order to duplicate an event an Event ID is required. None was given.', |
|
| 453 | + 'event_espresso' |
|
| 454 | + ), |
|
| 455 | + __FILE__, |
|
| 456 | + __FUNCTION__, |
|
| 457 | + __LINE__ |
|
| 458 | + ); |
|
| 459 | + $this->_redirect_after_action(false, '', '', [], true); |
|
| 460 | + return; |
|
| 461 | + } |
|
| 462 | + // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
| 463 | + $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 464 | + if (! $orig_event instanceof EE_Event) { |
|
| 465 | + throw new EE_Error( |
|
| 466 | + sprintf( |
|
| 467 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
| 468 | + $EVT_ID |
|
| 469 | + ) |
|
| 470 | + ); |
|
| 471 | + } |
|
| 472 | + // k now let's clone the $orig_event before getting relations |
|
| 473 | + $new_event = clone $orig_event; |
|
| 474 | + // original datetimes |
|
| 475 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
| 476 | + // other original relations |
|
| 477 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
| 478 | + // reset the ID and modify other details to make it clear this is a dupe |
|
| 479 | + $new_event->set('EVT_ID', 0); |
|
| 480 | + $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
| 481 | + $new_event->set('EVT_name', $new_name); |
|
| 482 | + $new_event->set( |
|
| 483 | + 'EVT_slug', |
|
| 484 | + wp_unique_post_slug( |
|
| 485 | + sanitize_title($orig_event->name()), |
|
| 486 | + 0, |
|
| 487 | + 'publish', |
|
| 488 | + 'espresso_events', |
|
| 489 | + 0 |
|
| 490 | + ) |
|
| 491 | + ); |
|
| 492 | + $new_event->set('status', 'draft'); |
|
| 493 | + // duplicate discussion settings |
|
| 494 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
| 495 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
| 496 | + // save the new event |
|
| 497 | + $new_event->save(); |
|
| 498 | + // venues |
|
| 499 | + foreach ($orig_ven as $ven) { |
|
| 500 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
| 501 | + } |
|
| 502 | + $new_event->save(); |
|
| 503 | + // now we need to get the question group relations and handle that |
|
| 504 | + // first primary question groups |
|
| 505 | + $orig_primary_qgs = $orig_event->get_many_related( |
|
| 506 | + 'Question_Group', |
|
| 507 | + [['Event_Question_Group.EQG_primary' => true]] |
|
| 508 | + ); |
|
| 509 | + if (! empty($orig_primary_qgs)) { |
|
| 510 | + foreach ($orig_primary_qgs as $obj) { |
|
| 511 | + if ($obj instanceof EE_Question_Group) { |
|
| 512 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + // next additional attendee question groups |
|
| 517 | + $orig_additional_qgs = $orig_event->get_many_related( |
|
| 518 | + 'Question_Group', |
|
| 519 | + [['Event_Question_Group.EQG_additional' => true]] |
|
| 520 | + ); |
|
| 521 | + if (! empty($orig_additional_qgs)) { |
|
| 522 | + foreach ($orig_additional_qgs as $obj) { |
|
| 523 | + if ($obj instanceof EE_Question_Group) { |
|
| 524 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + $new_event->save(); |
|
| 530 | + |
|
| 531 | + // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
| 532 | + $cloned_tickets = []; |
|
| 533 | + foreach ($orig_datetimes as $orig_dtt) { |
|
| 534 | + if (! $orig_dtt instanceof EE_Datetime) { |
|
| 535 | + continue; |
|
| 536 | + } |
|
| 537 | + $new_dtt = clone $orig_dtt; |
|
| 538 | + $orig_tickets = $orig_dtt->tickets(); |
|
| 539 | + // save new dtt then add to event |
|
| 540 | + $new_dtt->set('DTT_ID', 0); |
|
| 541 | + $new_dtt->set('DTT_sold', 0); |
|
| 542 | + $new_dtt->set_reserved(0); |
|
| 543 | + $new_dtt->save(); |
|
| 544 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
| 545 | + $new_event->save(); |
|
| 546 | + // now let's get the ticket relations setup. |
|
| 547 | + foreach ((array) $orig_tickets as $orig_ticket) { |
|
| 548 | + // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
| 549 | + if (! $orig_ticket instanceof EE_Ticket) { |
|
| 550 | + continue; |
|
| 551 | + } |
|
| 552 | + // is this ticket archived? If it is then let's skip |
|
| 553 | + if ($orig_ticket->get('TKT_deleted')) { |
|
| 554 | + continue; |
|
| 555 | + } |
|
| 556 | + // does this original ticket already exist in the clone_tickets cache? |
|
| 557 | + // If so we'll just use the new ticket from it. |
|
| 558 | + if (isset($cloned_tickets[ $orig_ticket->ID() ])) { |
|
| 559 | + $new_ticket = $cloned_tickets[ $orig_ticket->ID() ]; |
|
| 560 | + } else { |
|
| 561 | + $new_ticket = clone $orig_ticket; |
|
| 562 | + // get relations on the $orig_ticket that we need to set up. |
|
| 563 | + $orig_prices = $orig_ticket->prices(); |
|
| 564 | + $new_ticket->set('TKT_ID', 0); |
|
| 565 | + $new_ticket->set('TKT_sold', 0); |
|
| 566 | + $new_ticket->set('TKT_reserved', 0); |
|
| 567 | + // make sure new ticket has ID. |
|
| 568 | + $new_ticket->save(); |
|
| 569 | + // price relations on new ticket need to be setup. |
|
| 570 | + foreach ($orig_prices as $orig_price) { |
|
| 571 | + // don't clone default prices, just add a relation |
|
| 572 | + if ($orig_price->is_default()) { |
|
| 573 | + $new_ticket->_add_relation_to($orig_price, 'Price'); |
|
| 574 | + $new_ticket->save(); |
|
| 575 | + continue; |
|
| 576 | + } |
|
| 577 | + $new_price = clone $orig_price; |
|
| 578 | + $new_price->set('PRC_ID', 0); |
|
| 579 | + $new_price->save(); |
|
| 580 | + $new_ticket->_add_relation_to($new_price, 'Price'); |
|
| 581 | + } |
|
| 582 | + $new_ticket->save(); |
|
| 583 | + |
|
| 584 | + do_action( |
|
| 585 | + 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
| 586 | + $orig_ticket, |
|
| 587 | + $new_ticket, |
|
| 588 | + $orig_prices, |
|
| 589 | + $orig_event, |
|
| 590 | + $orig_dtt, |
|
| 591 | + $new_dtt |
|
| 592 | + ); |
|
| 593 | + $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket; |
|
| 594 | + } |
|
| 595 | + // k now we can add the new ticket as a relation to the new datetime |
|
| 596 | + // and make sure it's added to our cached $cloned_tickets array |
|
| 597 | + // for use with later datetimes that have the same ticket. |
|
| 598 | + $new_dtt->_add_relation_to($new_ticket, 'Ticket'); |
|
| 599 | + } |
|
| 600 | + $new_dtt->save(); |
|
| 601 | + } |
|
| 602 | + // clone taxonomy information |
|
| 603 | + $taxonomies_to_clone_with = apply_filters( |
|
| 604 | + 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
| 605 | + ['espresso_event_categories', 'espresso_event_type', 'post_tag'] |
|
| 606 | + ); |
|
| 607 | + // get terms for original event (notice) |
|
| 608 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
| 609 | + // loop through terms and add them to new event. |
|
| 610 | + foreach ($orig_terms as $term) { |
|
| 611 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + // duplicate other core WP_Post items for this event. |
|
| 615 | + // post thumbnail (feature image). |
|
| 616 | + $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
| 617 | + if ($feature_image_id) { |
|
| 618 | + update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + // duplicate page_template setting |
|
| 622 | + $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
| 623 | + if ($page_template) { |
|
| 624 | + update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
| 628 | + // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
| 629 | + if ($new_event->ID()) { |
|
| 630 | + $redirect_args = [ |
|
| 631 | + 'post' => $new_event->ID(), |
|
| 632 | + 'action' => 'edit', |
|
| 633 | + ]; |
|
| 634 | + EE_Error::add_success( |
|
| 635 | + esc_html__( |
|
| 636 | + 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
| 637 | + 'event_espresso' |
|
| 638 | + ) |
|
| 639 | + ); |
|
| 640 | + } else { |
|
| 641 | + $redirect_args = [ |
|
| 642 | + 'action' => 'default', |
|
| 643 | + ]; |
|
| 644 | + EE_Error::add_error( |
|
| 645 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
| 646 | + __FILE__, |
|
| 647 | + __FUNCTION__, |
|
| 648 | + __LINE__ |
|
| 649 | + ); |
|
| 650 | + } |
|
| 651 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + |
|
| 655 | + /** |
|
| 656 | + * Generates output for the import page. |
|
| 657 | + * |
|
| 658 | + * @throws EE_Error |
|
| 659 | + */ |
|
| 660 | + protected function _import_page() |
|
| 661 | + { |
|
| 662 | + $title = esc_html__('Import', 'event_espresso'); |
|
| 663 | + $intro = esc_html__( |
|
| 664 | + 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
| 665 | + 'event_espresso' |
|
| 666 | + ); |
|
| 667 | + |
|
| 668 | + $form_url = EVENTS_ADMIN_URL; |
|
| 669 | + $action = 'import_events'; |
|
| 670 | + $type = 'csv'; |
|
| 671 | + |
|
| 672 | + $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
| 673 | + $title, |
|
| 674 | + $intro, |
|
| 675 | + $form_url, |
|
| 676 | + $action, |
|
| 677 | + $type |
|
| 678 | + ); |
|
| 679 | + |
|
| 680 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 681 | + ['action' => 'sample_export_file'], |
|
| 682 | + $this->_admin_base_url |
|
| 683 | + ); |
|
| 684 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 685 | + EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
| 686 | + $this->_template_args, |
|
| 687 | + true |
|
| 688 | + ); |
|
| 689 | + $this->display_admin_page_with_sidebar(); |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * _import_events |
|
| 695 | + * This handles displaying the screen and running imports for importing events. |
|
| 696 | + * |
|
| 697 | + * @return void |
|
| 698 | + * @throws EE_Error |
|
| 699 | + */ |
|
| 700 | + protected function _import_events() |
|
| 701 | + { |
|
| 702 | + require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
| 703 | + $success = EE_Import::instance()->import(); |
|
| 704 | + $this->_redirect_after_action( |
|
| 705 | + $success, |
|
| 706 | + esc_html__('Import File', 'event_espresso'), |
|
| 707 | + 'ran', |
|
| 708 | + ['action' => 'import_page'], |
|
| 709 | + true |
|
| 710 | + ); |
|
| 711 | + } |
|
| 712 | + |
|
| 713 | + |
|
| 714 | + /** |
|
| 715 | + * _events_export |
|
| 716 | + * Will export all (or just the given event) to a Excel compatible file. |
|
| 717 | + * |
|
| 718 | + * @access protected |
|
| 719 | + * @return void |
|
| 720 | + */ |
|
| 721 | + protected function _events_export() |
|
| 722 | + { |
|
| 723 | + $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
|
| 724 | + $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int'); |
|
| 725 | + $this->request->mergeRequestParams( |
|
| 726 | + [ |
|
| 727 | + 'export' => 'report', |
|
| 728 | + 'action' => 'all_event_data', |
|
| 729 | + 'EVT_ID' => $EVT_ID, |
|
| 730 | + ] |
|
| 731 | + ); |
|
| 732 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 733 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 734 | + $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
| 735 | + $EE_Export->export(); |
|
| 736 | + } |
|
| 737 | + } |
|
| 738 | + |
|
| 739 | + |
|
| 740 | + /** |
|
| 741 | + * handle category exports() |
|
| 742 | + * |
|
| 743 | + * @return void |
|
| 744 | + */ |
|
| 745 | + protected function _categories_export() |
|
| 746 | + { |
|
| 747 | + $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int'); |
|
| 748 | + $this->request->mergeRequestParams( |
|
| 749 | + [ |
|
| 750 | + 'export' => 'report', |
|
| 751 | + 'action' => 'categories', |
|
| 752 | + 'EVT_ID' => $EVT_ID, |
|
| 753 | + ] |
|
| 754 | + ); |
|
| 755 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 756 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 757 | + $EE_Export = EE_Export::instance($this->request->requestParams()); |
|
| 758 | + $EE_Export->export(); |
|
| 759 | + } |
|
| 760 | + } |
|
| 761 | + |
|
| 762 | + |
|
| 763 | + /** |
|
| 764 | + * Creates a sample CSV file for importing |
|
| 765 | + */ |
|
| 766 | + protected function _sample_export_file() |
|
| 767 | + { |
|
| 768 | + $EE_Export = EE_Export::instance(); |
|
| 769 | + if ($EE_Export instanceof EE_Export) { |
|
| 770 | + $EE_Export->export(); |
|
| 771 | + } |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + |
|
| 775 | + /************* Template Settings *************/ |
|
| 776 | + /** |
|
| 777 | + * Generates template settings page output |
|
| 778 | + * |
|
| 779 | + * @throws DomainException |
|
| 780 | + * @throws EE_Error |
|
| 781 | + * @throws InvalidArgumentException |
|
| 782 | + * @throws InvalidDataTypeException |
|
| 783 | + * @throws InvalidInterfaceException |
|
| 784 | + */ |
|
| 785 | + protected function _template_settings() |
|
| 786 | + { |
|
| 787 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
| 788 | + /** |
|
| 789 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
| 790 | + * from General_Settings_Admin_Page to here. |
|
| 791 | + */ |
|
| 792 | + $this->_template_args = apply_filters( |
|
| 793 | + 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
| 794 | + $this->_template_args |
|
| 795 | + ); |
|
| 796 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
| 797 | + $this->_set_publish_post_box_vars(); |
|
| 798 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 799 | + EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
| 800 | + $this->_template_args, |
|
| 801 | + true |
|
| 802 | + ); |
|
| 803 | + $this->display_admin_page_with_sidebar(); |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + |
|
| 807 | + /** |
|
| 808 | + * Handler for updating template settings. |
|
| 809 | + * |
|
| 810 | + * @throws EE_Error |
|
| 811 | + */ |
|
| 812 | + protected function _update_template_settings() |
|
| 813 | + { |
|
| 814 | + /** |
|
| 815 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
| 816 | + * from General_Settings_Admin_Page to here. |
|
| 817 | + */ |
|
| 818 | + EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
| 819 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
| 820 | + EE_Registry::instance()->CFG->template_settings, |
|
| 821 | + $this->request->requestParams() |
|
| 822 | + ); |
|
| 823 | + // update custom post type slugs and detect if we need to flush rewrite rules |
|
| 824 | + $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
| 825 | + |
|
| 826 | + $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug'); |
|
| 827 | + |
|
| 828 | + EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug |
|
| 829 | + ? EEH_URL::slugify($event_cpt_slug, 'events') |
|
| 830 | + : EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
| 831 | + |
|
| 832 | + $what = esc_html__('Template Settings', 'event_espresso'); |
|
| 833 | + $success = $this->_update_espresso_configuration( |
|
| 834 | + $what, |
|
| 835 | + EE_Registry::instance()->CFG->template_settings, |
|
| 836 | + __FILE__, |
|
| 837 | + __FUNCTION__, |
|
| 838 | + __LINE__ |
|
| 839 | + ); |
|
| 840 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) { |
|
| 841 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
| 842 | + $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
| 843 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
| 844 | + ); |
|
| 845 | + $rewrite_rules->flush(); |
|
| 846 | + } |
|
| 847 | + $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']); |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + |
|
| 851 | + /** |
|
| 852 | + * _premium_event_editor_meta_boxes |
|
| 853 | + * add all metaboxes related to the event_editor |
|
| 854 | + * |
|
| 855 | + * @access protected |
|
| 856 | + * @return void |
|
| 857 | + * @throws EE_Error |
|
| 858 | + * @throws ReflectionException |
|
| 859 | + */ |
|
| 860 | + protected function _premium_event_editor_meta_boxes() |
|
| 861 | + { |
|
| 862 | + $this->verify_cpt_object(); |
|
| 863 | + // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
| 864 | + if ( |
|
| 865 | + ! $this->admin_config->useAdvancedEditor() |
|
| 866 | + || ! $this->feature->allowed('use_reg_options_meta_box') |
|
| 867 | + ) { |
|
| 868 | + $this->addMetaBox( |
|
| 869 | + 'espresso_event_editor_event_options', |
|
| 870 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
| 871 | + [$this, 'registration_options_meta_box'], |
|
| 872 | + $this->page_slug, |
|
| 873 | + 'side', |
|
| 874 | + 'core' |
|
| 875 | + ); |
|
| 876 | + } |
|
| 877 | + } |
|
| 878 | + |
|
| 879 | + |
|
| 880 | + /** |
|
| 881 | + * override caf metabox |
|
| 882 | + * |
|
| 883 | + * @return void |
|
| 884 | + * @throws EE_Error |
|
| 885 | + * @throws ReflectionException |
|
| 886 | + */ |
|
| 887 | + public function registration_options_meta_box() |
|
| 888 | + { |
|
| 889 | + $yes_no_values = [ |
|
| 890 | + ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')], |
|
| 891 | + ['id' => false, 'text' => esc_html__('No', 'event_espresso')], |
|
| 892 | + ]; |
|
| 893 | + |
|
| 894 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 895 | + [ |
|
| 896 | + EEM_Registration::status_id_cancelled, |
|
| 897 | + EEM_Registration::status_id_declined, |
|
| 898 | + EEM_Registration::status_id_incomplete, |
|
| 899 | + EEM_Registration::status_id_wait_list, |
|
| 900 | + ], |
|
| 901 | + true |
|
| 902 | + ); |
|
| 903 | + |
|
| 904 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 905 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
| 906 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 907 | + |
|
| 908 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 909 | + 'default_reg_status', |
|
| 910 | + $default_reg_status_values, |
|
| 911 | + $this->_cpt_model_obj->default_registration_status(), |
|
| 912 | + '', |
|
| 913 | + 'ee-input-width--reg', |
|
| 914 | + false |
|
| 915 | + ); |
|
| 916 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 917 | + 'display_desc', |
|
| 918 | + $yes_no_values, |
|
| 919 | + $this->_cpt_model_obj->display_description() |
|
| 920 | + ); |
|
| 921 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 922 | + 'display_ticket_selector', |
|
| 923 | + $yes_no_values, |
|
| 924 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
| 925 | + '', |
|
| 926 | + 'ee-input-width--small', |
|
| 927 | + false |
|
| 928 | + ); |
|
| 929 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 930 | + 'EVT_default_registration_status', |
|
| 931 | + $default_reg_status_values, |
|
| 932 | + $this->_cpt_model_obj->default_registration_status(), |
|
| 933 | + '', |
|
| 934 | + 'ee-input-width--reg', |
|
| 935 | + false |
|
| 936 | + ); |
|
| 937 | + $template_args['additional_registration_options'] = apply_filters( |
|
| 938 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 939 | + '', |
|
| 940 | + $template_args, |
|
| 941 | + $yes_no_values, |
|
| 942 | + $default_reg_status_values |
|
| 943 | + ); |
|
| 944 | + EEH_Template::display_template( |
|
| 945 | + EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 946 | + $template_args |
|
| 947 | + ); |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + |
|
| 951 | + |
|
| 952 | + /** |
|
| 953 | + * wp_list_table_mods for caf |
|
| 954 | + * ============================ |
|
| 955 | + */ |
|
| 956 | + |
|
| 957 | + |
|
| 958 | + /** |
|
| 959 | + * espresso_event_months_dropdown |
|
| 960 | + * |
|
| 961 | + * @deprecatd 5.0.0.p |
|
| 962 | + * @access public |
|
| 963 | + * @return string dropdown listing month/year selections for events. |
|
| 964 | + * @throws EE_Error |
|
| 965 | + */ |
|
| 966 | + public function espresso_event_months_dropdown(): string |
|
| 967 | + { |
|
| 968 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
| 969 | + // Note we need to include any other filters that are set! |
|
| 970 | + return EEH_Form_Fields::generate_event_months_dropdown( |
|
| 971 | + $this->request->getRequestParam('month_range'), |
|
| 972 | + $this->request->getRequestParam('status'), |
|
| 973 | + $this->request->getRequestParam('EVT_CAT', 0, 'int'), |
|
| 974 | + $this->request->getRequestParam('active_status') |
|
| 975 | + ); |
|
| 976 | + } |
|
| 977 | + |
|
| 978 | + |
|
| 979 | + /** |
|
| 980 | + * returns a list of "active" statuses on the event |
|
| 981 | + * |
|
| 982 | + * @deprecatd 5.0.0.p |
|
| 983 | + * @param string $current_value whatever the current active status is |
|
| 984 | + * @return string |
|
| 985 | + */ |
|
| 986 | + public function active_status_dropdown(string $current_value = ''): string |
|
| 987 | + { |
|
| 988 | + $select_name = 'active_status'; |
|
| 989 | + $values = [ |
|
| 990 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
| 991 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
| 992 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
| 993 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
| 994 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
| 995 | + ]; |
|
| 996 | + |
|
| 997 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value); |
|
| 998 | + } |
|
| 999 | + |
|
| 1000 | + |
|
| 1001 | + /** |
|
| 1002 | + * returns a list of "venues" |
|
| 1003 | + * |
|
| 1004 | + * @deprecatd 5.0.0.p |
|
| 1005 | + * @param string $current_value whatever the current active status is |
|
| 1006 | + * @return string |
|
| 1007 | + * @throws EE_Error |
|
| 1008 | + * @throws ReflectionException |
|
| 1009 | + */ |
|
| 1010 | + protected function venuesDropdown(string $current_value = ''): string |
|
| 1011 | + { |
|
| 1012 | + $values = ['' => esc_html__('All Venues', 'event_espresso')]; |
|
| 1013 | + // populate the list of venues. |
|
| 1014 | + $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
|
| 1015 | + |
|
| 1016 | + foreach ($venues as $venue) { |
|
| 1017 | + $values[ $venue->ID() ] = $venue->name(); |
|
| 1018 | + } |
|
| 1019 | + |
|
| 1020 | + return EEH_Form_Fields::select_input('venue', $values, $current_value); |
|
| 1021 | + } |
|
| 1022 | + |
|
| 1023 | + |
|
| 1024 | + /** |
|
| 1025 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
| 1026 | + * |
|
| 1027 | + * @deprecatd 5.0.0.p |
|
| 1028 | + * @access public |
|
| 1029 | + * @return string html |
|
| 1030 | + * @throws EE_Error |
|
| 1031 | + * @throws ReflectionException |
|
| 1032 | + */ |
|
| 1033 | + public function category_dropdown(): string |
|
| 1034 | + { |
|
| 1035 | + return EEH_Form_Fields::generate_event_category_dropdown( |
|
| 1036 | + $this->request->getRequestParam('EVT_CAT', -1, 'int') |
|
| 1037 | + ); |
|
| 1038 | + } |
|
| 1039 | + |
|
| 1040 | + |
|
| 1041 | + /** |
|
| 1042 | + * get total number of events today |
|
| 1043 | + * |
|
| 1044 | + * @access public |
|
| 1045 | + * @return int |
|
| 1046 | + * @throws EE_Error |
|
| 1047 | + * @throws InvalidArgumentException |
|
| 1048 | + * @throws InvalidDataTypeException |
|
| 1049 | + * @throws InvalidInterfaceException |
|
| 1050 | + * @throws ReflectionException |
|
| 1051 | + */ |
|
| 1052 | + public function total_events_today(): int |
|
| 1053 | + { |
|
| 1054 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1055 | + 'DTT_EVT_start', |
|
| 1056 | + date('Y-m-d') . ' 00:00:00', |
|
| 1057 | + 'Y-m-d H:i:s', |
|
| 1058 | + 'UTC' |
|
| 1059 | + ); |
|
| 1060 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1061 | + 'DTT_EVT_start', |
|
| 1062 | + date('Y-m-d') . ' 23:59:59', |
|
| 1063 | + 'Y-m-d H:i:s', |
|
| 1064 | + 'UTC' |
|
| 1065 | + ); |
|
| 1066 | + $where = [ |
|
| 1067 | + 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
| 1068 | + ]; |
|
| 1069 | + return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
| 1070 | + } |
|
| 1071 | + |
|
| 1072 | + |
|
| 1073 | + /** |
|
| 1074 | + * get total number of events this month |
|
| 1075 | + * |
|
| 1076 | + * @access public |
|
| 1077 | + * @return int |
|
| 1078 | + * @throws EE_Error |
|
| 1079 | + * @throws InvalidArgumentException |
|
| 1080 | + * @throws InvalidDataTypeException |
|
| 1081 | + * @throws InvalidInterfaceException |
|
| 1082 | + * @throws ReflectionException |
|
| 1083 | + */ |
|
| 1084 | + public function total_events_this_month(): int |
|
| 1085 | + { |
|
| 1086 | + // Dates |
|
| 1087 | + $this_year_r = date('Y'); |
|
| 1088 | + $this_month_r = date('m'); |
|
| 1089 | + $days_this_month = date('t'); |
|
| 1090 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1091 | + 'DTT_EVT_start', |
|
| 1092 | + $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
| 1093 | + 'Y-m-d H:i:s', |
|
| 1094 | + 'UTC' |
|
| 1095 | + ); |
|
| 1096 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1097 | + 'DTT_EVT_start', |
|
| 1098 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
| 1099 | + 'Y-m-d H:i:s', |
|
| 1100 | + 'UTC' |
|
| 1101 | + ); |
|
| 1102 | + $where = [ |
|
| 1103 | + 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
|
| 1104 | + ]; |
|
| 1105 | + return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + |
|
| 1109 | + /** DEFAULT TICKETS STUFF **/ |
|
| 1110 | + |
|
| 1111 | + /** |
|
| 1112 | + * Output default tickets list table view. |
|
| 1113 | + * |
|
| 1114 | + * @throws EE_Error |
|
| 1115 | + */ |
|
| 1116 | + public function _tickets_overview_list_table() |
|
| 1117 | + { |
|
| 1118 | + if ( |
|
| 1119 | + $this->admin_config->useAdvancedEditor() |
|
| 1120 | + && $this->feature->allowed('use_default_ticket_manager') |
|
| 1121 | + ) { |
|
| 1122 | + // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
|
| 1123 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 1124 | + EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php', |
|
| 1125 | + [], |
|
| 1126 | + true |
|
| 1127 | + ); |
|
| 1128 | + $this->display_admin_page_with_no_sidebar(); |
|
| 1129 | + } else { |
|
| 1130 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
| 1131 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1132 | + } |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + |
|
| 1136 | + /** |
|
| 1137 | + * @param int $per_page |
|
| 1138 | + * @param bool $count |
|
| 1139 | + * @param bool $trashed |
|
| 1140 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
| 1141 | + * @throws EE_Error |
|
| 1142 | + * @throws ReflectionException |
|
| 1143 | + */ |
|
| 1144 | + public function get_default_tickets(int $per_page = 10, bool $count = false, bool $trashed = false) |
|
| 1145 | + { |
|
| 1146 | + $orderby = $this->request->getRequestParam('orderby', 'TKT_name'); |
|
| 1147 | + $order = $this->request->getRequestParam('order', 'ASC'); |
|
| 1148 | + switch ($orderby) { |
|
| 1149 | + case 'TKT_name': |
|
| 1150 | + $orderby = ['TKT_name' => $order]; |
|
| 1151 | + break; |
|
| 1152 | + case 'TKT_price': |
|
| 1153 | + $orderby = ['TKT_price' => $order]; |
|
| 1154 | + break; |
|
| 1155 | + case 'TKT_uses': |
|
| 1156 | + $orderby = ['TKT_uses' => $order]; |
|
| 1157 | + break; |
|
| 1158 | + case 'TKT_min': |
|
| 1159 | + $orderby = ['TKT_min' => $order]; |
|
| 1160 | + break; |
|
| 1161 | + case 'TKT_max': |
|
| 1162 | + $orderby = ['TKT_max' => $order]; |
|
| 1163 | + break; |
|
| 1164 | + case 'TKT_qty': |
|
| 1165 | + $orderby = ['TKT_qty' => $order]; |
|
| 1166 | + break; |
|
| 1167 | + } |
|
| 1168 | + |
|
| 1169 | + $current_page = $this->request->getRequestParam('paged', 1, 'int'); |
|
| 1170 | + $per_page = $this->request->getRequestParam('perpage', $per_page, 'int'); |
|
| 1171 | + $offset = ($current_page - 1) * $per_page; |
|
| 1172 | + |
|
| 1173 | + $where = [ |
|
| 1174 | + 'TKT_is_default' => 1, |
|
| 1175 | + 'TKT_deleted' => $trashed, |
|
| 1176 | + ]; |
|
| 1177 | + |
|
| 1178 | + $search_term = $this->request->getRequestParam('s'); |
|
| 1179 | + if ($search_term) { |
|
| 1180 | + $search_term = '%' . $search_term . '%'; |
|
| 1181 | + $where['OR'] = [ |
|
| 1182 | + 'TKT_name' => ['LIKE', $search_term], |
|
| 1183 | + 'TKT_description' => ['LIKE', $search_term], |
|
| 1184 | + ]; |
|
| 1185 | + } |
|
| 1186 | + |
|
| 1187 | + return $count |
|
| 1188 | + ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where]) |
|
| 1189 | + : EEM_Ticket::instance()->get_all_deleted_and_undeleted( |
|
| 1190 | + [ |
|
| 1191 | + $where, |
|
| 1192 | + 'order_by' => $orderby, |
|
| 1193 | + 'limit' => [$offset, $per_page], |
|
| 1194 | + 'group_by' => 'TKT_ID', |
|
| 1195 | + ] |
|
| 1196 | + ); |
|
| 1197 | + } |
|
| 1198 | + |
|
| 1199 | + |
|
| 1200 | + /** |
|
| 1201 | + * @param bool $trash |
|
| 1202 | + * @throws EE_Error |
|
| 1203 | + * @throws InvalidArgumentException |
|
| 1204 | + * @throws InvalidDataTypeException |
|
| 1205 | + * @throws InvalidInterfaceException |
|
| 1206 | + * @throws ReflectionException |
|
| 1207 | + */ |
|
| 1208 | + protected function _trash_or_restore_ticket(bool $trash = false) |
|
| 1209 | + { |
|
| 1210 | + $success = 1; |
|
| 1211 | + $TKT = EEM_Ticket::instance(); |
|
| 1212 | + // checkboxes? |
|
| 1213 | + $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
| 1214 | + if (! empty($checkboxes)) { |
|
| 1215 | + // if array has more than one element then success message should be plural |
|
| 1216 | + $success = count($checkboxes) > 1 ? 2 : 1; |
|
| 1217 | + // cycle thru the boxes |
|
| 1218 | + foreach ($checkboxes as $TKT_ID => $value) { |
|
| 1219 | + if ($trash) { |
|
| 1220 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1221 | + $success = 0; |
|
| 1222 | + } |
|
| 1223 | + } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1224 | + $success = 0; |
|
| 1225 | + } |
|
| 1226 | + } |
|
| 1227 | + } else { |
|
| 1228 | + // grab single id and trash |
|
| 1229 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
| 1230 | + if ($trash) { |
|
| 1231 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1232 | + $success = 0; |
|
| 1233 | + } |
|
| 1234 | + } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1235 | + $success = 0; |
|
| 1236 | + } |
|
| 1237 | + } |
|
| 1238 | + $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
| 1239 | + $query_args = [ |
|
| 1240 | + 'action' => 'ticket_list_table', |
|
| 1241 | + 'status' => $trash ? '' : 'trashed', |
|
| 1242 | + ]; |
|
| 1243 | + $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
| 1244 | + } |
|
| 1245 | + |
|
| 1246 | + |
|
| 1247 | + /** |
|
| 1248 | + * Handles trashing default ticket. |
|
| 1249 | + * |
|
| 1250 | + * @throws EE_Error |
|
| 1251 | + * @throws ReflectionException |
|
| 1252 | + */ |
|
| 1253 | + protected function _delete_ticket() |
|
| 1254 | + { |
|
| 1255 | + $success = 1; |
|
| 1256 | + // checkboxes? |
|
| 1257 | + $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
|
| 1258 | + if (! empty($checkboxes)) { |
|
| 1259 | + // if array has more than one element then success message should be plural |
|
| 1260 | + $success = count($checkboxes) > 1 ? 2 : 1; |
|
| 1261 | + // cycle thru the boxes |
|
| 1262 | + foreach ($checkboxes as $TKT_ID => $value) { |
|
| 1263 | + // delete |
|
| 1264 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1265 | + $success = 0; |
|
| 1266 | + } |
|
| 1267 | + } |
|
| 1268 | + } else { |
|
| 1269 | + // grab single id and trash |
|
| 1270 | + $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
|
| 1271 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1272 | + $success = 0; |
|
| 1273 | + } |
|
| 1274 | + } |
|
| 1275 | + $action_desc = 'deleted'; |
|
| 1276 | + $query_args = [ |
|
| 1277 | + 'action' => 'ticket_list_table', |
|
| 1278 | + 'status' => 'trashed', |
|
| 1279 | + ]; |
|
| 1280 | + // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
| 1281 | + if ( |
|
| 1282 | + EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
| 1283 | + [['TKT_is_default' => 1]], |
|
| 1284 | + 'TKT_ID', |
|
| 1285 | + true |
|
| 1286 | + ) |
|
| 1287 | + ) { |
|
| 1288 | + $query_args = []; |
|
| 1289 | + } |
|
| 1290 | + $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args); |
|
| 1291 | + } |
|
| 1292 | + |
|
| 1293 | + |
|
| 1294 | + /** |
|
| 1295 | + * @param int $TKT_ID |
|
| 1296 | + * @return bool|int |
|
| 1297 | + * @throws EE_Error |
|
| 1298 | + * @throws ReflectionException |
|
| 1299 | + */ |
|
| 1300 | + protected function _delete_the_ticket(int $TKT_ID) |
|
| 1301 | + { |
|
| 1302 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
| 1303 | + if (! $ticket instanceof EE_Ticket) { |
|
| 1304 | + return false; |
|
| 1305 | + } |
|
| 1306 | + $ticket->_remove_relations('Datetime'); |
|
| 1307 | + // delete all related prices first |
|
| 1308 | + $ticket->delete_related_permanently('Price'); |
|
| 1309 | + return $ticket->delete_permanently(); |
|
| 1310 | + } |
|
| 1311 | 1311 | } |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct($routing = true) |
| 26 | 26 | { |
| 27 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
| 28 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
| 29 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
| 30 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
| 27 | + if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
| 28 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
| 29 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
| 30 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
| 31 | 31 | } |
| 32 | 32 | parent::__construct($routing); |
| 33 | 33 | $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | parent::_set_page_config(); |
| 40 | 40 | |
| 41 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
| 41 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
| 42 | 42 | // is there an evt_id in the request? |
| 43 | 43 | $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
| 44 | 44 | $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int'); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | 'noheader' => true, |
| 137 | 137 | ], |
| 138 | 138 | ]; |
| 139 | - $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
| 139 | + $new_page_routes = array_merge($new_page_routes, $legacy_editor_page_routes); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | public function load_scripts_styles_edit() |
| 298 | 298 | { |
| 299 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
| 299 | + if ( ! $this->admin_config->useAdvancedEditor()) { |
|
| 300 | 300 | wp_register_script( |
| 301 | 301 | 'ee-event-editor-heartbeat', |
| 302 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
| 302 | + EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', |
|
| 303 | 303 | ['ee_admin_js', 'heartbeat'], |
| 304 | 304 | EVENT_ESPRESSO_VERSION, |
| 305 | 305 | true |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | wp_enqueue_script('event_editor_js'); |
| 311 | 311 | wp_register_style( |
| 312 | 312 | 'event-editor-css', |
| 313 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 313 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
| 314 | 314 | ['ee-admin-css'], |
| 315 | 315 | EVENT_ESPRESSO_VERSION |
| 316 | 316 | ); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | protected function _set_list_table_views_default() |
| 330 | 330 | { |
| 331 | 331 | parent::_set_list_table_views_default(); |
| 332 | - $new_views = [ |
|
| 332 | + $new_views = [ |
|
| 333 | 333 | 'today' => [ |
| 334 | 334 | 'slug' => 'today', |
| 335 | 335 | 'label' => esc_html__('Today', 'event_espresso'), |
@@ -378,8 +378,8 @@ discard block |
||
| 378 | 378 | ); |
| 379 | 379 | |
| 380 | 380 | $action_links[] = ' |
| 381 | - <a href="' . $reports_link . '" |
|
| 382 | - aria-label="' . esc_attr__('View Report', 'event_espresso') . '" |
|
| 381 | + <a href="' . $reports_link.'" |
|
| 382 | + aria-label="' . esc_attr__('View Report', 'event_espresso').'" |
|
| 383 | 383 | class="ee-aria-tooltip button button--icon-only" |
| 384 | 384 | > |
| 385 | 385 | <span class="dashicons dashicons-chart-bar"></span> |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | // first make sure the ID for the event is in the request. |
| 447 | 447 | // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
| 448 | 448 | $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int'); |
| 449 | - if (! $EVT_ID) { |
|
| 449 | + if ( ! $EVT_ID) { |
|
| 450 | 450 | EE_Error::add_error( |
| 451 | 451 | esc_html__( |
| 452 | 452 | 'In order to duplicate an event an Event ID is required. None was given.', |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | // k we've got EVT_ID so let's use that to get the event we'll duplicate |
| 463 | 463 | $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
| 464 | - if (! $orig_event instanceof EE_Event) { |
|
| 464 | + if ( ! $orig_event instanceof EE_Event) { |
|
| 465 | 465 | throw new EE_Error( |
| 466 | 466 | sprintf( |
| 467 | 467 | esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | $orig_ven = $orig_event->get_many_related('Venue'); |
| 478 | 478 | // reset the ID and modify other details to make it clear this is a dupe |
| 479 | 479 | $new_event->set('EVT_ID', 0); |
| 480 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
| 480 | + $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso'); |
|
| 481 | 481 | $new_event->set('EVT_name', $new_name); |
| 482 | 482 | $new_event->set( |
| 483 | 483 | 'EVT_slug', |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | 'Question_Group', |
| 507 | 507 | [['Event_Question_Group.EQG_primary' => true]] |
| 508 | 508 | ); |
| 509 | - if (! empty($orig_primary_qgs)) { |
|
| 509 | + if ( ! empty($orig_primary_qgs)) { |
|
| 510 | 510 | foreach ($orig_primary_qgs as $obj) { |
| 511 | 511 | if ($obj instanceof EE_Question_Group) { |
| 512 | 512 | $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | 'Question_Group', |
| 519 | 519 | [['Event_Question_Group.EQG_additional' => true]] |
| 520 | 520 | ); |
| 521 | - if (! empty($orig_additional_qgs)) { |
|
| 521 | + if ( ! empty($orig_additional_qgs)) { |
|
| 522 | 522 | foreach ($orig_additional_qgs as $obj) { |
| 523 | 523 | if ($obj instanceof EE_Question_Group) { |
| 524 | 524 | $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
| 532 | 532 | $cloned_tickets = []; |
| 533 | 533 | foreach ($orig_datetimes as $orig_dtt) { |
| 534 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
| 534 | + if ( ! $orig_dtt instanceof EE_Datetime) { |
|
| 535 | 535 | continue; |
| 536 | 536 | } |
| 537 | 537 | $new_dtt = clone $orig_dtt; |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | // now let's get the ticket relations setup. |
| 547 | 547 | foreach ((array) $orig_tickets as $orig_ticket) { |
| 548 | 548 | // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
| 549 | - if (! $orig_ticket instanceof EE_Ticket) { |
|
| 549 | + if ( ! $orig_ticket instanceof EE_Ticket) { |
|
| 550 | 550 | continue; |
| 551 | 551 | } |
| 552 | 552 | // is this ticket archived? If it is then let's skip |
@@ -555,8 +555,8 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | // does this original ticket already exist in the clone_tickets cache? |
| 557 | 557 | // If so we'll just use the new ticket from it. |
| 558 | - if (isset($cloned_tickets[ $orig_ticket->ID() ])) { |
|
| 559 | - $new_ticket = $cloned_tickets[ $orig_ticket->ID() ]; |
|
| 558 | + if (isset($cloned_tickets[$orig_ticket->ID()])) { |
|
| 559 | + $new_ticket = $cloned_tickets[$orig_ticket->ID()]; |
|
| 560 | 560 | } else { |
| 561 | 561 | $new_ticket = clone $orig_ticket; |
| 562 | 562 | // get relations on the $orig_ticket that we need to set up. |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | $orig_dtt, |
| 591 | 591 | $new_dtt |
| 592 | 592 | ); |
| 593 | - $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket; |
|
| 593 | + $cloned_tickets[$orig_ticket->ID()] = $new_ticket; |
|
| 594 | 594 | } |
| 595 | 595 | // k now we can add the new ticket as a relation to the new datetime |
| 596 | 596 | // and make sure it's added to our cached $cloned_tickets array |
@@ -677,12 +677,12 @@ discard block |
||
| 677 | 677 | $type |
| 678 | 678 | ); |
| 679 | 679 | |
| 680 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 680 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 681 | 681 | ['action' => 'sample_export_file'], |
| 682 | 682 | $this->_admin_base_url |
| 683 | 683 | ); |
| 684 | 684 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 685 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
| 685 | + EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', |
|
| 686 | 686 | $this->_template_args, |
| 687 | 687 | true |
| 688 | 688 | ); |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | */ |
| 700 | 700 | protected function _import_events() |
| 701 | 701 | { |
| 702 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
| 702 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
| 703 | 703 | $success = EE_Import::instance()->import(); |
| 704 | 704 | $this->_redirect_after_action( |
| 705 | 705 | $success, |
@@ -729,8 +729,8 @@ discard block |
||
| 729 | 729 | 'EVT_ID' => $EVT_ID, |
| 730 | 730 | ] |
| 731 | 731 | ); |
| 732 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 733 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 732 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 733 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 734 | 734 | $EE_Export = EE_Export::instance($this->request->requestParams()); |
| 735 | 735 | $EE_Export->export(); |
| 736 | 736 | } |
@@ -752,8 +752,8 @@ discard block |
||
| 752 | 752 | 'EVT_ID' => $EVT_ID, |
| 753 | 753 | ] |
| 754 | 754 | ); |
| 755 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 756 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 755 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 756 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 757 | 757 | $EE_Export = EE_Export::instance($this->request->requestParams()); |
| 758 | 758 | $EE_Export->export(); |
| 759 | 759 | } |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | $this->_set_add_edit_form_tags('update_template_settings'); |
| 797 | 797 | $this->_set_publish_post_box_vars(); |
| 798 | 798 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 799 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
| 799 | + EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', |
|
| 800 | 800 | $this->_template_args, |
| 801 | 801 | true |
| 802 | 802 | ); |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | $template_args['_event'] = $this->_cpt_model_obj; |
| 906 | 906 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
| 907 | 907 | |
| 908 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 908 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 909 | 909 | 'default_reg_status', |
| 910 | 910 | $default_reg_status_values, |
| 911 | 911 | $this->_cpt_model_obj->default_registration_status(), |
@@ -913,12 +913,12 @@ discard block |
||
| 913 | 913 | 'ee-input-width--reg', |
| 914 | 914 | false |
| 915 | 915 | ); |
| 916 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 916 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 917 | 917 | 'display_desc', |
| 918 | 918 | $yes_no_values, |
| 919 | 919 | $this->_cpt_model_obj->display_description() |
| 920 | 920 | ); |
| 921 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 921 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 922 | 922 | 'display_ticket_selector', |
| 923 | 923 | $yes_no_values, |
| 924 | 924 | $this->_cpt_model_obj->display_ticket_selector(), |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | $default_reg_status_values |
| 943 | 943 | ); |
| 944 | 944 | EEH_Template::display_template( |
| 945 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 945 | + EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php', |
|
| 946 | 946 | $template_args |
| 947 | 947 | ); |
| 948 | 948 | } |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]); |
| 1015 | 1015 | |
| 1016 | 1016 | foreach ($venues as $venue) { |
| 1017 | - $values[ $venue->ID() ] = $venue->name(); |
|
| 1017 | + $values[$venue->ID()] = $venue->name(); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | return EEH_Form_Fields::select_input('venue', $values, $current_value); |
@@ -1053,13 +1053,13 @@ discard block |
||
| 1053 | 1053 | { |
| 1054 | 1054 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
| 1055 | 1055 | 'DTT_EVT_start', |
| 1056 | - date('Y-m-d') . ' 00:00:00', |
|
| 1056 | + date('Y-m-d').' 00:00:00', |
|
| 1057 | 1057 | 'Y-m-d H:i:s', |
| 1058 | 1058 | 'UTC' |
| 1059 | 1059 | ); |
| 1060 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1060 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1061 | 1061 | 'DTT_EVT_start', |
| 1062 | - date('Y-m-d') . ' 23:59:59', |
|
| 1062 | + date('Y-m-d').' 23:59:59', |
|
| 1063 | 1063 | 'Y-m-d H:i:s', |
| 1064 | 1064 | 'UTC' |
| 1065 | 1065 | ); |
@@ -1089,17 +1089,17 @@ discard block |
||
| 1089 | 1089 | $days_this_month = date('t'); |
| 1090 | 1090 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
| 1091 | 1091 | 'DTT_EVT_start', |
| 1092 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
| 1092 | + $this_year_r.'-'.$this_month_r.'-01 00:00:00', |
|
| 1093 | 1093 | 'Y-m-d H:i:s', |
| 1094 | 1094 | 'UTC' |
| 1095 | 1095 | ); |
| 1096 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1096 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1097 | 1097 | 'DTT_EVT_start', |
| 1098 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
| 1098 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', |
|
| 1099 | 1099 | 'Y-m-d H:i:s', |
| 1100 | 1100 | 'UTC' |
| 1101 | 1101 | ); |
| 1102 | - $where = [ |
|
| 1102 | + $where = [ |
|
| 1103 | 1103 | 'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]], |
| 1104 | 1104 | ]; |
| 1105 | 1105 | return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true); |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | ) { |
| 1122 | 1122 | // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version |
| 1123 | 1123 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 1124 | - EVENTS_CAF_TEMPLATE_PATH . 'default_tickets_moved_notice.template.php', |
|
| 1124 | + EVENTS_CAF_TEMPLATE_PATH.'default_tickets_moved_notice.template.php', |
|
| 1125 | 1125 | [], |
| 1126 | 1126 | true |
| 1127 | 1127 | ); |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | |
| 1178 | 1178 | $search_term = $this->request->getRequestParam('s'); |
| 1179 | 1179 | if ($search_term) { |
| 1180 | - $search_term = '%' . $search_term . '%'; |
|
| 1180 | + $search_term = '%'.$search_term.'%'; |
|
| 1181 | 1181 | $where['OR'] = [ |
| 1182 | 1182 | 'TKT_name' => ['LIKE', $search_term], |
| 1183 | 1183 | 'TKT_description' => ['LIKE', $search_term], |
@@ -1211,16 +1211,16 @@ discard block |
||
| 1211 | 1211 | $TKT = EEM_Ticket::instance(); |
| 1212 | 1212 | // checkboxes? |
| 1213 | 1213 | $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
| 1214 | - if (! empty($checkboxes)) { |
|
| 1214 | + if ( ! empty($checkboxes)) { |
|
| 1215 | 1215 | // if array has more than one element then success message should be plural |
| 1216 | 1216 | $success = count($checkboxes) > 1 ? 2 : 1; |
| 1217 | 1217 | // cycle thru the boxes |
| 1218 | 1218 | foreach ($checkboxes as $TKT_ID => $value) { |
| 1219 | 1219 | if ($trash) { |
| 1220 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1220 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1221 | 1221 | $success = 0; |
| 1222 | 1222 | } |
| 1223 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1223 | + } elseif ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1224 | 1224 | $success = 0; |
| 1225 | 1225 | } |
| 1226 | 1226 | } |
@@ -1228,10 +1228,10 @@ discard block |
||
| 1228 | 1228 | // grab single id and trash |
| 1229 | 1229 | $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
| 1230 | 1230 | if ($trash) { |
| 1231 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1231 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1232 | 1232 | $success = 0; |
| 1233 | 1233 | } |
| 1234 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1234 | + } elseif ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1235 | 1235 | $success = 0; |
| 1236 | 1236 | } |
| 1237 | 1237 | } |
@@ -1255,20 +1255,20 @@ discard block |
||
| 1255 | 1255 | $success = 1; |
| 1256 | 1256 | // checkboxes? |
| 1257 | 1257 | $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true); |
| 1258 | - if (! empty($checkboxes)) { |
|
| 1258 | + if ( ! empty($checkboxes)) { |
|
| 1259 | 1259 | // if array has more than one element then success message should be plural |
| 1260 | 1260 | $success = count($checkboxes) > 1 ? 2 : 1; |
| 1261 | 1261 | // cycle thru the boxes |
| 1262 | 1262 | foreach ($checkboxes as $TKT_ID => $value) { |
| 1263 | 1263 | // delete |
| 1264 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1264 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1265 | 1265 | $success = 0; |
| 1266 | 1266 | } |
| 1267 | 1267 | } |
| 1268 | 1268 | } else { |
| 1269 | 1269 | // grab single id and trash |
| 1270 | 1270 | $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int'); |
| 1271 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1271 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1272 | 1272 | $success = 0; |
| 1273 | 1273 | } |
| 1274 | 1274 | } |
@@ -1300,7 +1300,7 @@ discard block |
||
| 1300 | 1300 | protected function _delete_the_ticket(int $TKT_ID) |
| 1301 | 1301 | { |
| 1302 | 1302 | $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
| 1303 | - if (! $ticket instanceof EE_Ticket) { |
|
| 1303 | + if ( ! $ticket instanceof EE_Ticket) { |
|
| 1304 | 1304 | return false; |
| 1305 | 1305 | } |
| 1306 | 1306 | $ticket->_remove_relations('Datetime'); |
@@ -15,2331 +15,2331 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class espresso_events_Events_Hooks_Extend extends EE_Admin_Hooks |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * This property is just used to hold the status of whether an event is currently being |
|
| 20 | - * created (true) or edited (false) |
|
| 21 | - * |
|
| 22 | - * @access protected |
|
| 23 | - * @var bool |
|
| 24 | - */ |
|
| 25 | - protected $_is_creating_event; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Used to contain the format strings for date and time that will be used for php date and |
|
| 29 | - * time. |
|
| 30 | - * Is set in the _set_hooks_properties() method. |
|
| 31 | - * |
|
| 32 | - * @var array |
|
| 33 | - */ |
|
| 34 | - protected $_date_format_strings; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var string $_date_time_format |
|
| 38 | - */ |
|
| 39 | - protected $_date_time_format; |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @throws InvalidArgumentException |
|
| 44 | - * @throws InvalidInterfaceException |
|
| 45 | - * @throws InvalidDataTypeException |
|
| 46 | - */ |
|
| 47 | - protected function _set_hooks_properties() |
|
| 48 | - { |
|
| 49 | - $this->_name = 'events'; |
|
| 50 | - // capability check |
|
| 51 | - if ( |
|
| 52 | - $this->_adminpage_obj->adminConfig()->useAdvancedEditor() |
|
| 53 | - || ! EE_Registry::instance()->CAP->current_user_can( |
|
| 54 | - 'ee_read_default_prices', |
|
| 55 | - 'advanced_ticket_datetime_metabox' |
|
| 56 | - ) |
|
| 57 | - ) { |
|
| 58 | - $this->_metaboxes = []; |
|
| 59 | - $this->_scripts_styles = []; |
|
| 60 | - return; |
|
| 61 | - } |
|
| 62 | - $this->_setup_metaboxes(); |
|
| 63 | - $this->_set_date_time_formats(); |
|
| 64 | - $this->_validate_format_strings(); |
|
| 65 | - $this->_set_scripts_styles(); |
|
| 66 | - add_filter( |
|
| 67 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 68 | - [$this, 'caf_updates'] |
|
| 69 | - ); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * @return void |
|
| 75 | - */ |
|
| 76 | - protected function _setup_metaboxes() |
|
| 77 | - { |
|
| 78 | - // if we were going to add our own metaboxes we'd use the below. |
|
| 79 | - $this->_metaboxes = [ |
|
| 80 | - 0 => [ |
|
| 81 | - 'page_route' => ['edit', 'create_new'], |
|
| 82 | - 'func' => [$this, 'pricing_metabox'], |
|
| 83 | - 'label' => esc_html__('Event Tickets & Datetimes', 'event_espresso'), |
|
| 84 | - 'priority' => 'high', |
|
| 85 | - 'context' => 'normal', |
|
| 86 | - ], |
|
| 87 | - ]; |
|
| 88 | - $this->_remove_metaboxes = [ |
|
| 89 | - 0 => [ |
|
| 90 | - 'page_route' => ['edit', 'create_new'], |
|
| 91 | - 'id' => 'espresso_event_editor_tickets', |
|
| 92 | - 'context' => 'normal', |
|
| 93 | - ], |
|
| 94 | - ]; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @return void |
|
| 100 | - */ |
|
| 101 | - protected function _set_date_time_formats() |
|
| 102 | - { |
|
| 103 | - /** |
|
| 104 | - * Format strings for date and time. Defaults are existing behaviour from 4.1. |
|
| 105 | - * Note, that if you return null as the value for 'date', and 'time' in the array, then |
|
| 106 | - * EE will automatically use the set wp_options, 'date_format', and 'time_format'. |
|
| 107 | - * |
|
| 108 | - * @since 4.6.7 |
|
| 109 | - * @var array Expected an array returned with 'date' and 'time' keys. |
|
| 110 | - */ |
|
| 111 | - $this->_date_format_strings = apply_filters( |
|
| 112 | - 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', |
|
| 113 | - [ |
|
| 114 | - 'date' => 'Y-m-d', |
|
| 115 | - 'time' => 'h:i a', |
|
| 116 | - ] |
|
| 117 | - ); |
|
| 118 | - // validate |
|
| 119 | - $this->_date_format_strings['date'] = $this->_date_format_strings['date'] ?? ''; |
|
| 120 | - $this->_date_format_strings['time'] = $this->_date_format_strings['time'] ?? ''; |
|
| 121 | - |
|
| 122 | - $this->_date_time_format = $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @return void |
|
| 128 | - */ |
|
| 129 | - protected function _validate_format_strings() |
|
| 130 | - { |
|
| 131 | - // validate format strings |
|
| 132 | - $format_validation = EEH_DTT_Helper::validate_format_string( |
|
| 133 | - $this->_date_time_format |
|
| 134 | - ); |
|
| 135 | - if (is_array($format_validation)) { |
|
| 136 | - $msg = '<p>'; |
|
| 137 | - $msg .= sprintf( |
|
| 138 | - esc_html__( |
|
| 139 | - 'The format "%s" was likely added via a filter and is invalid for the following reasons:', |
|
| 140 | - 'event_espresso' |
|
| 141 | - ), |
|
| 142 | - $this->_date_time_format |
|
| 143 | - ); |
|
| 144 | - $msg .= '</p><ul>'; |
|
| 145 | - foreach ($format_validation as $error) { |
|
| 146 | - $msg .= '<li>' . $error . '</li>'; |
|
| 147 | - } |
|
| 148 | - $msg .= '</ul><p>'; |
|
| 149 | - $msg .= sprintf( |
|
| 150 | - esc_html__( |
|
| 151 | - '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', |
|
| 152 | - 'event_espresso' |
|
| 153 | - ), |
|
| 154 | - '<span style="color:#D54E21;">', |
|
| 155 | - '</span>' |
|
| 156 | - ); |
|
| 157 | - $msg .= '</p>'; |
|
| 158 | - EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 159 | - $this->_date_format_strings = [ |
|
| 160 | - 'date' => 'Y-m-d', |
|
| 161 | - 'time' => 'h:i a', |
|
| 162 | - ]; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * @return void |
|
| 169 | - */ |
|
| 170 | - protected function _set_scripts_styles() |
|
| 171 | - { |
|
| 172 | - $this->_scripts_styles = [ |
|
| 173 | - 'registers' => [ |
|
| 174 | - 'ee-tickets-datetimes-css' => [ |
|
| 175 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
| 176 | - 'type' => 'css', |
|
| 177 | - ], |
|
| 178 | - 'ee-dtt-ticket-metabox' => [ |
|
| 179 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
| 180 | - 'depends' => ['ee-datepicker', 'ee-dialog', 'underscore'], |
|
| 181 | - ], |
|
| 182 | - ], |
|
| 183 | - 'deregisters' => [ |
|
| 184 | - 'event-editor-css' => ['type' => 'css'], |
|
| 185 | - 'event-datetime-metabox' => ['type' => 'js'], |
|
| 186 | - ], |
|
| 187 | - 'enqueues' => [ |
|
| 188 | - 'ee-tickets-datetimes-css' => ['edit', 'create_new'], |
|
| 189 | - 'ee-dtt-ticket-metabox' => ['edit', 'create_new'], |
|
| 190 | - ], |
|
| 191 | - 'localize' => [ |
|
| 192 | - 'ee-dtt-ticket-metabox' => [ |
|
| 193 | - 'DTT_TRASH_BLOCK' => [ |
|
| 194 | - 'main_warning' => esc_html__( |
|
| 195 | - 'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', |
|
| 196 | - 'event_espresso' |
|
| 197 | - ), |
|
| 198 | - 'after_warning' => esc_html__( |
|
| 199 | - 'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', |
|
| 200 | - 'event_espresso' |
|
| 201 | - ), |
|
| 202 | - 'cancel_button' => ' |
|
| 18 | + /** |
|
| 19 | + * This property is just used to hold the status of whether an event is currently being |
|
| 20 | + * created (true) or edited (false) |
|
| 21 | + * |
|
| 22 | + * @access protected |
|
| 23 | + * @var bool |
|
| 24 | + */ |
|
| 25 | + protected $_is_creating_event; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Used to contain the format strings for date and time that will be used for php date and |
|
| 29 | + * time. |
|
| 30 | + * Is set in the _set_hooks_properties() method. |
|
| 31 | + * |
|
| 32 | + * @var array |
|
| 33 | + */ |
|
| 34 | + protected $_date_format_strings; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var string $_date_time_format |
|
| 38 | + */ |
|
| 39 | + protected $_date_time_format; |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @throws InvalidArgumentException |
|
| 44 | + * @throws InvalidInterfaceException |
|
| 45 | + * @throws InvalidDataTypeException |
|
| 46 | + */ |
|
| 47 | + protected function _set_hooks_properties() |
|
| 48 | + { |
|
| 49 | + $this->_name = 'events'; |
|
| 50 | + // capability check |
|
| 51 | + if ( |
|
| 52 | + $this->_adminpage_obj->adminConfig()->useAdvancedEditor() |
|
| 53 | + || ! EE_Registry::instance()->CAP->current_user_can( |
|
| 54 | + 'ee_read_default_prices', |
|
| 55 | + 'advanced_ticket_datetime_metabox' |
|
| 56 | + ) |
|
| 57 | + ) { |
|
| 58 | + $this->_metaboxes = []; |
|
| 59 | + $this->_scripts_styles = []; |
|
| 60 | + return; |
|
| 61 | + } |
|
| 62 | + $this->_setup_metaboxes(); |
|
| 63 | + $this->_set_date_time_formats(); |
|
| 64 | + $this->_validate_format_strings(); |
|
| 65 | + $this->_set_scripts_styles(); |
|
| 66 | + add_filter( |
|
| 67 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 68 | + [$this, 'caf_updates'] |
|
| 69 | + ); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * @return void |
|
| 75 | + */ |
|
| 76 | + protected function _setup_metaboxes() |
|
| 77 | + { |
|
| 78 | + // if we were going to add our own metaboxes we'd use the below. |
|
| 79 | + $this->_metaboxes = [ |
|
| 80 | + 0 => [ |
|
| 81 | + 'page_route' => ['edit', 'create_new'], |
|
| 82 | + 'func' => [$this, 'pricing_metabox'], |
|
| 83 | + 'label' => esc_html__('Event Tickets & Datetimes', 'event_espresso'), |
|
| 84 | + 'priority' => 'high', |
|
| 85 | + 'context' => 'normal', |
|
| 86 | + ], |
|
| 87 | + ]; |
|
| 88 | + $this->_remove_metaboxes = [ |
|
| 89 | + 0 => [ |
|
| 90 | + 'page_route' => ['edit', 'create_new'], |
|
| 91 | + 'id' => 'espresso_event_editor_tickets', |
|
| 92 | + 'context' => 'normal', |
|
| 93 | + ], |
|
| 94 | + ]; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @return void |
|
| 100 | + */ |
|
| 101 | + protected function _set_date_time_formats() |
|
| 102 | + { |
|
| 103 | + /** |
|
| 104 | + * Format strings for date and time. Defaults are existing behaviour from 4.1. |
|
| 105 | + * Note, that if you return null as the value for 'date', and 'time' in the array, then |
|
| 106 | + * EE will automatically use the set wp_options, 'date_format', and 'time_format'. |
|
| 107 | + * |
|
| 108 | + * @since 4.6.7 |
|
| 109 | + * @var array Expected an array returned with 'date' and 'time' keys. |
|
| 110 | + */ |
|
| 111 | + $this->_date_format_strings = apply_filters( |
|
| 112 | + 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', |
|
| 113 | + [ |
|
| 114 | + 'date' => 'Y-m-d', |
|
| 115 | + 'time' => 'h:i a', |
|
| 116 | + ] |
|
| 117 | + ); |
|
| 118 | + // validate |
|
| 119 | + $this->_date_format_strings['date'] = $this->_date_format_strings['date'] ?? ''; |
|
| 120 | + $this->_date_format_strings['time'] = $this->_date_format_strings['time'] ?? ''; |
|
| 121 | + |
|
| 122 | + $this->_date_time_format = $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @return void |
|
| 128 | + */ |
|
| 129 | + protected function _validate_format_strings() |
|
| 130 | + { |
|
| 131 | + // validate format strings |
|
| 132 | + $format_validation = EEH_DTT_Helper::validate_format_string( |
|
| 133 | + $this->_date_time_format |
|
| 134 | + ); |
|
| 135 | + if (is_array($format_validation)) { |
|
| 136 | + $msg = '<p>'; |
|
| 137 | + $msg .= sprintf( |
|
| 138 | + esc_html__( |
|
| 139 | + 'The format "%s" was likely added via a filter and is invalid for the following reasons:', |
|
| 140 | + 'event_espresso' |
|
| 141 | + ), |
|
| 142 | + $this->_date_time_format |
|
| 143 | + ); |
|
| 144 | + $msg .= '</p><ul>'; |
|
| 145 | + foreach ($format_validation as $error) { |
|
| 146 | + $msg .= '<li>' . $error . '</li>'; |
|
| 147 | + } |
|
| 148 | + $msg .= '</ul><p>'; |
|
| 149 | + $msg .= sprintf( |
|
| 150 | + esc_html__( |
|
| 151 | + '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', |
|
| 152 | + 'event_espresso' |
|
| 153 | + ), |
|
| 154 | + '<span style="color:#D54E21;">', |
|
| 155 | + '</span>' |
|
| 156 | + ); |
|
| 157 | + $msg .= '</p>'; |
|
| 158 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 159 | + $this->_date_format_strings = [ |
|
| 160 | + 'date' => 'Y-m-d', |
|
| 161 | + 'time' => 'h:i a', |
|
| 162 | + ]; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * @return void |
|
| 169 | + */ |
|
| 170 | + protected function _set_scripts_styles() |
|
| 171 | + { |
|
| 172 | + $this->_scripts_styles = [ |
|
| 173 | + 'registers' => [ |
|
| 174 | + 'ee-tickets-datetimes-css' => [ |
|
| 175 | + 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
| 176 | + 'type' => 'css', |
|
| 177 | + ], |
|
| 178 | + 'ee-dtt-ticket-metabox' => [ |
|
| 179 | + 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
| 180 | + 'depends' => ['ee-datepicker', 'ee-dialog', 'underscore'], |
|
| 181 | + ], |
|
| 182 | + ], |
|
| 183 | + 'deregisters' => [ |
|
| 184 | + 'event-editor-css' => ['type' => 'css'], |
|
| 185 | + 'event-datetime-metabox' => ['type' => 'js'], |
|
| 186 | + ], |
|
| 187 | + 'enqueues' => [ |
|
| 188 | + 'ee-tickets-datetimes-css' => ['edit', 'create_new'], |
|
| 189 | + 'ee-dtt-ticket-metabox' => ['edit', 'create_new'], |
|
| 190 | + ], |
|
| 191 | + 'localize' => [ |
|
| 192 | + 'ee-dtt-ticket-metabox' => [ |
|
| 193 | + 'DTT_TRASH_BLOCK' => [ |
|
| 194 | + 'main_warning' => esc_html__( |
|
| 195 | + 'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', |
|
| 196 | + 'event_espresso' |
|
| 197 | + ), |
|
| 198 | + 'after_warning' => esc_html__( |
|
| 199 | + 'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', |
|
| 200 | + 'event_espresso' |
|
| 201 | + ), |
|
| 202 | + 'cancel_button' => ' |
|
| 203 | 203 | <button class="button--secondary ee-modal-cancel"> |
| 204 | 204 | ' . esc_html__('Cancel', 'event_espresso') . ' |
| 205 | 205 | </button>', |
| 206 | - 'close_button' => ' |
|
| 206 | + 'close_button' => ' |
|
| 207 | 207 | <button class="button--secondary ee-modal-cancel"> |
| 208 | 208 | ' . esc_html__('Close', 'event_espresso') . ' |
| 209 | 209 | </button>', |
| 210 | - 'single_warning_from_tkt' => esc_html__( |
|
| 211 | - 'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', |
|
| 212 | - 'event_espresso' |
|
| 213 | - ), |
|
| 214 | - 'single_warning_from_dtt' => esc_html__( |
|
| 215 | - 'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', |
|
| 216 | - 'event_espresso' |
|
| 217 | - ), |
|
| 218 | - 'dismiss_button' => ' |
|
| 210 | + 'single_warning_from_tkt' => esc_html__( |
|
| 211 | + 'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', |
|
| 212 | + 'event_espresso' |
|
| 213 | + ), |
|
| 214 | + 'single_warning_from_dtt' => esc_html__( |
|
| 215 | + 'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', |
|
| 216 | + 'event_espresso' |
|
| 217 | + ), |
|
| 218 | + 'dismiss_button' => ' |
|
| 219 | 219 | <button class="button--secondary ee-modal-cancel"> |
| 220 | 220 | ' . esc_html__('Dismiss', 'event_espresso') . ' |
| 221 | 221 | </button>', |
| 222 | - ], |
|
| 223 | - 'DTT_ERROR_MSG' => [ |
|
| 224 | - 'no_ticket_name' => esc_html__('General Admission', 'event_espresso'), |
|
| 225 | - 'dismiss_button' => ' |
|
| 222 | + ], |
|
| 223 | + 'DTT_ERROR_MSG' => [ |
|
| 224 | + 'no_ticket_name' => esc_html__('General Admission', 'event_espresso'), |
|
| 225 | + 'dismiss_button' => ' |
|
| 226 | 226 | <div class="save-cancel-button-container"> |
| 227 | 227 | <button class="button--secondary ee-modal-cancel"> |
| 228 | 228 | ' . esc_html__('Dismiss', 'event_espresso') . ' |
| 229 | 229 | </button> |
| 230 | 230 | </div>', |
| 231 | - ], |
|
| 232 | - 'DTT_OVERSELL_WARNING' => [ |
|
| 233 | - 'datetime_ticket' => esc_html__( |
|
| 234 | - 'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', |
|
| 235 | - 'event_espresso' |
|
| 236 | - ), |
|
| 237 | - 'ticket_datetime' => esc_html__( |
|
| 238 | - 'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', |
|
| 239 | - 'event_espresso' |
|
| 240 | - ), |
|
| 241 | - ], |
|
| 242 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( |
|
| 243 | - $this->_date_format_strings['date'], |
|
| 244 | - $this->_date_format_strings['time'] |
|
| 245 | - ), |
|
| 246 | - 'DTT_START_OF_WEEK' => ['dayValue' => (int) get_option('start_of_week')], |
|
| 247 | - ], |
|
| 248 | - ], |
|
| 249 | - ]; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * @param array $update_callbacks |
|
| 255 | - * @return array |
|
| 256 | - */ |
|
| 257 | - public function caf_updates(array $update_callbacks): array |
|
| 258 | - { |
|
| 259 | - unset($update_callbacks['_default_tickets_update']); |
|
| 260 | - $update_callbacks['datetime_and_tickets_caf_update'] = [$this, 'datetime_and_tickets_caf_update']; |
|
| 261 | - return $update_callbacks; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
| 267 | - * |
|
| 268 | - * @param EE_Event $event The Event object we're attaching data to |
|
| 269 | - * @param array $data The request data from the form |
|
| 270 | - * @throws ReflectionException |
|
| 271 | - * @throws Exception |
|
| 272 | - * @throws InvalidInterfaceException |
|
| 273 | - * @throws InvalidDataTypeException |
|
| 274 | - * @throws EE_Error |
|
| 275 | - * @throws InvalidArgumentException |
|
| 276 | - */ |
|
| 277 | - public function datetime_and_tickets_caf_update(EE_Event $event, array $data) |
|
| 278 | - { |
|
| 279 | - // first we need to start with datetimes cause they are the "root" items attached to events. |
|
| 280 | - $saved_datetimes = $this->_update_datetimes($event, $data); |
|
| 281 | - // next tackle the tickets (and prices?) |
|
| 282 | - $this->_update_tickets($event, $saved_datetimes, $data); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * update event_datetimes |
|
| 288 | - * |
|
| 289 | - * @param EE_Event $event Event being updated |
|
| 290 | - * @param array $data the request data from the form |
|
| 291 | - * @return EE_Datetime[] |
|
| 292 | - * @throws Exception |
|
| 293 | - * @throws ReflectionException |
|
| 294 | - * @throws InvalidInterfaceException |
|
| 295 | - * @throws InvalidDataTypeException |
|
| 296 | - * @throws InvalidArgumentException |
|
| 297 | - * @throws EE_Error |
|
| 298 | - */ |
|
| 299 | - protected function _update_datetimes(EE_Event $event, array $data): array |
|
| 300 | - { |
|
| 301 | - $saved_datetime_ids = []; |
|
| 302 | - $saved_datetime_objs = []; |
|
| 303 | - $timezone = $data['timezone_string'] ?? null; |
|
| 304 | - $datetime_model = EEM_Datetime::instance($timezone); |
|
| 305 | - |
|
| 306 | - if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) { |
|
| 307 | - throw new InvalidArgumentException( |
|
| 308 | - esc_html__( |
|
| 309 | - 'The "edit_event_datetimes" array is invalid therefore the event can not be updated.', |
|
| 310 | - 'event_espresso' |
|
| 311 | - ) |
|
| 312 | - ); |
|
| 313 | - } |
|
| 314 | - foreach ($data['edit_event_datetimes'] as $row => $datetime_data) { |
|
| 315 | - // trim all values to ensure any excess whitespace is removed. |
|
| 316 | - $datetime_data = array_map( |
|
| 317 | - function ($datetime_data) { |
|
| 318 | - return is_array($datetime_data) |
|
| 319 | - ? $datetime_data |
|
| 320 | - : trim($datetime_data); |
|
| 321 | - }, |
|
| 322 | - $datetime_data |
|
| 323 | - ); |
|
| 324 | - |
|
| 325 | - $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end']) |
|
| 326 | - && ! empty($datetime_data['DTT_EVT_end']) |
|
| 327 | - ? $datetime_data['DTT_EVT_end'] |
|
| 328 | - : $datetime_data['DTT_EVT_start']; |
|
| 329 | - $datetime_values = [ |
|
| 330 | - 'DTT_ID' => ! empty($datetime_data['DTT_ID']) |
|
| 331 | - ? $datetime_data['DTT_ID'] |
|
| 332 | - : null, |
|
| 333 | - 'DTT_name' => ! empty($datetime_data['DTT_name']) |
|
| 334 | - ? $datetime_data['DTT_name'] |
|
| 335 | - : '', |
|
| 336 | - 'DTT_description' => ! empty($datetime_data['DTT_description']) |
|
| 337 | - ? $datetime_data['DTT_description'] |
|
| 338 | - : '', |
|
| 339 | - 'DTT_EVT_start' => $datetime_data['DTT_EVT_start'], |
|
| 340 | - 'DTT_EVT_end' => $datetime_data['DTT_EVT_end'], |
|
| 341 | - 'DTT_reg_limit' => empty($datetime_data['DTT_reg_limit']) |
|
| 342 | - ? EE_INF |
|
| 343 | - : $datetime_data['DTT_reg_limit'], |
|
| 344 | - 'DTT_order' => ! isset($datetime_data['DTT_order']) |
|
| 345 | - ? $row |
|
| 346 | - : $datetime_data['DTT_order'], |
|
| 347 | - ]; |
|
| 348 | - |
|
| 349 | - // if we have an id then let's get existing object first and then set the new values. |
|
| 350 | - // Otherwise we instantiate a new object for save. |
|
| 351 | - if (! empty($datetime_data['DTT_ID'])) { |
|
| 352 | - $datetime = EE_Registry::instance() |
|
| 353 | - ->load_model('Datetime', [$timezone]) |
|
| 354 | - ->get_one_by_ID($datetime_data['DTT_ID']); |
|
| 355 | - // set date and time format according to what is set in this class. |
|
| 356 | - $datetime->set_date_format($this->_date_format_strings['date']); |
|
| 357 | - $datetime->set_time_format($this->_date_format_strings['time']); |
|
| 358 | - foreach ($datetime_values as $field => $value) { |
|
| 359 | - $datetime->set($field, $value); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - // make sure the $datetime_id here is saved just in case |
|
| 363 | - // after the add_relation_to() the autosave replaces it. |
|
| 364 | - // We need to do this so we dont' TRASH the parent DTT. |
|
| 365 | - // (save the ID for both key and value to avoid duplications) |
|
| 366 | - $saved_datetime_ids[ $datetime->ID() ] = $datetime->ID(); |
|
| 367 | - } else { |
|
| 368 | - $datetime = EE_Datetime::new_instance( |
|
| 369 | - $datetime_values, |
|
| 370 | - $timezone, |
|
| 371 | - [$this->_date_format_strings['date'], $this->_date_format_strings['time']] |
|
| 372 | - ); |
|
| 373 | - foreach ($datetime_values as $field => $value) { |
|
| 374 | - $datetime->set($field, $value); |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - $datetime->save(); |
|
| 378 | - do_action( |
|
| 379 | - 'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save', |
|
| 380 | - $datetime, |
|
| 381 | - $row, |
|
| 382 | - $datetime_data, |
|
| 383 | - $data |
|
| 384 | - ); |
|
| 385 | - $datetime = $event->_add_relation_to($datetime, 'Datetime'); |
|
| 386 | - // before going any further make sure our dates are setup correctly |
|
| 387 | - // so that the end date is always equal or greater than the start date. |
|
| 388 | - if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) { |
|
| 389 | - $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start')); |
|
| 390 | - $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days'); |
|
| 391 | - $datetime->save(); |
|
| 392 | - } |
|
| 393 | - // now we have to make sure we add the new DTT_ID to the $saved_datetime_ids array |
|
| 394 | - // because it is possible there was a new one created for the autosave. |
|
| 395 | - // (save the ID for both key and value to avoid duplications) |
|
| 396 | - $DTT_ID = $datetime->ID(); |
|
| 397 | - $saved_datetime_ids[ $DTT_ID ] = $DTT_ID; |
|
| 398 | - $saved_datetime_objs[ $row ] = $datetime; |
|
| 399 | - // @todo if ANY of these updates fail then we want the appropriate global error message. |
|
| 400 | - } |
|
| 401 | - $event->save(); |
|
| 402 | - // now we need to REMOVE any datetimes that got deleted. |
|
| 403 | - // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them. |
|
| 404 | - // So its safe to permanently delete at this point. |
|
| 405 | - $old_datetimes = explode(',', $data['datetime_IDs']); |
|
| 406 | - $old_datetimes = $old_datetimes[0] === '' |
|
| 407 | - ? [] |
|
| 408 | - : $old_datetimes; |
|
| 409 | - if (is_array($old_datetimes)) { |
|
| 410 | - $datetimes_to_delete = array_diff($old_datetimes, $saved_datetime_ids); |
|
| 411 | - foreach ($datetimes_to_delete as $id) { |
|
| 412 | - $id = absint($id); |
|
| 413 | - if (empty($id)) { |
|
| 414 | - continue; |
|
| 415 | - } |
|
| 416 | - $dtt_to_remove = $datetime_model->get_one_by_ID($id); |
|
| 417 | - // remove tkt relationships. |
|
| 418 | - $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
|
| 419 | - foreach ($related_tickets as $ticket) { |
|
| 420 | - $dtt_to_remove->_remove_relation_to($ticket, 'Ticket'); |
|
| 421 | - } |
|
| 422 | - $event->_remove_relation_to($id, 'Datetime'); |
|
| 423 | - $dtt_to_remove->refresh_cache_of_related_objects(); |
|
| 424 | - } |
|
| 425 | - } |
|
| 426 | - return $saved_datetime_objs; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * update tickets |
|
| 432 | - * |
|
| 433 | - * @param EE_Event $event Event object being updated |
|
| 434 | - * @param EE_Datetime[] $saved_datetimes an array of datetime ids being updated |
|
| 435 | - * @param array $data incoming request data |
|
| 436 | - * @return EE_Ticket[] |
|
| 437 | - * @throws Exception |
|
| 438 | - * @throws ReflectionException |
|
| 439 | - * @throws InvalidInterfaceException |
|
| 440 | - * @throws InvalidDataTypeException |
|
| 441 | - * @throws InvalidArgumentException |
|
| 442 | - * @throws EE_Error |
|
| 443 | - */ |
|
| 444 | - protected function _update_tickets(EE_Event $event, array $saved_datetimes, array $data): array |
|
| 445 | - { |
|
| 446 | - $new_ticket = null; |
|
| 447 | - // stripslashes because WP filtered the $_POST ($data) array to add slashes |
|
| 448 | - $data = stripslashes_deep($data); |
|
| 449 | - $timezone = $data['timezone_string'] ?? null; |
|
| 450 | - $ticket_model = EEM_Ticket::instance($timezone); |
|
| 451 | - |
|
| 452 | - $saved_tickets = []; |
|
| 453 | - $old_tickets = isset($data['ticket_IDs']) |
|
| 454 | - ? explode(',', $data['ticket_IDs']) |
|
| 455 | - : []; |
|
| 456 | - if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) { |
|
| 457 | - throw new InvalidArgumentException( |
|
| 458 | - esc_html__( |
|
| 459 | - 'The "edit_tickets" array is invalid therefore the event can not be updated.', |
|
| 460 | - 'event_espresso' |
|
| 461 | - ) |
|
| 462 | - ); |
|
| 463 | - } |
|
| 464 | - foreach ($data['edit_tickets'] as $row => $ticket_data) { |
|
| 465 | - $update_prices = $create_new_TKT = false; |
|
| 466 | - // figure out what datetimes were added to the ticket |
|
| 467 | - // and what datetimes were removed from the ticket in the session. |
|
| 468 | - $starting_ticket_datetime_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]); |
|
| 469 | - $ticket_datetime_rows = explode(',', $data['ticket_datetime_rows'][ $row ]); |
|
| 470 | - $datetimes_added = array_diff($ticket_datetime_rows, $starting_ticket_datetime_rows); |
|
| 471 | - $datetimes_removed = array_diff($starting_ticket_datetime_rows, $ticket_datetime_rows); |
|
| 472 | - // trim inputs to ensure any excess whitespace is removed. |
|
| 473 | - $ticket_data = array_map( |
|
| 474 | - function ($ticket_data) { |
|
| 475 | - return is_array($ticket_data) |
|
| 476 | - ? $ticket_data |
|
| 477 | - : trim($ticket_data); |
|
| 478 | - }, |
|
| 479 | - $ticket_data |
|
| 480 | - ); |
|
| 481 | - // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle |
|
| 482 | - // because we're doing calculations prior to using the models. |
|
| 483 | - // note incoming ['TKT_price'] value is already in standard notation (via js). |
|
| 484 | - $ticket_price = isset($ticket_data['TKT_price']) |
|
| 485 | - ? round((float) $ticket_data['TKT_price'], 3) |
|
| 486 | - : 0; |
|
| 487 | - // note incoming base price needs converted from localized value. |
|
| 488 | - $base_price = isset($ticket_data['TKT_base_price']) |
|
| 489 | - ? EEH_Money::convert_to_float_from_localized_money($ticket_data['TKT_base_price']) |
|
| 490 | - : 0; |
|
| 491 | - // if ticket price == 0 and $base_price != 0 then ticket price == base_price |
|
| 492 | - $ticket_price = $ticket_price === 0 && $base_price !== 0 |
|
| 493 | - ? $base_price |
|
| 494 | - : $ticket_price; |
|
| 495 | - $base_price_id = $ticket_data['TKT_base_price_ID'] ?? 0; |
|
| 496 | - $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ]) |
|
| 497 | - ? $data['edit_prices'][ $row ] |
|
| 498 | - : []; |
|
| 499 | - $now = null; |
|
| 500 | - if (empty($ticket_data['TKT_start_date'])) { |
|
| 501 | - // lets' use now in the set timezone. |
|
| 502 | - $now = new DateTime('now', new DateTimeZone($event->get_timezone())); |
|
| 503 | - $ticket_data['TKT_start_date'] = $now->format($this->_date_time_format); |
|
| 504 | - } |
|
| 505 | - if (empty($ticket_data['TKT_end_date'])) { |
|
| 506 | - /** |
|
| 507 | - * set the TKT_end_date to the first datetime attached to the ticket. |
|
| 508 | - */ |
|
| 509 | - $first_datetime = $saved_datetimes[ reset($ticket_datetime_rows) ]; |
|
| 510 | - $ticket_data['TKT_end_date'] = $first_datetime->start_date_and_time($this->_date_time_format); |
|
| 511 | - } |
|
| 512 | - $TKT_values = [ |
|
| 513 | - 'TKT_ID' => ! empty($ticket_data['TKT_ID']) |
|
| 514 | - ? $ticket_data['TKT_ID'] |
|
| 515 | - : null, |
|
| 516 | - 'TTM_ID' => ! empty($ticket_data['TTM_ID']) |
|
| 517 | - ? $ticket_data['TTM_ID'] |
|
| 518 | - : 0, |
|
| 519 | - 'TKT_name' => ! empty($ticket_data['TKT_name']) |
|
| 520 | - ? $ticket_data['TKT_name'] |
|
| 521 | - : '', |
|
| 522 | - 'TKT_description' => ! empty($ticket_data['TKT_description']) |
|
| 523 | - && $ticket_data['TKT_description'] !== esc_html__( |
|
| 524 | - 'You can modify this description', |
|
| 525 | - 'event_espresso' |
|
| 526 | - ) |
|
| 527 | - ? $ticket_data['TKT_description'] |
|
| 528 | - : '', |
|
| 529 | - 'TKT_start_date' => $ticket_data['TKT_start_date'], |
|
| 530 | - 'TKT_end_date' => $ticket_data['TKT_end_date'], |
|
| 531 | - 'TKT_qty' => ! isset($ticket_data['TKT_qty']) || $ticket_data['TKT_qty'] === '' |
|
| 532 | - ? EE_INF |
|
| 533 | - : $ticket_data['TKT_qty'], |
|
| 534 | - 'TKT_uses' => ! isset($ticket_data['TKT_uses']) || $ticket_data['TKT_uses'] === '' |
|
| 535 | - ? EE_INF |
|
| 536 | - : $ticket_data['TKT_uses'], |
|
| 537 | - 'TKT_min' => empty($ticket_data['TKT_min']) |
|
| 538 | - ? 0 |
|
| 539 | - : $ticket_data['TKT_min'], |
|
| 540 | - 'TKT_max' => empty($ticket_data['TKT_max']) |
|
| 541 | - ? EE_INF |
|
| 542 | - : $ticket_data['TKT_max'], |
|
| 543 | - 'TKT_row' => $row, |
|
| 544 | - 'TKT_order' => $ticket_data['TKT_order'] ?? 0, |
|
| 545 | - 'TKT_taxable' => ! empty($ticket_data['TKT_taxable']) |
|
| 546 | - ? 1 |
|
| 547 | - : 0, |
|
| 548 | - 'TKT_required' => ! empty($ticket_data['TKT_required']) |
|
| 549 | - ? 1 |
|
| 550 | - : 0, |
|
| 551 | - 'TKT_price' => $ticket_price, |
|
| 552 | - ]; |
|
| 553 | - // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, |
|
| 554 | - // which means in turn that the prices will become new prices as well. |
|
| 555 | - if (isset($ticket_data['TKT_is_default']) && $ticket_data['TKT_is_default']) { |
|
| 556 | - $TKT_values['TKT_ID'] = 0; |
|
| 557 | - $TKT_values['TKT_is_default'] = 0; |
|
| 558 | - $update_prices = true; |
|
| 559 | - } |
|
| 560 | - // if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
| 561 | - // we actually do our saves ahead of doing any add_relations to |
|
| 562 | - // because its entirely possible that this ticket wasn't removed or added to any datetime in the session |
|
| 563 | - // but DID have it's items modified. |
|
| 564 | - // keep in mind that if the TKT has been sold (and we have changed pricing information), |
|
| 565 | - // then we won't be updating the ticket but instead a new ticket will be created and the old one archived. |
|
| 566 | - if (absint($TKT_values['TKT_ID'])) { |
|
| 567 | - $ticket = EE_Registry::instance() |
|
| 568 | - ->load_model('Ticket', [$timezone]) |
|
| 569 | - ->get_one_by_ID($TKT_values['TKT_ID']); |
|
| 570 | - if ($ticket instanceof EE_Ticket) { |
|
| 571 | - $ticket = $this->_update_ticket_datetimes( |
|
| 572 | - $ticket, |
|
| 573 | - $saved_datetimes, |
|
| 574 | - $datetimes_added, |
|
| 575 | - $datetimes_removed |
|
| 576 | - ); |
|
| 577 | - // are there any registrations using this ticket ? |
|
| 578 | - $tickets_sold = $ticket->count_related( |
|
| 579 | - 'Registration', |
|
| 580 | - [ |
|
| 581 | - [ |
|
| 582 | - 'STS_ID' => ['NOT IN', [EEM_Registration::status_id_incomplete]], |
|
| 583 | - ], |
|
| 584 | - ] |
|
| 585 | - ); |
|
| 586 | - // set ticket formats |
|
| 587 | - $ticket->set_date_format($this->_date_format_strings['date']); |
|
| 588 | - $ticket->set_time_format($this->_date_format_strings['time']); |
|
| 589 | - // let's just check the total price for the existing ticket |
|
| 590 | - // and determine if it matches the new total price. |
|
| 591 | - // if they are different then we create a new ticket (if tickets sold) |
|
| 592 | - // if they aren't different then we go ahead and modify existing ticket. |
|
| 593 | - $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted(); |
|
| 594 | - // set new values |
|
| 595 | - foreach ($TKT_values as $field => $value) { |
|
| 596 | - if ($field === 'TKT_qty') { |
|
| 597 | - $ticket->set_qty($value); |
|
| 598 | - } else { |
|
| 599 | - $ticket->set($field, $value); |
|
| 600 | - } |
|
| 601 | - } |
|
| 602 | - // if $create_new_TKT is false then we can safely update the existing ticket. |
|
| 603 | - // Otherwise we have to create a new ticket. |
|
| 604 | - if ($create_new_TKT) { |
|
| 605 | - $new_ticket = $this->_duplicate_ticket( |
|
| 606 | - $ticket, |
|
| 607 | - $price_rows, |
|
| 608 | - $ticket_price, |
|
| 609 | - $base_price, |
|
| 610 | - $base_price_id |
|
| 611 | - ); |
|
| 612 | - } |
|
| 613 | - } |
|
| 614 | - } else { |
|
| 615 | - // no TKT_id so a new TKT |
|
| 616 | - $ticket = EE_Ticket::new_instance( |
|
| 617 | - $TKT_values, |
|
| 618 | - $timezone, |
|
| 619 | - [$this->_date_format_strings['date'], $this->_date_format_strings['time']] |
|
| 620 | - ); |
|
| 621 | - if ($ticket instanceof EE_Ticket) { |
|
| 622 | - // make sure ticket has an ID of setting relations won't work |
|
| 623 | - $ticket->save(); |
|
| 624 | - $ticket = $this->_update_ticket_datetimes( |
|
| 625 | - $ticket, |
|
| 626 | - $saved_datetimes, |
|
| 627 | - $datetimes_added, |
|
| 628 | - $datetimes_removed |
|
| 629 | - ); |
|
| 630 | - $update_prices = true; |
|
| 631 | - } |
|
| 632 | - } |
|
| 633 | - // make sure any current values have been saved. |
|
| 634 | - // $ticket->save(); |
|
| 635 | - // before going any further make sure our dates are setup correctly |
|
| 636 | - // so that the end date is always equal or greater than the start date. |
|
| 637 | - if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) { |
|
| 638 | - $ticket->set('TKT_end_date', $ticket->get('TKT_start_date')); |
|
| 639 | - $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days'); |
|
| 640 | - } |
|
| 641 | - // let's make sure the base price is handled |
|
| 642 | - $ticket = ! $create_new_TKT |
|
| 643 | - ? $this->_add_prices_to_ticket( |
|
| 644 | - [], |
|
| 645 | - $ticket, |
|
| 646 | - $update_prices, |
|
| 647 | - $base_price, |
|
| 648 | - $base_price_id |
|
| 649 | - ) |
|
| 650 | - : $ticket; |
|
| 651 | - // add/update price_modifiers |
|
| 652 | - $ticket = ! $create_new_TKT |
|
| 653 | - ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices) |
|
| 654 | - : $ticket; |
|
| 655 | - // need to make sue that the TKT_price is accurate after saving the prices. |
|
| 656 | - $ticket->ensure_TKT_Price_correct(); |
|
| 657 | - // handle CREATING a default ticket from the incoming ticket but ONLY if this isn't an autosave. |
|
| 658 | - if (! defined('DOING_AUTOSAVE') && ! empty($ticket_data['TKT_is_default_selector'])) { |
|
| 659 | - $new_default = clone $ticket; |
|
| 660 | - $new_default->set('TKT_ID', 0); |
|
| 661 | - $new_default->set('TKT_is_default', 1); |
|
| 662 | - $new_default->set('TKT_row', 1); |
|
| 663 | - $new_default->set('TKT_price', $ticket_price); |
|
| 664 | - // remove any datetime relations cause we DON'T want datetime relations attached |
|
| 665 | - // (note this is just removing the cached relations in the object) |
|
| 666 | - $new_default->_remove_relations('Datetime'); |
|
| 667 | - // @todo we need to add the current attached prices as new prices to the new default ticket. |
|
| 668 | - $new_default = $this->_add_prices_to_ticket( |
|
| 669 | - $price_rows, |
|
| 670 | - $new_default, |
|
| 671 | - true |
|
| 672 | - ); |
|
| 673 | - // don't forget the base price! |
|
| 674 | - $new_default = $this->_add_prices_to_ticket( |
|
| 675 | - [], |
|
| 676 | - $new_default, |
|
| 677 | - true, |
|
| 678 | - $base_price, |
|
| 679 | - $base_price_id |
|
| 680 | - ); |
|
| 681 | - $new_default->save(); |
|
| 682 | - do_action( |
|
| 683 | - 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', |
|
| 684 | - $new_default, |
|
| 685 | - $row, |
|
| 686 | - $ticket, |
|
| 687 | - $data |
|
| 688 | - ); |
|
| 689 | - } |
|
| 690 | - // DO ALL datetime relationships for both current tickets and any archived tickets |
|
| 691 | - // for the given datetime that are related to the current ticket. |
|
| 692 | - // TODO... not sure exactly how we're going to do this considering we don't know |
|
| 693 | - // what current ticket the archived tickets are related to |
|
| 694 | - // (and TKT_parent is used for autosaves so that's not a field we can reliably use). |
|
| 695 | - // let's assign any tickets that have been setup to the saved_tickets tracker |
|
| 696 | - // save existing TKT |
|
| 697 | - $ticket->save(); |
|
| 698 | - if ($create_new_TKT && $new_ticket instanceof EE_Ticket) { |
|
| 699 | - // save new TKT |
|
| 700 | - $new_ticket->save(); |
|
| 701 | - // add new ticket to array |
|
| 702 | - $saved_tickets[ $new_ticket->ID() ] = $new_ticket; |
|
| 703 | - do_action( |
|
| 704 | - 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', |
|
| 705 | - $new_ticket, |
|
| 706 | - $row, |
|
| 707 | - $ticket_data, |
|
| 708 | - $data |
|
| 709 | - ); |
|
| 710 | - } else { |
|
| 711 | - // add ticket to saved tickets |
|
| 712 | - $saved_tickets[ $ticket->ID() ] = $ticket; |
|
| 713 | - do_action( |
|
| 714 | - 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', |
|
| 715 | - $ticket, |
|
| 716 | - $row, |
|
| 717 | - $ticket_data, |
|
| 718 | - $data |
|
| 719 | - ); |
|
| 720 | - } |
|
| 721 | - } |
|
| 722 | - // now we need to handle tickets actually "deleted permanently". |
|
| 723 | - // There are cases where we'd want this to happen |
|
| 724 | - // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
|
| 725 | - // Or a draft event was saved and in the process of editing a ticket is trashed. |
|
| 726 | - // No sense in keeping all the related data in the db! |
|
| 727 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' |
|
| 728 | - ? [] |
|
| 729 | - : $old_tickets; |
|
| 730 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
| 731 | - foreach ($tickets_removed as $id) { |
|
| 732 | - $id = absint($id); |
|
| 733 | - // get the ticket for this id |
|
| 734 | - $ticket_to_remove = $ticket_model->get_one_by_ID($id); |
|
| 735 | - // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
|
| 736 | - if ($ticket_to_remove->get('TKT_is_default')) { |
|
| 737 | - continue; |
|
| 738 | - } |
|
| 739 | - // if this ticket has any registrations attached so then we just ARCHIVE |
|
| 740 | - // because we don't actually permanently delete these tickets. |
|
| 741 | - if ($ticket_to_remove->count_related('Registration') > 0) { |
|
| 742 | - $ticket_to_remove->delete(); |
|
| 743 | - continue; |
|
| 744 | - } |
|
| 745 | - // need to get all the related datetimes on this ticket and remove from every single one of them |
|
| 746 | - // (remember this process can ONLY kick off if there are NO tickets_sold) |
|
| 747 | - $datetimes = $ticket_to_remove->get_many_related('Datetime'); |
|
| 748 | - foreach ($datetimes as $datetime) { |
|
| 749 | - $ticket_to_remove->_remove_relation_to($datetime, 'Datetime'); |
|
| 750 | - } |
|
| 751 | - // need to do the same for prices (except these prices can also be deleted because again, |
|
| 752 | - // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
| 753 | - $ticket_to_remove->delete_related('Price'); |
|
| 754 | - do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $ticket_to_remove); |
|
| 755 | - // finally let's delete this ticket |
|
| 756 | - // (which should not be blocked at this point b/c we've removed all our relationships) |
|
| 757 | - $ticket_to_remove->delete_or_restore(); |
|
| 758 | - } |
|
| 759 | - return $saved_tickets; |
|
| 760 | - } |
|
| 761 | - |
|
| 762 | - |
|
| 763 | - /** |
|
| 764 | - * @access protected |
|
| 765 | - * @param EE_Ticket $ticket |
|
| 766 | - * @param EE_Datetime[] $saved_datetimes |
|
| 767 | - * @param int[] $added_datetimes |
|
| 768 | - * @param int[] $removed_datetimes |
|
| 769 | - * @return EE_Ticket |
|
| 770 | - * @throws EE_Error |
|
| 771 | - * @throws ReflectionException |
|
| 772 | - */ |
|
| 773 | - protected function _update_ticket_datetimes( |
|
| 774 | - EE_Ticket $ticket, |
|
| 775 | - array $saved_datetimes = [], |
|
| 776 | - array $added_datetimes = [], |
|
| 777 | - array $removed_datetimes = [] |
|
| 778 | - ): EE_Ticket { |
|
| 779 | - // to start we have to add the ticket to all the datetimes its supposed to be with, |
|
| 780 | - // and removing the ticket from datetimes it got removed from. |
|
| 781 | - // first let's add datetimes |
|
| 782 | - if (! empty($added_datetimes) && is_array($added_datetimes)) { |
|
| 783 | - foreach ($added_datetimes as $row_id) { |
|
| 784 | - if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) { |
|
| 785 | - $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime'); |
|
| 786 | - // Is this an existing ticket (has an ID) and does it have any sold? |
|
| 787 | - // If so, then we need to add that to the DTT sold because this DTT is getting added. |
|
| 788 | - if ($ticket->ID() && $ticket->sold() > 0) { |
|
| 789 | - $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false); |
|
| 790 | - } |
|
| 791 | - } |
|
| 792 | - } |
|
| 793 | - } |
|
| 794 | - // then remove datetimes |
|
| 795 | - if (! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
| 796 | - foreach ($removed_datetimes as $row_id) { |
|
| 797 | - // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
|
| 798 | - // So make sure we skip over this if the datetime isn't in the $saved_datetimes array) |
|
| 799 | - if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) { |
|
| 800 | - $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime'); |
|
| 801 | - } |
|
| 802 | - } |
|
| 803 | - } |
|
| 804 | - // cap ticket qty by datetime reg limits |
|
| 805 | - $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
| 806 | - return $ticket; |
|
| 807 | - } |
|
| 808 | - |
|
| 809 | - |
|
| 810 | - /** |
|
| 811 | - * @access protected |
|
| 812 | - * @param EE_Ticket $ticket |
|
| 813 | - * @param array $price_rows |
|
| 814 | - * @param int|float $ticket_price |
|
| 815 | - * @param int|float $base_price |
|
| 816 | - * @param int $base_price_id |
|
| 817 | - * @return EE_Ticket |
|
| 818 | - * @throws ReflectionException |
|
| 819 | - * @throws InvalidArgumentException |
|
| 820 | - * @throws InvalidInterfaceException |
|
| 821 | - * @throws InvalidDataTypeException |
|
| 822 | - * @throws EE_Error |
|
| 823 | - */ |
|
| 824 | - protected function _duplicate_ticket( |
|
| 825 | - EE_Ticket $ticket, |
|
| 826 | - array $price_rows = [], |
|
| 827 | - $ticket_price = 0, |
|
| 828 | - $base_price = 0, |
|
| 829 | - int $base_price_id = 0 |
|
| 830 | - ): EE_Ticket { |
|
| 831 | - // create new ticket that's a copy of the existing |
|
| 832 | - // except a new id of course (and not archived) |
|
| 833 | - // AND has the new TKT_price associated with it. |
|
| 834 | - $new_ticket = clone $ticket; |
|
| 835 | - $new_ticket->set('TKT_ID', 0); |
|
| 836 | - $new_ticket->set_deleted(0); |
|
| 837 | - $new_ticket->set_price($ticket_price); |
|
| 838 | - $new_ticket->set_sold(0); |
|
| 839 | - // let's get a new ID for this ticket |
|
| 840 | - $new_ticket->save(); |
|
| 841 | - // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
|
| 842 | - $datetimes_on_existing = $ticket->datetimes(); |
|
| 843 | - $new_ticket = $this->_update_ticket_datetimes( |
|
| 844 | - $new_ticket, |
|
| 845 | - $datetimes_on_existing, |
|
| 846 | - array_keys($datetimes_on_existing) |
|
| 847 | - ); |
|
| 848 | - // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
|
| 849 | - // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
|
| 850 | - // available. |
|
| 851 | - if ($ticket->sold() > 0) { |
|
| 852 | - $new_qty = $ticket->qty() - $ticket->sold(); |
|
| 853 | - $new_ticket->set_qty($new_qty); |
|
| 854 | - } |
|
| 855 | - // now we update the prices just for this ticket |
|
| 856 | - $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
| 857 | - // and we update the base price |
|
| 858 | - return $this->_add_prices_to_ticket( |
|
| 859 | - [], |
|
| 860 | - $new_ticket, |
|
| 861 | - true, |
|
| 862 | - $base_price, |
|
| 863 | - $base_price_id |
|
| 864 | - ); |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - |
|
| 868 | - /** |
|
| 869 | - * This attaches a list of given prices to a ticket. |
|
| 870 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
| 871 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
| 872 | - * price info and prices are automatically "archived" via the ticket. |
|
| 873 | - * |
|
| 874 | - * @access private |
|
| 875 | - * @param array $prices Array of prices from the form. |
|
| 876 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
| 877 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
| 878 | - * @param int|bool $base_price if FALSE then NOT doing a base price add. |
|
| 879 | - * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
|
| 880 | - * @return EE_Ticket |
|
| 881 | - * @throws ReflectionException |
|
| 882 | - * @throws InvalidArgumentException |
|
| 883 | - * @throws InvalidInterfaceException |
|
| 884 | - * @throws InvalidDataTypeException |
|
| 885 | - * @throws EE_Error |
|
| 886 | - */ |
|
| 887 | - protected function _add_prices_to_ticket( |
|
| 888 | - array $prices, |
|
| 889 | - EE_Ticket $ticket, |
|
| 890 | - bool $new_prices = false, |
|
| 891 | - $base_price = false, |
|
| 892 | - $base_price_id = false |
|
| 893 | - ): EE_Ticket { |
|
| 894 | - $price_model = EEM_Price::instance(); |
|
| 895 | - // let's just get any current prices that may exist on the given ticket |
|
| 896 | - // so we can remove any prices that got trashed in this session. |
|
| 897 | - $current_prices_on_ticket = $base_price !== false |
|
| 898 | - ? $ticket->base_price(true) |
|
| 899 | - : $ticket->price_modifiers(); |
|
| 900 | - $updated_prices = []; |
|
| 901 | - // if $base_price ! FALSE then updating a base price. |
|
| 902 | - if ($base_price !== false) { |
|
| 903 | - $prices[1] = [ |
|
| 904 | - 'PRC_ID' => $new_prices || $base_price_id === 1 |
|
| 905 | - ? null |
|
| 906 | - : $base_price_id, |
|
| 907 | - 'PRT_ID' => 1, |
|
| 908 | - 'PRC_amount' => $base_price, |
|
| 909 | - 'PRC_name' => $ticket->get('TKT_name'), |
|
| 910 | - 'PRC_desc' => $ticket->get('TKT_description'), |
|
| 911 | - ]; |
|
| 912 | - } |
|
| 913 | - // possibly need to save ticket |
|
| 914 | - if (! $ticket->ID()) { |
|
| 915 | - $ticket->save(); |
|
| 916 | - } |
|
| 917 | - foreach ($prices as $row => $prc) { |
|
| 918 | - $prt_id = ! empty($prc['PRT_ID']) |
|
| 919 | - ? $prc['PRT_ID'] |
|
| 920 | - : null; |
|
| 921 | - if (empty($prt_id)) { |
|
| 922 | - continue; |
|
| 923 | - } //prices MUST have a price type id. |
|
| 924 | - $PRC_values = [ |
|
| 925 | - 'PRC_ID' => ! empty($prc['PRC_ID']) |
|
| 926 | - ? $prc['PRC_ID'] |
|
| 927 | - : null, |
|
| 928 | - 'PRT_ID' => $prt_id, |
|
| 929 | - 'PRC_amount' => ! empty($prc['PRC_amount']) |
|
| 930 | - ? $prc['PRC_amount'] |
|
| 931 | - : 0, |
|
| 932 | - 'PRC_name' => ! empty($prc['PRC_name']) |
|
| 933 | - ? $prc['PRC_name'] |
|
| 934 | - : '', |
|
| 935 | - 'PRC_desc' => ! empty($prc['PRC_desc']) |
|
| 936 | - ? $prc['PRC_desc'] |
|
| 937 | - : '', |
|
| 938 | - 'PRC_is_default' => false, |
|
| 939 | - // make sure we set PRC_is_default to false for all ticket saves from event_editor |
|
| 940 | - 'PRC_order' => $row, |
|
| 941 | - ]; |
|
| 942 | - if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
| 943 | - $PRC_values['PRC_ID'] = 0; |
|
| 944 | - $price = EE_Registry::instance()->load_class( |
|
| 945 | - 'Price', |
|
| 946 | - [$PRC_values], |
|
| 947 | - false, |
|
| 948 | - false |
|
| 949 | - ); |
|
| 950 | - } else { |
|
| 951 | - $price = $price_model->get_one_by_ID($prc['PRC_ID']); |
|
| 952 | - // update this price with new values |
|
| 953 | - foreach ($PRC_values as $field => $value) { |
|
| 954 | - $price->set($field, $value); |
|
| 955 | - } |
|
| 956 | - } |
|
| 957 | - $price->save(); |
|
| 958 | - $updated_prices[ $price->ID() ] = $price; |
|
| 959 | - $ticket->_add_relation_to($price, 'Price'); |
|
| 960 | - } |
|
| 961 | - // now let's remove any prices that got removed from the ticket |
|
| 962 | - if (! empty($current_prices_on_ticket)) { |
|
| 963 | - $current = array_keys($current_prices_on_ticket); |
|
| 964 | - $updated = array_keys($updated_prices); |
|
| 965 | - $prices_to_remove = array_diff($current, $updated); |
|
| 966 | - if (! empty($prices_to_remove)) { |
|
| 967 | - foreach ($prices_to_remove as $prc_id) { |
|
| 968 | - $p = $current_prices_on_ticket[ $prc_id ]; |
|
| 969 | - $ticket->_remove_relation_to($p, 'Price'); |
|
| 970 | - // delete permanently the price |
|
| 971 | - $p->delete_or_restore(); |
|
| 972 | - } |
|
| 973 | - } |
|
| 974 | - } |
|
| 975 | - return $ticket; |
|
| 976 | - } |
|
| 977 | - |
|
| 978 | - |
|
| 979 | - /** |
|
| 980 | - * @throws ReflectionException |
|
| 981 | - * @throws InvalidArgumentException |
|
| 982 | - * @throws InvalidInterfaceException |
|
| 983 | - * @throws InvalidDataTypeException |
|
| 984 | - * @throws DomainException |
|
| 985 | - * @throws EE_Error |
|
| 986 | - */ |
|
| 987 | - public function pricing_metabox() |
|
| 988 | - { |
|
| 989 | - $event = $this->_adminpage_obj->get_cpt_model_obj(); |
|
| 990 | - $timezone = $event instanceof EE_Event |
|
| 991 | - ? $event->timezone_string() |
|
| 992 | - : null; |
|
| 993 | - $price_model = EEM_Price::instance($timezone); |
|
| 994 | - $ticket_model = EEM_Ticket::instance($timezone); |
|
| 995 | - $datetime_model = EEM_Datetime::instance($timezone); |
|
| 996 | - $all_tickets = []; |
|
| 997 | - |
|
| 998 | - // set is_creating_event property. |
|
| 999 | - $EVT_ID = $event->ID(); |
|
| 1000 | - $this->_is_creating_event = empty($this->_req_data['post']); |
|
| 1001 | - $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = []; |
|
| 1002 | - |
|
| 1003 | - // default main template args |
|
| 1004 | - $main_template_args = [ |
|
| 1005 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link( |
|
| 1006 | - 'event_editor_event_datetimes_help_tab', |
|
| 1007 | - $this->_adminpage_obj->page_slug, |
|
| 1008 | - $this->_adminpage_obj->get_req_action() |
|
| 1009 | - ), |
|
| 1010 | - |
|
| 1011 | - // todo need to add a filter to the template for the help text |
|
| 1012 | - // in the Events_Admin_Page core file so we can add further help |
|
| 1013 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link( |
|
| 1014 | - 'add_new_dtt_info', |
|
| 1015 | - $this->_adminpage_obj->page_slug, |
|
| 1016 | - $this->_adminpage_obj->get_req_action() |
|
| 1017 | - ), |
|
| 1018 | - // todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
| 1019 | - 'datetime_rows' => '', |
|
| 1020 | - 'show_tickets_container' => '', |
|
| 1021 | - 'ticket_rows' => '', |
|
| 1022 | - 'ee_collapsible_status' => ' ee-collapsible-open', |
|
| 1023 | - // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open' |
|
| 1024 | - ]; |
|
| 1025 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1026 | - |
|
| 1027 | - /** |
|
| 1028 | - * 1. Start with retrieving Datetimes |
|
| 1029 | - * 2. For each datetime get related tickets |
|
| 1030 | - * 3. For each ticket get related prices |
|
| 1031 | - */ |
|
| 1032 | - $datetimes = $datetime_model->get_all_event_dates($EVT_ID); |
|
| 1033 | - $main_template_args['total_dtt_rows'] = count($datetimes); |
|
| 1034 | - |
|
| 1035 | - /** |
|
| 1036 | - * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 |
|
| 1037 | - * for why we are counting $datetime_row and then setting that on the Datetime object |
|
| 1038 | - */ |
|
| 1039 | - $datetime_row = 1; |
|
| 1040 | - foreach ($datetimes as $datetime) { |
|
| 1041 | - $DTT_ID = $datetime->get('DTT_ID'); |
|
| 1042 | - $datetime->set('DTT_order', $datetime_row); |
|
| 1043 | - $existing_datetime_ids[] = $DTT_ID; |
|
| 1044 | - // tickets attached |
|
| 1045 | - $related_tickets = $datetime->ID() > 0 |
|
| 1046 | - ? $datetime->get_many_related( |
|
| 1047 | - 'Ticket', |
|
| 1048 | - [ |
|
| 1049 | - [ |
|
| 1050 | - 'OR' => ['TKT_deleted' => 1, 'TKT_deleted*' => 0], |
|
| 1051 | - ], |
|
| 1052 | - 'default_where_conditions' => 'none', |
|
| 1053 | - 'order_by' => ['TKT_order' => 'ASC'], |
|
| 1054 | - ] |
|
| 1055 | - ) |
|
| 1056 | - : []; |
|
| 1057 | - // if there are no related tickets this is likely a new event OR auto-draft |
|
| 1058 | - // event so we need to generate the default tickets because datetimes |
|
| 1059 | - // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
|
| 1060 | - // datetime on the event. |
|
| 1061 | - if (empty($related_tickets) && count($datetimes) < 2) { |
|
| 1062 | - $related_tickets = $ticket_model->get_all_default_tickets(); |
|
| 1063 | - // this should be ordered by TKT_ID, so let's grab the first default ticket |
|
| 1064 | - // (which will be the main default) and ensure it has any default prices added to it (but do NOT save). |
|
| 1065 | - $default_prices = $price_model->get_all_default_prices(); |
|
| 1066 | - $main_default_ticket = reset($related_tickets); |
|
| 1067 | - if ($main_default_ticket instanceof EE_Ticket) { |
|
| 1068 | - foreach ($default_prices as $default_price) { |
|
| 1069 | - if ($default_price instanceof EE_Price && $default_price->is_base_price()) { |
|
| 1070 | - continue; |
|
| 1071 | - } |
|
| 1072 | - $main_default_ticket->cache('Price', $default_price); |
|
| 1073 | - } |
|
| 1074 | - } |
|
| 1075 | - } |
|
| 1076 | - // we can't actually setup rows in this loop yet cause we don't know all |
|
| 1077 | - // the unique tickets for this event yet (tickets are linked through all datetimes). |
|
| 1078 | - // So we're going to temporarily cache some of that information. |
|
| 1079 | - // loop through and setup the ticket rows and make sure the order is set. |
|
| 1080 | - foreach ($related_tickets as $ticket) { |
|
| 1081 | - $TKT_ID = $ticket->get('TKT_ID'); |
|
| 1082 | - $ticket_row = $ticket->get('TKT_row'); |
|
| 1083 | - // we only want unique tickets in our final display!! |
|
| 1084 | - if (! in_array($TKT_ID, $existing_ticket_ids, true)) { |
|
| 1085 | - $existing_ticket_ids[] = $TKT_ID; |
|
| 1086 | - $all_tickets[] = $ticket; |
|
| 1087 | - } |
|
| 1088 | - // temporary cache of this ticket info for this datetime for later processing of datetime rows. |
|
| 1089 | - $datetime_tickets[ $DTT_ID ][] = $ticket_row; |
|
| 1090 | - // temporary cache of this datetime info for this ticket for later processing of ticket rows. |
|
| 1091 | - if ( |
|
| 1092 | - ! isset($ticket_datetimes[ $TKT_ID ]) |
|
| 1093 | - || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true) |
|
| 1094 | - ) { |
|
| 1095 | - $ticket_datetimes[ $TKT_ID ][] = $datetime_row; |
|
| 1096 | - } |
|
| 1097 | - } |
|
| 1098 | - $datetime_row++; |
|
| 1099 | - } |
|
| 1100 | - $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
| 1101 | - $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
| 1102 | - $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
| 1103 | - // sort $all_tickets by order |
|
| 1104 | - usort( |
|
| 1105 | - $all_tickets, |
|
| 1106 | - function (EE_Ticket $a, EE_Ticket $b) { |
|
| 1107 | - $a_order = (int) $a->get('TKT_order'); |
|
| 1108 | - $b_order = (int) $b->get('TKT_order'); |
|
| 1109 | - if ($a_order === $b_order) { |
|
| 1110 | - return 0; |
|
| 1111 | - } |
|
| 1112 | - return ($a_order < $b_order) |
|
| 1113 | - ? -1 |
|
| 1114 | - : 1; |
|
| 1115 | - } |
|
| 1116 | - ); |
|
| 1117 | - // k NOW we have all the data we need for setting up the datetime rows |
|
| 1118 | - // and ticket rows so we start our datetime loop again. |
|
| 1119 | - $datetime_row = 1; |
|
| 1120 | - foreach ($datetimes as $datetime) { |
|
| 1121 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( |
|
| 1122 | - $datetime_row, |
|
| 1123 | - $datetime, |
|
| 1124 | - $datetime_tickets, |
|
| 1125 | - $all_tickets, |
|
| 1126 | - false, |
|
| 1127 | - $datetimes |
|
| 1128 | - ); |
|
| 1129 | - $datetime_row++; |
|
| 1130 | - } |
|
| 1131 | - // then loop through all tickets for the ticket rows. |
|
| 1132 | - $ticket_row = 1; |
|
| 1133 | - foreach ($all_tickets as $ticket) { |
|
| 1134 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( |
|
| 1135 | - $ticket_row, |
|
| 1136 | - $ticket, |
|
| 1137 | - $ticket_datetimes, |
|
| 1138 | - $datetimes, |
|
| 1139 | - false, |
|
| 1140 | - $all_tickets |
|
| 1141 | - ); |
|
| 1142 | - $ticket_row++; |
|
| 1143 | - } |
|
| 1144 | - $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets); |
|
| 1145 | - |
|
| 1146 | - $status_change_notice = LoaderFactory::getLoader()->getShared( |
|
| 1147 | - 'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice' |
|
| 1148 | - ); |
|
| 1149 | - |
|
| 1150 | - $main_template_args['status_change_notice'] = $status_change_notice->display( |
|
| 1151 | - '__event-editor', |
|
| 1152 | - 'espresso-events' |
|
| 1153 | - ); |
|
| 1154 | - |
|
| 1155 | - EEH_Template::display_template( |
|
| 1156 | - PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php', |
|
| 1157 | - $main_template_args |
|
| 1158 | - ); |
|
| 1159 | - } |
|
| 1160 | - |
|
| 1161 | - |
|
| 1162 | - /** |
|
| 1163 | - * @param int|string $datetime_row |
|
| 1164 | - * @param EE_Datetime $datetime |
|
| 1165 | - * @param array $datetime_tickets |
|
| 1166 | - * @param array $all_tickets |
|
| 1167 | - * @param bool $default |
|
| 1168 | - * @param array $all_datetimes |
|
| 1169 | - * @return string |
|
| 1170 | - * @throws DomainException |
|
| 1171 | - * @throws EE_Error |
|
| 1172 | - * @throws ReflectionException |
|
| 1173 | - */ |
|
| 1174 | - protected function _get_datetime_row( |
|
| 1175 | - $datetime_row, |
|
| 1176 | - EE_Datetime $datetime, |
|
| 1177 | - array $datetime_tickets = [], |
|
| 1178 | - array $all_tickets = [], |
|
| 1179 | - bool $default = false, |
|
| 1180 | - array $all_datetimes = [] |
|
| 1181 | - ): string { |
|
| 1182 | - return EEH_Template::display_template( |
|
| 1183 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php', |
|
| 1184 | - [ |
|
| 1185 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( |
|
| 1186 | - $datetime_row, |
|
| 1187 | - $datetime, |
|
| 1188 | - $default, |
|
| 1189 | - $all_datetimes |
|
| 1190 | - ), |
|
| 1191 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( |
|
| 1192 | - $datetime_row, |
|
| 1193 | - $datetime, |
|
| 1194 | - $datetime_tickets, |
|
| 1195 | - $all_tickets, |
|
| 1196 | - $default |
|
| 1197 | - ), |
|
| 1198 | - 'dtt_row' => $default |
|
| 1199 | - ? 'DTTNUM' |
|
| 1200 | - : $datetime_row, |
|
| 1201 | - ], |
|
| 1202 | - true |
|
| 1203 | - ); |
|
| 1204 | - } |
|
| 1205 | - |
|
| 1206 | - |
|
| 1207 | - /** |
|
| 1208 | - * This method is used to generate a datetime fields edit row. |
|
| 1209 | - * The same row is used to generate a row with valid DTT objects |
|
| 1210 | - * and the default row that is used as the skeleton by the js. |
|
| 1211 | - * |
|
| 1212 | - * @param int|string $datetime_row The row number for the row being generated. |
|
| 1213 | - * @param EE_Datetime|null $datetime |
|
| 1214 | - * @param bool $default Whether a default row is being generated or not. |
|
| 1215 | - * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor. |
|
| 1216 | - * @return string |
|
| 1217 | - * @throws EE_Error |
|
| 1218 | - * @throws ReflectionException |
|
| 1219 | - */ |
|
| 1220 | - protected function _get_dtt_edit_row( |
|
| 1221 | - $datetime_row, |
|
| 1222 | - ?EE_Datetime $datetime, |
|
| 1223 | - bool $default, |
|
| 1224 | - array $all_datetimes |
|
| 1225 | - ): string { |
|
| 1226 | - // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true. |
|
| 1227 | - $default = ! $datetime instanceof EE_Datetime |
|
| 1228 | - ? true |
|
| 1229 | - : $default; |
|
| 1230 | - $template_args = [ |
|
| 1231 | - 'dtt_row' => $default |
|
| 1232 | - ? 'DTTNUM' |
|
| 1233 | - : $datetime_row, |
|
| 1234 | - 'event_datetimes_name' => $default |
|
| 1235 | - ? 'DTTNAMEATTR' |
|
| 1236 | - : 'edit_event_datetimes', |
|
| 1237 | - 'edit_dtt_expanded' => '', |
|
| 1238 | - 'DTT_ID' => $default |
|
| 1239 | - ? '' |
|
| 1240 | - : $datetime->ID(), |
|
| 1241 | - 'DTT_name' => $default |
|
| 1242 | - ? '' |
|
| 1243 | - : $datetime->get_f('DTT_name'), |
|
| 1244 | - 'DTT_description' => $default |
|
| 1245 | - ? '' |
|
| 1246 | - : $datetime->get_raw('DTT_description'), |
|
| 1247 | - 'DTT_EVT_start' => $default |
|
| 1248 | - ? '' |
|
| 1249 | - : $datetime->start_date($this->_date_time_format), |
|
| 1250 | - 'DTT_EVT_end' => $default |
|
| 1251 | - ? '' |
|
| 1252 | - : $datetime->end_date($this->_date_time_format), |
|
| 1253 | - 'DTT_reg_limit' => $default |
|
| 1254 | - ? '' |
|
| 1255 | - : $datetime->get_pretty( |
|
| 1256 | - 'DTT_reg_limit', |
|
| 1257 | - 'input' |
|
| 1258 | - ), |
|
| 1259 | - 'DTT_order' => $default |
|
| 1260 | - ? 'DTTNUM' |
|
| 1261 | - : $datetime_row, |
|
| 1262 | - 'dtt_sold' => $default |
|
| 1263 | - ? '0' |
|
| 1264 | - : $datetime->get('DTT_sold'), |
|
| 1265 | - 'dtt_reserved' => $default |
|
| 1266 | - ? '0' |
|
| 1267 | - : $datetime->reserved(), |
|
| 1268 | - 'can_clone' => $datetime instanceof EE_Datetime, |
|
| 1269 | - 'can_trash' => count($all_datetimes) > 1 |
|
| 1270 | - && $datetime instanceof EE_Datetime |
|
| 1271 | - && ! $datetime->get('DTT_sold'), |
|
| 1272 | - 'trash_icon' => ! empty($datetime) && $datetime->get('DTT_sold') > 0 |
|
| 1273 | - ? 'trash-entity dashicons dashicons-lock' |
|
| 1274 | - : 'trash-entity dashicons dashicons-post-trash clickable', |
|
| 1275 | - 'reg_list_url' => $default || ! $datetime->event() instanceof EE_Event |
|
| 1276 | - ? '' |
|
| 1277 | - : EE_Admin_Page::add_query_args_and_nonce( |
|
| 1278 | - [ |
|
| 1279 | - 'event_id' => $datetime->event()->ID(), |
|
| 1280 | - 'datetime_id' => $datetime->ID(), |
|
| 1281 | - 'use_filters' => true, |
|
| 1282 | - ], |
|
| 1283 | - REG_ADMIN_URL |
|
| 1284 | - ), |
|
| 1285 | - ]; |
|
| 1286 | - $template_args['show_trash'] = count($all_datetimes) === 1 |
|
| 1287 | - && $template_args['trash_icon'] !== 'dashicons dashicons-lock' |
|
| 1288 | - ? 'display:none' |
|
| 1289 | - : ''; |
|
| 1290 | - // allow filtering of template args at this point. |
|
| 1291 | - $template_args = apply_filters( |
|
| 1292 | - 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', |
|
| 1293 | - $template_args, |
|
| 1294 | - $datetime_row, |
|
| 1295 | - $datetime, |
|
| 1296 | - $default, |
|
| 1297 | - $all_datetimes, |
|
| 1298 | - $this->_is_creating_event |
|
| 1299 | - ); |
|
| 1300 | - return EEH_Template::display_template( |
|
| 1301 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php', |
|
| 1302 | - $template_args, |
|
| 1303 | - true |
|
| 1304 | - ); |
|
| 1305 | - } |
|
| 1306 | - |
|
| 1307 | - |
|
| 1308 | - /** |
|
| 1309 | - * @param int|string $datetime_row |
|
| 1310 | - * @param EE_Datetime|null $datetime |
|
| 1311 | - * @param array $datetime_tickets |
|
| 1312 | - * @param array $all_tickets |
|
| 1313 | - * @param bool $default |
|
| 1314 | - * @return string |
|
| 1315 | - * @throws DomainException |
|
| 1316 | - * @throws EE_Error |
|
| 1317 | - * @throws ReflectionException |
|
| 1318 | - */ |
|
| 1319 | - protected function _get_dtt_attached_tickets_row( |
|
| 1320 | - $datetime_row, |
|
| 1321 | - ?EE_Datetime $datetime, |
|
| 1322 | - array $datetime_tickets = [], |
|
| 1323 | - array $all_tickets = [], |
|
| 1324 | - bool $default = false |
|
| 1325 | - ): string { |
|
| 1326 | - $template_args = [ |
|
| 1327 | - 'dtt_row' => $default |
|
| 1328 | - ? 'DTTNUM' |
|
| 1329 | - : $datetime_row, |
|
| 1330 | - 'event_datetimes_name' => $default |
|
| 1331 | - ? 'DTTNAMEATTR' |
|
| 1332 | - : 'edit_event_datetimes', |
|
| 1333 | - 'DTT_description' => $default |
|
| 1334 | - ? '' |
|
| 1335 | - : $datetime->get_raw('DTT_description'), |
|
| 1336 | - 'datetime_tickets_list' => $default |
|
| 1337 | - ? '<li class="hidden"></li>' |
|
| 1338 | - : '', |
|
| 1339 | - 'show_tickets_row' => 'display:none;', |
|
| 1340 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link( |
|
| 1341 | - 'add_new_ticket_via_datetime', |
|
| 1342 | - $this->_adminpage_obj->page_slug, |
|
| 1343 | - $this->_adminpage_obj->get_req_action() |
|
| 1344 | - ), |
|
| 1345 | - // todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
| 1346 | - 'DTT_ID' => $default |
|
| 1347 | - ? '' |
|
| 1348 | - : $datetime->ID(), |
|
| 1349 | - ]; |
|
| 1350 | - // need to setup the list items (but only if this isn't a default skeleton setup) |
|
| 1351 | - if (! $default) { |
|
| 1352 | - $ticket_row = 1; |
|
| 1353 | - foreach ($all_tickets as $ticket) { |
|
| 1354 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( |
|
| 1355 | - $datetime_row, |
|
| 1356 | - $ticket_row, |
|
| 1357 | - $datetime, |
|
| 1358 | - $ticket, |
|
| 1359 | - $datetime_tickets |
|
| 1360 | - ); |
|
| 1361 | - $ticket_row++; |
|
| 1362 | - } |
|
| 1363 | - } |
|
| 1364 | - // filter template args at this point |
|
| 1365 | - $template_args = apply_filters( |
|
| 1366 | - 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', |
|
| 1367 | - $template_args, |
|
| 1368 | - $datetime_row, |
|
| 1369 | - $datetime, |
|
| 1370 | - $datetime_tickets, |
|
| 1371 | - $all_tickets, |
|
| 1372 | - $default, |
|
| 1373 | - $this->_is_creating_event |
|
| 1374 | - ); |
|
| 1375 | - return EEH_Template::display_template( |
|
| 1376 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php', |
|
| 1377 | - $template_args, |
|
| 1378 | - true |
|
| 1379 | - ); |
|
| 1380 | - } |
|
| 1381 | - |
|
| 1382 | - |
|
| 1383 | - /** |
|
| 1384 | - * @param int|string $datetime_row |
|
| 1385 | - * @param int|string $ticket_row |
|
| 1386 | - * @param EE_Datetime|null $datetime |
|
| 1387 | - * @param EE_Ticket|null $ticket |
|
| 1388 | - * @param array $datetime_tickets |
|
| 1389 | - * @param bool $default |
|
| 1390 | - * @return string |
|
| 1391 | - * @throws EE_Error |
|
| 1392 | - * @throws ReflectionException |
|
| 1393 | - */ |
|
| 1394 | - protected function _get_datetime_tickets_list_item( |
|
| 1395 | - $datetime_row, |
|
| 1396 | - $ticket_row, |
|
| 1397 | - ?EE_Datetime $datetime, |
|
| 1398 | - ?EE_Ticket $ticket, |
|
| 1399 | - array $datetime_tickets = [], |
|
| 1400 | - bool $default = false |
|
| 1401 | - ): string { |
|
| 1402 | - $datetime_tickets = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ]) |
|
| 1403 | - ? $datetime_tickets[ $datetime->ID() ] |
|
| 1404 | - : []; |
|
| 1405 | - $display_row = $ticket instanceof EE_Ticket |
|
| 1406 | - ? $ticket->get('TKT_row') |
|
| 1407 | - : 0; |
|
| 1408 | - $no_ticket = $default && empty($ticket); |
|
| 1409 | - $template_args = [ |
|
| 1410 | - 'dtt_row' => $default |
|
| 1411 | - ? 'DTTNUM' |
|
| 1412 | - : $datetime_row, |
|
| 1413 | - 'tkt_row' => $no_ticket |
|
| 1414 | - ? 'TICKETNUM' |
|
| 1415 | - : $ticket_row, |
|
| 1416 | - 'datetime_ticket_checked' => in_array($display_row, $datetime_tickets, true) |
|
| 1417 | - ? ' checked' |
|
| 1418 | - : '', |
|
| 1419 | - 'ticket_selected' => in_array($display_row, $datetime_tickets, true) |
|
| 1420 | - ? ' ticket-selected' |
|
| 1421 | - : '', |
|
| 1422 | - 'TKT_name' => $no_ticket |
|
| 1423 | - ? 'TKTNAME' |
|
| 1424 | - : $ticket->get('TKT_name'), |
|
| 1425 | - 'tkt_status_class' => $no_ticket || $this->_is_creating_event |
|
| 1426 | - ? ' tkt-status-' . EE_Ticket::onsale |
|
| 1427 | - : ' tkt-status-' . $ticket->ticket_status(), |
|
| 1428 | - ]; |
|
| 1429 | - // filter template args |
|
| 1430 | - $template_args = apply_filters( |
|
| 1431 | - 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', |
|
| 1432 | - $template_args, |
|
| 1433 | - $datetime_row, |
|
| 1434 | - $ticket_row, |
|
| 1435 | - $datetime, |
|
| 1436 | - $ticket, |
|
| 1437 | - $datetime_tickets, |
|
| 1438 | - $default, |
|
| 1439 | - $this->_is_creating_event |
|
| 1440 | - ); |
|
| 1441 | - return EEH_Template::display_template( |
|
| 1442 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php', |
|
| 1443 | - $template_args, |
|
| 1444 | - true |
|
| 1445 | - ); |
|
| 1446 | - } |
|
| 1447 | - |
|
| 1448 | - |
|
| 1449 | - /** |
|
| 1450 | - * This generates the ticket row for tickets. |
|
| 1451 | - * This same method is used to generate both the actual rows and the js skeleton row |
|
| 1452 | - * (when default === true) |
|
| 1453 | - * |
|
| 1454 | - * @param int|string $ticket_row Represents the row number being generated. |
|
| 1455 | - * @param EE_Ticket|null $ticket |
|
| 1456 | - * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket |
|
| 1457 | - * or empty for default |
|
| 1458 | - * @param EE_Datetime[] $all_datetimes All Datetimes on the event or empty for default. |
|
| 1459 | - * @param bool $default Whether default row being generated or not. |
|
| 1460 | - * @param EE_Ticket[] $all_tickets This is an array of all tickets attached to the event |
|
| 1461 | - * (or empty in the case of defaults) |
|
| 1462 | - * @return string |
|
| 1463 | - * @throws InvalidArgumentException |
|
| 1464 | - * @throws InvalidInterfaceException |
|
| 1465 | - * @throws InvalidDataTypeException |
|
| 1466 | - * @throws DomainException |
|
| 1467 | - * @throws EE_Error |
|
| 1468 | - * @throws ReflectionException |
|
| 1469 | - */ |
|
| 1470 | - protected function _get_ticket_row( |
|
| 1471 | - $ticket_row, |
|
| 1472 | - ?EE_Ticket $ticket, |
|
| 1473 | - array $ticket_datetimes, |
|
| 1474 | - array $all_datetimes, |
|
| 1475 | - bool $default = false, |
|
| 1476 | - array $all_tickets = [] |
|
| 1477 | - ): string { |
|
| 1478 | - // if $ticket is not an instance of EE_Ticket then force default to true. |
|
| 1479 | - $default = ! $ticket instanceof EE_Ticket |
|
| 1480 | - ? true |
|
| 1481 | - : $default; |
|
| 1482 | - $prices = ! empty($ticket) && ! $default |
|
| 1483 | - ? $ticket->get_many_related( |
|
| 1484 | - 'Price', |
|
| 1485 | - ['default_where_conditions' => 'none', 'order_by' => ['PRC_order' => 'ASC']] |
|
| 1486 | - ) |
|
| 1487 | - : []; |
|
| 1488 | - // if there is only one price (which would be the base price) |
|
| 1489 | - // or NO prices and this ticket is a default ticket, |
|
| 1490 | - // let's just make sure there are no cached default prices on the object. |
|
| 1491 | - // This is done by not including any query_params. |
|
| 1492 | - if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
| 1493 | - $prices = $ticket->prices(); |
|
| 1494 | - } |
|
| 1495 | - // check if we're dealing with a default ticket in which case |
|
| 1496 | - // we don't want any starting_ticket_datetime_row values set |
|
| 1497 | - // (otherwise there won't be any new relationships created for tickets based off of the default ticket). |
|
| 1498 | - // This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
|
| 1499 | - $default_datetime = $default || ($ticket instanceof EE_Ticket && $ticket->is_default()); |
|
| 1500 | - $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ]) |
|
| 1501 | - ? $ticket_datetimes[ $ticket->ID() ] |
|
| 1502 | - : []; |
|
| 1503 | - $ticket_subtotal = $default |
|
| 1504 | - ? 0 |
|
| 1505 | - : $ticket->get_ticket_subtotal(); |
|
| 1506 | - $base_price = $default |
|
| 1507 | - ? null |
|
| 1508 | - : $ticket->base_price(); |
|
| 1509 | - $count_price_mods = EEM_Price::instance()->get_all_default_prices(true); |
|
| 1510 | - // breaking out complicated condition for ticket_status |
|
| 1511 | - if ($default) { |
|
| 1512 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1513 | - } else { |
|
| 1514 | - $ticket_status_class = $ticket->is_default() |
|
| 1515 | - ? ' tkt-status-' . EE_Ticket::onsale |
|
| 1516 | - : ' tkt-status-' . $ticket->ticket_status(); |
|
| 1517 | - } |
|
| 1518 | - // breaking out complicated condition for TKT_taxable |
|
| 1519 | - if ($default) { |
|
| 1520 | - $TKT_taxable = ''; |
|
| 1521 | - } else { |
|
| 1522 | - $TKT_taxable = $ticket->taxable() |
|
| 1523 | - ? 'checked' |
|
| 1524 | - : ''; |
|
| 1525 | - } |
|
| 1526 | - if ($default) { |
|
| 1527 | - $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence'); |
|
| 1528 | - } elseif ($ticket->is_default()) { |
|
| 1529 | - $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence'); |
|
| 1530 | - } else { |
|
| 1531 | - $TKT_status = $ticket->ticket_status(true); |
|
| 1532 | - } |
|
| 1533 | - if ($default) { |
|
| 1534 | - $TKT_min = ''; |
|
| 1535 | - } else { |
|
| 1536 | - $TKT_min = $ticket->min(); |
|
| 1537 | - if ($TKT_min === -1 || $TKT_min === 0) { |
|
| 1538 | - $TKT_min = ''; |
|
| 1539 | - } |
|
| 1540 | - } |
|
| 1541 | - $template_args = [ |
|
| 1542 | - 'tkt_row' => $default |
|
| 1543 | - ? 'TICKETNUM' |
|
| 1544 | - : $ticket_row, |
|
| 1545 | - 'TKT_order' => $default |
|
| 1546 | - ? 'TICKETNUM' |
|
| 1547 | - : $ticket_row, |
|
| 1548 | - // on initial page load this will always be the correct order. |
|
| 1549 | - 'tkt_status_class' => $ticket_status_class, |
|
| 1550 | - 'display_edit_tkt_row' => 'display:none;', |
|
| 1551 | - 'edit_tkt_expanded' => '', |
|
| 1552 | - 'edit_tickets_name' => $default |
|
| 1553 | - ? 'TICKETNAMEATTR' |
|
| 1554 | - : 'edit_tickets', |
|
| 1555 | - 'TKT_name' => $default |
|
| 1556 | - ? '' |
|
| 1557 | - : $ticket->get_f('TKT_name'), |
|
| 1558 | - 'TKT_start_date' => $default |
|
| 1559 | - ? '' |
|
| 1560 | - : $ticket->get_date('TKT_start_date', $this->_date_time_format), |
|
| 1561 | - 'TKT_end_date' => $default |
|
| 1562 | - ? '' |
|
| 1563 | - : $ticket->get_date('TKT_end_date', $this->_date_time_format), |
|
| 1564 | - 'TKT_status' => $TKT_status, |
|
| 1565 | - 'TKT_price' => $default |
|
| 1566 | - ? '' |
|
| 1567 | - : EEH_Template::format_currency( |
|
| 1568 | - $ticket->get_ticket_total_with_taxes(), |
|
| 1569 | - false, |
|
| 1570 | - false |
|
| 1571 | - ), |
|
| 1572 | - 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
|
| 1573 | - 'TKT_price_amount' => $default |
|
| 1574 | - ? 0 |
|
| 1575 | - : $ticket_subtotal, |
|
| 1576 | - 'TKT_qty' => $default |
|
| 1577 | - ? '' |
|
| 1578 | - : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
| 1579 | - 'TKT_qty_for_input' => $default |
|
| 1580 | - ? '' |
|
| 1581 | - : $ticket->get_pretty('TKT_qty', 'input'), |
|
| 1582 | - 'TKT_uses' => $default |
|
| 1583 | - ? '' |
|
| 1584 | - : $ticket->get_pretty('TKT_uses', 'input'), |
|
| 1585 | - 'TKT_min' => $TKT_min, |
|
| 1586 | - 'TKT_max' => $default |
|
| 1587 | - ? '' |
|
| 1588 | - : $ticket->get_pretty('TKT_max', 'input'), |
|
| 1589 | - 'TKT_sold' => $default |
|
| 1590 | - ? 0 |
|
| 1591 | - : $ticket->tickets_sold(), |
|
| 1592 | - 'TKT_reserved' => $default |
|
| 1593 | - ? 0 |
|
| 1594 | - : $ticket->reserved(), |
|
| 1595 | - 'TKT_registrations' => $default |
|
| 1596 | - ? 0 |
|
| 1597 | - : $ticket->count_registrations( |
|
| 1598 | - [ |
|
| 1599 | - [ |
|
| 1600 | - 'STS_ID' => [ |
|
| 1601 | - '!=', |
|
| 1602 | - EEM_Registration::status_id_incomplete, |
|
| 1603 | - ], |
|
| 1604 | - ], |
|
| 1605 | - ] |
|
| 1606 | - ), |
|
| 1607 | - 'TKT_ID' => $default |
|
| 1608 | - ? 0 |
|
| 1609 | - : $ticket->ID(), |
|
| 1610 | - 'TKT_description' => $default |
|
| 1611 | - ? '' |
|
| 1612 | - : $ticket->get_raw('TKT_description'), |
|
| 1613 | - 'TKT_is_default' => $default |
|
| 1614 | - ? 0 |
|
| 1615 | - : $ticket->is_default(), |
|
| 1616 | - 'TKT_required' => $default |
|
| 1617 | - ? 0 |
|
| 1618 | - : $ticket->required(), |
|
| 1619 | - 'TKT_is_default_selector' => '', |
|
| 1620 | - 'ticket_price_rows' => '', |
|
| 1621 | - 'TKT_base_price' => $default || ! $base_price instanceof EE_Price |
|
| 1622 | - ? '' |
|
| 1623 | - : $base_price->get_pretty('PRC_amount', 'localized_float'), |
|
| 1624 | - 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price |
|
| 1625 | - ? 0 |
|
| 1626 | - : $base_price->ID(), |
|
| 1627 | - 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) |
|
| 1628 | - ? '' |
|
| 1629 | - : 'display:none;', |
|
| 1630 | - 'show_price_mod_button' => count($prices) > 1 |
|
| 1631 | - || ($default && $count_price_mods > 0) |
|
| 1632 | - || (! $default && $ticket->deleted()) |
|
| 1633 | - ? 'display:none;' |
|
| 1634 | - : '', |
|
| 1635 | - 'total_price_rows' => count($prices) > 1 |
|
| 1636 | - ? count($prices) |
|
| 1637 | - : 1, |
|
| 1638 | - 'ticket_datetimes_list' => $default |
|
| 1639 | - ? '<li class="hidden"></li>' |
|
| 1640 | - : '', |
|
| 1641 | - 'starting_ticket_datetime_rows' => $default || $default_datetime |
|
| 1642 | - ? '' |
|
| 1643 | - : implode(',', $tkt_datetimes), |
|
| 1644 | - 'ticket_datetime_rows' => $default |
|
| 1645 | - ? '' |
|
| 1646 | - : implode(',', $tkt_datetimes), |
|
| 1647 | - 'existing_ticket_price_ids' => $default |
|
| 1648 | - ? '' |
|
| 1649 | - : implode(',', array_keys($prices)), |
|
| 1650 | - 'ticket_template_id' => $default |
|
| 1651 | - ? 0 |
|
| 1652 | - : $ticket->get('TTM_ID'), |
|
| 1653 | - 'TKT_taxable' => $TKT_taxable, |
|
| 1654 | - 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->taxable() |
|
| 1655 | - ? '' |
|
| 1656 | - : 'display:none;', |
|
| 1657 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1658 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency( |
|
| 1659 | - $ticket_subtotal, |
|
| 1660 | - false, |
|
| 1661 | - false |
|
| 1662 | - ), |
|
| 1663 | - 'TKT_subtotal_amount' => $ticket_subtotal, |
|
| 1664 | - 'tax_rows' => $this->_get_tax_rows($ticket_row, $ticket), |
|
| 1665 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->deleted(), |
|
| 1666 | - 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->deleted() |
|
| 1667 | - ? ' ticket-archived' |
|
| 1668 | - : '', |
|
| 1669 | - 'trash_icon' => $ticket instanceof EE_Ticket |
|
| 1670 | - && $ticket->deleted() |
|
| 1671 | - && ! $ticket->is_permanently_deleteable() |
|
| 1672 | - ? 'dashicons dashicons-lock ' |
|
| 1673 | - : 'trash-entity dashicons dashicons-post-trash clickable', |
|
| 1674 | - |
|
| 1675 | - 'can_clone' => $ticket instanceof EE_Ticket && ! $ticket->deleted(), |
|
| 1676 | - 'can_trash' => $ticket instanceof EE_Ticket |
|
| 1677 | - && (! $ticket->deleted() && $ticket->is_permanently_deleteable()), |
|
| 1678 | - ]; |
|
| 1679 | - $template_args['trash_hidden'] = count($all_tickets) === 1 |
|
| 1680 | - && $template_args['trash_icon'] !== 'dashicons dashicons-lock' |
|
| 1681 | - ? 'display:none' |
|
| 1682 | - : ''; |
|
| 1683 | - // handle rows that should NOT be empty |
|
| 1684 | - if (empty($template_args['TKT_start_date'])) { |
|
| 1685 | - // if empty then the start date will be now. |
|
| 1686 | - $template_args['TKT_start_date'] = date( |
|
| 1687 | - $this->_date_time_format, |
|
| 1688 | - current_time('timestamp') |
|
| 1689 | - ); |
|
| 1690 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1691 | - } |
|
| 1692 | - if (empty($template_args['TKT_end_date'])) { |
|
| 1693 | - // get the earliest datetime (if present); |
|
| 1694 | - $earliest_datetime = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 |
|
| 1695 | - ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related( |
|
| 1696 | - 'Datetime', |
|
| 1697 | - ['order_by' => ['DTT_EVT_start' => 'ASC']] |
|
| 1698 | - ) |
|
| 1699 | - : null; |
|
| 1700 | - if (! empty($earliest_datetime)) { |
|
| 1701 | - $template_args['TKT_end_date'] = $earliest_datetime->get_datetime( |
|
| 1702 | - 'DTT_EVT_start', |
|
| 1703 | - $this->_date_time_format |
|
| 1704 | - ); |
|
| 1705 | - } else { |
|
| 1706 | - // default so let's just use what's been set for the default date-time which is 30 days from now. |
|
| 1707 | - $template_args['TKT_end_date'] = date( |
|
| 1708 | - $this->_date_time_format, |
|
| 1709 | - mktime( |
|
| 1710 | - 24, |
|
| 1711 | - 0, |
|
| 1712 | - 0, |
|
| 1713 | - date('m'), |
|
| 1714 | - date('d') + 29, |
|
| 1715 | - date('Y') |
|
| 1716 | - ) |
|
| 1717 | - ); |
|
| 1718 | - } |
|
| 1719 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1720 | - } |
|
| 1721 | - // generate ticket_datetime items |
|
| 1722 | - if (! $default) { |
|
| 1723 | - $datetime_row = 1; |
|
| 1724 | - foreach ($all_datetimes as $datetime) { |
|
| 1725 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( |
|
| 1726 | - $datetime_row, |
|
| 1727 | - $ticket_row, |
|
| 1728 | - $datetime, |
|
| 1729 | - $ticket, |
|
| 1730 | - $ticket_datetimes, |
|
| 1731 | - $default |
|
| 1732 | - ); |
|
| 1733 | - $datetime_row++; |
|
| 1734 | - } |
|
| 1735 | - } |
|
| 1736 | - $price_row = 1; |
|
| 1737 | - foreach ($prices as $price) { |
|
| 1738 | - if (! $price instanceof EE_Price) { |
|
| 1739 | - continue; |
|
| 1740 | - } |
|
| 1741 | - if ($price->is_base_price()) { |
|
| 1742 | - $price_row++; |
|
| 1743 | - continue; |
|
| 1744 | - } |
|
| 1745 | - |
|
| 1746 | - $show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1); |
|
| 1747 | - $show_create = ! (count($prices) > 1 && count($prices) !== $price_row); |
|
| 1748 | - |
|
| 1749 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( |
|
| 1750 | - $ticket_row, |
|
| 1751 | - $price_row, |
|
| 1752 | - $price, |
|
| 1753 | - $default, |
|
| 1754 | - $ticket, |
|
| 1755 | - $show_trash, |
|
| 1756 | - $show_create |
|
| 1757 | - ); |
|
| 1758 | - $price_row++; |
|
| 1759 | - } |
|
| 1760 | - // filter $template_args |
|
| 1761 | - $template_args = apply_filters( |
|
| 1762 | - 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', |
|
| 1763 | - $template_args, |
|
| 1764 | - $ticket_row, |
|
| 1765 | - $ticket, |
|
| 1766 | - $ticket_datetimes, |
|
| 1767 | - $all_datetimes, |
|
| 1768 | - $default, |
|
| 1769 | - $all_tickets, |
|
| 1770 | - $this->_is_creating_event |
|
| 1771 | - ); |
|
| 1772 | - return EEH_Template::display_template( |
|
| 1773 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php', |
|
| 1774 | - $template_args, |
|
| 1775 | - true |
|
| 1776 | - ); |
|
| 1777 | - } |
|
| 1778 | - |
|
| 1779 | - |
|
| 1780 | - /** |
|
| 1781 | - * @param int|string $ticket_row |
|
| 1782 | - * @param EE_Ticket|null $ticket |
|
| 1783 | - * @return string |
|
| 1784 | - * @throws DomainException |
|
| 1785 | - * @throws EE_Error |
|
| 1786 | - * @throws ReflectionException |
|
| 1787 | - */ |
|
| 1788 | - protected function _get_tax_rows($ticket_row, ?EE_Ticket $ticket): string |
|
| 1789 | - { |
|
| 1790 | - $tax_rows = ''; |
|
| 1791 | - /** @var EE_Price[] $taxes */ |
|
| 1792 | - $taxes = EE_Taxes::get_taxes_for_admin(); |
|
| 1793 | - foreach ($taxes as $tax) { |
|
| 1794 | - $tax_added = $this->_get_tax_added($tax, $ticket); |
|
| 1795 | - $template_args = [ |
|
| 1796 | - 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') |
|
| 1797 | - ? '' |
|
| 1798 | - : 'display:none;', |
|
| 1799 | - 'tax_id' => $tax->ID(), |
|
| 1800 | - 'tkt_row' => $ticket_row, |
|
| 1801 | - 'tax_label' => $tax->get('PRC_name'), |
|
| 1802 | - 'tax_added' => $tax_added, |
|
| 1803 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, false, false), |
|
| 1804 | - 'tax_amount' => $tax->get('PRC_amount'), |
|
| 1805 | - ]; |
|
| 1806 | - $template_args = apply_filters( |
|
| 1807 | - 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', |
|
| 1808 | - $template_args, |
|
| 1809 | - $ticket_row, |
|
| 1810 | - $ticket, |
|
| 1811 | - $this->_is_creating_event |
|
| 1812 | - ); |
|
| 1813 | - $tax_rows .= EEH_Template::display_template( |
|
| 1814 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php', |
|
| 1815 | - $template_args, |
|
| 1816 | - true |
|
| 1817 | - ); |
|
| 1818 | - } |
|
| 1819 | - return $tax_rows; |
|
| 1820 | - } |
|
| 1821 | - |
|
| 1822 | - |
|
| 1823 | - /** |
|
| 1824 | - * @param EE_Price $tax |
|
| 1825 | - * @param EE_Ticket|null $ticket |
|
| 1826 | - * @return float|int |
|
| 1827 | - * @throws EE_Error |
|
| 1828 | - * @throws ReflectionException |
|
| 1829 | - */ |
|
| 1830 | - protected function _get_tax_added(EE_Price $tax, ?EE_Ticket $ticket) |
|
| 1831 | - { |
|
| 1832 | - $subtotal = empty($ticket) |
|
| 1833 | - ? 0 |
|
| 1834 | - : $ticket->get_ticket_subtotal(); |
|
| 1835 | - return $subtotal * $tax->get('PRC_amount') / 100; |
|
| 1836 | - } |
|
| 1837 | - |
|
| 1838 | - |
|
| 1839 | - /** |
|
| 1840 | - * @param int|string $ticket_row |
|
| 1841 | - * @param int|string $price_row |
|
| 1842 | - * @param EE_Price|null $price |
|
| 1843 | - * @param bool $default |
|
| 1844 | - * @param EE_Ticket|null $ticket |
|
| 1845 | - * @param bool $show_trash |
|
| 1846 | - * @param bool $show_create |
|
| 1847 | - * @return string |
|
| 1848 | - * @throws InvalidArgumentException |
|
| 1849 | - * @throws InvalidInterfaceException |
|
| 1850 | - * @throws InvalidDataTypeException |
|
| 1851 | - * @throws DomainException |
|
| 1852 | - * @throws EE_Error |
|
| 1853 | - * @throws ReflectionException |
|
| 1854 | - */ |
|
| 1855 | - protected function _get_ticket_price_row( |
|
| 1856 | - $ticket_row, |
|
| 1857 | - $price_row, |
|
| 1858 | - ?EE_Price $price, |
|
| 1859 | - bool $default, |
|
| 1860 | - ?EE_Ticket $ticket, |
|
| 1861 | - bool $show_trash = true, |
|
| 1862 | - bool $show_create = true |
|
| 1863 | - ): string { |
|
| 1864 | - $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted'); |
|
| 1865 | - $template_args = [ |
|
| 1866 | - 'tkt_row' => $default && empty($ticket) |
|
| 1867 | - ? 'TICKETNUM' |
|
| 1868 | - : $ticket_row, |
|
| 1869 | - 'PRC_order' => $default && empty($price) |
|
| 1870 | - ? 'PRICENUM' |
|
| 1871 | - : $price_row, |
|
| 1872 | - 'edit_prices_name' => $default && empty($price) |
|
| 1873 | - ? 'PRICENAMEATTR' |
|
| 1874 | - : 'edit_prices', |
|
| 1875 | - 'price_type_selector' => $this->_get_price_type_selector( |
|
| 1876 | - $ticket_row, |
|
| 1877 | - $price_row, |
|
| 1878 | - $price, |
|
| 1879 | - $default, |
|
| 1880 | - $send_disabled |
|
| 1881 | - ), |
|
| 1882 | - 'PRC_ID' => $default && empty($price) |
|
| 1883 | - ? 0 |
|
| 1884 | - : $price->ID(), |
|
| 1885 | - 'PRC_is_default' => $default && empty($price) |
|
| 1886 | - ? 0 |
|
| 1887 | - : $price->get('PRC_is_default'), |
|
| 1888 | - 'PRC_name' => $default && empty($price) |
|
| 1889 | - ? '' |
|
| 1890 | - : $price->get('PRC_name'), |
|
| 1891 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1892 | - 'show_plus_or_minus' => $default && empty($price) |
|
| 1893 | - ? '' |
|
| 1894 | - : 'display:none;', |
|
| 1895 | - 'show_plus' => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price()) |
|
| 1896 | - ? 'display:none;' |
|
| 1897 | - : '', |
|
| 1898 | - 'show_minus' => ($default && empty($price)) || ! $price->is_discount() |
|
| 1899 | - ? 'display:none;' |
|
| 1900 | - : '', |
|
| 1901 | - 'show_currency_symbol' => ($default && empty($price)) || $price->is_percent() |
|
| 1902 | - ? 'display:none' |
|
| 1903 | - : '', |
|
| 1904 | - 'PRC_amount' => $default && empty($price) |
|
| 1905 | - ? 0 |
|
| 1906 | - : $price->get_pretty('PRC_amount', 'localized_float'), |
|
| 1907 | - 'show_percentage' => ($default && empty($price)) || ! $price->is_percent() |
|
| 1908 | - ? 'display:none;' |
|
| 1909 | - : '', |
|
| 1910 | - 'show_trash_icon' => $show_trash |
|
| 1911 | - ? '' |
|
| 1912 | - : ' style="display:none;"', |
|
| 1913 | - 'show_create_button' => $show_create |
|
| 1914 | - ? '' |
|
| 1915 | - : ' style="display:none;"', |
|
| 1916 | - 'PRC_desc' => $default && empty($price) |
|
| 1917 | - ? '' |
|
| 1918 | - : $price->get('PRC_desc'), |
|
| 1919 | - 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted'), |
|
| 1920 | - ]; |
|
| 1921 | - $template_args = apply_filters( |
|
| 1922 | - 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', |
|
| 1923 | - $template_args, |
|
| 1924 | - $ticket_row, |
|
| 1925 | - $price_row, |
|
| 1926 | - $price, |
|
| 1927 | - $default, |
|
| 1928 | - $ticket, |
|
| 1929 | - $show_trash, |
|
| 1930 | - $show_create, |
|
| 1931 | - $this->_is_creating_event |
|
| 1932 | - ); |
|
| 1933 | - return EEH_Template::display_template( |
|
| 1934 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php', |
|
| 1935 | - $template_args, |
|
| 1936 | - true |
|
| 1937 | - ); |
|
| 1938 | - } |
|
| 1939 | - |
|
| 1940 | - |
|
| 1941 | - /** |
|
| 1942 | - * @param int|string $ticket_row |
|
| 1943 | - * @param int|string $price_row |
|
| 1944 | - * @param EE_Price|null $price |
|
| 1945 | - * @param bool $default |
|
| 1946 | - * @param bool $disabled |
|
| 1947 | - * @return string |
|
| 1948 | - * @throws ReflectionException |
|
| 1949 | - * @throws InvalidArgumentException |
|
| 1950 | - * @throws InvalidInterfaceException |
|
| 1951 | - * @throws InvalidDataTypeException |
|
| 1952 | - * @throws DomainException |
|
| 1953 | - * @throws EE_Error |
|
| 1954 | - */ |
|
| 1955 | - protected function _get_price_type_selector( |
|
| 1956 | - $ticket_row, |
|
| 1957 | - $price_row, |
|
| 1958 | - ?EE_Price $price, |
|
| 1959 | - bool $default, |
|
| 1960 | - bool $disabled = false |
|
| 1961 | - ): string { |
|
| 1962 | - if (($price instanceof EE_Price && $price->is_base_price()) || (! $price instanceof EE_Price && $default)) { |
|
| 1963 | - return $this->_get_base_price_template( |
|
| 1964 | - $ticket_row, |
|
| 1965 | - $price_row, |
|
| 1966 | - $price, |
|
| 1967 | - $default |
|
| 1968 | - ); |
|
| 1969 | - } |
|
| 1970 | - return $this->_get_price_modifier_template( |
|
| 1971 | - $ticket_row, |
|
| 1972 | - $price_row, |
|
| 1973 | - $price, |
|
| 1974 | - $default, |
|
| 1975 | - $disabled |
|
| 1976 | - ); |
|
| 1977 | - } |
|
| 1978 | - |
|
| 1979 | - |
|
| 1980 | - /** |
|
| 1981 | - * @param int|string $ticket_row |
|
| 1982 | - * @param int|string $price_row |
|
| 1983 | - * @param EE_Price|null $price |
|
| 1984 | - * @param bool $default |
|
| 1985 | - * @return string |
|
| 1986 | - * @throws DomainException |
|
| 1987 | - * @throws EE_Error |
|
| 1988 | - * @throws ReflectionException |
|
| 1989 | - */ |
|
| 1990 | - protected function _get_base_price_template( |
|
| 1991 | - $ticket_row, |
|
| 1992 | - $price_row, |
|
| 1993 | - ?EE_Price $price, |
|
| 1994 | - bool $default |
|
| 1995 | - ): string { |
|
| 1996 | - $template_args = [ |
|
| 1997 | - 'tkt_row' => $default |
|
| 1998 | - ? 'TICKETNUM' |
|
| 1999 | - : $ticket_row, |
|
| 2000 | - 'PRC_order' => $default && empty($price) |
|
| 2001 | - ? 'PRICENUM' |
|
| 2002 | - : $price_row, |
|
| 2003 | - 'PRT_ID' => $default && empty($price) |
|
| 2004 | - ? 1 |
|
| 2005 | - : $price->get('PRT_ID'), |
|
| 2006 | - 'PRT_name' => esc_html__('Price', 'event_espresso'), |
|
| 2007 | - 'price_selected_operator' => '+', |
|
| 2008 | - 'price_selected_is_percent' => 0, |
|
| 2009 | - ]; |
|
| 2010 | - $template_args = apply_filters( |
|
| 2011 | - 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', |
|
| 2012 | - $template_args, |
|
| 2013 | - $ticket_row, |
|
| 2014 | - $price_row, |
|
| 2015 | - $price, |
|
| 2016 | - $default, |
|
| 2017 | - $this->_is_creating_event |
|
| 2018 | - ); |
|
| 2019 | - return EEH_Template::display_template( |
|
| 2020 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php', |
|
| 2021 | - $template_args, |
|
| 2022 | - true |
|
| 2023 | - ); |
|
| 2024 | - } |
|
| 2025 | - |
|
| 2026 | - |
|
| 2027 | - /** |
|
| 2028 | - * @param int|string $ticket_row |
|
| 2029 | - * @param int|string $price_row |
|
| 2030 | - * @param EE_Price|null $price |
|
| 2031 | - * @param bool $default |
|
| 2032 | - * @param bool $disabled |
|
| 2033 | - * @return string |
|
| 2034 | - * @throws ReflectionException |
|
| 2035 | - * @throws InvalidArgumentException |
|
| 2036 | - * @throws InvalidInterfaceException |
|
| 2037 | - * @throws InvalidDataTypeException |
|
| 2038 | - * @throws DomainException |
|
| 2039 | - * @throws EE_Error |
|
| 2040 | - */ |
|
| 2041 | - protected function _get_price_modifier_template( |
|
| 2042 | - $ticket_row, |
|
| 2043 | - $price_row, |
|
| 2044 | - ?EE_Price $price, |
|
| 2045 | - bool $default, |
|
| 2046 | - bool $disabled = false |
|
| 2047 | - ): string { |
|
| 2048 | - $use_default = $default && ! $price instanceof EE_Price; |
|
| 2049 | - $selected_price_type_id = $use_default ? 0 : $price->type(); |
|
| 2050 | - |
|
| 2051 | - $select_name = $use_default |
|
| 2052 | - ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' |
|
| 2053 | - : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]'; |
|
| 2054 | - |
|
| 2055 | - $price_type_model = EEM_Price_Type::instance(); |
|
| 2056 | - $price_types = $price_type_model->get_all([['NOT' => ['PBT_ID' => '1']]]); |
|
| 2057 | - $all_price_types = $use_default |
|
| 2058 | - ? [esc_html__('Select Modifier', 'event_espresso')] |
|
| 2059 | - : []; |
|
| 2060 | - $price_option_spans = ''; |
|
| 2061 | - // setup price types for selector |
|
| 2062 | - foreach ($price_types as $price_type) { |
|
| 2063 | - if (! $price_type instanceof EE_Price_Type) { |
|
| 2064 | - continue; |
|
| 2065 | - } |
|
| 2066 | - $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name'); |
|
| 2067 | - // while we're in the loop lets set up the option spans used by js |
|
| 2068 | - $span_args = [ |
|
| 2069 | - 'PRT_ID' => $price_type->ID(), |
|
| 2070 | - 'PRT_operator' => $price_type->is_discount() |
|
| 2071 | - ? '-' |
|
| 2072 | - : '+', |
|
| 2073 | - 'PRT_is_percent' => $price_type->get('PRT_is_percent') |
|
| 2074 | - ? 1 |
|
| 2075 | - : 0, |
|
| 2076 | - ]; |
|
| 2077 | - $price_option_spans .= EEH_Template::display_template( |
|
| 2078 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php', |
|
| 2079 | - $span_args, |
|
| 2080 | - true |
|
| 2081 | - ); |
|
| 2082 | - } |
|
| 2083 | - |
|
| 2084 | - $select_name = $disabled |
|
| 2085 | - ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]' |
|
| 2086 | - : $select_name; |
|
| 2087 | - |
|
| 2088 | - $select_input = new EE_Select_Input( |
|
| 2089 | - $all_price_types, |
|
| 2090 | - [ |
|
| 2091 | - 'default' => $selected_price_type_id, |
|
| 2092 | - 'html_name' => $select_name, |
|
| 2093 | - 'html_class' => 'edit-price-PRT_ID', |
|
| 2094 | - 'other_html_attributes' => $disabled |
|
| 2095 | - ? 'style="width:auto;" disabled' |
|
| 2096 | - : 'style="width:auto;"', |
|
| 2097 | - ] |
|
| 2098 | - ); |
|
| 2099 | - |
|
| 2100 | - $price_selected_operator = $price instanceof EE_Price && $price->is_discount() |
|
| 2101 | - ? '-' |
|
| 2102 | - : '+'; |
|
| 2103 | - $price_selected_operator = $use_default |
|
| 2104 | - ? '' |
|
| 2105 | - : $price_selected_operator; |
|
| 2106 | - $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() |
|
| 2107 | - ? 1 |
|
| 2108 | - : 0; |
|
| 2109 | - $price_selected_is_percent = $use_default |
|
| 2110 | - ? '' |
|
| 2111 | - : $price_selected_is_percent; |
|
| 2112 | - $template_args = [ |
|
| 2113 | - 'tkt_row' => $default |
|
| 2114 | - ? 'TICKETNUM' |
|
| 2115 | - : $ticket_row, |
|
| 2116 | - 'PRC_order' => $use_default |
|
| 2117 | - ? 'PRICENUM' |
|
| 2118 | - : $price_row, |
|
| 2119 | - 'price_modifier_selector' => $select_input->get_html_for_input(), |
|
| 2120 | - 'main_name' => $select_name, |
|
| 2121 | - 'selected_price_type_id' => $selected_price_type_id, |
|
| 2122 | - 'price_option_spans' => $price_option_spans, |
|
| 2123 | - 'price_selected_operator' => $price_selected_operator, |
|
| 2124 | - 'price_selected_is_percent' => $price_selected_is_percent, |
|
| 2125 | - 'disabled' => $disabled, |
|
| 2126 | - ]; |
|
| 2127 | - $template_args = apply_filters( |
|
| 2128 | - 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', |
|
| 2129 | - $template_args, |
|
| 2130 | - $ticket_row, |
|
| 2131 | - $price_row, |
|
| 2132 | - $price, |
|
| 2133 | - $default, |
|
| 2134 | - $disabled, |
|
| 2135 | - $this->_is_creating_event |
|
| 2136 | - ); |
|
| 2137 | - return EEH_Template::display_template( |
|
| 2138 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php', |
|
| 2139 | - $template_args, |
|
| 2140 | - true |
|
| 2141 | - ); |
|
| 2142 | - } |
|
| 2143 | - |
|
| 2144 | - |
|
| 2145 | - /** |
|
| 2146 | - * @param int|string $datetime_row |
|
| 2147 | - * @param int|string $ticket_row |
|
| 2148 | - * @param EE_Datetime|null $datetime |
|
| 2149 | - * @param EE_Ticket|null $ticket |
|
| 2150 | - * @param array $ticket_datetimes |
|
| 2151 | - * @param bool $default |
|
| 2152 | - * @return string |
|
| 2153 | - * @throws DomainException |
|
| 2154 | - * @throws EE_Error |
|
| 2155 | - * @throws ReflectionException |
|
| 2156 | - */ |
|
| 2157 | - protected function _get_ticket_datetime_list_item( |
|
| 2158 | - $datetime_row, |
|
| 2159 | - $ticket_row, |
|
| 2160 | - ?EE_Datetime $datetime, |
|
| 2161 | - ?EE_Ticket $ticket, |
|
| 2162 | - array $ticket_datetimes = [], |
|
| 2163 | - bool $default = false |
|
| 2164 | - ): string { |
|
| 2165 | - $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ]) |
|
| 2166 | - ? $ticket_datetimes[ $ticket->ID() ] |
|
| 2167 | - : []; |
|
| 2168 | - $template_args = [ |
|
| 2169 | - 'dtt_row' => $default && ! $datetime instanceof EE_Datetime |
|
| 2170 | - ? 'DTTNUM' |
|
| 2171 | - : $datetime_row, |
|
| 2172 | - 'tkt_row' => $default |
|
| 2173 | - ? 'TICKETNUM' |
|
| 2174 | - : $ticket_row, |
|
| 2175 | - 'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true) |
|
| 2176 | - ? ' ticket-selected' |
|
| 2177 | - : '', |
|
| 2178 | - 'ticket_datetime_checked' => in_array($datetime_row, $tkt_datetimes, true) |
|
| 2179 | - ? ' checked' |
|
| 2180 | - : '', |
|
| 2181 | - 'DTT_name' => $default && empty($datetime) |
|
| 2182 | - ? 'DTTNAME' |
|
| 2183 | - : $datetime->get_dtt_display_name(true), |
|
| 2184 | - 'tkt_status_class' => '', |
|
| 2185 | - ]; |
|
| 2186 | - $template_args = apply_filters( |
|
| 2187 | - 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', |
|
| 2188 | - $template_args, |
|
| 2189 | - $datetime_row, |
|
| 2190 | - $ticket_row, |
|
| 2191 | - $datetime, |
|
| 2192 | - $ticket, |
|
| 2193 | - $ticket_datetimes, |
|
| 2194 | - $default, |
|
| 2195 | - $this->_is_creating_event |
|
| 2196 | - ); |
|
| 2197 | - return EEH_Template::display_template( |
|
| 2198 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php', |
|
| 2199 | - $template_args, |
|
| 2200 | - true |
|
| 2201 | - ); |
|
| 2202 | - } |
|
| 2203 | - |
|
| 2204 | - |
|
| 2205 | - /** |
|
| 2206 | - * @param array $all_datetimes |
|
| 2207 | - * @param array $all_tickets |
|
| 2208 | - * @return string |
|
| 2209 | - * @throws ReflectionException |
|
| 2210 | - * @throws InvalidArgumentException |
|
| 2211 | - * @throws InvalidInterfaceException |
|
| 2212 | - * @throws InvalidDataTypeException |
|
| 2213 | - * @throws DomainException |
|
| 2214 | - * @throws EE_Error |
|
| 2215 | - */ |
|
| 2216 | - protected function _get_ticket_js_structure(array $all_datetimes = [], array $all_tickets = []): string |
|
| 2217 | - { |
|
| 2218 | - $template_args = [ |
|
| 2219 | - 'default_datetime_edit_row' => $this->_get_dtt_edit_row( |
|
| 2220 | - 'DTTNUM', |
|
| 2221 | - null, |
|
| 2222 | - true, |
|
| 2223 | - $all_datetimes |
|
| 2224 | - ), |
|
| 2225 | - 'default_ticket_row' => $this->_get_ticket_row( |
|
| 2226 | - 'TICKETNUM', |
|
| 2227 | - null, |
|
| 2228 | - [], |
|
| 2229 | - [], |
|
| 2230 | - true |
|
| 2231 | - ), |
|
| 2232 | - 'default_price_row' => $this->_get_ticket_price_row( |
|
| 2233 | - 'TICKETNUM', |
|
| 2234 | - 'PRICENUM', |
|
| 2235 | - null, |
|
| 2236 | - true, |
|
| 2237 | - null |
|
| 2238 | - ), |
|
| 2239 | - |
|
| 2240 | - 'default_price_rows' => '', |
|
| 2241 | - 'default_base_price_amount' => 0, |
|
| 2242 | - 'default_base_price_name' => '', |
|
| 2243 | - 'default_base_price_description' => '', |
|
| 2244 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( |
|
| 2245 | - 'TICKETNUM', |
|
| 2246 | - 'PRICENUM', |
|
| 2247 | - null, |
|
| 2248 | - true |
|
| 2249 | - ), |
|
| 2250 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( |
|
| 2251 | - 'DTTNUM', |
|
| 2252 | - null, |
|
| 2253 | - [], |
|
| 2254 | - [], |
|
| 2255 | - true |
|
| 2256 | - ), |
|
| 2257 | - 'existing_available_datetime_tickets_list' => '', |
|
| 2258 | - 'existing_available_ticket_datetimes_list' => '', |
|
| 2259 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( |
|
| 2260 | - 'DTTNUM', |
|
| 2261 | - 'TICKETNUM', |
|
| 2262 | - null, |
|
| 2263 | - null, |
|
| 2264 | - [], |
|
| 2265 | - true |
|
| 2266 | - ), |
|
| 2267 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( |
|
| 2268 | - 'DTTNUM', |
|
| 2269 | - 'TICKETNUM', |
|
| 2270 | - null, |
|
| 2271 | - null, |
|
| 2272 | - [], |
|
| 2273 | - true |
|
| 2274 | - ), |
|
| 2275 | - ]; |
|
| 2276 | - $ticket_row = 1; |
|
| 2277 | - foreach ($all_tickets as $ticket) { |
|
| 2278 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( |
|
| 2279 | - 'DTTNUM', |
|
| 2280 | - $ticket_row, |
|
| 2281 | - null, |
|
| 2282 | - $ticket, |
|
| 2283 | - [], |
|
| 2284 | - true |
|
| 2285 | - ); |
|
| 2286 | - $ticket_row++; |
|
| 2287 | - } |
|
| 2288 | - $datetime_row = 1; |
|
| 2289 | - foreach ($all_datetimes as $datetime) { |
|
| 2290 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( |
|
| 2291 | - $datetime_row, |
|
| 2292 | - 'TICKETNUM', |
|
| 2293 | - $datetime, |
|
| 2294 | - null, |
|
| 2295 | - [], |
|
| 2296 | - true |
|
| 2297 | - ); |
|
| 2298 | - $datetime_row++; |
|
| 2299 | - } |
|
| 2300 | - $price_model = EEM_Price::instance(); |
|
| 2301 | - $default_prices = $price_model->get_all_default_prices(); |
|
| 2302 | - $price_row = 1; |
|
| 2303 | - foreach ($default_prices as $price) { |
|
| 2304 | - if (! $price instanceof EE_Price) { |
|
| 2305 | - continue; |
|
| 2306 | - } |
|
| 2307 | - if ($price->is_base_price()) { |
|
| 2308 | - $template_args['default_base_price_amount'] = $price->get_pretty( |
|
| 2309 | - 'PRC_amount', |
|
| 2310 | - 'localized_float' |
|
| 2311 | - ); |
|
| 2312 | - $template_args['default_base_price_name'] = $price->get('PRC_name'); |
|
| 2313 | - $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
|
| 2314 | - $price_row++; |
|
| 2315 | - continue; |
|
| 2316 | - } |
|
| 2317 | - |
|
| 2318 | - $show_trash = ! ((count($default_prices) > 1 && $price_row === 1) || count($default_prices) === 1); |
|
| 2319 | - $show_create = ! (count($default_prices) > 1 && count($default_prices) !== $price_row); |
|
| 2320 | - |
|
| 2321 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( |
|
| 2322 | - 'TICKETNUM', |
|
| 2323 | - $price_row, |
|
| 2324 | - $price, |
|
| 2325 | - true, |
|
| 2326 | - null, |
|
| 2327 | - $show_trash, |
|
| 2328 | - $show_create |
|
| 2329 | - ); |
|
| 2330 | - $price_row++; |
|
| 2331 | - } |
|
| 2332 | - $template_args = apply_filters( |
|
| 2333 | - 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', |
|
| 2334 | - $template_args, |
|
| 2335 | - $all_datetimes, |
|
| 2336 | - $all_tickets, |
|
| 2337 | - $this->_is_creating_event |
|
| 2338 | - ); |
|
| 2339 | - return EEH_Template::display_template( |
|
| 2340 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php', |
|
| 2341 | - $template_args, |
|
| 2342 | - true |
|
| 2343 | - ); |
|
| 2344 | - } |
|
| 231 | + ], |
|
| 232 | + 'DTT_OVERSELL_WARNING' => [ |
|
| 233 | + 'datetime_ticket' => esc_html__( |
|
| 234 | + 'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', |
|
| 235 | + 'event_espresso' |
|
| 236 | + ), |
|
| 237 | + 'ticket_datetime' => esc_html__( |
|
| 238 | + 'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', |
|
| 239 | + 'event_espresso' |
|
| 240 | + ), |
|
| 241 | + ], |
|
| 242 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( |
|
| 243 | + $this->_date_format_strings['date'], |
|
| 244 | + $this->_date_format_strings['time'] |
|
| 245 | + ), |
|
| 246 | + 'DTT_START_OF_WEEK' => ['dayValue' => (int) get_option('start_of_week')], |
|
| 247 | + ], |
|
| 248 | + ], |
|
| 249 | + ]; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @param array $update_callbacks |
|
| 255 | + * @return array |
|
| 256 | + */ |
|
| 257 | + public function caf_updates(array $update_callbacks): array |
|
| 258 | + { |
|
| 259 | + unset($update_callbacks['_default_tickets_update']); |
|
| 260 | + $update_callbacks['datetime_and_tickets_caf_update'] = [$this, 'datetime_and_tickets_caf_update']; |
|
| 261 | + return $update_callbacks; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
| 267 | + * |
|
| 268 | + * @param EE_Event $event The Event object we're attaching data to |
|
| 269 | + * @param array $data The request data from the form |
|
| 270 | + * @throws ReflectionException |
|
| 271 | + * @throws Exception |
|
| 272 | + * @throws InvalidInterfaceException |
|
| 273 | + * @throws InvalidDataTypeException |
|
| 274 | + * @throws EE_Error |
|
| 275 | + * @throws InvalidArgumentException |
|
| 276 | + */ |
|
| 277 | + public function datetime_and_tickets_caf_update(EE_Event $event, array $data) |
|
| 278 | + { |
|
| 279 | + // first we need to start with datetimes cause they are the "root" items attached to events. |
|
| 280 | + $saved_datetimes = $this->_update_datetimes($event, $data); |
|
| 281 | + // next tackle the tickets (and prices?) |
|
| 282 | + $this->_update_tickets($event, $saved_datetimes, $data); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * update event_datetimes |
|
| 288 | + * |
|
| 289 | + * @param EE_Event $event Event being updated |
|
| 290 | + * @param array $data the request data from the form |
|
| 291 | + * @return EE_Datetime[] |
|
| 292 | + * @throws Exception |
|
| 293 | + * @throws ReflectionException |
|
| 294 | + * @throws InvalidInterfaceException |
|
| 295 | + * @throws InvalidDataTypeException |
|
| 296 | + * @throws InvalidArgumentException |
|
| 297 | + * @throws EE_Error |
|
| 298 | + */ |
|
| 299 | + protected function _update_datetimes(EE_Event $event, array $data): array |
|
| 300 | + { |
|
| 301 | + $saved_datetime_ids = []; |
|
| 302 | + $saved_datetime_objs = []; |
|
| 303 | + $timezone = $data['timezone_string'] ?? null; |
|
| 304 | + $datetime_model = EEM_Datetime::instance($timezone); |
|
| 305 | + |
|
| 306 | + if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) { |
|
| 307 | + throw new InvalidArgumentException( |
|
| 308 | + esc_html__( |
|
| 309 | + 'The "edit_event_datetimes" array is invalid therefore the event can not be updated.', |
|
| 310 | + 'event_espresso' |
|
| 311 | + ) |
|
| 312 | + ); |
|
| 313 | + } |
|
| 314 | + foreach ($data['edit_event_datetimes'] as $row => $datetime_data) { |
|
| 315 | + // trim all values to ensure any excess whitespace is removed. |
|
| 316 | + $datetime_data = array_map( |
|
| 317 | + function ($datetime_data) { |
|
| 318 | + return is_array($datetime_data) |
|
| 319 | + ? $datetime_data |
|
| 320 | + : trim($datetime_data); |
|
| 321 | + }, |
|
| 322 | + $datetime_data |
|
| 323 | + ); |
|
| 324 | + |
|
| 325 | + $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end']) |
|
| 326 | + && ! empty($datetime_data['DTT_EVT_end']) |
|
| 327 | + ? $datetime_data['DTT_EVT_end'] |
|
| 328 | + : $datetime_data['DTT_EVT_start']; |
|
| 329 | + $datetime_values = [ |
|
| 330 | + 'DTT_ID' => ! empty($datetime_data['DTT_ID']) |
|
| 331 | + ? $datetime_data['DTT_ID'] |
|
| 332 | + : null, |
|
| 333 | + 'DTT_name' => ! empty($datetime_data['DTT_name']) |
|
| 334 | + ? $datetime_data['DTT_name'] |
|
| 335 | + : '', |
|
| 336 | + 'DTT_description' => ! empty($datetime_data['DTT_description']) |
|
| 337 | + ? $datetime_data['DTT_description'] |
|
| 338 | + : '', |
|
| 339 | + 'DTT_EVT_start' => $datetime_data['DTT_EVT_start'], |
|
| 340 | + 'DTT_EVT_end' => $datetime_data['DTT_EVT_end'], |
|
| 341 | + 'DTT_reg_limit' => empty($datetime_data['DTT_reg_limit']) |
|
| 342 | + ? EE_INF |
|
| 343 | + : $datetime_data['DTT_reg_limit'], |
|
| 344 | + 'DTT_order' => ! isset($datetime_data['DTT_order']) |
|
| 345 | + ? $row |
|
| 346 | + : $datetime_data['DTT_order'], |
|
| 347 | + ]; |
|
| 348 | + |
|
| 349 | + // if we have an id then let's get existing object first and then set the new values. |
|
| 350 | + // Otherwise we instantiate a new object for save. |
|
| 351 | + if (! empty($datetime_data['DTT_ID'])) { |
|
| 352 | + $datetime = EE_Registry::instance() |
|
| 353 | + ->load_model('Datetime', [$timezone]) |
|
| 354 | + ->get_one_by_ID($datetime_data['DTT_ID']); |
|
| 355 | + // set date and time format according to what is set in this class. |
|
| 356 | + $datetime->set_date_format($this->_date_format_strings['date']); |
|
| 357 | + $datetime->set_time_format($this->_date_format_strings['time']); |
|
| 358 | + foreach ($datetime_values as $field => $value) { |
|
| 359 | + $datetime->set($field, $value); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + // make sure the $datetime_id here is saved just in case |
|
| 363 | + // after the add_relation_to() the autosave replaces it. |
|
| 364 | + // We need to do this so we dont' TRASH the parent DTT. |
|
| 365 | + // (save the ID for both key and value to avoid duplications) |
|
| 366 | + $saved_datetime_ids[ $datetime->ID() ] = $datetime->ID(); |
|
| 367 | + } else { |
|
| 368 | + $datetime = EE_Datetime::new_instance( |
|
| 369 | + $datetime_values, |
|
| 370 | + $timezone, |
|
| 371 | + [$this->_date_format_strings['date'], $this->_date_format_strings['time']] |
|
| 372 | + ); |
|
| 373 | + foreach ($datetime_values as $field => $value) { |
|
| 374 | + $datetime->set($field, $value); |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + $datetime->save(); |
|
| 378 | + do_action( |
|
| 379 | + 'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save', |
|
| 380 | + $datetime, |
|
| 381 | + $row, |
|
| 382 | + $datetime_data, |
|
| 383 | + $data |
|
| 384 | + ); |
|
| 385 | + $datetime = $event->_add_relation_to($datetime, 'Datetime'); |
|
| 386 | + // before going any further make sure our dates are setup correctly |
|
| 387 | + // so that the end date is always equal or greater than the start date. |
|
| 388 | + if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) { |
|
| 389 | + $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start')); |
|
| 390 | + $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days'); |
|
| 391 | + $datetime->save(); |
|
| 392 | + } |
|
| 393 | + // now we have to make sure we add the new DTT_ID to the $saved_datetime_ids array |
|
| 394 | + // because it is possible there was a new one created for the autosave. |
|
| 395 | + // (save the ID for both key and value to avoid duplications) |
|
| 396 | + $DTT_ID = $datetime->ID(); |
|
| 397 | + $saved_datetime_ids[ $DTT_ID ] = $DTT_ID; |
|
| 398 | + $saved_datetime_objs[ $row ] = $datetime; |
|
| 399 | + // @todo if ANY of these updates fail then we want the appropriate global error message. |
|
| 400 | + } |
|
| 401 | + $event->save(); |
|
| 402 | + // now we need to REMOVE any datetimes that got deleted. |
|
| 403 | + // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them. |
|
| 404 | + // So its safe to permanently delete at this point. |
|
| 405 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
| 406 | + $old_datetimes = $old_datetimes[0] === '' |
|
| 407 | + ? [] |
|
| 408 | + : $old_datetimes; |
|
| 409 | + if (is_array($old_datetimes)) { |
|
| 410 | + $datetimes_to_delete = array_diff($old_datetimes, $saved_datetime_ids); |
|
| 411 | + foreach ($datetimes_to_delete as $id) { |
|
| 412 | + $id = absint($id); |
|
| 413 | + if (empty($id)) { |
|
| 414 | + continue; |
|
| 415 | + } |
|
| 416 | + $dtt_to_remove = $datetime_model->get_one_by_ID($id); |
|
| 417 | + // remove tkt relationships. |
|
| 418 | + $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
|
| 419 | + foreach ($related_tickets as $ticket) { |
|
| 420 | + $dtt_to_remove->_remove_relation_to($ticket, 'Ticket'); |
|
| 421 | + } |
|
| 422 | + $event->_remove_relation_to($id, 'Datetime'); |
|
| 423 | + $dtt_to_remove->refresh_cache_of_related_objects(); |
|
| 424 | + } |
|
| 425 | + } |
|
| 426 | + return $saved_datetime_objs; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * update tickets |
|
| 432 | + * |
|
| 433 | + * @param EE_Event $event Event object being updated |
|
| 434 | + * @param EE_Datetime[] $saved_datetimes an array of datetime ids being updated |
|
| 435 | + * @param array $data incoming request data |
|
| 436 | + * @return EE_Ticket[] |
|
| 437 | + * @throws Exception |
|
| 438 | + * @throws ReflectionException |
|
| 439 | + * @throws InvalidInterfaceException |
|
| 440 | + * @throws InvalidDataTypeException |
|
| 441 | + * @throws InvalidArgumentException |
|
| 442 | + * @throws EE_Error |
|
| 443 | + */ |
|
| 444 | + protected function _update_tickets(EE_Event $event, array $saved_datetimes, array $data): array |
|
| 445 | + { |
|
| 446 | + $new_ticket = null; |
|
| 447 | + // stripslashes because WP filtered the $_POST ($data) array to add slashes |
|
| 448 | + $data = stripslashes_deep($data); |
|
| 449 | + $timezone = $data['timezone_string'] ?? null; |
|
| 450 | + $ticket_model = EEM_Ticket::instance($timezone); |
|
| 451 | + |
|
| 452 | + $saved_tickets = []; |
|
| 453 | + $old_tickets = isset($data['ticket_IDs']) |
|
| 454 | + ? explode(',', $data['ticket_IDs']) |
|
| 455 | + : []; |
|
| 456 | + if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) { |
|
| 457 | + throw new InvalidArgumentException( |
|
| 458 | + esc_html__( |
|
| 459 | + 'The "edit_tickets" array is invalid therefore the event can not be updated.', |
|
| 460 | + 'event_espresso' |
|
| 461 | + ) |
|
| 462 | + ); |
|
| 463 | + } |
|
| 464 | + foreach ($data['edit_tickets'] as $row => $ticket_data) { |
|
| 465 | + $update_prices = $create_new_TKT = false; |
|
| 466 | + // figure out what datetimes were added to the ticket |
|
| 467 | + // and what datetimes were removed from the ticket in the session. |
|
| 468 | + $starting_ticket_datetime_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]); |
|
| 469 | + $ticket_datetime_rows = explode(',', $data['ticket_datetime_rows'][ $row ]); |
|
| 470 | + $datetimes_added = array_diff($ticket_datetime_rows, $starting_ticket_datetime_rows); |
|
| 471 | + $datetimes_removed = array_diff($starting_ticket_datetime_rows, $ticket_datetime_rows); |
|
| 472 | + // trim inputs to ensure any excess whitespace is removed. |
|
| 473 | + $ticket_data = array_map( |
|
| 474 | + function ($ticket_data) { |
|
| 475 | + return is_array($ticket_data) |
|
| 476 | + ? $ticket_data |
|
| 477 | + : trim($ticket_data); |
|
| 478 | + }, |
|
| 479 | + $ticket_data |
|
| 480 | + ); |
|
| 481 | + // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle |
|
| 482 | + // because we're doing calculations prior to using the models. |
|
| 483 | + // note incoming ['TKT_price'] value is already in standard notation (via js). |
|
| 484 | + $ticket_price = isset($ticket_data['TKT_price']) |
|
| 485 | + ? round((float) $ticket_data['TKT_price'], 3) |
|
| 486 | + : 0; |
|
| 487 | + // note incoming base price needs converted from localized value. |
|
| 488 | + $base_price = isset($ticket_data['TKT_base_price']) |
|
| 489 | + ? EEH_Money::convert_to_float_from_localized_money($ticket_data['TKT_base_price']) |
|
| 490 | + : 0; |
|
| 491 | + // if ticket price == 0 and $base_price != 0 then ticket price == base_price |
|
| 492 | + $ticket_price = $ticket_price === 0 && $base_price !== 0 |
|
| 493 | + ? $base_price |
|
| 494 | + : $ticket_price; |
|
| 495 | + $base_price_id = $ticket_data['TKT_base_price_ID'] ?? 0; |
|
| 496 | + $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ]) |
|
| 497 | + ? $data['edit_prices'][ $row ] |
|
| 498 | + : []; |
|
| 499 | + $now = null; |
|
| 500 | + if (empty($ticket_data['TKT_start_date'])) { |
|
| 501 | + // lets' use now in the set timezone. |
|
| 502 | + $now = new DateTime('now', new DateTimeZone($event->get_timezone())); |
|
| 503 | + $ticket_data['TKT_start_date'] = $now->format($this->_date_time_format); |
|
| 504 | + } |
|
| 505 | + if (empty($ticket_data['TKT_end_date'])) { |
|
| 506 | + /** |
|
| 507 | + * set the TKT_end_date to the first datetime attached to the ticket. |
|
| 508 | + */ |
|
| 509 | + $first_datetime = $saved_datetimes[ reset($ticket_datetime_rows) ]; |
|
| 510 | + $ticket_data['TKT_end_date'] = $first_datetime->start_date_and_time($this->_date_time_format); |
|
| 511 | + } |
|
| 512 | + $TKT_values = [ |
|
| 513 | + 'TKT_ID' => ! empty($ticket_data['TKT_ID']) |
|
| 514 | + ? $ticket_data['TKT_ID'] |
|
| 515 | + : null, |
|
| 516 | + 'TTM_ID' => ! empty($ticket_data['TTM_ID']) |
|
| 517 | + ? $ticket_data['TTM_ID'] |
|
| 518 | + : 0, |
|
| 519 | + 'TKT_name' => ! empty($ticket_data['TKT_name']) |
|
| 520 | + ? $ticket_data['TKT_name'] |
|
| 521 | + : '', |
|
| 522 | + 'TKT_description' => ! empty($ticket_data['TKT_description']) |
|
| 523 | + && $ticket_data['TKT_description'] !== esc_html__( |
|
| 524 | + 'You can modify this description', |
|
| 525 | + 'event_espresso' |
|
| 526 | + ) |
|
| 527 | + ? $ticket_data['TKT_description'] |
|
| 528 | + : '', |
|
| 529 | + 'TKT_start_date' => $ticket_data['TKT_start_date'], |
|
| 530 | + 'TKT_end_date' => $ticket_data['TKT_end_date'], |
|
| 531 | + 'TKT_qty' => ! isset($ticket_data['TKT_qty']) || $ticket_data['TKT_qty'] === '' |
|
| 532 | + ? EE_INF |
|
| 533 | + : $ticket_data['TKT_qty'], |
|
| 534 | + 'TKT_uses' => ! isset($ticket_data['TKT_uses']) || $ticket_data['TKT_uses'] === '' |
|
| 535 | + ? EE_INF |
|
| 536 | + : $ticket_data['TKT_uses'], |
|
| 537 | + 'TKT_min' => empty($ticket_data['TKT_min']) |
|
| 538 | + ? 0 |
|
| 539 | + : $ticket_data['TKT_min'], |
|
| 540 | + 'TKT_max' => empty($ticket_data['TKT_max']) |
|
| 541 | + ? EE_INF |
|
| 542 | + : $ticket_data['TKT_max'], |
|
| 543 | + 'TKT_row' => $row, |
|
| 544 | + 'TKT_order' => $ticket_data['TKT_order'] ?? 0, |
|
| 545 | + 'TKT_taxable' => ! empty($ticket_data['TKT_taxable']) |
|
| 546 | + ? 1 |
|
| 547 | + : 0, |
|
| 548 | + 'TKT_required' => ! empty($ticket_data['TKT_required']) |
|
| 549 | + ? 1 |
|
| 550 | + : 0, |
|
| 551 | + 'TKT_price' => $ticket_price, |
|
| 552 | + ]; |
|
| 553 | + // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, |
|
| 554 | + // which means in turn that the prices will become new prices as well. |
|
| 555 | + if (isset($ticket_data['TKT_is_default']) && $ticket_data['TKT_is_default']) { |
|
| 556 | + $TKT_values['TKT_ID'] = 0; |
|
| 557 | + $TKT_values['TKT_is_default'] = 0; |
|
| 558 | + $update_prices = true; |
|
| 559 | + } |
|
| 560 | + // if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
| 561 | + // we actually do our saves ahead of doing any add_relations to |
|
| 562 | + // because its entirely possible that this ticket wasn't removed or added to any datetime in the session |
|
| 563 | + // but DID have it's items modified. |
|
| 564 | + // keep in mind that if the TKT has been sold (and we have changed pricing information), |
|
| 565 | + // then we won't be updating the ticket but instead a new ticket will be created and the old one archived. |
|
| 566 | + if (absint($TKT_values['TKT_ID'])) { |
|
| 567 | + $ticket = EE_Registry::instance() |
|
| 568 | + ->load_model('Ticket', [$timezone]) |
|
| 569 | + ->get_one_by_ID($TKT_values['TKT_ID']); |
|
| 570 | + if ($ticket instanceof EE_Ticket) { |
|
| 571 | + $ticket = $this->_update_ticket_datetimes( |
|
| 572 | + $ticket, |
|
| 573 | + $saved_datetimes, |
|
| 574 | + $datetimes_added, |
|
| 575 | + $datetimes_removed |
|
| 576 | + ); |
|
| 577 | + // are there any registrations using this ticket ? |
|
| 578 | + $tickets_sold = $ticket->count_related( |
|
| 579 | + 'Registration', |
|
| 580 | + [ |
|
| 581 | + [ |
|
| 582 | + 'STS_ID' => ['NOT IN', [EEM_Registration::status_id_incomplete]], |
|
| 583 | + ], |
|
| 584 | + ] |
|
| 585 | + ); |
|
| 586 | + // set ticket formats |
|
| 587 | + $ticket->set_date_format($this->_date_format_strings['date']); |
|
| 588 | + $ticket->set_time_format($this->_date_format_strings['time']); |
|
| 589 | + // let's just check the total price for the existing ticket |
|
| 590 | + // and determine if it matches the new total price. |
|
| 591 | + // if they are different then we create a new ticket (if tickets sold) |
|
| 592 | + // if they aren't different then we go ahead and modify existing ticket. |
|
| 593 | + $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted(); |
|
| 594 | + // set new values |
|
| 595 | + foreach ($TKT_values as $field => $value) { |
|
| 596 | + if ($field === 'TKT_qty') { |
|
| 597 | + $ticket->set_qty($value); |
|
| 598 | + } else { |
|
| 599 | + $ticket->set($field, $value); |
|
| 600 | + } |
|
| 601 | + } |
|
| 602 | + // if $create_new_TKT is false then we can safely update the existing ticket. |
|
| 603 | + // Otherwise we have to create a new ticket. |
|
| 604 | + if ($create_new_TKT) { |
|
| 605 | + $new_ticket = $this->_duplicate_ticket( |
|
| 606 | + $ticket, |
|
| 607 | + $price_rows, |
|
| 608 | + $ticket_price, |
|
| 609 | + $base_price, |
|
| 610 | + $base_price_id |
|
| 611 | + ); |
|
| 612 | + } |
|
| 613 | + } |
|
| 614 | + } else { |
|
| 615 | + // no TKT_id so a new TKT |
|
| 616 | + $ticket = EE_Ticket::new_instance( |
|
| 617 | + $TKT_values, |
|
| 618 | + $timezone, |
|
| 619 | + [$this->_date_format_strings['date'], $this->_date_format_strings['time']] |
|
| 620 | + ); |
|
| 621 | + if ($ticket instanceof EE_Ticket) { |
|
| 622 | + // make sure ticket has an ID of setting relations won't work |
|
| 623 | + $ticket->save(); |
|
| 624 | + $ticket = $this->_update_ticket_datetimes( |
|
| 625 | + $ticket, |
|
| 626 | + $saved_datetimes, |
|
| 627 | + $datetimes_added, |
|
| 628 | + $datetimes_removed |
|
| 629 | + ); |
|
| 630 | + $update_prices = true; |
|
| 631 | + } |
|
| 632 | + } |
|
| 633 | + // make sure any current values have been saved. |
|
| 634 | + // $ticket->save(); |
|
| 635 | + // before going any further make sure our dates are setup correctly |
|
| 636 | + // so that the end date is always equal or greater than the start date. |
|
| 637 | + if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) { |
|
| 638 | + $ticket->set('TKT_end_date', $ticket->get('TKT_start_date')); |
|
| 639 | + $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days'); |
|
| 640 | + } |
|
| 641 | + // let's make sure the base price is handled |
|
| 642 | + $ticket = ! $create_new_TKT |
|
| 643 | + ? $this->_add_prices_to_ticket( |
|
| 644 | + [], |
|
| 645 | + $ticket, |
|
| 646 | + $update_prices, |
|
| 647 | + $base_price, |
|
| 648 | + $base_price_id |
|
| 649 | + ) |
|
| 650 | + : $ticket; |
|
| 651 | + // add/update price_modifiers |
|
| 652 | + $ticket = ! $create_new_TKT |
|
| 653 | + ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices) |
|
| 654 | + : $ticket; |
|
| 655 | + // need to make sue that the TKT_price is accurate after saving the prices. |
|
| 656 | + $ticket->ensure_TKT_Price_correct(); |
|
| 657 | + // handle CREATING a default ticket from the incoming ticket but ONLY if this isn't an autosave. |
|
| 658 | + if (! defined('DOING_AUTOSAVE') && ! empty($ticket_data['TKT_is_default_selector'])) { |
|
| 659 | + $new_default = clone $ticket; |
|
| 660 | + $new_default->set('TKT_ID', 0); |
|
| 661 | + $new_default->set('TKT_is_default', 1); |
|
| 662 | + $new_default->set('TKT_row', 1); |
|
| 663 | + $new_default->set('TKT_price', $ticket_price); |
|
| 664 | + // remove any datetime relations cause we DON'T want datetime relations attached |
|
| 665 | + // (note this is just removing the cached relations in the object) |
|
| 666 | + $new_default->_remove_relations('Datetime'); |
|
| 667 | + // @todo we need to add the current attached prices as new prices to the new default ticket. |
|
| 668 | + $new_default = $this->_add_prices_to_ticket( |
|
| 669 | + $price_rows, |
|
| 670 | + $new_default, |
|
| 671 | + true |
|
| 672 | + ); |
|
| 673 | + // don't forget the base price! |
|
| 674 | + $new_default = $this->_add_prices_to_ticket( |
|
| 675 | + [], |
|
| 676 | + $new_default, |
|
| 677 | + true, |
|
| 678 | + $base_price, |
|
| 679 | + $base_price_id |
|
| 680 | + ); |
|
| 681 | + $new_default->save(); |
|
| 682 | + do_action( |
|
| 683 | + 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', |
|
| 684 | + $new_default, |
|
| 685 | + $row, |
|
| 686 | + $ticket, |
|
| 687 | + $data |
|
| 688 | + ); |
|
| 689 | + } |
|
| 690 | + // DO ALL datetime relationships for both current tickets and any archived tickets |
|
| 691 | + // for the given datetime that are related to the current ticket. |
|
| 692 | + // TODO... not sure exactly how we're going to do this considering we don't know |
|
| 693 | + // what current ticket the archived tickets are related to |
|
| 694 | + // (and TKT_parent is used for autosaves so that's not a field we can reliably use). |
|
| 695 | + // let's assign any tickets that have been setup to the saved_tickets tracker |
|
| 696 | + // save existing TKT |
|
| 697 | + $ticket->save(); |
|
| 698 | + if ($create_new_TKT && $new_ticket instanceof EE_Ticket) { |
|
| 699 | + // save new TKT |
|
| 700 | + $new_ticket->save(); |
|
| 701 | + // add new ticket to array |
|
| 702 | + $saved_tickets[ $new_ticket->ID() ] = $new_ticket; |
|
| 703 | + do_action( |
|
| 704 | + 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', |
|
| 705 | + $new_ticket, |
|
| 706 | + $row, |
|
| 707 | + $ticket_data, |
|
| 708 | + $data |
|
| 709 | + ); |
|
| 710 | + } else { |
|
| 711 | + // add ticket to saved tickets |
|
| 712 | + $saved_tickets[ $ticket->ID() ] = $ticket; |
|
| 713 | + do_action( |
|
| 714 | + 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', |
|
| 715 | + $ticket, |
|
| 716 | + $row, |
|
| 717 | + $ticket_data, |
|
| 718 | + $data |
|
| 719 | + ); |
|
| 720 | + } |
|
| 721 | + } |
|
| 722 | + // now we need to handle tickets actually "deleted permanently". |
|
| 723 | + // There are cases where we'd want this to happen |
|
| 724 | + // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
|
| 725 | + // Or a draft event was saved and in the process of editing a ticket is trashed. |
|
| 726 | + // No sense in keeping all the related data in the db! |
|
| 727 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' |
|
| 728 | + ? [] |
|
| 729 | + : $old_tickets; |
|
| 730 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
| 731 | + foreach ($tickets_removed as $id) { |
|
| 732 | + $id = absint($id); |
|
| 733 | + // get the ticket for this id |
|
| 734 | + $ticket_to_remove = $ticket_model->get_one_by_ID($id); |
|
| 735 | + // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
|
| 736 | + if ($ticket_to_remove->get('TKT_is_default')) { |
|
| 737 | + continue; |
|
| 738 | + } |
|
| 739 | + // if this ticket has any registrations attached so then we just ARCHIVE |
|
| 740 | + // because we don't actually permanently delete these tickets. |
|
| 741 | + if ($ticket_to_remove->count_related('Registration') > 0) { |
|
| 742 | + $ticket_to_remove->delete(); |
|
| 743 | + continue; |
|
| 744 | + } |
|
| 745 | + // need to get all the related datetimes on this ticket and remove from every single one of them |
|
| 746 | + // (remember this process can ONLY kick off if there are NO tickets_sold) |
|
| 747 | + $datetimes = $ticket_to_remove->get_many_related('Datetime'); |
|
| 748 | + foreach ($datetimes as $datetime) { |
|
| 749 | + $ticket_to_remove->_remove_relation_to($datetime, 'Datetime'); |
|
| 750 | + } |
|
| 751 | + // need to do the same for prices (except these prices can also be deleted because again, |
|
| 752 | + // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
| 753 | + $ticket_to_remove->delete_related('Price'); |
|
| 754 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $ticket_to_remove); |
|
| 755 | + // finally let's delete this ticket |
|
| 756 | + // (which should not be blocked at this point b/c we've removed all our relationships) |
|
| 757 | + $ticket_to_remove->delete_or_restore(); |
|
| 758 | + } |
|
| 759 | + return $saved_tickets; |
|
| 760 | + } |
|
| 761 | + |
|
| 762 | + |
|
| 763 | + /** |
|
| 764 | + * @access protected |
|
| 765 | + * @param EE_Ticket $ticket |
|
| 766 | + * @param EE_Datetime[] $saved_datetimes |
|
| 767 | + * @param int[] $added_datetimes |
|
| 768 | + * @param int[] $removed_datetimes |
|
| 769 | + * @return EE_Ticket |
|
| 770 | + * @throws EE_Error |
|
| 771 | + * @throws ReflectionException |
|
| 772 | + */ |
|
| 773 | + protected function _update_ticket_datetimes( |
|
| 774 | + EE_Ticket $ticket, |
|
| 775 | + array $saved_datetimes = [], |
|
| 776 | + array $added_datetimes = [], |
|
| 777 | + array $removed_datetimes = [] |
|
| 778 | + ): EE_Ticket { |
|
| 779 | + // to start we have to add the ticket to all the datetimes its supposed to be with, |
|
| 780 | + // and removing the ticket from datetimes it got removed from. |
|
| 781 | + // first let's add datetimes |
|
| 782 | + if (! empty($added_datetimes) && is_array($added_datetimes)) { |
|
| 783 | + foreach ($added_datetimes as $row_id) { |
|
| 784 | + if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) { |
|
| 785 | + $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime'); |
|
| 786 | + // Is this an existing ticket (has an ID) and does it have any sold? |
|
| 787 | + // If so, then we need to add that to the DTT sold because this DTT is getting added. |
|
| 788 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
| 789 | + $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false); |
|
| 790 | + } |
|
| 791 | + } |
|
| 792 | + } |
|
| 793 | + } |
|
| 794 | + // then remove datetimes |
|
| 795 | + if (! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
| 796 | + foreach ($removed_datetimes as $row_id) { |
|
| 797 | + // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
|
| 798 | + // So make sure we skip over this if the datetime isn't in the $saved_datetimes array) |
|
| 799 | + if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) { |
|
| 800 | + $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime'); |
|
| 801 | + } |
|
| 802 | + } |
|
| 803 | + } |
|
| 804 | + // cap ticket qty by datetime reg limits |
|
| 805 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
| 806 | + return $ticket; |
|
| 807 | + } |
|
| 808 | + |
|
| 809 | + |
|
| 810 | + /** |
|
| 811 | + * @access protected |
|
| 812 | + * @param EE_Ticket $ticket |
|
| 813 | + * @param array $price_rows |
|
| 814 | + * @param int|float $ticket_price |
|
| 815 | + * @param int|float $base_price |
|
| 816 | + * @param int $base_price_id |
|
| 817 | + * @return EE_Ticket |
|
| 818 | + * @throws ReflectionException |
|
| 819 | + * @throws InvalidArgumentException |
|
| 820 | + * @throws InvalidInterfaceException |
|
| 821 | + * @throws InvalidDataTypeException |
|
| 822 | + * @throws EE_Error |
|
| 823 | + */ |
|
| 824 | + protected function _duplicate_ticket( |
|
| 825 | + EE_Ticket $ticket, |
|
| 826 | + array $price_rows = [], |
|
| 827 | + $ticket_price = 0, |
|
| 828 | + $base_price = 0, |
|
| 829 | + int $base_price_id = 0 |
|
| 830 | + ): EE_Ticket { |
|
| 831 | + // create new ticket that's a copy of the existing |
|
| 832 | + // except a new id of course (and not archived) |
|
| 833 | + // AND has the new TKT_price associated with it. |
|
| 834 | + $new_ticket = clone $ticket; |
|
| 835 | + $new_ticket->set('TKT_ID', 0); |
|
| 836 | + $new_ticket->set_deleted(0); |
|
| 837 | + $new_ticket->set_price($ticket_price); |
|
| 838 | + $new_ticket->set_sold(0); |
|
| 839 | + // let's get a new ID for this ticket |
|
| 840 | + $new_ticket->save(); |
|
| 841 | + // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
|
| 842 | + $datetimes_on_existing = $ticket->datetimes(); |
|
| 843 | + $new_ticket = $this->_update_ticket_datetimes( |
|
| 844 | + $new_ticket, |
|
| 845 | + $datetimes_on_existing, |
|
| 846 | + array_keys($datetimes_on_existing) |
|
| 847 | + ); |
|
| 848 | + // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
|
| 849 | + // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
|
| 850 | + // available. |
|
| 851 | + if ($ticket->sold() > 0) { |
|
| 852 | + $new_qty = $ticket->qty() - $ticket->sold(); |
|
| 853 | + $new_ticket->set_qty($new_qty); |
|
| 854 | + } |
|
| 855 | + // now we update the prices just for this ticket |
|
| 856 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
| 857 | + // and we update the base price |
|
| 858 | + return $this->_add_prices_to_ticket( |
|
| 859 | + [], |
|
| 860 | + $new_ticket, |
|
| 861 | + true, |
|
| 862 | + $base_price, |
|
| 863 | + $base_price_id |
|
| 864 | + ); |
|
| 865 | + } |
|
| 866 | + |
|
| 867 | + |
|
| 868 | + /** |
|
| 869 | + * This attaches a list of given prices to a ticket. |
|
| 870 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
| 871 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
| 872 | + * price info and prices are automatically "archived" via the ticket. |
|
| 873 | + * |
|
| 874 | + * @access private |
|
| 875 | + * @param array $prices Array of prices from the form. |
|
| 876 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
| 877 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
| 878 | + * @param int|bool $base_price if FALSE then NOT doing a base price add. |
|
| 879 | + * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
|
| 880 | + * @return EE_Ticket |
|
| 881 | + * @throws ReflectionException |
|
| 882 | + * @throws InvalidArgumentException |
|
| 883 | + * @throws InvalidInterfaceException |
|
| 884 | + * @throws InvalidDataTypeException |
|
| 885 | + * @throws EE_Error |
|
| 886 | + */ |
|
| 887 | + protected function _add_prices_to_ticket( |
|
| 888 | + array $prices, |
|
| 889 | + EE_Ticket $ticket, |
|
| 890 | + bool $new_prices = false, |
|
| 891 | + $base_price = false, |
|
| 892 | + $base_price_id = false |
|
| 893 | + ): EE_Ticket { |
|
| 894 | + $price_model = EEM_Price::instance(); |
|
| 895 | + // let's just get any current prices that may exist on the given ticket |
|
| 896 | + // so we can remove any prices that got trashed in this session. |
|
| 897 | + $current_prices_on_ticket = $base_price !== false |
|
| 898 | + ? $ticket->base_price(true) |
|
| 899 | + : $ticket->price_modifiers(); |
|
| 900 | + $updated_prices = []; |
|
| 901 | + // if $base_price ! FALSE then updating a base price. |
|
| 902 | + if ($base_price !== false) { |
|
| 903 | + $prices[1] = [ |
|
| 904 | + 'PRC_ID' => $new_prices || $base_price_id === 1 |
|
| 905 | + ? null |
|
| 906 | + : $base_price_id, |
|
| 907 | + 'PRT_ID' => 1, |
|
| 908 | + 'PRC_amount' => $base_price, |
|
| 909 | + 'PRC_name' => $ticket->get('TKT_name'), |
|
| 910 | + 'PRC_desc' => $ticket->get('TKT_description'), |
|
| 911 | + ]; |
|
| 912 | + } |
|
| 913 | + // possibly need to save ticket |
|
| 914 | + if (! $ticket->ID()) { |
|
| 915 | + $ticket->save(); |
|
| 916 | + } |
|
| 917 | + foreach ($prices as $row => $prc) { |
|
| 918 | + $prt_id = ! empty($prc['PRT_ID']) |
|
| 919 | + ? $prc['PRT_ID'] |
|
| 920 | + : null; |
|
| 921 | + if (empty($prt_id)) { |
|
| 922 | + continue; |
|
| 923 | + } //prices MUST have a price type id. |
|
| 924 | + $PRC_values = [ |
|
| 925 | + 'PRC_ID' => ! empty($prc['PRC_ID']) |
|
| 926 | + ? $prc['PRC_ID'] |
|
| 927 | + : null, |
|
| 928 | + 'PRT_ID' => $prt_id, |
|
| 929 | + 'PRC_amount' => ! empty($prc['PRC_amount']) |
|
| 930 | + ? $prc['PRC_amount'] |
|
| 931 | + : 0, |
|
| 932 | + 'PRC_name' => ! empty($prc['PRC_name']) |
|
| 933 | + ? $prc['PRC_name'] |
|
| 934 | + : '', |
|
| 935 | + 'PRC_desc' => ! empty($prc['PRC_desc']) |
|
| 936 | + ? $prc['PRC_desc'] |
|
| 937 | + : '', |
|
| 938 | + 'PRC_is_default' => false, |
|
| 939 | + // make sure we set PRC_is_default to false for all ticket saves from event_editor |
|
| 940 | + 'PRC_order' => $row, |
|
| 941 | + ]; |
|
| 942 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
| 943 | + $PRC_values['PRC_ID'] = 0; |
|
| 944 | + $price = EE_Registry::instance()->load_class( |
|
| 945 | + 'Price', |
|
| 946 | + [$PRC_values], |
|
| 947 | + false, |
|
| 948 | + false |
|
| 949 | + ); |
|
| 950 | + } else { |
|
| 951 | + $price = $price_model->get_one_by_ID($prc['PRC_ID']); |
|
| 952 | + // update this price with new values |
|
| 953 | + foreach ($PRC_values as $field => $value) { |
|
| 954 | + $price->set($field, $value); |
|
| 955 | + } |
|
| 956 | + } |
|
| 957 | + $price->save(); |
|
| 958 | + $updated_prices[ $price->ID() ] = $price; |
|
| 959 | + $ticket->_add_relation_to($price, 'Price'); |
|
| 960 | + } |
|
| 961 | + // now let's remove any prices that got removed from the ticket |
|
| 962 | + if (! empty($current_prices_on_ticket)) { |
|
| 963 | + $current = array_keys($current_prices_on_ticket); |
|
| 964 | + $updated = array_keys($updated_prices); |
|
| 965 | + $prices_to_remove = array_diff($current, $updated); |
|
| 966 | + if (! empty($prices_to_remove)) { |
|
| 967 | + foreach ($prices_to_remove as $prc_id) { |
|
| 968 | + $p = $current_prices_on_ticket[ $prc_id ]; |
|
| 969 | + $ticket->_remove_relation_to($p, 'Price'); |
|
| 970 | + // delete permanently the price |
|
| 971 | + $p->delete_or_restore(); |
|
| 972 | + } |
|
| 973 | + } |
|
| 974 | + } |
|
| 975 | + return $ticket; |
|
| 976 | + } |
|
| 977 | + |
|
| 978 | + |
|
| 979 | + /** |
|
| 980 | + * @throws ReflectionException |
|
| 981 | + * @throws InvalidArgumentException |
|
| 982 | + * @throws InvalidInterfaceException |
|
| 983 | + * @throws InvalidDataTypeException |
|
| 984 | + * @throws DomainException |
|
| 985 | + * @throws EE_Error |
|
| 986 | + */ |
|
| 987 | + public function pricing_metabox() |
|
| 988 | + { |
|
| 989 | + $event = $this->_adminpage_obj->get_cpt_model_obj(); |
|
| 990 | + $timezone = $event instanceof EE_Event |
|
| 991 | + ? $event->timezone_string() |
|
| 992 | + : null; |
|
| 993 | + $price_model = EEM_Price::instance($timezone); |
|
| 994 | + $ticket_model = EEM_Ticket::instance($timezone); |
|
| 995 | + $datetime_model = EEM_Datetime::instance($timezone); |
|
| 996 | + $all_tickets = []; |
|
| 997 | + |
|
| 998 | + // set is_creating_event property. |
|
| 999 | + $EVT_ID = $event->ID(); |
|
| 1000 | + $this->_is_creating_event = empty($this->_req_data['post']); |
|
| 1001 | + $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = []; |
|
| 1002 | + |
|
| 1003 | + // default main template args |
|
| 1004 | + $main_template_args = [ |
|
| 1005 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link( |
|
| 1006 | + 'event_editor_event_datetimes_help_tab', |
|
| 1007 | + $this->_adminpage_obj->page_slug, |
|
| 1008 | + $this->_adminpage_obj->get_req_action() |
|
| 1009 | + ), |
|
| 1010 | + |
|
| 1011 | + // todo need to add a filter to the template for the help text |
|
| 1012 | + // in the Events_Admin_Page core file so we can add further help |
|
| 1013 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link( |
|
| 1014 | + 'add_new_dtt_info', |
|
| 1015 | + $this->_adminpage_obj->page_slug, |
|
| 1016 | + $this->_adminpage_obj->get_req_action() |
|
| 1017 | + ), |
|
| 1018 | + // todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
| 1019 | + 'datetime_rows' => '', |
|
| 1020 | + 'show_tickets_container' => '', |
|
| 1021 | + 'ticket_rows' => '', |
|
| 1022 | + 'ee_collapsible_status' => ' ee-collapsible-open', |
|
| 1023 | + // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open' |
|
| 1024 | + ]; |
|
| 1025 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1026 | + |
|
| 1027 | + /** |
|
| 1028 | + * 1. Start with retrieving Datetimes |
|
| 1029 | + * 2. For each datetime get related tickets |
|
| 1030 | + * 3. For each ticket get related prices |
|
| 1031 | + */ |
|
| 1032 | + $datetimes = $datetime_model->get_all_event_dates($EVT_ID); |
|
| 1033 | + $main_template_args['total_dtt_rows'] = count($datetimes); |
|
| 1034 | + |
|
| 1035 | + /** |
|
| 1036 | + * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 |
|
| 1037 | + * for why we are counting $datetime_row and then setting that on the Datetime object |
|
| 1038 | + */ |
|
| 1039 | + $datetime_row = 1; |
|
| 1040 | + foreach ($datetimes as $datetime) { |
|
| 1041 | + $DTT_ID = $datetime->get('DTT_ID'); |
|
| 1042 | + $datetime->set('DTT_order', $datetime_row); |
|
| 1043 | + $existing_datetime_ids[] = $DTT_ID; |
|
| 1044 | + // tickets attached |
|
| 1045 | + $related_tickets = $datetime->ID() > 0 |
|
| 1046 | + ? $datetime->get_many_related( |
|
| 1047 | + 'Ticket', |
|
| 1048 | + [ |
|
| 1049 | + [ |
|
| 1050 | + 'OR' => ['TKT_deleted' => 1, 'TKT_deleted*' => 0], |
|
| 1051 | + ], |
|
| 1052 | + 'default_where_conditions' => 'none', |
|
| 1053 | + 'order_by' => ['TKT_order' => 'ASC'], |
|
| 1054 | + ] |
|
| 1055 | + ) |
|
| 1056 | + : []; |
|
| 1057 | + // if there are no related tickets this is likely a new event OR auto-draft |
|
| 1058 | + // event so we need to generate the default tickets because datetimes |
|
| 1059 | + // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
|
| 1060 | + // datetime on the event. |
|
| 1061 | + if (empty($related_tickets) && count($datetimes) < 2) { |
|
| 1062 | + $related_tickets = $ticket_model->get_all_default_tickets(); |
|
| 1063 | + // this should be ordered by TKT_ID, so let's grab the first default ticket |
|
| 1064 | + // (which will be the main default) and ensure it has any default prices added to it (but do NOT save). |
|
| 1065 | + $default_prices = $price_model->get_all_default_prices(); |
|
| 1066 | + $main_default_ticket = reset($related_tickets); |
|
| 1067 | + if ($main_default_ticket instanceof EE_Ticket) { |
|
| 1068 | + foreach ($default_prices as $default_price) { |
|
| 1069 | + if ($default_price instanceof EE_Price && $default_price->is_base_price()) { |
|
| 1070 | + continue; |
|
| 1071 | + } |
|
| 1072 | + $main_default_ticket->cache('Price', $default_price); |
|
| 1073 | + } |
|
| 1074 | + } |
|
| 1075 | + } |
|
| 1076 | + // we can't actually setup rows in this loop yet cause we don't know all |
|
| 1077 | + // the unique tickets for this event yet (tickets are linked through all datetimes). |
|
| 1078 | + // So we're going to temporarily cache some of that information. |
|
| 1079 | + // loop through and setup the ticket rows and make sure the order is set. |
|
| 1080 | + foreach ($related_tickets as $ticket) { |
|
| 1081 | + $TKT_ID = $ticket->get('TKT_ID'); |
|
| 1082 | + $ticket_row = $ticket->get('TKT_row'); |
|
| 1083 | + // we only want unique tickets in our final display!! |
|
| 1084 | + if (! in_array($TKT_ID, $existing_ticket_ids, true)) { |
|
| 1085 | + $existing_ticket_ids[] = $TKT_ID; |
|
| 1086 | + $all_tickets[] = $ticket; |
|
| 1087 | + } |
|
| 1088 | + // temporary cache of this ticket info for this datetime for later processing of datetime rows. |
|
| 1089 | + $datetime_tickets[ $DTT_ID ][] = $ticket_row; |
|
| 1090 | + // temporary cache of this datetime info for this ticket for later processing of ticket rows. |
|
| 1091 | + if ( |
|
| 1092 | + ! isset($ticket_datetimes[ $TKT_ID ]) |
|
| 1093 | + || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true) |
|
| 1094 | + ) { |
|
| 1095 | + $ticket_datetimes[ $TKT_ID ][] = $datetime_row; |
|
| 1096 | + } |
|
| 1097 | + } |
|
| 1098 | + $datetime_row++; |
|
| 1099 | + } |
|
| 1100 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
| 1101 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
| 1102 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
| 1103 | + // sort $all_tickets by order |
|
| 1104 | + usort( |
|
| 1105 | + $all_tickets, |
|
| 1106 | + function (EE_Ticket $a, EE_Ticket $b) { |
|
| 1107 | + $a_order = (int) $a->get('TKT_order'); |
|
| 1108 | + $b_order = (int) $b->get('TKT_order'); |
|
| 1109 | + if ($a_order === $b_order) { |
|
| 1110 | + return 0; |
|
| 1111 | + } |
|
| 1112 | + return ($a_order < $b_order) |
|
| 1113 | + ? -1 |
|
| 1114 | + : 1; |
|
| 1115 | + } |
|
| 1116 | + ); |
|
| 1117 | + // k NOW we have all the data we need for setting up the datetime rows |
|
| 1118 | + // and ticket rows so we start our datetime loop again. |
|
| 1119 | + $datetime_row = 1; |
|
| 1120 | + foreach ($datetimes as $datetime) { |
|
| 1121 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row( |
|
| 1122 | + $datetime_row, |
|
| 1123 | + $datetime, |
|
| 1124 | + $datetime_tickets, |
|
| 1125 | + $all_tickets, |
|
| 1126 | + false, |
|
| 1127 | + $datetimes |
|
| 1128 | + ); |
|
| 1129 | + $datetime_row++; |
|
| 1130 | + } |
|
| 1131 | + // then loop through all tickets for the ticket rows. |
|
| 1132 | + $ticket_row = 1; |
|
| 1133 | + foreach ($all_tickets as $ticket) { |
|
| 1134 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row( |
|
| 1135 | + $ticket_row, |
|
| 1136 | + $ticket, |
|
| 1137 | + $ticket_datetimes, |
|
| 1138 | + $datetimes, |
|
| 1139 | + false, |
|
| 1140 | + $all_tickets |
|
| 1141 | + ); |
|
| 1142 | + $ticket_row++; |
|
| 1143 | + } |
|
| 1144 | + $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets); |
|
| 1145 | + |
|
| 1146 | + $status_change_notice = LoaderFactory::getLoader()->getShared( |
|
| 1147 | + 'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice' |
|
| 1148 | + ); |
|
| 1149 | + |
|
| 1150 | + $main_template_args['status_change_notice'] = $status_change_notice->display( |
|
| 1151 | + '__event-editor', |
|
| 1152 | + 'espresso-events' |
|
| 1153 | + ); |
|
| 1154 | + |
|
| 1155 | + EEH_Template::display_template( |
|
| 1156 | + PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php', |
|
| 1157 | + $main_template_args |
|
| 1158 | + ); |
|
| 1159 | + } |
|
| 1160 | + |
|
| 1161 | + |
|
| 1162 | + /** |
|
| 1163 | + * @param int|string $datetime_row |
|
| 1164 | + * @param EE_Datetime $datetime |
|
| 1165 | + * @param array $datetime_tickets |
|
| 1166 | + * @param array $all_tickets |
|
| 1167 | + * @param bool $default |
|
| 1168 | + * @param array $all_datetimes |
|
| 1169 | + * @return string |
|
| 1170 | + * @throws DomainException |
|
| 1171 | + * @throws EE_Error |
|
| 1172 | + * @throws ReflectionException |
|
| 1173 | + */ |
|
| 1174 | + protected function _get_datetime_row( |
|
| 1175 | + $datetime_row, |
|
| 1176 | + EE_Datetime $datetime, |
|
| 1177 | + array $datetime_tickets = [], |
|
| 1178 | + array $all_tickets = [], |
|
| 1179 | + bool $default = false, |
|
| 1180 | + array $all_datetimes = [] |
|
| 1181 | + ): string { |
|
| 1182 | + return EEH_Template::display_template( |
|
| 1183 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php', |
|
| 1184 | + [ |
|
| 1185 | + 'dtt_edit_row' => $this->_get_dtt_edit_row( |
|
| 1186 | + $datetime_row, |
|
| 1187 | + $datetime, |
|
| 1188 | + $default, |
|
| 1189 | + $all_datetimes |
|
| 1190 | + ), |
|
| 1191 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( |
|
| 1192 | + $datetime_row, |
|
| 1193 | + $datetime, |
|
| 1194 | + $datetime_tickets, |
|
| 1195 | + $all_tickets, |
|
| 1196 | + $default |
|
| 1197 | + ), |
|
| 1198 | + 'dtt_row' => $default |
|
| 1199 | + ? 'DTTNUM' |
|
| 1200 | + : $datetime_row, |
|
| 1201 | + ], |
|
| 1202 | + true |
|
| 1203 | + ); |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + |
|
| 1207 | + /** |
|
| 1208 | + * This method is used to generate a datetime fields edit row. |
|
| 1209 | + * The same row is used to generate a row with valid DTT objects |
|
| 1210 | + * and the default row that is used as the skeleton by the js. |
|
| 1211 | + * |
|
| 1212 | + * @param int|string $datetime_row The row number for the row being generated. |
|
| 1213 | + * @param EE_Datetime|null $datetime |
|
| 1214 | + * @param bool $default Whether a default row is being generated or not. |
|
| 1215 | + * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor. |
|
| 1216 | + * @return string |
|
| 1217 | + * @throws EE_Error |
|
| 1218 | + * @throws ReflectionException |
|
| 1219 | + */ |
|
| 1220 | + protected function _get_dtt_edit_row( |
|
| 1221 | + $datetime_row, |
|
| 1222 | + ?EE_Datetime $datetime, |
|
| 1223 | + bool $default, |
|
| 1224 | + array $all_datetimes |
|
| 1225 | + ): string { |
|
| 1226 | + // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true. |
|
| 1227 | + $default = ! $datetime instanceof EE_Datetime |
|
| 1228 | + ? true |
|
| 1229 | + : $default; |
|
| 1230 | + $template_args = [ |
|
| 1231 | + 'dtt_row' => $default |
|
| 1232 | + ? 'DTTNUM' |
|
| 1233 | + : $datetime_row, |
|
| 1234 | + 'event_datetimes_name' => $default |
|
| 1235 | + ? 'DTTNAMEATTR' |
|
| 1236 | + : 'edit_event_datetimes', |
|
| 1237 | + 'edit_dtt_expanded' => '', |
|
| 1238 | + 'DTT_ID' => $default |
|
| 1239 | + ? '' |
|
| 1240 | + : $datetime->ID(), |
|
| 1241 | + 'DTT_name' => $default |
|
| 1242 | + ? '' |
|
| 1243 | + : $datetime->get_f('DTT_name'), |
|
| 1244 | + 'DTT_description' => $default |
|
| 1245 | + ? '' |
|
| 1246 | + : $datetime->get_raw('DTT_description'), |
|
| 1247 | + 'DTT_EVT_start' => $default |
|
| 1248 | + ? '' |
|
| 1249 | + : $datetime->start_date($this->_date_time_format), |
|
| 1250 | + 'DTT_EVT_end' => $default |
|
| 1251 | + ? '' |
|
| 1252 | + : $datetime->end_date($this->_date_time_format), |
|
| 1253 | + 'DTT_reg_limit' => $default |
|
| 1254 | + ? '' |
|
| 1255 | + : $datetime->get_pretty( |
|
| 1256 | + 'DTT_reg_limit', |
|
| 1257 | + 'input' |
|
| 1258 | + ), |
|
| 1259 | + 'DTT_order' => $default |
|
| 1260 | + ? 'DTTNUM' |
|
| 1261 | + : $datetime_row, |
|
| 1262 | + 'dtt_sold' => $default |
|
| 1263 | + ? '0' |
|
| 1264 | + : $datetime->get('DTT_sold'), |
|
| 1265 | + 'dtt_reserved' => $default |
|
| 1266 | + ? '0' |
|
| 1267 | + : $datetime->reserved(), |
|
| 1268 | + 'can_clone' => $datetime instanceof EE_Datetime, |
|
| 1269 | + 'can_trash' => count($all_datetimes) > 1 |
|
| 1270 | + && $datetime instanceof EE_Datetime |
|
| 1271 | + && ! $datetime->get('DTT_sold'), |
|
| 1272 | + 'trash_icon' => ! empty($datetime) && $datetime->get('DTT_sold') > 0 |
|
| 1273 | + ? 'trash-entity dashicons dashicons-lock' |
|
| 1274 | + : 'trash-entity dashicons dashicons-post-trash clickable', |
|
| 1275 | + 'reg_list_url' => $default || ! $datetime->event() instanceof EE_Event |
|
| 1276 | + ? '' |
|
| 1277 | + : EE_Admin_Page::add_query_args_and_nonce( |
|
| 1278 | + [ |
|
| 1279 | + 'event_id' => $datetime->event()->ID(), |
|
| 1280 | + 'datetime_id' => $datetime->ID(), |
|
| 1281 | + 'use_filters' => true, |
|
| 1282 | + ], |
|
| 1283 | + REG_ADMIN_URL |
|
| 1284 | + ), |
|
| 1285 | + ]; |
|
| 1286 | + $template_args['show_trash'] = count($all_datetimes) === 1 |
|
| 1287 | + && $template_args['trash_icon'] !== 'dashicons dashicons-lock' |
|
| 1288 | + ? 'display:none' |
|
| 1289 | + : ''; |
|
| 1290 | + // allow filtering of template args at this point. |
|
| 1291 | + $template_args = apply_filters( |
|
| 1292 | + 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', |
|
| 1293 | + $template_args, |
|
| 1294 | + $datetime_row, |
|
| 1295 | + $datetime, |
|
| 1296 | + $default, |
|
| 1297 | + $all_datetimes, |
|
| 1298 | + $this->_is_creating_event |
|
| 1299 | + ); |
|
| 1300 | + return EEH_Template::display_template( |
|
| 1301 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php', |
|
| 1302 | + $template_args, |
|
| 1303 | + true |
|
| 1304 | + ); |
|
| 1305 | + } |
|
| 1306 | + |
|
| 1307 | + |
|
| 1308 | + /** |
|
| 1309 | + * @param int|string $datetime_row |
|
| 1310 | + * @param EE_Datetime|null $datetime |
|
| 1311 | + * @param array $datetime_tickets |
|
| 1312 | + * @param array $all_tickets |
|
| 1313 | + * @param bool $default |
|
| 1314 | + * @return string |
|
| 1315 | + * @throws DomainException |
|
| 1316 | + * @throws EE_Error |
|
| 1317 | + * @throws ReflectionException |
|
| 1318 | + */ |
|
| 1319 | + protected function _get_dtt_attached_tickets_row( |
|
| 1320 | + $datetime_row, |
|
| 1321 | + ?EE_Datetime $datetime, |
|
| 1322 | + array $datetime_tickets = [], |
|
| 1323 | + array $all_tickets = [], |
|
| 1324 | + bool $default = false |
|
| 1325 | + ): string { |
|
| 1326 | + $template_args = [ |
|
| 1327 | + 'dtt_row' => $default |
|
| 1328 | + ? 'DTTNUM' |
|
| 1329 | + : $datetime_row, |
|
| 1330 | + 'event_datetimes_name' => $default |
|
| 1331 | + ? 'DTTNAMEATTR' |
|
| 1332 | + : 'edit_event_datetimes', |
|
| 1333 | + 'DTT_description' => $default |
|
| 1334 | + ? '' |
|
| 1335 | + : $datetime->get_raw('DTT_description'), |
|
| 1336 | + 'datetime_tickets_list' => $default |
|
| 1337 | + ? '<li class="hidden"></li>' |
|
| 1338 | + : '', |
|
| 1339 | + 'show_tickets_row' => 'display:none;', |
|
| 1340 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link( |
|
| 1341 | + 'add_new_ticket_via_datetime', |
|
| 1342 | + $this->_adminpage_obj->page_slug, |
|
| 1343 | + $this->_adminpage_obj->get_req_action() |
|
| 1344 | + ), |
|
| 1345 | + // todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
| 1346 | + 'DTT_ID' => $default |
|
| 1347 | + ? '' |
|
| 1348 | + : $datetime->ID(), |
|
| 1349 | + ]; |
|
| 1350 | + // need to setup the list items (but only if this isn't a default skeleton setup) |
|
| 1351 | + if (! $default) { |
|
| 1352 | + $ticket_row = 1; |
|
| 1353 | + foreach ($all_tickets as $ticket) { |
|
| 1354 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( |
|
| 1355 | + $datetime_row, |
|
| 1356 | + $ticket_row, |
|
| 1357 | + $datetime, |
|
| 1358 | + $ticket, |
|
| 1359 | + $datetime_tickets |
|
| 1360 | + ); |
|
| 1361 | + $ticket_row++; |
|
| 1362 | + } |
|
| 1363 | + } |
|
| 1364 | + // filter template args at this point |
|
| 1365 | + $template_args = apply_filters( |
|
| 1366 | + 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', |
|
| 1367 | + $template_args, |
|
| 1368 | + $datetime_row, |
|
| 1369 | + $datetime, |
|
| 1370 | + $datetime_tickets, |
|
| 1371 | + $all_tickets, |
|
| 1372 | + $default, |
|
| 1373 | + $this->_is_creating_event |
|
| 1374 | + ); |
|
| 1375 | + return EEH_Template::display_template( |
|
| 1376 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php', |
|
| 1377 | + $template_args, |
|
| 1378 | + true |
|
| 1379 | + ); |
|
| 1380 | + } |
|
| 1381 | + |
|
| 1382 | + |
|
| 1383 | + /** |
|
| 1384 | + * @param int|string $datetime_row |
|
| 1385 | + * @param int|string $ticket_row |
|
| 1386 | + * @param EE_Datetime|null $datetime |
|
| 1387 | + * @param EE_Ticket|null $ticket |
|
| 1388 | + * @param array $datetime_tickets |
|
| 1389 | + * @param bool $default |
|
| 1390 | + * @return string |
|
| 1391 | + * @throws EE_Error |
|
| 1392 | + * @throws ReflectionException |
|
| 1393 | + */ |
|
| 1394 | + protected function _get_datetime_tickets_list_item( |
|
| 1395 | + $datetime_row, |
|
| 1396 | + $ticket_row, |
|
| 1397 | + ?EE_Datetime $datetime, |
|
| 1398 | + ?EE_Ticket $ticket, |
|
| 1399 | + array $datetime_tickets = [], |
|
| 1400 | + bool $default = false |
|
| 1401 | + ): string { |
|
| 1402 | + $datetime_tickets = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ]) |
|
| 1403 | + ? $datetime_tickets[ $datetime->ID() ] |
|
| 1404 | + : []; |
|
| 1405 | + $display_row = $ticket instanceof EE_Ticket |
|
| 1406 | + ? $ticket->get('TKT_row') |
|
| 1407 | + : 0; |
|
| 1408 | + $no_ticket = $default && empty($ticket); |
|
| 1409 | + $template_args = [ |
|
| 1410 | + 'dtt_row' => $default |
|
| 1411 | + ? 'DTTNUM' |
|
| 1412 | + : $datetime_row, |
|
| 1413 | + 'tkt_row' => $no_ticket |
|
| 1414 | + ? 'TICKETNUM' |
|
| 1415 | + : $ticket_row, |
|
| 1416 | + 'datetime_ticket_checked' => in_array($display_row, $datetime_tickets, true) |
|
| 1417 | + ? ' checked' |
|
| 1418 | + : '', |
|
| 1419 | + 'ticket_selected' => in_array($display_row, $datetime_tickets, true) |
|
| 1420 | + ? ' ticket-selected' |
|
| 1421 | + : '', |
|
| 1422 | + 'TKT_name' => $no_ticket |
|
| 1423 | + ? 'TKTNAME' |
|
| 1424 | + : $ticket->get('TKT_name'), |
|
| 1425 | + 'tkt_status_class' => $no_ticket || $this->_is_creating_event |
|
| 1426 | + ? ' tkt-status-' . EE_Ticket::onsale |
|
| 1427 | + : ' tkt-status-' . $ticket->ticket_status(), |
|
| 1428 | + ]; |
|
| 1429 | + // filter template args |
|
| 1430 | + $template_args = apply_filters( |
|
| 1431 | + 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', |
|
| 1432 | + $template_args, |
|
| 1433 | + $datetime_row, |
|
| 1434 | + $ticket_row, |
|
| 1435 | + $datetime, |
|
| 1436 | + $ticket, |
|
| 1437 | + $datetime_tickets, |
|
| 1438 | + $default, |
|
| 1439 | + $this->_is_creating_event |
|
| 1440 | + ); |
|
| 1441 | + return EEH_Template::display_template( |
|
| 1442 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php', |
|
| 1443 | + $template_args, |
|
| 1444 | + true |
|
| 1445 | + ); |
|
| 1446 | + } |
|
| 1447 | + |
|
| 1448 | + |
|
| 1449 | + /** |
|
| 1450 | + * This generates the ticket row for tickets. |
|
| 1451 | + * This same method is used to generate both the actual rows and the js skeleton row |
|
| 1452 | + * (when default === true) |
|
| 1453 | + * |
|
| 1454 | + * @param int|string $ticket_row Represents the row number being generated. |
|
| 1455 | + * @param EE_Ticket|null $ticket |
|
| 1456 | + * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket |
|
| 1457 | + * or empty for default |
|
| 1458 | + * @param EE_Datetime[] $all_datetimes All Datetimes on the event or empty for default. |
|
| 1459 | + * @param bool $default Whether default row being generated or not. |
|
| 1460 | + * @param EE_Ticket[] $all_tickets This is an array of all tickets attached to the event |
|
| 1461 | + * (or empty in the case of defaults) |
|
| 1462 | + * @return string |
|
| 1463 | + * @throws InvalidArgumentException |
|
| 1464 | + * @throws InvalidInterfaceException |
|
| 1465 | + * @throws InvalidDataTypeException |
|
| 1466 | + * @throws DomainException |
|
| 1467 | + * @throws EE_Error |
|
| 1468 | + * @throws ReflectionException |
|
| 1469 | + */ |
|
| 1470 | + protected function _get_ticket_row( |
|
| 1471 | + $ticket_row, |
|
| 1472 | + ?EE_Ticket $ticket, |
|
| 1473 | + array $ticket_datetimes, |
|
| 1474 | + array $all_datetimes, |
|
| 1475 | + bool $default = false, |
|
| 1476 | + array $all_tickets = [] |
|
| 1477 | + ): string { |
|
| 1478 | + // if $ticket is not an instance of EE_Ticket then force default to true. |
|
| 1479 | + $default = ! $ticket instanceof EE_Ticket |
|
| 1480 | + ? true |
|
| 1481 | + : $default; |
|
| 1482 | + $prices = ! empty($ticket) && ! $default |
|
| 1483 | + ? $ticket->get_many_related( |
|
| 1484 | + 'Price', |
|
| 1485 | + ['default_where_conditions' => 'none', 'order_by' => ['PRC_order' => 'ASC']] |
|
| 1486 | + ) |
|
| 1487 | + : []; |
|
| 1488 | + // if there is only one price (which would be the base price) |
|
| 1489 | + // or NO prices and this ticket is a default ticket, |
|
| 1490 | + // let's just make sure there are no cached default prices on the object. |
|
| 1491 | + // This is done by not including any query_params. |
|
| 1492 | + if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
| 1493 | + $prices = $ticket->prices(); |
|
| 1494 | + } |
|
| 1495 | + // check if we're dealing with a default ticket in which case |
|
| 1496 | + // we don't want any starting_ticket_datetime_row values set |
|
| 1497 | + // (otherwise there won't be any new relationships created for tickets based off of the default ticket). |
|
| 1498 | + // This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
|
| 1499 | + $default_datetime = $default || ($ticket instanceof EE_Ticket && $ticket->is_default()); |
|
| 1500 | + $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ]) |
|
| 1501 | + ? $ticket_datetimes[ $ticket->ID() ] |
|
| 1502 | + : []; |
|
| 1503 | + $ticket_subtotal = $default |
|
| 1504 | + ? 0 |
|
| 1505 | + : $ticket->get_ticket_subtotal(); |
|
| 1506 | + $base_price = $default |
|
| 1507 | + ? null |
|
| 1508 | + : $ticket->base_price(); |
|
| 1509 | + $count_price_mods = EEM_Price::instance()->get_all_default_prices(true); |
|
| 1510 | + // breaking out complicated condition for ticket_status |
|
| 1511 | + if ($default) { |
|
| 1512 | + $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1513 | + } else { |
|
| 1514 | + $ticket_status_class = $ticket->is_default() |
|
| 1515 | + ? ' tkt-status-' . EE_Ticket::onsale |
|
| 1516 | + : ' tkt-status-' . $ticket->ticket_status(); |
|
| 1517 | + } |
|
| 1518 | + // breaking out complicated condition for TKT_taxable |
|
| 1519 | + if ($default) { |
|
| 1520 | + $TKT_taxable = ''; |
|
| 1521 | + } else { |
|
| 1522 | + $TKT_taxable = $ticket->taxable() |
|
| 1523 | + ? 'checked' |
|
| 1524 | + : ''; |
|
| 1525 | + } |
|
| 1526 | + if ($default) { |
|
| 1527 | + $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence'); |
|
| 1528 | + } elseif ($ticket->is_default()) { |
|
| 1529 | + $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence'); |
|
| 1530 | + } else { |
|
| 1531 | + $TKT_status = $ticket->ticket_status(true); |
|
| 1532 | + } |
|
| 1533 | + if ($default) { |
|
| 1534 | + $TKT_min = ''; |
|
| 1535 | + } else { |
|
| 1536 | + $TKT_min = $ticket->min(); |
|
| 1537 | + if ($TKT_min === -1 || $TKT_min === 0) { |
|
| 1538 | + $TKT_min = ''; |
|
| 1539 | + } |
|
| 1540 | + } |
|
| 1541 | + $template_args = [ |
|
| 1542 | + 'tkt_row' => $default |
|
| 1543 | + ? 'TICKETNUM' |
|
| 1544 | + : $ticket_row, |
|
| 1545 | + 'TKT_order' => $default |
|
| 1546 | + ? 'TICKETNUM' |
|
| 1547 | + : $ticket_row, |
|
| 1548 | + // on initial page load this will always be the correct order. |
|
| 1549 | + 'tkt_status_class' => $ticket_status_class, |
|
| 1550 | + 'display_edit_tkt_row' => 'display:none;', |
|
| 1551 | + 'edit_tkt_expanded' => '', |
|
| 1552 | + 'edit_tickets_name' => $default |
|
| 1553 | + ? 'TICKETNAMEATTR' |
|
| 1554 | + : 'edit_tickets', |
|
| 1555 | + 'TKT_name' => $default |
|
| 1556 | + ? '' |
|
| 1557 | + : $ticket->get_f('TKT_name'), |
|
| 1558 | + 'TKT_start_date' => $default |
|
| 1559 | + ? '' |
|
| 1560 | + : $ticket->get_date('TKT_start_date', $this->_date_time_format), |
|
| 1561 | + 'TKT_end_date' => $default |
|
| 1562 | + ? '' |
|
| 1563 | + : $ticket->get_date('TKT_end_date', $this->_date_time_format), |
|
| 1564 | + 'TKT_status' => $TKT_status, |
|
| 1565 | + 'TKT_price' => $default |
|
| 1566 | + ? '' |
|
| 1567 | + : EEH_Template::format_currency( |
|
| 1568 | + $ticket->get_ticket_total_with_taxes(), |
|
| 1569 | + false, |
|
| 1570 | + false |
|
| 1571 | + ), |
|
| 1572 | + 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
|
| 1573 | + 'TKT_price_amount' => $default |
|
| 1574 | + ? 0 |
|
| 1575 | + : $ticket_subtotal, |
|
| 1576 | + 'TKT_qty' => $default |
|
| 1577 | + ? '' |
|
| 1578 | + : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
| 1579 | + 'TKT_qty_for_input' => $default |
|
| 1580 | + ? '' |
|
| 1581 | + : $ticket->get_pretty('TKT_qty', 'input'), |
|
| 1582 | + 'TKT_uses' => $default |
|
| 1583 | + ? '' |
|
| 1584 | + : $ticket->get_pretty('TKT_uses', 'input'), |
|
| 1585 | + 'TKT_min' => $TKT_min, |
|
| 1586 | + 'TKT_max' => $default |
|
| 1587 | + ? '' |
|
| 1588 | + : $ticket->get_pretty('TKT_max', 'input'), |
|
| 1589 | + 'TKT_sold' => $default |
|
| 1590 | + ? 0 |
|
| 1591 | + : $ticket->tickets_sold(), |
|
| 1592 | + 'TKT_reserved' => $default |
|
| 1593 | + ? 0 |
|
| 1594 | + : $ticket->reserved(), |
|
| 1595 | + 'TKT_registrations' => $default |
|
| 1596 | + ? 0 |
|
| 1597 | + : $ticket->count_registrations( |
|
| 1598 | + [ |
|
| 1599 | + [ |
|
| 1600 | + 'STS_ID' => [ |
|
| 1601 | + '!=', |
|
| 1602 | + EEM_Registration::status_id_incomplete, |
|
| 1603 | + ], |
|
| 1604 | + ], |
|
| 1605 | + ] |
|
| 1606 | + ), |
|
| 1607 | + 'TKT_ID' => $default |
|
| 1608 | + ? 0 |
|
| 1609 | + : $ticket->ID(), |
|
| 1610 | + 'TKT_description' => $default |
|
| 1611 | + ? '' |
|
| 1612 | + : $ticket->get_raw('TKT_description'), |
|
| 1613 | + 'TKT_is_default' => $default |
|
| 1614 | + ? 0 |
|
| 1615 | + : $ticket->is_default(), |
|
| 1616 | + 'TKT_required' => $default |
|
| 1617 | + ? 0 |
|
| 1618 | + : $ticket->required(), |
|
| 1619 | + 'TKT_is_default_selector' => '', |
|
| 1620 | + 'ticket_price_rows' => '', |
|
| 1621 | + 'TKT_base_price' => $default || ! $base_price instanceof EE_Price |
|
| 1622 | + ? '' |
|
| 1623 | + : $base_price->get_pretty('PRC_amount', 'localized_float'), |
|
| 1624 | + 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price |
|
| 1625 | + ? 0 |
|
| 1626 | + : $base_price->ID(), |
|
| 1627 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) |
|
| 1628 | + ? '' |
|
| 1629 | + : 'display:none;', |
|
| 1630 | + 'show_price_mod_button' => count($prices) > 1 |
|
| 1631 | + || ($default && $count_price_mods > 0) |
|
| 1632 | + || (! $default && $ticket->deleted()) |
|
| 1633 | + ? 'display:none;' |
|
| 1634 | + : '', |
|
| 1635 | + 'total_price_rows' => count($prices) > 1 |
|
| 1636 | + ? count($prices) |
|
| 1637 | + : 1, |
|
| 1638 | + 'ticket_datetimes_list' => $default |
|
| 1639 | + ? '<li class="hidden"></li>' |
|
| 1640 | + : '', |
|
| 1641 | + 'starting_ticket_datetime_rows' => $default || $default_datetime |
|
| 1642 | + ? '' |
|
| 1643 | + : implode(',', $tkt_datetimes), |
|
| 1644 | + 'ticket_datetime_rows' => $default |
|
| 1645 | + ? '' |
|
| 1646 | + : implode(',', $tkt_datetimes), |
|
| 1647 | + 'existing_ticket_price_ids' => $default |
|
| 1648 | + ? '' |
|
| 1649 | + : implode(',', array_keys($prices)), |
|
| 1650 | + 'ticket_template_id' => $default |
|
| 1651 | + ? 0 |
|
| 1652 | + : $ticket->get('TTM_ID'), |
|
| 1653 | + 'TKT_taxable' => $TKT_taxable, |
|
| 1654 | + 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->taxable() |
|
| 1655 | + ? '' |
|
| 1656 | + : 'display:none;', |
|
| 1657 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1658 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency( |
|
| 1659 | + $ticket_subtotal, |
|
| 1660 | + false, |
|
| 1661 | + false |
|
| 1662 | + ), |
|
| 1663 | + 'TKT_subtotal_amount' => $ticket_subtotal, |
|
| 1664 | + 'tax_rows' => $this->_get_tax_rows($ticket_row, $ticket), |
|
| 1665 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->deleted(), |
|
| 1666 | + 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->deleted() |
|
| 1667 | + ? ' ticket-archived' |
|
| 1668 | + : '', |
|
| 1669 | + 'trash_icon' => $ticket instanceof EE_Ticket |
|
| 1670 | + && $ticket->deleted() |
|
| 1671 | + && ! $ticket->is_permanently_deleteable() |
|
| 1672 | + ? 'dashicons dashicons-lock ' |
|
| 1673 | + : 'trash-entity dashicons dashicons-post-trash clickable', |
|
| 1674 | + |
|
| 1675 | + 'can_clone' => $ticket instanceof EE_Ticket && ! $ticket->deleted(), |
|
| 1676 | + 'can_trash' => $ticket instanceof EE_Ticket |
|
| 1677 | + && (! $ticket->deleted() && $ticket->is_permanently_deleteable()), |
|
| 1678 | + ]; |
|
| 1679 | + $template_args['trash_hidden'] = count($all_tickets) === 1 |
|
| 1680 | + && $template_args['trash_icon'] !== 'dashicons dashicons-lock' |
|
| 1681 | + ? 'display:none' |
|
| 1682 | + : ''; |
|
| 1683 | + // handle rows that should NOT be empty |
|
| 1684 | + if (empty($template_args['TKT_start_date'])) { |
|
| 1685 | + // if empty then the start date will be now. |
|
| 1686 | + $template_args['TKT_start_date'] = date( |
|
| 1687 | + $this->_date_time_format, |
|
| 1688 | + current_time('timestamp') |
|
| 1689 | + ); |
|
| 1690 | + $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1691 | + } |
|
| 1692 | + if (empty($template_args['TKT_end_date'])) { |
|
| 1693 | + // get the earliest datetime (if present); |
|
| 1694 | + $earliest_datetime = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 |
|
| 1695 | + ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related( |
|
| 1696 | + 'Datetime', |
|
| 1697 | + ['order_by' => ['DTT_EVT_start' => 'ASC']] |
|
| 1698 | + ) |
|
| 1699 | + : null; |
|
| 1700 | + if (! empty($earliest_datetime)) { |
|
| 1701 | + $template_args['TKT_end_date'] = $earliest_datetime->get_datetime( |
|
| 1702 | + 'DTT_EVT_start', |
|
| 1703 | + $this->_date_time_format |
|
| 1704 | + ); |
|
| 1705 | + } else { |
|
| 1706 | + // default so let's just use what's been set for the default date-time which is 30 days from now. |
|
| 1707 | + $template_args['TKT_end_date'] = date( |
|
| 1708 | + $this->_date_time_format, |
|
| 1709 | + mktime( |
|
| 1710 | + 24, |
|
| 1711 | + 0, |
|
| 1712 | + 0, |
|
| 1713 | + date('m'), |
|
| 1714 | + date('d') + 29, |
|
| 1715 | + date('Y') |
|
| 1716 | + ) |
|
| 1717 | + ); |
|
| 1718 | + } |
|
| 1719 | + $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1720 | + } |
|
| 1721 | + // generate ticket_datetime items |
|
| 1722 | + if (! $default) { |
|
| 1723 | + $datetime_row = 1; |
|
| 1724 | + foreach ($all_datetimes as $datetime) { |
|
| 1725 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( |
|
| 1726 | + $datetime_row, |
|
| 1727 | + $ticket_row, |
|
| 1728 | + $datetime, |
|
| 1729 | + $ticket, |
|
| 1730 | + $ticket_datetimes, |
|
| 1731 | + $default |
|
| 1732 | + ); |
|
| 1733 | + $datetime_row++; |
|
| 1734 | + } |
|
| 1735 | + } |
|
| 1736 | + $price_row = 1; |
|
| 1737 | + foreach ($prices as $price) { |
|
| 1738 | + if (! $price instanceof EE_Price) { |
|
| 1739 | + continue; |
|
| 1740 | + } |
|
| 1741 | + if ($price->is_base_price()) { |
|
| 1742 | + $price_row++; |
|
| 1743 | + continue; |
|
| 1744 | + } |
|
| 1745 | + |
|
| 1746 | + $show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1); |
|
| 1747 | + $show_create = ! (count($prices) > 1 && count($prices) !== $price_row); |
|
| 1748 | + |
|
| 1749 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( |
|
| 1750 | + $ticket_row, |
|
| 1751 | + $price_row, |
|
| 1752 | + $price, |
|
| 1753 | + $default, |
|
| 1754 | + $ticket, |
|
| 1755 | + $show_trash, |
|
| 1756 | + $show_create |
|
| 1757 | + ); |
|
| 1758 | + $price_row++; |
|
| 1759 | + } |
|
| 1760 | + // filter $template_args |
|
| 1761 | + $template_args = apply_filters( |
|
| 1762 | + 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', |
|
| 1763 | + $template_args, |
|
| 1764 | + $ticket_row, |
|
| 1765 | + $ticket, |
|
| 1766 | + $ticket_datetimes, |
|
| 1767 | + $all_datetimes, |
|
| 1768 | + $default, |
|
| 1769 | + $all_tickets, |
|
| 1770 | + $this->_is_creating_event |
|
| 1771 | + ); |
|
| 1772 | + return EEH_Template::display_template( |
|
| 1773 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php', |
|
| 1774 | + $template_args, |
|
| 1775 | + true |
|
| 1776 | + ); |
|
| 1777 | + } |
|
| 1778 | + |
|
| 1779 | + |
|
| 1780 | + /** |
|
| 1781 | + * @param int|string $ticket_row |
|
| 1782 | + * @param EE_Ticket|null $ticket |
|
| 1783 | + * @return string |
|
| 1784 | + * @throws DomainException |
|
| 1785 | + * @throws EE_Error |
|
| 1786 | + * @throws ReflectionException |
|
| 1787 | + */ |
|
| 1788 | + protected function _get_tax_rows($ticket_row, ?EE_Ticket $ticket): string |
|
| 1789 | + { |
|
| 1790 | + $tax_rows = ''; |
|
| 1791 | + /** @var EE_Price[] $taxes */ |
|
| 1792 | + $taxes = EE_Taxes::get_taxes_for_admin(); |
|
| 1793 | + foreach ($taxes as $tax) { |
|
| 1794 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
| 1795 | + $template_args = [ |
|
| 1796 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') |
|
| 1797 | + ? '' |
|
| 1798 | + : 'display:none;', |
|
| 1799 | + 'tax_id' => $tax->ID(), |
|
| 1800 | + 'tkt_row' => $ticket_row, |
|
| 1801 | + 'tax_label' => $tax->get('PRC_name'), |
|
| 1802 | + 'tax_added' => $tax_added, |
|
| 1803 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, false, false), |
|
| 1804 | + 'tax_amount' => $tax->get('PRC_amount'), |
|
| 1805 | + ]; |
|
| 1806 | + $template_args = apply_filters( |
|
| 1807 | + 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', |
|
| 1808 | + $template_args, |
|
| 1809 | + $ticket_row, |
|
| 1810 | + $ticket, |
|
| 1811 | + $this->_is_creating_event |
|
| 1812 | + ); |
|
| 1813 | + $tax_rows .= EEH_Template::display_template( |
|
| 1814 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php', |
|
| 1815 | + $template_args, |
|
| 1816 | + true |
|
| 1817 | + ); |
|
| 1818 | + } |
|
| 1819 | + return $tax_rows; |
|
| 1820 | + } |
|
| 1821 | + |
|
| 1822 | + |
|
| 1823 | + /** |
|
| 1824 | + * @param EE_Price $tax |
|
| 1825 | + * @param EE_Ticket|null $ticket |
|
| 1826 | + * @return float|int |
|
| 1827 | + * @throws EE_Error |
|
| 1828 | + * @throws ReflectionException |
|
| 1829 | + */ |
|
| 1830 | + protected function _get_tax_added(EE_Price $tax, ?EE_Ticket $ticket) |
|
| 1831 | + { |
|
| 1832 | + $subtotal = empty($ticket) |
|
| 1833 | + ? 0 |
|
| 1834 | + : $ticket->get_ticket_subtotal(); |
|
| 1835 | + return $subtotal * $tax->get('PRC_amount') / 100; |
|
| 1836 | + } |
|
| 1837 | + |
|
| 1838 | + |
|
| 1839 | + /** |
|
| 1840 | + * @param int|string $ticket_row |
|
| 1841 | + * @param int|string $price_row |
|
| 1842 | + * @param EE_Price|null $price |
|
| 1843 | + * @param bool $default |
|
| 1844 | + * @param EE_Ticket|null $ticket |
|
| 1845 | + * @param bool $show_trash |
|
| 1846 | + * @param bool $show_create |
|
| 1847 | + * @return string |
|
| 1848 | + * @throws InvalidArgumentException |
|
| 1849 | + * @throws InvalidInterfaceException |
|
| 1850 | + * @throws InvalidDataTypeException |
|
| 1851 | + * @throws DomainException |
|
| 1852 | + * @throws EE_Error |
|
| 1853 | + * @throws ReflectionException |
|
| 1854 | + */ |
|
| 1855 | + protected function _get_ticket_price_row( |
|
| 1856 | + $ticket_row, |
|
| 1857 | + $price_row, |
|
| 1858 | + ?EE_Price $price, |
|
| 1859 | + bool $default, |
|
| 1860 | + ?EE_Ticket $ticket, |
|
| 1861 | + bool $show_trash = true, |
|
| 1862 | + bool $show_create = true |
|
| 1863 | + ): string { |
|
| 1864 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted'); |
|
| 1865 | + $template_args = [ |
|
| 1866 | + 'tkt_row' => $default && empty($ticket) |
|
| 1867 | + ? 'TICKETNUM' |
|
| 1868 | + : $ticket_row, |
|
| 1869 | + 'PRC_order' => $default && empty($price) |
|
| 1870 | + ? 'PRICENUM' |
|
| 1871 | + : $price_row, |
|
| 1872 | + 'edit_prices_name' => $default && empty($price) |
|
| 1873 | + ? 'PRICENAMEATTR' |
|
| 1874 | + : 'edit_prices', |
|
| 1875 | + 'price_type_selector' => $this->_get_price_type_selector( |
|
| 1876 | + $ticket_row, |
|
| 1877 | + $price_row, |
|
| 1878 | + $price, |
|
| 1879 | + $default, |
|
| 1880 | + $send_disabled |
|
| 1881 | + ), |
|
| 1882 | + 'PRC_ID' => $default && empty($price) |
|
| 1883 | + ? 0 |
|
| 1884 | + : $price->ID(), |
|
| 1885 | + 'PRC_is_default' => $default && empty($price) |
|
| 1886 | + ? 0 |
|
| 1887 | + : $price->get('PRC_is_default'), |
|
| 1888 | + 'PRC_name' => $default && empty($price) |
|
| 1889 | + ? '' |
|
| 1890 | + : $price->get('PRC_name'), |
|
| 1891 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1892 | + 'show_plus_or_minus' => $default && empty($price) |
|
| 1893 | + ? '' |
|
| 1894 | + : 'display:none;', |
|
| 1895 | + 'show_plus' => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price()) |
|
| 1896 | + ? 'display:none;' |
|
| 1897 | + : '', |
|
| 1898 | + 'show_minus' => ($default && empty($price)) || ! $price->is_discount() |
|
| 1899 | + ? 'display:none;' |
|
| 1900 | + : '', |
|
| 1901 | + 'show_currency_symbol' => ($default && empty($price)) || $price->is_percent() |
|
| 1902 | + ? 'display:none' |
|
| 1903 | + : '', |
|
| 1904 | + 'PRC_amount' => $default && empty($price) |
|
| 1905 | + ? 0 |
|
| 1906 | + : $price->get_pretty('PRC_amount', 'localized_float'), |
|
| 1907 | + 'show_percentage' => ($default && empty($price)) || ! $price->is_percent() |
|
| 1908 | + ? 'display:none;' |
|
| 1909 | + : '', |
|
| 1910 | + 'show_trash_icon' => $show_trash |
|
| 1911 | + ? '' |
|
| 1912 | + : ' style="display:none;"', |
|
| 1913 | + 'show_create_button' => $show_create |
|
| 1914 | + ? '' |
|
| 1915 | + : ' style="display:none;"', |
|
| 1916 | + 'PRC_desc' => $default && empty($price) |
|
| 1917 | + ? '' |
|
| 1918 | + : $price->get('PRC_desc'), |
|
| 1919 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted'), |
|
| 1920 | + ]; |
|
| 1921 | + $template_args = apply_filters( |
|
| 1922 | + 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', |
|
| 1923 | + $template_args, |
|
| 1924 | + $ticket_row, |
|
| 1925 | + $price_row, |
|
| 1926 | + $price, |
|
| 1927 | + $default, |
|
| 1928 | + $ticket, |
|
| 1929 | + $show_trash, |
|
| 1930 | + $show_create, |
|
| 1931 | + $this->_is_creating_event |
|
| 1932 | + ); |
|
| 1933 | + return EEH_Template::display_template( |
|
| 1934 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php', |
|
| 1935 | + $template_args, |
|
| 1936 | + true |
|
| 1937 | + ); |
|
| 1938 | + } |
|
| 1939 | + |
|
| 1940 | + |
|
| 1941 | + /** |
|
| 1942 | + * @param int|string $ticket_row |
|
| 1943 | + * @param int|string $price_row |
|
| 1944 | + * @param EE_Price|null $price |
|
| 1945 | + * @param bool $default |
|
| 1946 | + * @param bool $disabled |
|
| 1947 | + * @return string |
|
| 1948 | + * @throws ReflectionException |
|
| 1949 | + * @throws InvalidArgumentException |
|
| 1950 | + * @throws InvalidInterfaceException |
|
| 1951 | + * @throws InvalidDataTypeException |
|
| 1952 | + * @throws DomainException |
|
| 1953 | + * @throws EE_Error |
|
| 1954 | + */ |
|
| 1955 | + protected function _get_price_type_selector( |
|
| 1956 | + $ticket_row, |
|
| 1957 | + $price_row, |
|
| 1958 | + ?EE_Price $price, |
|
| 1959 | + bool $default, |
|
| 1960 | + bool $disabled = false |
|
| 1961 | + ): string { |
|
| 1962 | + if (($price instanceof EE_Price && $price->is_base_price()) || (! $price instanceof EE_Price && $default)) { |
|
| 1963 | + return $this->_get_base_price_template( |
|
| 1964 | + $ticket_row, |
|
| 1965 | + $price_row, |
|
| 1966 | + $price, |
|
| 1967 | + $default |
|
| 1968 | + ); |
|
| 1969 | + } |
|
| 1970 | + return $this->_get_price_modifier_template( |
|
| 1971 | + $ticket_row, |
|
| 1972 | + $price_row, |
|
| 1973 | + $price, |
|
| 1974 | + $default, |
|
| 1975 | + $disabled |
|
| 1976 | + ); |
|
| 1977 | + } |
|
| 1978 | + |
|
| 1979 | + |
|
| 1980 | + /** |
|
| 1981 | + * @param int|string $ticket_row |
|
| 1982 | + * @param int|string $price_row |
|
| 1983 | + * @param EE_Price|null $price |
|
| 1984 | + * @param bool $default |
|
| 1985 | + * @return string |
|
| 1986 | + * @throws DomainException |
|
| 1987 | + * @throws EE_Error |
|
| 1988 | + * @throws ReflectionException |
|
| 1989 | + */ |
|
| 1990 | + protected function _get_base_price_template( |
|
| 1991 | + $ticket_row, |
|
| 1992 | + $price_row, |
|
| 1993 | + ?EE_Price $price, |
|
| 1994 | + bool $default |
|
| 1995 | + ): string { |
|
| 1996 | + $template_args = [ |
|
| 1997 | + 'tkt_row' => $default |
|
| 1998 | + ? 'TICKETNUM' |
|
| 1999 | + : $ticket_row, |
|
| 2000 | + 'PRC_order' => $default && empty($price) |
|
| 2001 | + ? 'PRICENUM' |
|
| 2002 | + : $price_row, |
|
| 2003 | + 'PRT_ID' => $default && empty($price) |
|
| 2004 | + ? 1 |
|
| 2005 | + : $price->get('PRT_ID'), |
|
| 2006 | + 'PRT_name' => esc_html__('Price', 'event_espresso'), |
|
| 2007 | + 'price_selected_operator' => '+', |
|
| 2008 | + 'price_selected_is_percent' => 0, |
|
| 2009 | + ]; |
|
| 2010 | + $template_args = apply_filters( |
|
| 2011 | + 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', |
|
| 2012 | + $template_args, |
|
| 2013 | + $ticket_row, |
|
| 2014 | + $price_row, |
|
| 2015 | + $price, |
|
| 2016 | + $default, |
|
| 2017 | + $this->_is_creating_event |
|
| 2018 | + ); |
|
| 2019 | + return EEH_Template::display_template( |
|
| 2020 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php', |
|
| 2021 | + $template_args, |
|
| 2022 | + true |
|
| 2023 | + ); |
|
| 2024 | + } |
|
| 2025 | + |
|
| 2026 | + |
|
| 2027 | + /** |
|
| 2028 | + * @param int|string $ticket_row |
|
| 2029 | + * @param int|string $price_row |
|
| 2030 | + * @param EE_Price|null $price |
|
| 2031 | + * @param bool $default |
|
| 2032 | + * @param bool $disabled |
|
| 2033 | + * @return string |
|
| 2034 | + * @throws ReflectionException |
|
| 2035 | + * @throws InvalidArgumentException |
|
| 2036 | + * @throws InvalidInterfaceException |
|
| 2037 | + * @throws InvalidDataTypeException |
|
| 2038 | + * @throws DomainException |
|
| 2039 | + * @throws EE_Error |
|
| 2040 | + */ |
|
| 2041 | + protected function _get_price_modifier_template( |
|
| 2042 | + $ticket_row, |
|
| 2043 | + $price_row, |
|
| 2044 | + ?EE_Price $price, |
|
| 2045 | + bool $default, |
|
| 2046 | + bool $disabled = false |
|
| 2047 | + ): string { |
|
| 2048 | + $use_default = $default && ! $price instanceof EE_Price; |
|
| 2049 | + $selected_price_type_id = $use_default ? 0 : $price->type(); |
|
| 2050 | + |
|
| 2051 | + $select_name = $use_default |
|
| 2052 | + ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' |
|
| 2053 | + : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]'; |
|
| 2054 | + |
|
| 2055 | + $price_type_model = EEM_Price_Type::instance(); |
|
| 2056 | + $price_types = $price_type_model->get_all([['NOT' => ['PBT_ID' => '1']]]); |
|
| 2057 | + $all_price_types = $use_default |
|
| 2058 | + ? [esc_html__('Select Modifier', 'event_espresso')] |
|
| 2059 | + : []; |
|
| 2060 | + $price_option_spans = ''; |
|
| 2061 | + // setup price types for selector |
|
| 2062 | + foreach ($price_types as $price_type) { |
|
| 2063 | + if (! $price_type instanceof EE_Price_Type) { |
|
| 2064 | + continue; |
|
| 2065 | + } |
|
| 2066 | + $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name'); |
|
| 2067 | + // while we're in the loop lets set up the option spans used by js |
|
| 2068 | + $span_args = [ |
|
| 2069 | + 'PRT_ID' => $price_type->ID(), |
|
| 2070 | + 'PRT_operator' => $price_type->is_discount() |
|
| 2071 | + ? '-' |
|
| 2072 | + : '+', |
|
| 2073 | + 'PRT_is_percent' => $price_type->get('PRT_is_percent') |
|
| 2074 | + ? 1 |
|
| 2075 | + : 0, |
|
| 2076 | + ]; |
|
| 2077 | + $price_option_spans .= EEH_Template::display_template( |
|
| 2078 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php', |
|
| 2079 | + $span_args, |
|
| 2080 | + true |
|
| 2081 | + ); |
|
| 2082 | + } |
|
| 2083 | + |
|
| 2084 | + $select_name = $disabled |
|
| 2085 | + ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]' |
|
| 2086 | + : $select_name; |
|
| 2087 | + |
|
| 2088 | + $select_input = new EE_Select_Input( |
|
| 2089 | + $all_price_types, |
|
| 2090 | + [ |
|
| 2091 | + 'default' => $selected_price_type_id, |
|
| 2092 | + 'html_name' => $select_name, |
|
| 2093 | + 'html_class' => 'edit-price-PRT_ID', |
|
| 2094 | + 'other_html_attributes' => $disabled |
|
| 2095 | + ? 'style="width:auto;" disabled' |
|
| 2096 | + : 'style="width:auto;"', |
|
| 2097 | + ] |
|
| 2098 | + ); |
|
| 2099 | + |
|
| 2100 | + $price_selected_operator = $price instanceof EE_Price && $price->is_discount() |
|
| 2101 | + ? '-' |
|
| 2102 | + : '+'; |
|
| 2103 | + $price_selected_operator = $use_default |
|
| 2104 | + ? '' |
|
| 2105 | + : $price_selected_operator; |
|
| 2106 | + $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() |
|
| 2107 | + ? 1 |
|
| 2108 | + : 0; |
|
| 2109 | + $price_selected_is_percent = $use_default |
|
| 2110 | + ? '' |
|
| 2111 | + : $price_selected_is_percent; |
|
| 2112 | + $template_args = [ |
|
| 2113 | + 'tkt_row' => $default |
|
| 2114 | + ? 'TICKETNUM' |
|
| 2115 | + : $ticket_row, |
|
| 2116 | + 'PRC_order' => $use_default |
|
| 2117 | + ? 'PRICENUM' |
|
| 2118 | + : $price_row, |
|
| 2119 | + 'price_modifier_selector' => $select_input->get_html_for_input(), |
|
| 2120 | + 'main_name' => $select_name, |
|
| 2121 | + 'selected_price_type_id' => $selected_price_type_id, |
|
| 2122 | + 'price_option_spans' => $price_option_spans, |
|
| 2123 | + 'price_selected_operator' => $price_selected_operator, |
|
| 2124 | + 'price_selected_is_percent' => $price_selected_is_percent, |
|
| 2125 | + 'disabled' => $disabled, |
|
| 2126 | + ]; |
|
| 2127 | + $template_args = apply_filters( |
|
| 2128 | + 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', |
|
| 2129 | + $template_args, |
|
| 2130 | + $ticket_row, |
|
| 2131 | + $price_row, |
|
| 2132 | + $price, |
|
| 2133 | + $default, |
|
| 2134 | + $disabled, |
|
| 2135 | + $this->_is_creating_event |
|
| 2136 | + ); |
|
| 2137 | + return EEH_Template::display_template( |
|
| 2138 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php', |
|
| 2139 | + $template_args, |
|
| 2140 | + true |
|
| 2141 | + ); |
|
| 2142 | + } |
|
| 2143 | + |
|
| 2144 | + |
|
| 2145 | + /** |
|
| 2146 | + * @param int|string $datetime_row |
|
| 2147 | + * @param int|string $ticket_row |
|
| 2148 | + * @param EE_Datetime|null $datetime |
|
| 2149 | + * @param EE_Ticket|null $ticket |
|
| 2150 | + * @param array $ticket_datetimes |
|
| 2151 | + * @param bool $default |
|
| 2152 | + * @return string |
|
| 2153 | + * @throws DomainException |
|
| 2154 | + * @throws EE_Error |
|
| 2155 | + * @throws ReflectionException |
|
| 2156 | + */ |
|
| 2157 | + protected function _get_ticket_datetime_list_item( |
|
| 2158 | + $datetime_row, |
|
| 2159 | + $ticket_row, |
|
| 2160 | + ?EE_Datetime $datetime, |
|
| 2161 | + ?EE_Ticket $ticket, |
|
| 2162 | + array $ticket_datetimes = [], |
|
| 2163 | + bool $default = false |
|
| 2164 | + ): string { |
|
| 2165 | + $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ]) |
|
| 2166 | + ? $ticket_datetimes[ $ticket->ID() ] |
|
| 2167 | + : []; |
|
| 2168 | + $template_args = [ |
|
| 2169 | + 'dtt_row' => $default && ! $datetime instanceof EE_Datetime |
|
| 2170 | + ? 'DTTNUM' |
|
| 2171 | + : $datetime_row, |
|
| 2172 | + 'tkt_row' => $default |
|
| 2173 | + ? 'TICKETNUM' |
|
| 2174 | + : $ticket_row, |
|
| 2175 | + 'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true) |
|
| 2176 | + ? ' ticket-selected' |
|
| 2177 | + : '', |
|
| 2178 | + 'ticket_datetime_checked' => in_array($datetime_row, $tkt_datetimes, true) |
|
| 2179 | + ? ' checked' |
|
| 2180 | + : '', |
|
| 2181 | + 'DTT_name' => $default && empty($datetime) |
|
| 2182 | + ? 'DTTNAME' |
|
| 2183 | + : $datetime->get_dtt_display_name(true), |
|
| 2184 | + 'tkt_status_class' => '', |
|
| 2185 | + ]; |
|
| 2186 | + $template_args = apply_filters( |
|
| 2187 | + 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', |
|
| 2188 | + $template_args, |
|
| 2189 | + $datetime_row, |
|
| 2190 | + $ticket_row, |
|
| 2191 | + $datetime, |
|
| 2192 | + $ticket, |
|
| 2193 | + $ticket_datetimes, |
|
| 2194 | + $default, |
|
| 2195 | + $this->_is_creating_event |
|
| 2196 | + ); |
|
| 2197 | + return EEH_Template::display_template( |
|
| 2198 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php', |
|
| 2199 | + $template_args, |
|
| 2200 | + true |
|
| 2201 | + ); |
|
| 2202 | + } |
|
| 2203 | + |
|
| 2204 | + |
|
| 2205 | + /** |
|
| 2206 | + * @param array $all_datetimes |
|
| 2207 | + * @param array $all_tickets |
|
| 2208 | + * @return string |
|
| 2209 | + * @throws ReflectionException |
|
| 2210 | + * @throws InvalidArgumentException |
|
| 2211 | + * @throws InvalidInterfaceException |
|
| 2212 | + * @throws InvalidDataTypeException |
|
| 2213 | + * @throws DomainException |
|
| 2214 | + * @throws EE_Error |
|
| 2215 | + */ |
|
| 2216 | + protected function _get_ticket_js_structure(array $all_datetimes = [], array $all_tickets = []): string |
|
| 2217 | + { |
|
| 2218 | + $template_args = [ |
|
| 2219 | + 'default_datetime_edit_row' => $this->_get_dtt_edit_row( |
|
| 2220 | + 'DTTNUM', |
|
| 2221 | + null, |
|
| 2222 | + true, |
|
| 2223 | + $all_datetimes |
|
| 2224 | + ), |
|
| 2225 | + 'default_ticket_row' => $this->_get_ticket_row( |
|
| 2226 | + 'TICKETNUM', |
|
| 2227 | + null, |
|
| 2228 | + [], |
|
| 2229 | + [], |
|
| 2230 | + true |
|
| 2231 | + ), |
|
| 2232 | + 'default_price_row' => $this->_get_ticket_price_row( |
|
| 2233 | + 'TICKETNUM', |
|
| 2234 | + 'PRICENUM', |
|
| 2235 | + null, |
|
| 2236 | + true, |
|
| 2237 | + null |
|
| 2238 | + ), |
|
| 2239 | + |
|
| 2240 | + 'default_price_rows' => '', |
|
| 2241 | + 'default_base_price_amount' => 0, |
|
| 2242 | + 'default_base_price_name' => '', |
|
| 2243 | + 'default_base_price_description' => '', |
|
| 2244 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( |
|
| 2245 | + 'TICKETNUM', |
|
| 2246 | + 'PRICENUM', |
|
| 2247 | + null, |
|
| 2248 | + true |
|
| 2249 | + ), |
|
| 2250 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( |
|
| 2251 | + 'DTTNUM', |
|
| 2252 | + null, |
|
| 2253 | + [], |
|
| 2254 | + [], |
|
| 2255 | + true |
|
| 2256 | + ), |
|
| 2257 | + 'existing_available_datetime_tickets_list' => '', |
|
| 2258 | + 'existing_available_ticket_datetimes_list' => '', |
|
| 2259 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( |
|
| 2260 | + 'DTTNUM', |
|
| 2261 | + 'TICKETNUM', |
|
| 2262 | + null, |
|
| 2263 | + null, |
|
| 2264 | + [], |
|
| 2265 | + true |
|
| 2266 | + ), |
|
| 2267 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( |
|
| 2268 | + 'DTTNUM', |
|
| 2269 | + 'TICKETNUM', |
|
| 2270 | + null, |
|
| 2271 | + null, |
|
| 2272 | + [], |
|
| 2273 | + true |
|
| 2274 | + ), |
|
| 2275 | + ]; |
|
| 2276 | + $ticket_row = 1; |
|
| 2277 | + foreach ($all_tickets as $ticket) { |
|
| 2278 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( |
|
| 2279 | + 'DTTNUM', |
|
| 2280 | + $ticket_row, |
|
| 2281 | + null, |
|
| 2282 | + $ticket, |
|
| 2283 | + [], |
|
| 2284 | + true |
|
| 2285 | + ); |
|
| 2286 | + $ticket_row++; |
|
| 2287 | + } |
|
| 2288 | + $datetime_row = 1; |
|
| 2289 | + foreach ($all_datetimes as $datetime) { |
|
| 2290 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( |
|
| 2291 | + $datetime_row, |
|
| 2292 | + 'TICKETNUM', |
|
| 2293 | + $datetime, |
|
| 2294 | + null, |
|
| 2295 | + [], |
|
| 2296 | + true |
|
| 2297 | + ); |
|
| 2298 | + $datetime_row++; |
|
| 2299 | + } |
|
| 2300 | + $price_model = EEM_Price::instance(); |
|
| 2301 | + $default_prices = $price_model->get_all_default_prices(); |
|
| 2302 | + $price_row = 1; |
|
| 2303 | + foreach ($default_prices as $price) { |
|
| 2304 | + if (! $price instanceof EE_Price) { |
|
| 2305 | + continue; |
|
| 2306 | + } |
|
| 2307 | + if ($price->is_base_price()) { |
|
| 2308 | + $template_args['default_base_price_amount'] = $price->get_pretty( |
|
| 2309 | + 'PRC_amount', |
|
| 2310 | + 'localized_float' |
|
| 2311 | + ); |
|
| 2312 | + $template_args['default_base_price_name'] = $price->get('PRC_name'); |
|
| 2313 | + $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
|
| 2314 | + $price_row++; |
|
| 2315 | + continue; |
|
| 2316 | + } |
|
| 2317 | + |
|
| 2318 | + $show_trash = ! ((count($default_prices) > 1 && $price_row === 1) || count($default_prices) === 1); |
|
| 2319 | + $show_create = ! (count($default_prices) > 1 && count($default_prices) !== $price_row); |
|
| 2320 | + |
|
| 2321 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row( |
|
| 2322 | + 'TICKETNUM', |
|
| 2323 | + $price_row, |
|
| 2324 | + $price, |
|
| 2325 | + true, |
|
| 2326 | + null, |
|
| 2327 | + $show_trash, |
|
| 2328 | + $show_create |
|
| 2329 | + ); |
|
| 2330 | + $price_row++; |
|
| 2331 | + } |
|
| 2332 | + $template_args = apply_filters( |
|
| 2333 | + 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', |
|
| 2334 | + $template_args, |
|
| 2335 | + $all_datetimes, |
|
| 2336 | + $all_tickets, |
|
| 2337 | + $this->_is_creating_event |
|
| 2338 | + ); |
|
| 2339 | + return EEH_Template::display_template( |
|
| 2340 | + PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php', |
|
| 2341 | + $template_args, |
|
| 2342 | + true |
|
| 2343 | + ); |
|
| 2344 | + } |
|
| 2345 | 2345 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | protected function _setup_metaboxes() |
| 77 | 77 | { |
| 78 | 78 | // if we were going to add our own metaboxes we'd use the below. |
| 79 | - $this->_metaboxes = [ |
|
| 79 | + $this->_metaboxes = [ |
|
| 80 | 80 | 0 => [ |
| 81 | 81 | 'page_route' => ['edit', 'create_new'], |
| 82 | 82 | 'func' => [$this, 'pricing_metabox'], |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $this->_date_format_strings['date'] = $this->_date_format_strings['date'] ?? ''; |
| 120 | 120 | $this->_date_format_strings['time'] = $this->_date_format_strings['time'] ?? ''; |
| 121 | 121 | |
| 122 | - $this->_date_time_format = $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']; |
|
| 122 | + $this->_date_time_format = $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | ); |
| 144 | 144 | $msg .= '</p><ul>'; |
| 145 | 145 | foreach ($format_validation as $error) { |
| 146 | - $msg .= '<li>' . $error . '</li>'; |
|
| 146 | + $msg .= '<li>'.$error.'</li>'; |
|
| 147 | 147 | } |
| 148 | 148 | $msg .= '</ul><p>'; |
| 149 | 149 | $msg .= sprintf( |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | $this->_scripts_styles = [ |
| 173 | 173 | 'registers' => [ |
| 174 | 174 | 'ee-tickets-datetimes-css' => [ |
| 175 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
| 175 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
| 176 | 176 | 'type' => 'css', |
| 177 | 177 | ], |
| 178 | 178 | 'ee-dtt-ticket-metabox' => [ |
| 179 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
| 179 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
| 180 | 180 | 'depends' => ['ee-datepicker', 'ee-dialog', 'underscore'], |
| 181 | 181 | ], |
| 182 | 182 | ], |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | ), |
| 202 | 202 | 'cancel_button' => ' |
| 203 | 203 | <button class="button--secondary ee-modal-cancel"> |
| 204 | - ' . esc_html__('Cancel', 'event_espresso') . ' |
|
| 204 | + ' . esc_html__('Cancel', 'event_espresso').' |
|
| 205 | 205 | </button>', |
| 206 | 206 | 'close_button' => ' |
| 207 | 207 | <button class="button--secondary ee-modal-cancel"> |
| 208 | - ' . esc_html__('Close', 'event_espresso') . ' |
|
| 208 | + ' . esc_html__('Close', 'event_espresso').' |
|
| 209 | 209 | </button>', |
| 210 | 210 | 'single_warning_from_tkt' => esc_html__( |
| 211 | 211 | 'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | ), |
| 218 | 218 | 'dismiss_button' => ' |
| 219 | 219 | <button class="button--secondary ee-modal-cancel"> |
| 220 | - ' . esc_html__('Dismiss', 'event_espresso') . ' |
|
| 220 | + ' . esc_html__('Dismiss', 'event_espresso').' |
|
| 221 | 221 | </button>', |
| 222 | 222 | ], |
| 223 | 223 | 'DTT_ERROR_MSG' => [ |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | 'dismiss_button' => ' |
| 226 | 226 | <div class="save-cancel-button-container"> |
| 227 | 227 | <button class="button--secondary ee-modal-cancel"> |
| 228 | - ' . esc_html__('Dismiss', 'event_espresso') . ' |
|
| 228 | + ' . esc_html__('Dismiss', 'event_espresso').' |
|
| 229 | 229 | </button> |
| 230 | 230 | </div>', |
| 231 | 231 | ], |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | foreach ($data['edit_event_datetimes'] as $row => $datetime_data) { |
| 315 | 315 | // trim all values to ensure any excess whitespace is removed. |
| 316 | 316 | $datetime_data = array_map( |
| 317 | - function ($datetime_data) { |
|
| 317 | + function($datetime_data) { |
|
| 318 | 318 | return is_array($datetime_data) |
| 319 | 319 | ? $datetime_data |
| 320 | 320 | : trim($datetime_data); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | && ! empty($datetime_data['DTT_EVT_end']) |
| 327 | 327 | ? $datetime_data['DTT_EVT_end'] |
| 328 | 328 | : $datetime_data['DTT_EVT_start']; |
| 329 | - $datetime_values = [ |
|
| 329 | + $datetime_values = [ |
|
| 330 | 330 | 'DTT_ID' => ! empty($datetime_data['DTT_ID']) |
| 331 | 331 | ? $datetime_data['DTT_ID'] |
| 332 | 332 | : null, |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | // if we have an id then let's get existing object first and then set the new values. |
| 350 | 350 | // Otherwise we instantiate a new object for save. |
| 351 | - if (! empty($datetime_data['DTT_ID'])) { |
|
| 351 | + if ( ! empty($datetime_data['DTT_ID'])) { |
|
| 352 | 352 | $datetime = EE_Registry::instance() |
| 353 | 353 | ->load_model('Datetime', [$timezone]) |
| 354 | 354 | ->get_one_by_ID($datetime_data['DTT_ID']); |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | // after the add_relation_to() the autosave replaces it. |
| 364 | 364 | // We need to do this so we dont' TRASH the parent DTT. |
| 365 | 365 | // (save the ID for both key and value to avoid duplications) |
| 366 | - $saved_datetime_ids[ $datetime->ID() ] = $datetime->ID(); |
|
| 366 | + $saved_datetime_ids[$datetime->ID()] = $datetime->ID(); |
|
| 367 | 367 | } else { |
| 368 | 368 | $datetime = EE_Datetime::new_instance( |
| 369 | 369 | $datetime_values, |
@@ -394,8 +394,8 @@ discard block |
||
| 394 | 394 | // because it is possible there was a new one created for the autosave. |
| 395 | 395 | // (save the ID for both key and value to avoid duplications) |
| 396 | 396 | $DTT_ID = $datetime->ID(); |
| 397 | - $saved_datetime_ids[ $DTT_ID ] = $DTT_ID; |
|
| 398 | - $saved_datetime_objs[ $row ] = $datetime; |
|
| 397 | + $saved_datetime_ids[$DTT_ID] = $DTT_ID; |
|
| 398 | + $saved_datetime_objs[$row] = $datetime; |
|
| 399 | 399 | // @todo if ANY of these updates fail then we want the appropriate global error message. |
| 400 | 400 | } |
| 401 | 401 | $event->save(); |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | $update_prices = $create_new_TKT = false; |
| 466 | 466 | // figure out what datetimes were added to the ticket |
| 467 | 467 | // and what datetimes were removed from the ticket in the session. |
| 468 | - $starting_ticket_datetime_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]); |
|
| 469 | - $ticket_datetime_rows = explode(',', $data['ticket_datetime_rows'][ $row ]); |
|
| 468 | + $starting_ticket_datetime_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
| 469 | + $ticket_datetime_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
| 470 | 470 | $datetimes_added = array_diff($ticket_datetime_rows, $starting_ticket_datetime_rows); |
| 471 | 471 | $datetimes_removed = array_diff($starting_ticket_datetime_rows, $ticket_datetime_rows); |
| 472 | 472 | // trim inputs to ensure any excess whitespace is removed. |
| 473 | 473 | $ticket_data = array_map( |
| 474 | - function ($ticket_data) { |
|
| 474 | + function($ticket_data) { |
|
| 475 | 475 | return is_array($ticket_data) |
| 476 | 476 | ? $ticket_data |
| 477 | 477 | : trim($ticket_data); |
@@ -493,8 +493,8 @@ discard block |
||
| 493 | 493 | ? $base_price |
| 494 | 494 | : $ticket_price; |
| 495 | 495 | $base_price_id = $ticket_data['TKT_base_price_ID'] ?? 0; |
| 496 | - $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ]) |
|
| 497 | - ? $data['edit_prices'][ $row ] |
|
| 496 | + $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) |
|
| 497 | + ? $data['edit_prices'][$row] |
|
| 498 | 498 | : []; |
| 499 | 499 | $now = null; |
| 500 | 500 | if (empty($ticket_data['TKT_start_date'])) { |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | /** |
| 507 | 507 | * set the TKT_end_date to the first datetime attached to the ticket. |
| 508 | 508 | */ |
| 509 | - $first_datetime = $saved_datetimes[ reset($ticket_datetime_rows) ]; |
|
| 509 | + $first_datetime = $saved_datetimes[reset($ticket_datetime_rows)]; |
|
| 510 | 510 | $ticket_data['TKT_end_date'] = $first_datetime->start_date_and_time($this->_date_time_format); |
| 511 | 511 | } |
| 512 | 512 | $TKT_values = [ |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | if ($ticket instanceof EE_Ticket) { |
| 622 | 622 | // make sure ticket has an ID of setting relations won't work |
| 623 | 623 | $ticket->save(); |
| 624 | - $ticket = $this->_update_ticket_datetimes( |
|
| 624 | + $ticket = $this->_update_ticket_datetimes( |
|
| 625 | 625 | $ticket, |
| 626 | 626 | $saved_datetimes, |
| 627 | 627 | $datetimes_added, |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | // need to make sue that the TKT_price is accurate after saving the prices. |
| 656 | 656 | $ticket->ensure_TKT_Price_correct(); |
| 657 | 657 | // handle CREATING a default ticket from the incoming ticket but ONLY if this isn't an autosave. |
| 658 | - if (! defined('DOING_AUTOSAVE') && ! empty($ticket_data['TKT_is_default_selector'])) { |
|
| 658 | + if ( ! defined('DOING_AUTOSAVE') && ! empty($ticket_data['TKT_is_default_selector'])) { |
|
| 659 | 659 | $new_default = clone $ticket; |
| 660 | 660 | $new_default->set('TKT_ID', 0); |
| 661 | 661 | $new_default->set('TKT_is_default', 1); |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | // save new TKT |
| 700 | 700 | $new_ticket->save(); |
| 701 | 701 | // add new ticket to array |
| 702 | - $saved_tickets[ $new_ticket->ID() ] = $new_ticket; |
|
| 702 | + $saved_tickets[$new_ticket->ID()] = $new_ticket; |
|
| 703 | 703 | do_action( |
| 704 | 704 | 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', |
| 705 | 705 | $new_ticket, |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | ); |
| 710 | 710 | } else { |
| 711 | 711 | // add ticket to saved tickets |
| 712 | - $saved_tickets[ $ticket->ID() ] = $ticket; |
|
| 712 | + $saved_tickets[$ticket->ID()] = $ticket; |
|
| 713 | 713 | do_action( |
| 714 | 714 | 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', |
| 715 | 715 | $ticket, |
@@ -779,25 +779,25 @@ discard block |
||
| 779 | 779 | // to start we have to add the ticket to all the datetimes its supposed to be with, |
| 780 | 780 | // and removing the ticket from datetimes it got removed from. |
| 781 | 781 | // first let's add datetimes |
| 782 | - if (! empty($added_datetimes) && is_array($added_datetimes)) { |
|
| 782 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
| 783 | 783 | foreach ($added_datetimes as $row_id) { |
| 784 | - if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) { |
|
| 785 | - $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime'); |
|
| 784 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
| 785 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
| 786 | 786 | // Is this an existing ticket (has an ID) and does it have any sold? |
| 787 | 787 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
| 788 | 788 | if ($ticket->ID() && $ticket->sold() > 0) { |
| 789 | - $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false); |
|
| 789 | + $saved_datetimes[$row_id]->increaseSold($ticket->sold(), false); |
|
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | } |
| 793 | 793 | } |
| 794 | 794 | // then remove datetimes |
| 795 | - if (! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
| 795 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
| 796 | 796 | foreach ($removed_datetimes as $row_id) { |
| 797 | 797 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
| 798 | 798 | // So make sure we skip over this if the datetime isn't in the $saved_datetimes array) |
| 799 | - if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) { |
|
| 800 | - $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime'); |
|
| 799 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
| 800 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | 803 | } |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | ]; |
| 912 | 912 | } |
| 913 | 913 | // possibly need to save ticket |
| 914 | - if (! $ticket->ID()) { |
|
| 914 | + if ( ! $ticket->ID()) { |
|
| 915 | 915 | $ticket->save(); |
| 916 | 916 | } |
| 917 | 917 | foreach ($prices as $row => $prc) { |
@@ -955,17 +955,17 @@ discard block |
||
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | 957 | $price->save(); |
| 958 | - $updated_prices[ $price->ID() ] = $price; |
|
| 958 | + $updated_prices[$price->ID()] = $price; |
|
| 959 | 959 | $ticket->_add_relation_to($price, 'Price'); |
| 960 | 960 | } |
| 961 | 961 | // now let's remove any prices that got removed from the ticket |
| 962 | - if (! empty($current_prices_on_ticket)) { |
|
| 962 | + if ( ! empty($current_prices_on_ticket)) { |
|
| 963 | 963 | $current = array_keys($current_prices_on_ticket); |
| 964 | 964 | $updated = array_keys($updated_prices); |
| 965 | 965 | $prices_to_remove = array_diff($current, $updated); |
| 966 | - if (! empty($prices_to_remove)) { |
|
| 966 | + if ( ! empty($prices_to_remove)) { |
|
| 967 | 967 | foreach ($prices_to_remove as $prc_id) { |
| 968 | - $p = $current_prices_on_ticket[ $prc_id ]; |
|
| 968 | + $p = $current_prices_on_ticket[$prc_id]; |
|
| 969 | 969 | $ticket->_remove_relation_to($p, 'Price'); |
| 970 | 970 | // delete permanently the price |
| 971 | 971 | $p->delete_or_restore(); |
@@ -1081,18 +1081,18 @@ discard block |
||
| 1081 | 1081 | $TKT_ID = $ticket->get('TKT_ID'); |
| 1082 | 1082 | $ticket_row = $ticket->get('TKT_row'); |
| 1083 | 1083 | // we only want unique tickets in our final display!! |
| 1084 | - if (! in_array($TKT_ID, $existing_ticket_ids, true)) { |
|
| 1084 | + if ( ! in_array($TKT_ID, $existing_ticket_ids, true)) { |
|
| 1085 | 1085 | $existing_ticket_ids[] = $TKT_ID; |
| 1086 | 1086 | $all_tickets[] = $ticket; |
| 1087 | 1087 | } |
| 1088 | 1088 | // temporary cache of this ticket info for this datetime for later processing of datetime rows. |
| 1089 | - $datetime_tickets[ $DTT_ID ][] = $ticket_row; |
|
| 1089 | + $datetime_tickets[$DTT_ID][] = $ticket_row; |
|
| 1090 | 1090 | // temporary cache of this datetime info for this ticket for later processing of ticket rows. |
| 1091 | 1091 | if ( |
| 1092 | - ! isset($ticket_datetimes[ $TKT_ID ]) |
|
| 1093 | - || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true) |
|
| 1092 | + ! isset($ticket_datetimes[$TKT_ID]) |
|
| 1093 | + || ! in_array($datetime_row, $ticket_datetimes[$TKT_ID], true) |
|
| 1094 | 1094 | ) { |
| 1095 | - $ticket_datetimes[ $TKT_ID ][] = $datetime_row; |
|
| 1095 | + $ticket_datetimes[$TKT_ID][] = $datetime_row; |
|
| 1096 | 1096 | } |
| 1097 | 1097 | } |
| 1098 | 1098 | $datetime_row++; |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | // sort $all_tickets by order |
| 1104 | 1104 | usort( |
| 1105 | 1105 | $all_tickets, |
| 1106 | - function (EE_Ticket $a, EE_Ticket $b) { |
|
| 1106 | + function(EE_Ticket $a, EE_Ticket $b) { |
|
| 1107 | 1107 | $a_order = (int) $a->get('TKT_order'); |
| 1108 | 1108 | $b_order = (int) $b->get('TKT_order'); |
| 1109 | 1109 | if ($a_order === $b_order) { |
@@ -1153,7 +1153,7 @@ discard block |
||
| 1153 | 1153 | ); |
| 1154 | 1154 | |
| 1155 | 1155 | EEH_Template::display_template( |
| 1156 | - PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php', |
|
| 1156 | + PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php', |
|
| 1157 | 1157 | $main_template_args |
| 1158 | 1158 | ); |
| 1159 | 1159 | } |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | array $all_datetimes = [] |
| 1181 | 1181 | ): string { |
| 1182 | 1182 | return EEH_Template::display_template( |
| 1183 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php', |
|
| 1183 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php', |
|
| 1184 | 1184 | [ |
| 1185 | 1185 | 'dtt_edit_row' => $this->_get_dtt_edit_row( |
| 1186 | 1186 | $datetime_row, |
@@ -1298,7 +1298,7 @@ discard block |
||
| 1298 | 1298 | $this->_is_creating_event |
| 1299 | 1299 | ); |
| 1300 | 1300 | return EEH_Template::display_template( |
| 1301 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php', |
|
| 1301 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php', |
|
| 1302 | 1302 | $template_args, |
| 1303 | 1303 | true |
| 1304 | 1304 | ); |
@@ -1348,7 +1348,7 @@ discard block |
||
| 1348 | 1348 | : $datetime->ID(), |
| 1349 | 1349 | ]; |
| 1350 | 1350 | // need to setup the list items (but only if this isn't a default skeleton setup) |
| 1351 | - if (! $default) { |
|
| 1351 | + if ( ! $default) { |
|
| 1352 | 1352 | $ticket_row = 1; |
| 1353 | 1353 | foreach ($all_tickets as $ticket) { |
| 1354 | 1354 | $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( |
@@ -1373,7 +1373,7 @@ discard block |
||
| 1373 | 1373 | $this->_is_creating_event |
| 1374 | 1374 | ); |
| 1375 | 1375 | return EEH_Template::display_template( |
| 1376 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php', |
|
| 1376 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php', |
|
| 1377 | 1377 | $template_args, |
| 1378 | 1378 | true |
| 1379 | 1379 | ); |
@@ -1399,8 +1399,8 @@ discard block |
||
| 1399 | 1399 | array $datetime_tickets = [], |
| 1400 | 1400 | bool $default = false |
| 1401 | 1401 | ): string { |
| 1402 | - $datetime_tickets = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ]) |
|
| 1403 | - ? $datetime_tickets[ $datetime->ID() ] |
|
| 1402 | + $datetime_tickets = $datetime instanceof EE_Datetime && isset($datetime_tickets[$datetime->ID()]) |
|
| 1403 | + ? $datetime_tickets[$datetime->ID()] |
|
| 1404 | 1404 | : []; |
| 1405 | 1405 | $display_row = $ticket instanceof EE_Ticket |
| 1406 | 1406 | ? $ticket->get('TKT_row') |
@@ -1423,8 +1423,8 @@ discard block |
||
| 1423 | 1423 | ? 'TKTNAME' |
| 1424 | 1424 | : $ticket->get('TKT_name'), |
| 1425 | 1425 | 'tkt_status_class' => $no_ticket || $this->_is_creating_event |
| 1426 | - ? ' tkt-status-' . EE_Ticket::onsale |
|
| 1427 | - : ' tkt-status-' . $ticket->ticket_status(), |
|
| 1426 | + ? ' tkt-status-'.EE_Ticket::onsale |
|
| 1427 | + : ' tkt-status-'.$ticket->ticket_status(), |
|
| 1428 | 1428 | ]; |
| 1429 | 1429 | // filter template args |
| 1430 | 1430 | $template_args = apply_filters( |
@@ -1439,7 +1439,7 @@ discard block |
||
| 1439 | 1439 | $this->_is_creating_event |
| 1440 | 1440 | ); |
| 1441 | 1441 | return EEH_Template::display_template( |
| 1442 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php', |
|
| 1442 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php', |
|
| 1443 | 1443 | $template_args, |
| 1444 | 1444 | true |
| 1445 | 1445 | ); |
@@ -1497,8 +1497,8 @@ discard block |
||
| 1497 | 1497 | // (otherwise there won't be any new relationships created for tickets based off of the default ticket). |
| 1498 | 1498 | // This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
| 1499 | 1499 | $default_datetime = $default || ($ticket instanceof EE_Ticket && $ticket->is_default()); |
| 1500 | - $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ]) |
|
| 1501 | - ? $ticket_datetimes[ $ticket->ID() ] |
|
| 1500 | + $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) |
|
| 1501 | + ? $ticket_datetimes[$ticket->ID()] |
|
| 1502 | 1502 | : []; |
| 1503 | 1503 | $ticket_subtotal = $default |
| 1504 | 1504 | ? 0 |
@@ -1509,11 +1509,11 @@ discard block |
||
| 1509 | 1509 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(true); |
| 1510 | 1510 | // breaking out complicated condition for ticket_status |
| 1511 | 1511 | if ($default) { |
| 1512 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1512 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
| 1513 | 1513 | } else { |
| 1514 | 1514 | $ticket_status_class = $ticket->is_default() |
| 1515 | - ? ' tkt-status-' . EE_Ticket::onsale |
|
| 1516 | - : ' tkt-status-' . $ticket->ticket_status(); |
|
| 1515 | + ? ' tkt-status-'.EE_Ticket::onsale |
|
| 1516 | + : ' tkt-status-'.$ticket->ticket_status(); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | // breaking out complicated condition for TKT_taxable |
| 1519 | 1519 | if ($default) { |
@@ -1538,7 +1538,7 @@ discard block |
||
| 1538 | 1538 | $TKT_min = ''; |
| 1539 | 1539 | } |
| 1540 | 1540 | } |
| 1541 | - $template_args = [ |
|
| 1541 | + $template_args = [ |
|
| 1542 | 1542 | 'tkt_row' => $default |
| 1543 | 1543 | ? 'TICKETNUM' |
| 1544 | 1544 | : $ticket_row, |
@@ -1629,7 +1629,7 @@ discard block |
||
| 1629 | 1629 | : 'display:none;', |
| 1630 | 1630 | 'show_price_mod_button' => count($prices) > 1 |
| 1631 | 1631 | || ($default && $count_price_mods > 0) |
| 1632 | - || (! $default && $ticket->deleted()) |
|
| 1632 | + || ( ! $default && $ticket->deleted()) |
|
| 1633 | 1633 | ? 'display:none;' |
| 1634 | 1634 | : '', |
| 1635 | 1635 | 'total_price_rows' => count($prices) > 1 |
@@ -1674,7 +1674,7 @@ discard block |
||
| 1674 | 1674 | |
| 1675 | 1675 | 'can_clone' => $ticket instanceof EE_Ticket && ! $ticket->deleted(), |
| 1676 | 1676 | 'can_trash' => $ticket instanceof EE_Ticket |
| 1677 | - && (! $ticket->deleted() && $ticket->is_permanently_deleteable()), |
|
| 1677 | + && ( ! $ticket->deleted() && $ticket->is_permanently_deleteable()), |
|
| 1678 | 1678 | ]; |
| 1679 | 1679 | $template_args['trash_hidden'] = count($all_tickets) === 1 |
| 1680 | 1680 | && $template_args['trash_icon'] !== 'dashicons dashicons-lock' |
@@ -1683,11 +1683,11 @@ discard block |
||
| 1683 | 1683 | // handle rows that should NOT be empty |
| 1684 | 1684 | if (empty($template_args['TKT_start_date'])) { |
| 1685 | 1685 | // if empty then the start date will be now. |
| 1686 | - $template_args['TKT_start_date'] = date( |
|
| 1686 | + $template_args['TKT_start_date'] = date( |
|
| 1687 | 1687 | $this->_date_time_format, |
| 1688 | 1688 | current_time('timestamp') |
| 1689 | 1689 | ); |
| 1690 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1690 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
| 1691 | 1691 | } |
| 1692 | 1692 | if (empty($template_args['TKT_end_date'])) { |
| 1693 | 1693 | // get the earliest datetime (if present); |
@@ -1697,7 +1697,7 @@ discard block |
||
| 1697 | 1697 | ['order_by' => ['DTT_EVT_start' => 'ASC']] |
| 1698 | 1698 | ) |
| 1699 | 1699 | : null; |
| 1700 | - if (! empty($earliest_datetime)) { |
|
| 1700 | + if ( ! empty($earliest_datetime)) { |
|
| 1701 | 1701 | $template_args['TKT_end_date'] = $earliest_datetime->get_datetime( |
| 1702 | 1702 | 'DTT_EVT_start', |
| 1703 | 1703 | $this->_date_time_format |
@@ -1716,10 +1716,10 @@ discard block |
||
| 1716 | 1716 | ) |
| 1717 | 1717 | ); |
| 1718 | 1718 | } |
| 1719 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
| 1719 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
| 1720 | 1720 | } |
| 1721 | 1721 | // generate ticket_datetime items |
| 1722 | - if (! $default) { |
|
| 1722 | + if ( ! $default) { |
|
| 1723 | 1723 | $datetime_row = 1; |
| 1724 | 1724 | foreach ($all_datetimes as $datetime) { |
| 1725 | 1725 | $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( |
@@ -1735,7 +1735,7 @@ discard block |
||
| 1735 | 1735 | } |
| 1736 | 1736 | $price_row = 1; |
| 1737 | 1737 | foreach ($prices as $price) { |
| 1738 | - if (! $price instanceof EE_Price) { |
|
| 1738 | + if ( ! $price instanceof EE_Price) { |
|
| 1739 | 1739 | continue; |
| 1740 | 1740 | } |
| 1741 | 1741 | if ($price->is_base_price()) { |
@@ -1770,7 +1770,7 @@ discard block |
||
| 1770 | 1770 | $this->_is_creating_event |
| 1771 | 1771 | ); |
| 1772 | 1772 | return EEH_Template::display_template( |
| 1773 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php', |
|
| 1773 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php', |
|
| 1774 | 1774 | $template_args, |
| 1775 | 1775 | true |
| 1776 | 1776 | ); |
@@ -1810,8 +1810,8 @@ discard block |
||
| 1810 | 1810 | $ticket, |
| 1811 | 1811 | $this->_is_creating_event |
| 1812 | 1812 | ); |
| 1813 | - $tax_rows .= EEH_Template::display_template( |
|
| 1814 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php', |
|
| 1813 | + $tax_rows .= EEH_Template::display_template( |
|
| 1814 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php', |
|
| 1815 | 1815 | $template_args, |
| 1816 | 1816 | true |
| 1817 | 1817 | ); |
@@ -1931,7 +1931,7 @@ discard block |
||
| 1931 | 1931 | $this->_is_creating_event |
| 1932 | 1932 | ); |
| 1933 | 1933 | return EEH_Template::display_template( |
| 1934 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php', |
|
| 1934 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php', |
|
| 1935 | 1935 | $template_args, |
| 1936 | 1936 | true |
| 1937 | 1937 | ); |
@@ -1959,7 +1959,7 @@ discard block |
||
| 1959 | 1959 | bool $default, |
| 1960 | 1960 | bool $disabled = false |
| 1961 | 1961 | ): string { |
| 1962 | - if (($price instanceof EE_Price && $price->is_base_price()) || (! $price instanceof EE_Price && $default)) { |
|
| 1962 | + if (($price instanceof EE_Price && $price->is_base_price()) || ( ! $price instanceof EE_Price && $default)) { |
|
| 1963 | 1963 | return $this->_get_base_price_template( |
| 1964 | 1964 | $ticket_row, |
| 1965 | 1965 | $price_row, |
@@ -2017,7 +2017,7 @@ discard block |
||
| 2017 | 2017 | $this->_is_creating_event |
| 2018 | 2018 | ); |
| 2019 | 2019 | return EEH_Template::display_template( |
| 2020 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php', |
|
| 2020 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php', |
|
| 2021 | 2021 | $template_args, |
| 2022 | 2022 | true |
| 2023 | 2023 | ); |
@@ -2046,11 +2046,11 @@ discard block |
||
| 2046 | 2046 | bool $disabled = false |
| 2047 | 2047 | ): string { |
| 2048 | 2048 | $use_default = $default && ! $price instanceof EE_Price; |
| 2049 | - $selected_price_type_id = $use_default ? 0 : $price->type(); |
|
| 2049 | + $selected_price_type_id = $use_default ? 0 : $price->type(); |
|
| 2050 | 2050 | |
| 2051 | 2051 | $select_name = $use_default |
| 2052 | 2052 | ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' |
| 2053 | - : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]'; |
|
| 2053 | + : 'edit_prices['.esc_attr($ticket_row).']['.esc_attr($price_row).'][PRT_ID]'; |
|
| 2054 | 2054 | |
| 2055 | 2055 | $price_type_model = EEM_Price_Type::instance(); |
| 2056 | 2056 | $price_types = $price_type_model->get_all([['NOT' => ['PBT_ID' => '1']]]); |
@@ -2060,12 +2060,12 @@ discard block |
||
| 2060 | 2060 | $price_option_spans = ''; |
| 2061 | 2061 | // setup price types for selector |
| 2062 | 2062 | foreach ($price_types as $price_type) { |
| 2063 | - if (! $price_type instanceof EE_Price_Type) { |
|
| 2063 | + if ( ! $price_type instanceof EE_Price_Type) { |
|
| 2064 | 2064 | continue; |
| 2065 | 2065 | } |
| 2066 | - $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name'); |
|
| 2066 | + $all_price_types[$price_type->ID()] = $price_type->get('PRT_name'); |
|
| 2067 | 2067 | // while we're in the loop lets set up the option spans used by js |
| 2068 | - $span_args = [ |
|
| 2068 | + $span_args = [ |
|
| 2069 | 2069 | 'PRT_ID' => $price_type->ID(), |
| 2070 | 2070 | 'PRT_operator' => $price_type->is_discount() |
| 2071 | 2071 | ? '-' |
@@ -2075,14 +2075,14 @@ discard block |
||
| 2075 | 2075 | : 0, |
| 2076 | 2076 | ]; |
| 2077 | 2077 | $price_option_spans .= EEH_Template::display_template( |
| 2078 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php', |
|
| 2078 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php', |
|
| 2079 | 2079 | $span_args, |
| 2080 | 2080 | true |
| 2081 | 2081 | ); |
| 2082 | 2082 | } |
| 2083 | 2083 | |
| 2084 | 2084 | $select_name = $disabled |
| 2085 | - ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]' |
|
| 2085 | + ? 'archive_price['.$ticket_row.']['.$price_row.'][PRT_ID]' |
|
| 2086 | 2086 | : $select_name; |
| 2087 | 2087 | |
| 2088 | 2088 | $select_input = new EE_Select_Input( |
@@ -2124,7 +2124,7 @@ discard block |
||
| 2124 | 2124 | 'price_selected_is_percent' => $price_selected_is_percent, |
| 2125 | 2125 | 'disabled' => $disabled, |
| 2126 | 2126 | ]; |
| 2127 | - $template_args = apply_filters( |
|
| 2127 | + $template_args = apply_filters( |
|
| 2128 | 2128 | 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', |
| 2129 | 2129 | $template_args, |
| 2130 | 2130 | $ticket_row, |
@@ -2135,7 +2135,7 @@ discard block |
||
| 2135 | 2135 | $this->_is_creating_event |
| 2136 | 2136 | ); |
| 2137 | 2137 | return EEH_Template::display_template( |
| 2138 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php', |
|
| 2138 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php', |
|
| 2139 | 2139 | $template_args, |
| 2140 | 2140 | true |
| 2141 | 2141 | ); |
@@ -2162,8 +2162,8 @@ discard block |
||
| 2162 | 2162 | array $ticket_datetimes = [], |
| 2163 | 2163 | bool $default = false |
| 2164 | 2164 | ): string { |
| 2165 | - $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ]) |
|
| 2166 | - ? $ticket_datetimes[ $ticket->ID() ] |
|
| 2165 | + $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) |
|
| 2166 | + ? $ticket_datetimes[$ticket->ID()] |
|
| 2167 | 2167 | : []; |
| 2168 | 2168 | $template_args = [ |
| 2169 | 2169 | 'dtt_row' => $default && ! $datetime instanceof EE_Datetime |
@@ -2195,7 +2195,7 @@ discard block |
||
| 2195 | 2195 | $this->_is_creating_event |
| 2196 | 2196 | ); |
| 2197 | 2197 | return EEH_Template::display_template( |
| 2198 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php', |
|
| 2198 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php', |
|
| 2199 | 2199 | $template_args, |
| 2200 | 2200 | true |
| 2201 | 2201 | ); |
@@ -2273,7 +2273,7 @@ discard block |
||
| 2273 | 2273 | true |
| 2274 | 2274 | ), |
| 2275 | 2275 | ]; |
| 2276 | - $ticket_row = 1; |
|
| 2276 | + $ticket_row = 1; |
|
| 2277 | 2277 | foreach ($all_tickets as $ticket) { |
| 2278 | 2278 | $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( |
| 2279 | 2279 | 'DTTNUM', |
@@ -2301,11 +2301,11 @@ discard block |
||
| 2301 | 2301 | $default_prices = $price_model->get_all_default_prices(); |
| 2302 | 2302 | $price_row = 1; |
| 2303 | 2303 | foreach ($default_prices as $price) { |
| 2304 | - if (! $price instanceof EE_Price) { |
|
| 2304 | + if ( ! $price instanceof EE_Price) { |
|
| 2305 | 2305 | continue; |
| 2306 | 2306 | } |
| 2307 | 2307 | if ($price->is_base_price()) { |
| 2308 | - $template_args['default_base_price_amount'] = $price->get_pretty( |
|
| 2308 | + $template_args['default_base_price_amount'] = $price->get_pretty( |
|
| 2309 | 2309 | 'PRC_amount', |
| 2310 | 2310 | 'localized_float' |
| 2311 | 2311 | ); |
@@ -2337,7 +2337,7 @@ discard block |
||
| 2337 | 2337 | $this->_is_creating_event |
| 2338 | 2338 | ); |
| 2339 | 2339 | return EEH_Template::display_template( |
| 2340 | - PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php', |
|
| 2340 | + PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php', |
|
| 2341 | 2341 | $template_args, |
| 2342 | 2342 | true |
| 2343 | 2343 | ); |
@@ -10,283 +10,283 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Custom_Messages_Template_List_Table extends Messages_Template_List_Table |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Setup initial data. |
|
| 15 | - * |
|
| 16 | - * @throws EE_Error |
|
| 17 | - * @throws ReflectionException |
|
| 18 | - */ |
|
| 19 | - protected function _setup_data() |
|
| 20 | - { |
|
| 21 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
| 22 | - $this->_per_page, |
|
| 23 | - $this->_view, |
|
| 24 | - false, |
|
| 25 | - false, |
|
| 26 | - false |
|
| 27 | - ); |
|
| 28 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
| 29 | - $this->_per_page, |
|
| 30 | - $this->_view, |
|
| 31 | - true, |
|
| 32 | - true, |
|
| 33 | - false |
|
| 34 | - ); |
|
| 35 | - } |
|
| 13 | + /** |
|
| 14 | + * Setup initial data. |
|
| 15 | + * |
|
| 16 | + * @throws EE_Error |
|
| 17 | + * @throws ReflectionException |
|
| 18 | + */ |
|
| 19 | + protected function _setup_data() |
|
| 20 | + { |
|
| 21 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
| 22 | + $this->_per_page, |
|
| 23 | + $this->_view, |
|
| 24 | + false, |
|
| 25 | + false, |
|
| 26 | + false |
|
| 27 | + ); |
|
| 28 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
| 29 | + $this->_per_page, |
|
| 30 | + $this->_view, |
|
| 31 | + true, |
|
| 32 | + true, |
|
| 33 | + false |
|
| 34 | + ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Set initial properties |
|
| 40 | - */ |
|
| 41 | - protected function _set_properties() |
|
| 42 | - { |
|
| 43 | - parent::_set_properties(); |
|
| 44 | - $this->_wp_list_args = [ |
|
| 45 | - 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
| 46 | - 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
| 47 | - 'ajax' => true, // for now, |
|
| 48 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
| 49 | - ]; |
|
| 38 | + /** |
|
| 39 | + * Set initial properties |
|
| 40 | + */ |
|
| 41 | + protected function _set_properties() |
|
| 42 | + { |
|
| 43 | + parent::_set_properties(); |
|
| 44 | + $this->_wp_list_args = [ |
|
| 45 | + 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
| 46 | + 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
| 47 | + 'ajax' => true, // for now, |
|
| 48 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
| 49 | + ]; |
|
| 50 | 50 | |
| 51 | - $this->_columns = array_merge( |
|
| 52 | - [ |
|
| 53 | - 'cb' => '<input type="checkbox" />', |
|
| 54 | - 'name' => esc_html__('Template Name', 'event_espresso'), |
|
| 55 | - ], |
|
| 56 | - $this->_columns, |
|
| 57 | - [ |
|
| 58 | - 'events' => esc_html__('Events', 'event_espresso'), |
|
| 59 | - 'actions' => $this->actionsColumnHeader(), |
|
| 60 | - ] |
|
| 61 | - ); |
|
| 62 | - } |
|
| 51 | + $this->_columns = array_merge( |
|
| 52 | + [ |
|
| 53 | + 'cb' => '<input type="checkbox" />', |
|
| 54 | + 'name' => esc_html__('Template Name', 'event_espresso'), |
|
| 55 | + ], |
|
| 56 | + $this->_columns, |
|
| 57 | + [ |
|
| 58 | + 'events' => esc_html__('Events', 'event_espresso'), |
|
| 59 | + 'actions' => $this->actionsColumnHeader(), |
|
| 60 | + ] |
|
| 61 | + ); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Custom message for when there are no items found. |
|
| 67 | - * |
|
| 68 | - * @since 4.3.0 |
|
| 69 | - */ |
|
| 70 | - public function no_items() |
|
| 71 | - { |
|
| 72 | - if ($this->_view !== 'trashed') { |
|
| 73 | - printf( |
|
| 74 | - esc_html__( |
|
| 75 | - '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
| 76 | - 'event_espresso' |
|
| 77 | - ), |
|
| 78 | - '<strong>', |
|
| 79 | - '</strong>' |
|
| 80 | - ); |
|
| 81 | - } else { |
|
| 82 | - parent::no_items(); |
|
| 83 | - } |
|
| 84 | - } |
|
| 65 | + /** |
|
| 66 | + * Custom message for when there are no items found. |
|
| 67 | + * |
|
| 68 | + * @since 4.3.0 |
|
| 69 | + */ |
|
| 70 | + public function no_items() |
|
| 71 | + { |
|
| 72 | + if ($this->_view !== 'trashed') { |
|
| 73 | + printf( |
|
| 74 | + esc_html__( |
|
| 75 | + '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
| 76 | + 'event_espresso' |
|
| 77 | + ), |
|
| 78 | + '<strong>', |
|
| 79 | + '</strong>' |
|
| 80 | + ); |
|
| 81 | + } else { |
|
| 82 | + parent::no_items(); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @param EE_Message_Template_Group $item |
|
| 89 | - * @return string |
|
| 90 | - * @throws EE_Error |
|
| 91 | - */ |
|
| 92 | - public function column_cb($item) |
|
| 93 | - { |
|
| 94 | - return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
| 95 | - } |
|
| 87 | + /** |
|
| 88 | + * @param EE_Message_Template_Group $item |
|
| 89 | + * @return string |
|
| 90 | + * @throws EE_Error |
|
| 91 | + */ |
|
| 92 | + public function column_cb($item) |
|
| 93 | + { |
|
| 94 | + return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * @param EE_Message_Template_Group $item |
|
| 100 | - * @return string |
|
| 101 | - * @throws EE_Error |
|
| 102 | - */ |
|
| 103 | - public function column_name(EE_Message_Template_Group $item): string |
|
| 104 | - { |
|
| 105 | - return '<p>' . $item->name() . '</p>'; |
|
| 106 | - } |
|
| 98 | + /** |
|
| 99 | + * @param EE_Message_Template_Group $item |
|
| 100 | + * @return string |
|
| 101 | + * @throws EE_Error |
|
| 102 | + */ |
|
| 103 | + public function column_name(EE_Message_Template_Group $item): string |
|
| 104 | + { |
|
| 105 | + return '<p>' . $item->name() . '</p>'; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @param EE_Message_Template_Group $item |
|
| 111 | - * @return string |
|
| 112 | - * @throws EE_Error |
|
| 113 | - * @throws EE_Error |
|
| 114 | - * @throws ReflectionException |
|
| 115 | - */ |
|
| 116 | - public function column_actions(EE_Message_Template_Group $item): string |
|
| 117 | - { |
|
| 118 | - $actions = ''; |
|
| 119 | - if ( |
|
| 120 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 121 | - 'ee_edit_messages', |
|
| 122 | - 'espresso_messages_add_new_message_template' |
|
| 123 | - ) |
|
| 124 | - ) { |
|
| 125 | - $create_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 126 | - [ |
|
| 127 | - 'GRP_ID' => $item->ID(), |
|
| 128 | - 'messenger' => $item->messenger(), |
|
| 129 | - 'message_type' => $item->message_type(), |
|
| 130 | - 'action' => 'add_new_message_template', |
|
| 131 | - ], |
|
| 132 | - EE_MSG_ADMIN_URL |
|
| 133 | - ); |
|
| 109 | + /** |
|
| 110 | + * @param EE_Message_Template_Group $item |
|
| 111 | + * @return string |
|
| 112 | + * @throws EE_Error |
|
| 113 | + * @throws EE_Error |
|
| 114 | + * @throws ReflectionException |
|
| 115 | + */ |
|
| 116 | + public function column_actions(EE_Message_Template_Group $item): string |
|
| 117 | + { |
|
| 118 | + $actions = ''; |
|
| 119 | + if ( |
|
| 120 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 121 | + 'ee_edit_messages', |
|
| 122 | + 'espresso_messages_add_new_message_template' |
|
| 123 | + ) |
|
| 124 | + ) { |
|
| 125 | + $create_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 126 | + [ |
|
| 127 | + 'GRP_ID' => $item->ID(), |
|
| 128 | + 'messenger' => $item->messenger(), |
|
| 129 | + 'message_type' => $item->message_type(), |
|
| 130 | + 'action' => 'add_new_message_template', |
|
| 131 | + ], |
|
| 132 | + EE_MSG_ADMIN_URL |
|
| 133 | + ); |
|
| 134 | 134 | |
| 135 | - $actions .= " |
|
| 135 | + $actions .= " |
|
| 136 | 136 | <a href='$create_link' |
| 137 | 137 | aria-label='" . esc_html__('Create Custom Message Template', 'event_espresso') . "' |
| 138 | 138 | class='ee-aria-tooltip button button--icon-only' |
| 139 | 139 | > |
| 140 | 140 | <span class='dashicons dashicons-admin-customizer'></span> |
| 141 | 141 | </a>"; |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | - if ( |
|
| 146 | - ! $item->get('MTP_deleted') |
|
| 147 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 148 | - 'ee_delete_message', |
|
| 149 | - 'espresso_messages_trash_message_template', |
|
| 150 | - $item->ID() |
|
| 151 | - ) |
|
| 152 | - ) { |
|
| 153 | - // add additional actions for trash/restore etc. |
|
| 154 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 155 | - [ |
|
| 156 | - 'action' => 'trash_message_template', |
|
| 157 | - 'id' => $item->GRP_ID(), |
|
| 158 | - 'noheader' => true, |
|
| 159 | - ], |
|
| 160 | - EE_MSG_ADMIN_URL |
|
| 161 | - ); |
|
| 162 | - $actions .= ' |
|
| 145 | + if ( |
|
| 146 | + ! $item->get('MTP_deleted') |
|
| 147 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 148 | + 'ee_delete_message', |
|
| 149 | + 'espresso_messages_trash_message_template', |
|
| 150 | + $item->ID() |
|
| 151 | + ) |
|
| 152 | + ) { |
|
| 153 | + // add additional actions for trash/restore etc. |
|
| 154 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 155 | + [ |
|
| 156 | + 'action' => 'trash_message_template', |
|
| 157 | + 'id' => $item->GRP_ID(), |
|
| 158 | + 'noheader' => true, |
|
| 159 | + ], |
|
| 160 | + EE_MSG_ADMIN_URL |
|
| 161 | + ); |
|
| 162 | + $actions .= ' |
|
| 163 | 163 | <a href="' . $trash_lnk_url . '" |
| 164 | 164 | aria-label="' . esc_attr__('Move Template Group to Trash', 'event_espresso') . '" |
| 165 | 165 | class="ee-aria-tooltip button button--icon-only" |
| 166 | 166 | > |
| 167 | 167 | <span class="dashicons dashicons-trash"></span> |
| 168 | 168 | </a>'; |
| 169 | - } else { |
|
| 170 | - if ( |
|
| 171 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 172 | - 'ee_delete_message', |
|
| 173 | - 'espresso_messages_restore_message_template', |
|
| 174 | - $item->ID() |
|
| 175 | - ) |
|
| 176 | - ) { |
|
| 177 | - // restore link |
|
| 178 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 179 | - [ |
|
| 180 | - 'action' => 'restore_message_template', |
|
| 181 | - 'id' => $item->GRP_ID(), |
|
| 182 | - 'noheader' => true, |
|
| 183 | - ], |
|
| 184 | - EE_MSG_ADMIN_URL |
|
| 185 | - ); |
|
| 186 | - $actions .= ' |
|
| 169 | + } else { |
|
| 170 | + if ( |
|
| 171 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 172 | + 'ee_delete_message', |
|
| 173 | + 'espresso_messages_restore_message_template', |
|
| 174 | + $item->ID() |
|
| 175 | + ) |
|
| 176 | + ) { |
|
| 177 | + // restore link |
|
| 178 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 179 | + [ |
|
| 180 | + 'action' => 'restore_message_template', |
|
| 181 | + 'id' => $item->GRP_ID(), |
|
| 182 | + 'noheader' => true, |
|
| 183 | + ], |
|
| 184 | + EE_MSG_ADMIN_URL |
|
| 185 | + ); |
|
| 186 | + $actions .= ' |
|
| 187 | 187 | <a href="' . $restore_lnk_url . '" |
| 188 | 188 | aria-label="' . esc_attr__('Restore Message Template', 'event_espresso') . '" |
| 189 | 189 | class="ee-aria-tooltip button button--icon-only" |
| 190 | 190 | > |
| 191 | 191 | <span class="dashicons dashicons-undo"></span> |
| 192 | 192 | </a>'; |
| 193 | - } |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - if ( |
|
| 196 | - $this->_view === 'trashed' |
|
| 197 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 198 | - 'ee_delete_message', |
|
| 199 | - 'espresso_messages_delete_message_template', |
|
| 200 | - $item->ID() |
|
| 201 | - ) |
|
| 202 | - ) { |
|
| 203 | - // delete price link |
|
| 204 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 205 | - [ |
|
| 206 | - 'action' => 'delete_message_template', |
|
| 207 | - 'id' => $item->GRP_ID(), |
|
| 208 | - 'noheader' => true, |
|
| 209 | - ], |
|
| 210 | - EE_MSG_ADMIN_URL |
|
| 211 | - ); |
|
| 212 | - $actions .= ' |
|
| 195 | + if ( |
|
| 196 | + $this->_view === 'trashed' |
|
| 197 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 198 | + 'ee_delete_message', |
|
| 199 | + 'espresso_messages_delete_message_template', |
|
| 200 | + $item->ID() |
|
| 201 | + ) |
|
| 202 | + ) { |
|
| 203 | + // delete price link |
|
| 204 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 205 | + [ |
|
| 206 | + 'action' => 'delete_message_template', |
|
| 207 | + 'id' => $item->GRP_ID(), |
|
| 208 | + 'noheader' => true, |
|
| 209 | + ], |
|
| 210 | + EE_MSG_ADMIN_URL |
|
| 211 | + ); |
|
| 212 | + $actions .= ' |
|
| 213 | 213 | <a href="' . $delete_lnk_url . '" |
| 214 | 214 | aria-label="' . esc_attr__('Delete Template Group Permanently', 'event_espresso') . '" |
| 215 | 215 | class="ee-aria-tooltip button button--icon-only" |
| 216 | 216 | > |
| 217 | 217 | <span class="dashicons dashicons-trash"></span> |
| 218 | 218 | </a>'; |
| 219 | - } |
|
| 220 | - } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - return $this->actionsModalMenu( |
|
| 223 | - $this->_action_string( |
|
| 224 | - $actions, |
|
| 225 | - $item, |
|
| 226 | - 'div', |
|
| 227 | - 'custom-messages-overview-actions ee-list-table-actions' |
|
| 228 | - ) |
|
| 229 | - ); |
|
| 230 | - } |
|
| 222 | + return $this->actionsModalMenu( |
|
| 223 | + $this->_action_string( |
|
| 224 | + $actions, |
|
| 225 | + $item, |
|
| 226 | + 'div', |
|
| 227 | + 'custom-messages-overview-actions ee-list-table-actions' |
|
| 228 | + ) |
|
| 229 | + ); |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * Set the view counts on the _views property |
|
| 235 | - * |
|
| 236 | - * @throws EE_Error |
|
| 237 | - * @throws ReflectionException |
|
| 238 | - */ |
|
| 239 | - protected function _add_view_counts() |
|
| 240 | - { |
|
| 241 | - foreach ($this->_views as $view => $args) { |
|
| 242 | - $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
| 243 | - $this->_per_page, |
|
| 244 | - $view, |
|
| 245 | - true, |
|
| 246 | - true, |
|
| 247 | - false |
|
| 248 | - ); |
|
| 249 | - } |
|
| 250 | - } |
|
| 233 | + /** |
|
| 234 | + * Set the view counts on the _views property |
|
| 235 | + * |
|
| 236 | + * @throws EE_Error |
|
| 237 | + * @throws ReflectionException |
|
| 238 | + */ |
|
| 239 | + protected function _add_view_counts() |
|
| 240 | + { |
|
| 241 | + foreach ($this->_views as $view => $args) { |
|
| 242 | + $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
| 243 | + $this->_per_page, |
|
| 244 | + $view, |
|
| 245 | + true, |
|
| 246 | + true, |
|
| 247 | + false |
|
| 248 | + ); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * column_events |
|
| 255 | - * This provides a count of events using this custom template |
|
| 256 | - * |
|
| 257 | - * @param EE_Message_Template_Group $item message_template group data |
|
| 258 | - * @return string column output |
|
| 259 | - */ |
|
| 260 | - public function column_events(EE_Message_Template_Group $item): string |
|
| 261 | - { |
|
| 262 | - return $item->count_events(); |
|
| 263 | - } |
|
| 253 | + /** |
|
| 254 | + * column_events |
|
| 255 | + * This provides a count of events using this custom template |
|
| 256 | + * |
|
| 257 | + * @param EE_Message_Template_Group $item message_template group data |
|
| 258 | + * @return string column output |
|
| 259 | + */ |
|
| 260 | + public function column_events(EE_Message_Template_Group $item): string |
|
| 261 | + { |
|
| 262 | + return $item->count_events(); |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * Generate dropdown filter select input for messengers |
|
| 268 | - * |
|
| 269 | - * @param bool $global |
|
| 270 | - * @return string |
|
| 271 | - * @throws EE_Error |
|
| 272 | - * @throws ReflectionException |
|
| 273 | - */ |
|
| 274 | - protected function _get_messengers_dropdown_filter(bool $global = true): string |
|
| 275 | - { |
|
| 276 | - return parent::_get_messengers_dropdown_filter(false); |
|
| 277 | - } |
|
| 266 | + /** |
|
| 267 | + * Generate dropdown filter select input for messengers |
|
| 268 | + * |
|
| 269 | + * @param bool $global |
|
| 270 | + * @return string |
|
| 271 | + * @throws EE_Error |
|
| 272 | + * @throws ReflectionException |
|
| 273 | + */ |
|
| 274 | + protected function _get_messengers_dropdown_filter(bool $global = true): string |
|
| 275 | + { |
|
| 276 | + return parent::_get_messengers_dropdown_filter(false); |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | 279 | |
| 280 | - /** |
|
| 281 | - * Generate dropdown filter select input for message types |
|
| 282 | - * |
|
| 283 | - * @param bool $global |
|
| 284 | - * @return string |
|
| 285 | - * @throws EE_Error |
|
| 286 | - * @throws ReflectionException |
|
| 287 | - */ |
|
| 288 | - protected function _get_message_types_dropdown_filter(bool $global = true): string |
|
| 289 | - { |
|
| 290 | - return parent::_get_message_types_dropdown_filter(false); |
|
| 291 | - } |
|
| 280 | + /** |
|
| 281 | + * Generate dropdown filter select input for message types |
|
| 282 | + * |
|
| 283 | + * @param bool $global |
|
| 284 | + * @return string |
|
| 285 | + * @throws EE_Error |
|
| 286 | + * @throws ReflectionException |
|
| 287 | + */ |
|
| 288 | + protected function _get_message_types_dropdown_filter(bool $global = true): string |
|
| 289 | + { |
|
| 290 | + return parent::_get_message_types_dropdown_filter(false); |
|
| 291 | + } |
|
| 292 | 292 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | protected function _setup_data() |
| 20 | 20 | { |
| 21 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
| 21 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
| 22 | 22 | $this->_per_page, |
| 23 | 23 | $this->_view, |
| 24 | 24 | false, |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function column_name(EE_Message_Template_Group $item): string |
| 104 | 104 | { |
| 105 | - return '<p>' . $item->name() . '</p>'; |
|
| 105 | + return '<p>'.$item->name().'</p>'; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $actions .= " |
| 136 | 136 | <a href='$create_link' |
| 137 | - aria-label='" . esc_html__('Create Custom Message Template', 'event_espresso') . "' |
|
| 137 | + aria-label='".esc_html__('Create Custom Message Template', 'event_espresso')."' |
|
| 138 | 138 | class='ee-aria-tooltip button button--icon-only' |
| 139 | 139 | > |
| 140 | 140 | <span class='dashicons dashicons-admin-customizer'></span> |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | EE_MSG_ADMIN_URL |
| 161 | 161 | ); |
| 162 | 162 | $actions .= ' |
| 163 | - <a href="' . $trash_lnk_url . '" |
|
| 164 | - aria-label="' . esc_attr__('Move Template Group to Trash', 'event_espresso') . '" |
|
| 163 | + <a href="' . $trash_lnk_url.'" |
|
| 164 | + aria-label="' . esc_attr__('Move Template Group to Trash', 'event_espresso').'" |
|
| 165 | 165 | class="ee-aria-tooltip button button--icon-only" |
| 166 | 166 | > |
| 167 | 167 | <span class="dashicons dashicons-trash"></span> |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | EE_MSG_ADMIN_URL |
| 185 | 185 | ); |
| 186 | 186 | $actions .= ' |
| 187 | - <a href="' . $restore_lnk_url . '" |
|
| 188 | - aria-label="' . esc_attr__('Restore Message Template', 'event_espresso') . '" |
|
| 187 | + <a href="' . $restore_lnk_url.'" |
|
| 188 | + aria-label="' . esc_attr__('Restore Message Template', 'event_espresso').'" |
|
| 189 | 189 | class="ee-aria-tooltip button button--icon-only" |
| 190 | 190 | > |
| 191 | 191 | <span class="dashicons dashicons-undo"></span> |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | EE_MSG_ADMIN_URL |
| 211 | 211 | ); |
| 212 | 212 | $actions .= ' |
| 213 | - <a href="' . $delete_lnk_url . '" |
|
| 214 | - aria-label="' . esc_attr__('Delete Template Group Permanently', 'event_espresso') . '" |
|
| 213 | + <a href="' . $delete_lnk_url.'" |
|
| 214 | + aria-label="' . esc_attr__('Delete Template Group Permanently', 'event_espresso').'" |
|
| 215 | 215 | class="ee-aria-tooltip button button--icon-only" |
| 216 | 216 | > |
| 217 | 217 | <span class="dashicons dashicons-trash"></span> |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | protected function _add_view_counts() |
| 240 | 240 | { |
| 241 | 241 | foreach ($this->_views as $view => $args) { |
| 242 | - $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
| 242 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
| 243 | 243 | $this->_per_page, |
| 244 | 244 | $view, |
| 245 | 245 | true, |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | $is_major_release = true; |
| 6 | 6 | $type = $is_major_release ? 'major' : 'minor'; |
| 7 | 7 | $heading = $is_major_release |
| 8 | - ? _n('Major Release Information', 'Major Releases', 1, 'event_espresso') |
|
| 9 | - : _n('Minor Release Information', 'Minor Releases', 1, 'event_espresso'); |
|
| 8 | + ? _n('Major Release Information', 'Major Releases', 1, 'event_espresso') |
|
| 9 | + : _n('Minor Release Information', 'Minor Releases', 1, 'event_espresso'); |
|
| 10 | 10 | |
| 11 | 11 | $version = explode('.', EVENT_ESPRESSO_VERSION); |
| 12 | 12 | array_pop($version); |
@@ -16,48 +16,48 @@ discard block |
||
| 16 | 16 | <div class="changelog point-releases"> |
| 17 | 17 | <h3><?php echo esc_html($heading); ?></h3> |
| 18 | 18 | <p><?php |
| 19 | - printf( |
|
| 20 | - esc_html__('%1$sVersion %2$s%3$s is a %4$s release.', 'event_espresso'), |
|
| 21 | - '<strong>', |
|
| 22 | - EVENT_ESPRESSO_VERSION, |
|
| 23 | - '</strong>', |
|
| 24 | - $type |
|
| 25 | - ); ?> |
|
| 19 | + printf( |
|
| 20 | + esc_html__('%1$sVersion %2$s%3$s is a %4$s release.', 'event_espresso'), |
|
| 21 | + '<strong>', |
|
| 22 | + EVENT_ESPRESSO_VERSION, |
|
| 23 | + '</strong>', |
|
| 24 | + $type |
|
| 25 | + ); ?> |
|
| 26 | 26 | <?php printf( |
| 27 | - esc_html__('For more information, see %1$sthe release notes%2$s.', 'event_espresso'), |
|
| 28 | - '<a href="https://eventespresso.com/wiki/ee4-changelog/#' |
|
| 29 | - . $version |
|
| 30 | - . '" target="_blank" rel="noopener noreferrer">', |
|
| 31 | - '</a>' |
|
| 32 | - ); ?> |
|
| 27 | + esc_html__('For more information, see %1$sthe release notes%2$s.', 'event_espresso'), |
|
| 28 | + '<a href="https://eventespresso.com/wiki/ee4-changelog/#' |
|
| 29 | + . $version |
|
| 30 | + . '" target="_blank" rel="noopener noreferrer">', |
|
| 31 | + '</a>' |
|
| 32 | + ); ?> |
|
| 33 | 33 | </p> |
| 34 | 34 | </div><!-- end .changelog .point-releases --> |
| 35 | 35 | |
| 36 | 36 | <div class="changelog"> |
| 37 | 37 | <?php |
| 38 | - // maintenance mode on? |
|
| 39 | - if (MaintenanceStatus::isFullSite()) { |
|
| 40 | - ?> |
|
| 38 | + // maintenance mode on? |
|
| 39 | + if (MaintenanceStatus::isFullSite()) { |
|
| 40 | + ?> |
|
| 41 | 41 | <div class="ee-attention"> |
| 42 | 42 | <h2 class="ee-maintenance-mode-callout"> |
| 43 | 43 | <?php esc_html_e('Event Espresso is in full maintenance mode.', 'event_espresso'); ?> |
| 44 | 44 | </h2> |
| 45 | 45 | <p> |
| 46 | 46 | <?php |
| 47 | - printf( |
|
| 48 | - esc_html__( |
|
| 49 | - 'A previous version of Event Espresso has detected. But before anything else can happen, we need to know whether or not to migrate (copy over) your existing event data so that it can be utilized by EE4. For more instructions on what to do, please visit the %1$sEvent Espresso Maintenance%2$s page.', |
|
| 50 | - 'event_espresso' |
|
| 51 | - ), |
|
| 52 | - '<a href="admin.php?page=espresso_maintenance_settings">', |
|
| 53 | - '</a>' |
|
| 54 | - ); |
|
| 55 | - ?> |
|
| 47 | + printf( |
|
| 48 | + esc_html__( |
|
| 49 | + 'A previous version of Event Espresso has detected. But before anything else can happen, we need to know whether or not to migrate (copy over) your existing event data so that it can be utilized by EE4. For more instructions on what to do, please visit the %1$sEvent Espresso Maintenance%2$s page.', |
|
| 50 | + 'event_espresso' |
|
| 51 | + ), |
|
| 52 | + '<a href="admin.php?page=espresso_maintenance_settings">', |
|
| 53 | + '</a>' |
|
| 54 | + ); |
|
| 55 | + ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - } |
|
| 60 | - ?> |
|
| 59 | + } |
|
| 60 | + ?> |
|
| 61 | 61 | |
| 62 | 62 | <h2 class="about-headline-callout">Updates & Fixes in EE v5.0</h2> |
| 63 | 63 | <p class="ee-highlight ee-highlight--info">This release introduces an improved event editor, support for recurring events, and improvements to existing core features. Here are the most interesting updates: |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | <div class='ee-new-features ee-card-grid ee-card-grid-3-cols'> |
| 68 | 68 | |
| 69 | 69 | <?php |
| 70 | - /* |
|
| 70 | + /* |
|
| 71 | 71 | WANT TO ADD A FEW FEATURE? |
| 72 | 72 | COPY THE FOLLOWING: |
| 73 | 73 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | ADD "ee-grid-row-span-3" TO THE "ee-card ee-new-feature-card" ex: |
| 100 | 100 | <div class='ee-card ee-new-feature-card ee-grid-row-span-3'> |
| 101 | 101 | */ |
| 102 | - ?> |
|
| 102 | + ?> |
|
| 103 | 103 | |
| 104 | 104 | <div class='ee-card ee-new-feature-card'> |
| 105 | 105 | <h4>Improved Event Editor and Support for Recurring Events</h4> |
@@ -18,197 +18,197 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Extend_About_Admin_Page extends About_Admin_Page |
| 20 | 20 | { |
| 21 | - public function __construct($routing = true) |
|
| 22 | - { |
|
| 23 | - parent::__construct($routing); |
|
| 24 | - define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'about/templates/'); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - protected function _set_page_routes() |
|
| 29 | - { |
|
| 30 | - $this->_page_routes = [ |
|
| 31 | - 'default' => [ |
|
| 32 | - 'func' => '_whats_new', |
|
| 33 | - 'capability' => 'manage_options', |
|
| 34 | - ], |
|
| 35 | - 'overview' => [ |
|
| 36 | - 'func' => '_overview', |
|
| 37 | - 'capability' => 'manage_options', |
|
| 38 | - ], |
|
| 39 | - 'credits' => [ |
|
| 40 | - 'func' => '_credits', |
|
| 41 | - 'capability' => 'manage_options', |
|
| 42 | - ], |
|
| 43 | - /*'decafvpro' => array( |
|
| 21 | + public function __construct($routing = true) |
|
| 22 | + { |
|
| 23 | + parent::__construct($routing); |
|
| 24 | + define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'about/templates/'); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + protected function _set_page_routes() |
|
| 29 | + { |
|
| 30 | + $this->_page_routes = [ |
|
| 31 | + 'default' => [ |
|
| 32 | + 'func' => '_whats_new', |
|
| 33 | + 'capability' => 'manage_options', |
|
| 34 | + ], |
|
| 35 | + 'overview' => [ |
|
| 36 | + 'func' => '_overview', |
|
| 37 | + 'capability' => 'manage_options', |
|
| 38 | + ], |
|
| 39 | + 'credits' => [ |
|
| 40 | + 'func' => '_credits', |
|
| 41 | + 'capability' => 'manage_options', |
|
| 42 | + ], |
|
| 43 | + /*'decafvpro' => array( |
|
| 44 | 44 | 'func' => '_decafvpro', |
| 45 | 45 | 'capability' => 'manage_options' |
| 46 | 46 | ),*/ |
| 47 | - 'reviews' => [ |
|
| 48 | - 'func' => '_reviews', |
|
| 49 | - 'capability' => 'manage_options', |
|
| 50 | - ], |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - ]; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - protected function _set_page_config() |
|
| 58 | - { |
|
| 59 | - parent::_set_page_config(); |
|
| 60 | - |
|
| 61 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'about'; |
|
| 62 | - $this->_page_config = [ |
|
| 63 | - 'default' => [ |
|
| 64 | - 'nav' => [ |
|
| 65 | - 'label' => esc_html__('What\'s New', 'event_espresso'), |
|
| 66 | - 'icon' => 'dashicons-bell', |
|
| 67 | - 'order' => 10, |
|
| 68 | - ], |
|
| 69 | - 'require_nonce' => false, |
|
| 70 | - ], |
|
| 71 | - 'overview' => [ |
|
| 72 | - 'nav' => [ |
|
| 73 | - 'label' => esc_html__('About', 'event_espresso'), |
|
| 74 | - 'icon' => 'dashicons-info', |
|
| 75 | - 'order' => 20, |
|
| 76 | - ], |
|
| 77 | - 'require_nonce' => false, |
|
| 78 | - ], |
|
| 79 | - 'credits' => [ |
|
| 80 | - 'nav' => [ |
|
| 81 | - 'label' => esc_html__('Credits', 'event_espresso'), |
|
| 82 | - 'icon' => 'dashicons-thumbs-up', |
|
| 83 | - 'order' => 30, |
|
| 84 | - ], |
|
| 85 | - 'require_nonce' => false, |
|
| 86 | - ], |
|
| 87 | - /*'decafvpro' => array( |
|
| 47 | + 'reviews' => [ |
|
| 48 | + 'func' => '_reviews', |
|
| 49 | + 'capability' => 'manage_options', |
|
| 50 | + ], |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + ]; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + protected function _set_page_config() |
|
| 58 | + { |
|
| 59 | + parent::_set_page_config(); |
|
| 60 | + |
|
| 61 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'about'; |
|
| 62 | + $this->_page_config = [ |
|
| 63 | + 'default' => [ |
|
| 64 | + 'nav' => [ |
|
| 65 | + 'label' => esc_html__('What\'s New', 'event_espresso'), |
|
| 66 | + 'icon' => 'dashicons-bell', |
|
| 67 | + 'order' => 10, |
|
| 68 | + ], |
|
| 69 | + 'require_nonce' => false, |
|
| 70 | + ], |
|
| 71 | + 'overview' => [ |
|
| 72 | + 'nav' => [ |
|
| 73 | + 'label' => esc_html__('About', 'event_espresso'), |
|
| 74 | + 'icon' => 'dashicons-info', |
|
| 75 | + 'order' => 20, |
|
| 76 | + ], |
|
| 77 | + 'require_nonce' => false, |
|
| 78 | + ], |
|
| 79 | + 'credits' => [ |
|
| 80 | + 'nav' => [ |
|
| 81 | + 'label' => esc_html__('Credits', 'event_espresso'), |
|
| 82 | + 'icon' => 'dashicons-thumbs-up', |
|
| 83 | + 'order' => 30, |
|
| 84 | + ], |
|
| 85 | + 'require_nonce' => false, |
|
| 86 | + ], |
|
| 87 | + /*'decafvpro' => array( |
|
| 88 | 88 | 'nav' => array( |
| 89 | 89 | 'label' => esc_html__('Decaf vs Regular', 'event_espresso'), |
| 90 | 90 | 'order' => 40), |
| 91 | 91 | 'require_nonce' => FALSE |
| 92 | 92 | ),*/ |
| 93 | - 'reviews' => [ |
|
| 94 | - 'nav' => [ |
|
| 95 | - 'label' => esc_html__('Reviews', 'event_espresso'), |
|
| 96 | - 'icon' => 'dashicons-star-filled', |
|
| 97 | - 'order' => 50, |
|
| 98 | - ], |
|
| 99 | - 'require_nonce' => false, |
|
| 100 | - ], |
|
| 101 | - |
|
| 102 | - ]; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - protected function _whats_new() |
|
| 107 | - { |
|
| 108 | - $steps = MaintenanceStatus::isNotDisabled() ? $this->_get_started_steps() : ''; |
|
| 109 | - $this->_admin_page_title = sprintf( |
|
| 110 | - esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
| 111 | - EVENT_ESPRESSO_VERSION |
|
| 112 | - ); |
|
| 113 | - $settings_message = $steps; |
|
| 114 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 115 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
| 116 | - 'event_espresso' |
|
| 117 | - ) . $settings_message; |
|
| 118 | - $template = |
|
| 119 | - is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php') |
|
| 120 | - ? EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php' |
|
| 121 | - : EE_ABOUT_TEMPLATE_PATH |
|
| 122 | - . 'whats_new.template.php'; |
|
| 123 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 124 | - $template, |
|
| 125 | - $this->_template_args, |
|
| 126 | - true |
|
| 127 | - ); |
|
| 128 | - $this->display_about_admin_page(); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - protected function _overview() |
|
| 133 | - { |
|
| 134 | - $this->_admin_page_title = esc_html__('About Event Espresso', 'event_espresso'); |
|
| 135 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 136 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
| 137 | - 'event_espresso' |
|
| 138 | - ); |
|
| 139 | - $template = |
|
| 140 | - is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php') |
|
| 141 | - ? EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php' |
|
| 142 | - : EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
| 143 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 144 | - $template, |
|
| 145 | - $this->_template_args, |
|
| 146 | - true |
|
| 147 | - ); |
|
| 148 | - $this->display_about_admin_page(); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - |
|
| 152 | - protected function _credits() |
|
| 153 | - { |
|
| 154 | - // $this->_template_args['admin_page_title'] = sprintf( |
|
| 155 | - // esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
| 156 | - // EVENT_ESPRESSO_VERSION |
|
| 157 | - // ); |
|
| 158 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 159 | - 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
| 160 | - 'event_espresso' |
|
| 161 | - ); |
|
| 162 | - $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
| 163 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 164 | - $template, |
|
| 165 | - $this->_template_args, |
|
| 166 | - true |
|
| 167 | - ); |
|
| 168 | - $this->display_about_admin_page(); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - protected function _decafvpro() |
|
| 173 | - { |
|
| 174 | - $this->_template_args['admin_page_title'] = sprintf( |
|
| 175 | - esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
| 176 | - EVENT_ESPRESSO_VERSION |
|
| 177 | - ); |
|
| 178 | - $this->_template_args['admin_page_subtitle'] = sprintf( |
|
| 179 | - esc_html__( |
|
| 180 | - 'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', |
|
| 181 | - 'event_espresso' |
|
| 182 | - ), |
|
| 183 | - '<em>', |
|
| 184 | - '</em>', |
|
| 185 | - '<strong>', |
|
| 186 | - '</strong>' |
|
| 187 | - ); |
|
| 188 | - $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
| 189 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 190 | - $template, |
|
| 191 | - $this->_template_args, |
|
| 192 | - true |
|
| 193 | - ); |
|
| 194 | - $this->display_about_admin_page(); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - |
|
| 198 | - protected function _reviews() |
|
| 199 | - { |
|
| 200 | - $this->_template_args['admin_page_title'] = |
|
| 201 | - esc_html__('Rave Reviews About Event Espresso 4', 'event_espresso'); |
|
| 202 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 203 | - 'At Event Espresso, customer satisfaction is our ultimate goal.', |
|
| 204 | - 'event_espresso' |
|
| 205 | - ); |
|
| 206 | - $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
| 207 | - $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 208 | - $template, |
|
| 209 | - $this->_template_args, |
|
| 210 | - true |
|
| 211 | - ); |
|
| 212 | - $this->display_about_admin_page(); |
|
| 213 | - } |
|
| 93 | + 'reviews' => [ |
|
| 94 | + 'nav' => [ |
|
| 95 | + 'label' => esc_html__('Reviews', 'event_espresso'), |
|
| 96 | + 'icon' => 'dashicons-star-filled', |
|
| 97 | + 'order' => 50, |
|
| 98 | + ], |
|
| 99 | + 'require_nonce' => false, |
|
| 100 | + ], |
|
| 101 | + |
|
| 102 | + ]; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + protected function _whats_new() |
|
| 107 | + { |
|
| 108 | + $steps = MaintenanceStatus::isNotDisabled() ? $this->_get_started_steps() : ''; |
|
| 109 | + $this->_admin_page_title = sprintf( |
|
| 110 | + esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
| 111 | + EVENT_ESPRESSO_VERSION |
|
| 112 | + ); |
|
| 113 | + $settings_message = $steps; |
|
| 114 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 115 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
| 116 | + 'event_espresso' |
|
| 117 | + ) . $settings_message; |
|
| 118 | + $template = |
|
| 119 | + is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php') |
|
| 120 | + ? EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php' |
|
| 121 | + : EE_ABOUT_TEMPLATE_PATH |
|
| 122 | + . 'whats_new.template.php'; |
|
| 123 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 124 | + $template, |
|
| 125 | + $this->_template_args, |
|
| 126 | + true |
|
| 127 | + ); |
|
| 128 | + $this->display_about_admin_page(); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + protected function _overview() |
|
| 133 | + { |
|
| 134 | + $this->_admin_page_title = esc_html__('About Event Espresso', 'event_espresso'); |
|
| 135 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 136 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
| 137 | + 'event_espresso' |
|
| 138 | + ); |
|
| 139 | + $template = |
|
| 140 | + is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php') |
|
| 141 | + ? EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php' |
|
| 142 | + : EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
| 143 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 144 | + $template, |
|
| 145 | + $this->_template_args, |
|
| 146 | + true |
|
| 147 | + ); |
|
| 148 | + $this->display_about_admin_page(); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + |
|
| 152 | + protected function _credits() |
|
| 153 | + { |
|
| 154 | + // $this->_template_args['admin_page_title'] = sprintf( |
|
| 155 | + // esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
| 156 | + // EVENT_ESPRESSO_VERSION |
|
| 157 | + // ); |
|
| 158 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 159 | + 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
|
| 160 | + 'event_espresso' |
|
| 161 | + ); |
|
| 162 | + $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
| 163 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 164 | + $template, |
|
| 165 | + $this->_template_args, |
|
| 166 | + true |
|
| 167 | + ); |
|
| 168 | + $this->display_about_admin_page(); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + protected function _decafvpro() |
|
| 173 | + { |
|
| 174 | + $this->_template_args['admin_page_title'] = sprintf( |
|
| 175 | + esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
|
| 176 | + EVENT_ESPRESSO_VERSION |
|
| 177 | + ); |
|
| 178 | + $this->_template_args['admin_page_subtitle'] = sprintf( |
|
| 179 | + esc_html__( |
|
| 180 | + 'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', |
|
| 181 | + 'event_espresso' |
|
| 182 | + ), |
|
| 183 | + '<em>', |
|
| 184 | + '</em>', |
|
| 185 | + '<strong>', |
|
| 186 | + '</strong>' |
|
| 187 | + ); |
|
| 188 | + $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
| 189 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 190 | + $template, |
|
| 191 | + $this->_template_args, |
|
| 192 | + true |
|
| 193 | + ); |
|
| 194 | + $this->display_about_admin_page(); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + |
|
| 198 | + protected function _reviews() |
|
| 199 | + { |
|
| 200 | + $this->_template_args['admin_page_title'] = |
|
| 201 | + esc_html__('Rave Reviews About Event Espresso 4', 'event_espresso'); |
|
| 202 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 203 | + 'At Event Espresso, customer satisfaction is our ultimate goal.', |
|
| 204 | + 'event_espresso' |
|
| 205 | + ); |
|
| 206 | + $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
| 207 | + $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
|
| 208 | + $template, |
|
| 209 | + $this->_template_args, |
|
| 210 | + true |
|
| 211 | + ); |
|
| 212 | + $this->display_about_admin_page(); |
|
| 213 | + } |
|
| 214 | 214 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function __construct($routing = true) |
| 22 | 22 | { |
| 23 | 23 | parent::__construct($routing); |
| 24 | - define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'about/templates/'); |
|
| 24 | + define('EE_ABOUT_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'about/templates/'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | parent::_set_page_config(); |
| 60 | 60 | |
| 61 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'about'; |
|
| 61 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'about'; |
|
| 62 | 62 | $this->_page_config = [ |
| 63 | 63 | 'default' => [ |
| 64 | 64 | 'nav' => [ |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | protected function _whats_new() |
| 107 | 107 | { |
| 108 | 108 | $steps = MaintenanceStatus::isNotDisabled() ? $this->_get_started_steps() : ''; |
| 109 | - $this->_admin_page_title = sprintf( |
|
| 109 | + $this->_admin_page_title = sprintf( |
|
| 110 | 110 | esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
| 111 | 111 | EVENT_ESPRESSO_VERSION |
| 112 | 112 | ); |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | $this->_template_args['admin_page_subtitle'] = esc_html__( |
| 115 | 115 | 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
| 116 | 116 | 'event_espresso' |
| 117 | - ) . $settings_message; |
|
| 118 | - $template = |
|
| 119 | - is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php') |
|
| 117 | + ).$settings_message; |
|
| 118 | + $template = |
|
| 119 | + is_readable(EE_ABOUT_CAF_TEMPLATE_PATH.'whats_new.template.php') |
|
| 120 | 120 | ? EE_ABOUT_CAF_TEMPLATE_PATH . 'whats_new.template.php' |
| 121 | 121 | : EE_ABOUT_TEMPLATE_PATH |
| 122 | 122 | . 'whats_new.template.php'; |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
| 137 | 137 | 'event_espresso' |
| 138 | 138 | ); |
| 139 | - $template = |
|
| 140 | - is_readable(EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php') |
|
| 139 | + $template = |
|
| 140 | + is_readable(EE_ABOUT_CAF_TEMPLATE_PATH.'ee4-overview.template.php') |
|
| 141 | 141 | ? EE_ABOUT_CAF_TEMPLATE_PATH . 'ee4-overview.template.php' |
| 142 | - : EE_ABOUT_TEMPLATE_PATH . 'ee4-overview.template.php'; |
|
| 142 | + : EE_ABOUT_TEMPLATE_PATH.'ee4-overview.template.php'; |
|
| 143 | 143 | $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
| 144 | 144 | $template, |
| 145 | 145 | $this->_template_args, |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | // esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
| 156 | 156 | // EVENT_ESPRESSO_VERSION |
| 157 | 157 | // ); |
| 158 | - $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 158 | + $this->_template_args['admin_page_subtitle'] = esc_html__( |
|
| 159 | 159 | 'Thank you for choosing Event Espresso, the most powerful Event Management plugin for WordPress.', |
| 160 | 160 | 'event_espresso' |
| 161 | 161 | ); |
| 162 | - $template = EE_ABOUT_TEMPLATE_PATH . 'credits.template.php'; |
|
| 162 | + $template = EE_ABOUT_TEMPLATE_PATH.'credits.template.php'; |
|
| 163 | 163 | $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
| 164 | 164 | $template, |
| 165 | 165 | $this->_template_args, |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | protected function _decafvpro() |
| 173 | 173 | { |
| 174 | - $this->_template_args['admin_page_title'] = sprintf( |
|
| 174 | + $this->_template_args['admin_page_title'] = sprintf( |
|
| 175 | 175 | esc_html__('Welcome to Event Espresso %s', 'event_espresso'), |
| 176 | 176 | EVENT_ESPRESSO_VERSION |
| 177 | 177 | ); |
| 178 | - $this->_template_args['admin_page_subtitle'] = sprintf( |
|
| 178 | + $this->_template_args['admin_page_subtitle'] = sprintf( |
|
| 179 | 179 | esc_html__( |
| 180 | 180 | 'Event Espresso lets you focus on doing %swhat you love%s — %sorganizing your events%s', |
| 181 | 181 | 'event_espresso' |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | '<strong>', |
| 186 | 186 | '</strong>' |
| 187 | 187 | ); |
| 188 | - $template = EE_ABOUT_TEMPLATE_PATH . 'decafvpro.template.php'; |
|
| 188 | + $template = EE_ABOUT_TEMPLATE_PATH.'decafvpro.template.php'; |
|
| 189 | 189 | $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
| 190 | 190 | $template, |
| 191 | 191 | $this->_template_args, |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | 'At Event Espresso, customer satisfaction is our ultimate goal.', |
| 204 | 204 | 'event_espresso' |
| 205 | 205 | ); |
| 206 | - $template = EE_ABOUT_TEMPLATE_PATH . 'reviews.template.php'; |
|
| 206 | + $template = EE_ABOUT_TEMPLATE_PATH.'reviews.template.php'; |
|
| 207 | 207 | $this->_template_args['about_admin_page_content'] = EEH_Template::display_template( |
| 208 | 208 | $template, |
| 209 | 209 | $this->_template_args, |
@@ -21,86 +21,86 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Stats |
| 23 | 23 | { |
| 24 | - public const OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS = 'ee_uxip_stats_expiry'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var Config |
|
| 28 | - */ |
|
| 29 | - private $config; |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var StatsGatherer |
|
| 34 | - */ |
|
| 35 | - private $stats_gatherer; |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var EE_Maintenance_Mode |
|
| 40 | - */ |
|
| 41 | - private $maintenance_mode; |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - public function __construct( |
|
| 45 | - Config $config, |
|
| 46 | - EE_Maintenance_Mode $maintenance_mode, |
|
| 47 | - StatsGatherer $stats_gatherer |
|
| 48 | - ) { |
|
| 49 | - $this->config = $config; |
|
| 50 | - $this->maintenance_mode = $maintenance_mode; |
|
| 51 | - $this->stats_gatherer = $stats_gatherer; |
|
| 52 | - $this->setUxipNotices(); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Displays uxip opt-in notice if necessary. |
|
| 58 | - */ |
|
| 59 | - private function setUxipNotices() |
|
| 60 | - { |
|
| 61 | - if ($this->canDisplayNotices()) { |
|
| 62 | - add_action('admin_notices', [$this, 'optinNotice']); |
|
| 63 | - add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']); |
|
| 64 | - add_action('wp_ajax_espresso_data_optin', [$this, 'ajaxHandler']); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * This returns the callback that PluginUpdateEngineChecker will use for getting any extra stats to send. |
|
| 71 | - * |
|
| 72 | - * @return Closure |
|
| 73 | - */ |
|
| 74 | - public function statsCallback(): Closure |
|
| 75 | - { |
|
| 76 | - // returns a callback that can is used to retrieve the stats to send along to the pue server. |
|
| 77 | - return function () { |
|
| 78 | - // we only send stats one a week, so let's see if our stat timestamp has expired. |
|
| 79 | - if (! $this->sendStats()) { |
|
| 80 | - return []; |
|
| 81 | - } |
|
| 82 | - return $this->stats_gatherer->stats(); |
|
| 83 | - }; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Return whether notices can be displayed or not |
|
| 89 | - * |
|
| 90 | - * @return bool |
|
| 91 | - */ |
|
| 92 | - private function canDisplayNotices(): bool |
|
| 93 | - { |
|
| 94 | - return MaintenanceStatus::isNotFullSite() && ! $this->config->hasNotifiedForUxip(); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Callback for the admin_notices hook that outputs the UXIP optin-in notice. |
|
| 100 | - */ |
|
| 101 | - public function optinNotice() |
|
| 102 | - { |
|
| 103 | - ?> |
|
| 24 | + public const OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS = 'ee_uxip_stats_expiry'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var Config |
|
| 28 | + */ |
|
| 29 | + private $config; |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var StatsGatherer |
|
| 34 | + */ |
|
| 35 | + private $stats_gatherer; |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var EE_Maintenance_Mode |
|
| 40 | + */ |
|
| 41 | + private $maintenance_mode; |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + public function __construct( |
|
| 45 | + Config $config, |
|
| 46 | + EE_Maintenance_Mode $maintenance_mode, |
|
| 47 | + StatsGatherer $stats_gatherer |
|
| 48 | + ) { |
|
| 49 | + $this->config = $config; |
|
| 50 | + $this->maintenance_mode = $maintenance_mode; |
|
| 51 | + $this->stats_gatherer = $stats_gatherer; |
|
| 52 | + $this->setUxipNotices(); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Displays uxip opt-in notice if necessary. |
|
| 58 | + */ |
|
| 59 | + private function setUxipNotices() |
|
| 60 | + { |
|
| 61 | + if ($this->canDisplayNotices()) { |
|
| 62 | + add_action('admin_notices', [$this, 'optinNotice']); |
|
| 63 | + add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']); |
|
| 64 | + add_action('wp_ajax_espresso_data_optin', [$this, 'ajaxHandler']); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * This returns the callback that PluginUpdateEngineChecker will use for getting any extra stats to send. |
|
| 71 | + * |
|
| 72 | + * @return Closure |
|
| 73 | + */ |
|
| 74 | + public function statsCallback(): Closure |
|
| 75 | + { |
|
| 76 | + // returns a callback that can is used to retrieve the stats to send along to the pue server. |
|
| 77 | + return function () { |
|
| 78 | + // we only send stats one a week, so let's see if our stat timestamp has expired. |
|
| 79 | + if (! $this->sendStats()) { |
|
| 80 | + return []; |
|
| 81 | + } |
|
| 82 | + return $this->stats_gatherer->stats(); |
|
| 83 | + }; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Return whether notices can be displayed or not |
|
| 89 | + * |
|
| 90 | + * @return bool |
|
| 91 | + */ |
|
| 92 | + private function canDisplayNotices(): bool |
|
| 93 | + { |
|
| 94 | + return MaintenanceStatus::isNotFullSite() && ! $this->config->hasNotifiedForUxip(); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Callback for the admin_notices hook that outputs the UXIP optin-in notice. |
|
| 100 | + */ |
|
| 101 | + public function optinNotice() |
|
| 102 | + { |
|
| 103 | + ?> |
|
| 104 | 104 | <div class="espresso-notices updated data-collect-optin" id="espresso-data-collect-optin-container"> |
| 105 | 105 | <div id="data-collect-optin-options-container"> |
| 106 | 106 | <span class="dashicons dashicons-admin-site"></span> |
@@ -113,128 +113,128 @@ discard block |
||
| 113 | 113 | </div> |
| 114 | 114 | </div> |
| 115 | 115 | <?php |
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Retrieves the optin text (static so it can be used in multiple places as necessary). |
|
| 121 | - * |
|
| 122 | - * @param bool $extra |
|
| 123 | - * @return string|void |
|
| 124 | - */ |
|
| 125 | - public static function optinText(bool $extra = true) |
|
| 126 | - { |
|
| 127 | - if (! $extra) { |
|
| 128 | - return ' |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Retrieves the optin text (static so it can be used in multiple places as necessary). |
|
| 121 | + * |
|
| 122 | + * @param bool $extra |
|
| 123 | + * @return string|void |
|
| 124 | + */ |
|
| 125 | + public static function optinText(bool $extra = true) |
|
| 126 | + { |
|
| 127 | + if (! $extra) { |
|
| 128 | + return ' |
|
| 129 | 129 | <h2 class="ee-admin-settings-hdr" id="UXIP_settings">' |
| 130 | - . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso') |
|
| 131 | - . EEH_Template::get_help_tab_link('organization_logo_info') |
|
| 132 | - . '</h2>' . sprintf( |
|
| 133 | - esc_html__( |
|
| 134 | - '%1$sPlease help us make Event Espresso better and vote for your favorite features.%2$s The %3$sUser eXperience Improvement Program (UXIP)%4$s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary and it is disabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %5$sPlease see our %6$sPrivacy Policy%7$s for more information.%8$s', |
|
| 135 | - 'event_espresso' |
|
| 136 | - ), |
|
| 137 | - '<p><em>', |
|
| 138 | - '</em></p><p>', |
|
| 139 | - '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', |
|
| 140 | - '</a>', |
|
| 141 | - '<br><br>', |
|
| 142 | - '<a href="https://eventespresso.com/about/privacy-policy/" target="_blank">', |
|
| 143 | - '</a>', |
|
| 144 | - '</p>' |
|
| 145 | - ); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - $settings_url = EEH_URL::add_query_args_and_nonce( |
|
| 149 | - ['action' => 'default'], |
|
| 150 | - admin_url('admin.php?page=espresso_general_settings') |
|
| 151 | - ); |
|
| 152 | - $settings_url .= '#UXIP_settings'; |
|
| 153 | - printf( |
|
| 154 | - esc_html__( |
|
| 155 | - 'The Event Espresso UXIP feature is not yet active on your site. For %1$smore info%2$s and to opt-in %3$sclick here%4$s.', |
|
| 156 | - 'event_espresso' |
|
| 157 | - ), |
|
| 158 | - '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', |
|
| 159 | - '</a>', |
|
| 160 | - '<a href="' . $settings_url . '" target="_blank">', |
|
| 161 | - '</a>' |
|
| 162 | - ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Callback for admin_enqueue_scripts that sets up the scripts and styles for the uxip notice |
|
| 168 | - */ |
|
| 169 | - public function enqueueScripts() |
|
| 170 | - { |
|
| 171 | - wp_register_script( |
|
| 172 | - 'ee-data-optin-js', |
|
| 173 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js', |
|
| 174 | - ['jquery'], |
|
| 175 | - EVENT_ESPRESSO_VERSION, |
|
| 176 | - true |
|
| 177 | - ); |
|
| 178 | - wp_register_style( |
|
| 179 | - 'ee-data-optin-css', |
|
| 180 | - EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css', |
|
| 181 | - [], |
|
| 182 | - EVENT_ESPRESSO_VERSION |
|
| 183 | - ); |
|
| 184 | - |
|
| 185 | - wp_enqueue_script('ee-data-optin-js'); |
|
| 186 | - wp_enqueue_style('ee-data-optin-css'); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Callback for wp_ajax_espresso_data_optin that handles the ajax request |
|
| 192 | - */ |
|
| 193 | - public function ajaxHandler() |
|
| 194 | - { |
|
| 195 | - /** @var RequestInterface $request */ |
|
| 196 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
| 197 | - $nonce = $request->getRequestParam('nonce'); |
|
| 198 | - // verify nonce |
|
| 199 | - if (! $nonce || ! wp_verify_nonce($nonce, 'ee-data-optin')) { |
|
| 200 | - exit(); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - // update has notified option |
|
| 204 | - $this->config->setHasNotifiedAboutUxip(); |
|
| 205 | - exit(); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Used to determine whether additional stats are sent. |
|
| 211 | - */ |
|
| 212 | - private function sendStats(): bool |
|
| 213 | - { |
|
| 214 | - return MaintenanceStatus::isNotFullSite() |
|
| 215 | - && $this->config->isOptedInForUxip() |
|
| 216 | - && $this->statSendTimestampExpired(); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Returns true when the timestamp used to track whether stats get sent (currently a weekly interval) is expired. |
|
| 222 | - * Returns false otherwise. |
|
| 223 | - * |
|
| 224 | - * @return bool |
|
| 225 | - */ |
|
| 226 | - private function statSendTimestampExpired(): bool |
|
| 227 | - { |
|
| 228 | - $current_expiry = get_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, null); |
|
| 229 | - if ($current_expiry === null) { |
|
| 230 | - add_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS, '', 'no'); |
|
| 231 | - return true; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - if (time() > (int) $current_expiry) { |
|
| 235 | - update_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS); |
|
| 236 | - return true; |
|
| 237 | - } |
|
| 238 | - return false; |
|
| 239 | - } |
|
| 130 | + . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso') |
|
| 131 | + . EEH_Template::get_help_tab_link('organization_logo_info') |
|
| 132 | + . '</h2>' . sprintf( |
|
| 133 | + esc_html__( |
|
| 134 | + '%1$sPlease help us make Event Espresso better and vote for your favorite features.%2$s The %3$sUser eXperience Improvement Program (UXIP)%4$s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary and it is disabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %5$sPlease see our %6$sPrivacy Policy%7$s for more information.%8$s', |
|
| 135 | + 'event_espresso' |
|
| 136 | + ), |
|
| 137 | + '<p><em>', |
|
| 138 | + '</em></p><p>', |
|
| 139 | + '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', |
|
| 140 | + '</a>', |
|
| 141 | + '<br><br>', |
|
| 142 | + '<a href="https://eventespresso.com/about/privacy-policy/" target="_blank">', |
|
| 143 | + '</a>', |
|
| 144 | + '</p>' |
|
| 145 | + ); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + $settings_url = EEH_URL::add_query_args_and_nonce( |
|
| 149 | + ['action' => 'default'], |
|
| 150 | + admin_url('admin.php?page=espresso_general_settings') |
|
| 151 | + ); |
|
| 152 | + $settings_url .= '#UXIP_settings'; |
|
| 153 | + printf( |
|
| 154 | + esc_html__( |
|
| 155 | + 'The Event Espresso UXIP feature is not yet active on your site. For %1$smore info%2$s and to opt-in %3$sclick here%4$s.', |
|
| 156 | + 'event_espresso' |
|
| 157 | + ), |
|
| 158 | + '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', |
|
| 159 | + '</a>', |
|
| 160 | + '<a href="' . $settings_url . '" target="_blank">', |
|
| 161 | + '</a>' |
|
| 162 | + ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Callback for admin_enqueue_scripts that sets up the scripts and styles for the uxip notice |
|
| 168 | + */ |
|
| 169 | + public function enqueueScripts() |
|
| 170 | + { |
|
| 171 | + wp_register_script( |
|
| 172 | + 'ee-data-optin-js', |
|
| 173 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js', |
|
| 174 | + ['jquery'], |
|
| 175 | + EVENT_ESPRESSO_VERSION, |
|
| 176 | + true |
|
| 177 | + ); |
|
| 178 | + wp_register_style( |
|
| 179 | + 'ee-data-optin-css', |
|
| 180 | + EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css', |
|
| 181 | + [], |
|
| 182 | + EVENT_ESPRESSO_VERSION |
|
| 183 | + ); |
|
| 184 | + |
|
| 185 | + wp_enqueue_script('ee-data-optin-js'); |
|
| 186 | + wp_enqueue_style('ee-data-optin-css'); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Callback for wp_ajax_espresso_data_optin that handles the ajax request |
|
| 192 | + */ |
|
| 193 | + public function ajaxHandler() |
|
| 194 | + { |
|
| 195 | + /** @var RequestInterface $request */ |
|
| 196 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
| 197 | + $nonce = $request->getRequestParam('nonce'); |
|
| 198 | + // verify nonce |
|
| 199 | + if (! $nonce || ! wp_verify_nonce($nonce, 'ee-data-optin')) { |
|
| 200 | + exit(); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + // update has notified option |
|
| 204 | + $this->config->setHasNotifiedAboutUxip(); |
|
| 205 | + exit(); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Used to determine whether additional stats are sent. |
|
| 211 | + */ |
|
| 212 | + private function sendStats(): bool |
|
| 213 | + { |
|
| 214 | + return MaintenanceStatus::isNotFullSite() |
|
| 215 | + && $this->config->isOptedInForUxip() |
|
| 216 | + && $this->statSendTimestampExpired(); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Returns true when the timestamp used to track whether stats get sent (currently a weekly interval) is expired. |
|
| 222 | + * Returns false otherwise. |
|
| 223 | + * |
|
| 224 | + * @return bool |
|
| 225 | + */ |
|
| 226 | + private function statSendTimestampExpired(): bool |
|
| 227 | + { |
|
| 228 | + $current_expiry = get_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, null); |
|
| 229 | + if ($current_expiry === null) { |
|
| 230 | + add_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS, '', 'no'); |
|
| 231 | + return true; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + if (time() > (int) $current_expiry) { |
|
| 235 | + update_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS); |
|
| 236 | + return true; |
|
| 237 | + } |
|
| 238 | + return false; |
|
| 239 | + } |
|
| 240 | 240 | } |
@@ -13,131 +13,131 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class EE_PMT_Check extends EE_PMT_Base |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @param EE_Payment_Method|null $pm_instance |
|
| 18 | - * @throws ReflectionException |
|
| 19 | - * @throws EE_Error |
|
| 20 | - */ |
|
| 21 | - public function __construct($pm_instance = null) |
|
| 22 | - { |
|
| 23 | - $this->_pretty_name = esc_html__("Check", 'event_espresso'); |
|
| 24 | - $this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso'); |
|
| 25 | - parent::__construct($pm_instance); |
|
| 26 | - $this->_default_button_url = $this->file_url() . 'lib/check-logo.png'; |
|
| 27 | - } |
|
| 16 | + /** |
|
| 17 | + * @param EE_Payment_Method|null $pm_instance |
|
| 18 | + * @throws ReflectionException |
|
| 19 | + * @throws EE_Error |
|
| 20 | + */ |
|
| 21 | + public function __construct($pm_instance = null) |
|
| 22 | + { |
|
| 23 | + $this->_pretty_name = esc_html__("Check", 'event_espresso'); |
|
| 24 | + $this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso'); |
|
| 25 | + parent::__construct($pm_instance); |
|
| 26 | + $this->_default_button_url = $this->file_url() . 'lib/check-logo.png'; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Creates the billing form for this payment method type |
|
| 33 | - * @param EE_Transaction|null $transaction |
|
| 34 | - * @return EE_Billing_Info_Form|null |
|
| 35 | - * @throws EE_Error |
|
| 36 | - * @throws ReflectionException |
|
| 37 | - */ |
|
| 38 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
| 39 | - { return null; |
|
| 40 | - } |
|
| 31 | + /** |
|
| 32 | + * Creates the billing form for this payment method type |
|
| 33 | + * @param EE_Transaction|null $transaction |
|
| 34 | + * @return EE_Billing_Info_Form|null |
|
| 35 | + * @throws EE_Error |
|
| 36 | + * @throws ReflectionException |
|
| 37 | + */ |
|
| 38 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
| 39 | + { return null; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Overrides parent to dynamically set some defaults, but only when the form is requested |
|
| 46 | - * |
|
| 47 | - * @return EE_Payment_Method_Form |
|
| 48 | - * @throws EE_Error |
|
| 49 | - * @throws ReflectionException |
|
| 50 | - */ |
|
| 51 | - public function generate_new_settings_form() |
|
| 52 | - { |
|
| 53 | - if (MaintenanceStatus::isNotFullSite()) { |
|
| 54 | - $organization = EE_Registry::instance()->CFG->organization; |
|
| 55 | - $organization_name = $organization->get_pretty('name'); |
|
| 56 | - $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : ''; |
|
| 57 | - $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : ''; |
|
| 58 | - $default_address .= $organization->city != '' ? $organization->get_pretty('city') : ''; |
|
| 59 | - $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />'; |
|
| 60 | - $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
| 61 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ; |
|
| 62 | - $default_address .= $state ? $state->name() . '<br />' : ''; |
|
| 63 | - $default_address .= $country ? $country->name() . '<br />' : ''; |
|
| 64 | - $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : ''; |
|
| 65 | - } else { |
|
| 66 | - $default_address = 'unknown'; |
|
| 67 | - $organization_name = 'unknown'; |
|
| 68 | - } |
|
| 69 | - return new EE_Payment_Method_Form(array( |
|
| 70 | - 'extra_meta_inputs' => array( |
|
| 71 | - 'check_title' => new EE_Text_Input(array( |
|
| 72 | - 'html_label_text' => sprintf(esc_html__("Title %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 73 | - 'default' => esc_html__("Check/Money Order Payments", 'event_espresso'), |
|
| 74 | - )), |
|
| 75 | - 'payment_instructions' => new EE_Text_Area_Input(array( |
|
| 76 | - 'html_label_text' => sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 77 | - 'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'), |
|
| 78 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
| 79 | - )), |
|
| 80 | - 'payable_to' => new EE_Text_Input(array( |
|
| 81 | - 'html_label_text' => sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 82 | - 'default' => $organization_name |
|
| 83 | - )), |
|
| 84 | - 'address_to_send_payment' => new EE_Text_Area_Input(array( |
|
| 85 | - 'html_label_text' => sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 86 | - 'default' => $default_address, |
|
| 87 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
| 88 | - )), |
|
| 89 | - ), |
|
| 90 | - 'exclude' => array('PMD_debug_mode') |
|
| 91 | - )); |
|
| 92 | - } |
|
| 44 | + /** |
|
| 45 | + * Overrides parent to dynamically set some defaults, but only when the form is requested |
|
| 46 | + * |
|
| 47 | + * @return EE_Payment_Method_Form |
|
| 48 | + * @throws EE_Error |
|
| 49 | + * @throws ReflectionException |
|
| 50 | + */ |
|
| 51 | + public function generate_new_settings_form() |
|
| 52 | + { |
|
| 53 | + if (MaintenanceStatus::isNotFullSite()) { |
|
| 54 | + $organization = EE_Registry::instance()->CFG->organization; |
|
| 55 | + $organization_name = $organization->get_pretty('name'); |
|
| 56 | + $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : ''; |
|
| 57 | + $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : ''; |
|
| 58 | + $default_address .= $organization->city != '' ? $organization->get_pretty('city') : ''; |
|
| 59 | + $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />'; |
|
| 60 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
| 61 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ; |
|
| 62 | + $default_address .= $state ? $state->name() . '<br />' : ''; |
|
| 63 | + $default_address .= $country ? $country->name() . '<br />' : ''; |
|
| 64 | + $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : ''; |
|
| 65 | + } else { |
|
| 66 | + $default_address = 'unknown'; |
|
| 67 | + $organization_name = 'unknown'; |
|
| 68 | + } |
|
| 69 | + return new EE_Payment_Method_Form(array( |
|
| 70 | + 'extra_meta_inputs' => array( |
|
| 71 | + 'check_title' => new EE_Text_Input(array( |
|
| 72 | + 'html_label_text' => sprintf(esc_html__("Title %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 73 | + 'default' => esc_html__("Check/Money Order Payments", 'event_espresso'), |
|
| 74 | + )), |
|
| 75 | + 'payment_instructions' => new EE_Text_Area_Input(array( |
|
| 76 | + 'html_label_text' => sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 77 | + 'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'), |
|
| 78 | + 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
| 79 | + )), |
|
| 80 | + 'payable_to' => new EE_Text_Input(array( |
|
| 81 | + 'html_label_text' => sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 82 | + 'default' => $organization_name |
|
| 83 | + )), |
|
| 84 | + 'address_to_send_payment' => new EE_Text_Area_Input(array( |
|
| 85 | + 'html_label_text' => sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()), |
|
| 86 | + 'default' => $default_address, |
|
| 87 | + 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
| 88 | + )), |
|
| 89 | + ), |
|
| 90 | + 'exclude' => array('PMD_debug_mode') |
|
| 91 | + )); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Adds the help tab |
|
| 98 | - * |
|
| 99 | - * @return array |
|
| 100 | - * @see EE_PMT_Base::help_tabs_config() |
|
| 101 | - */ |
|
| 102 | - public function help_tabs_config() |
|
| 103 | - { |
|
| 104 | - return array( |
|
| 105 | - $this->get_help_tab_name() => array( |
|
| 106 | - 'title' => esc_html__('Check Settings', 'event_espresso'), |
|
| 107 | - 'filename' => 'payment_methods_overview_check' |
|
| 108 | - ), |
|
| 109 | - ); |
|
| 110 | - } |
|
| 96 | + /** |
|
| 97 | + * Adds the help tab |
|
| 98 | + * |
|
| 99 | + * @return array |
|
| 100 | + * @see EE_PMT_Base::help_tabs_config() |
|
| 101 | + */ |
|
| 102 | + public function help_tabs_config() |
|
| 103 | + { |
|
| 104 | + return array( |
|
| 105 | + $this->get_help_tab_name() => array( |
|
| 106 | + 'title' => esc_html__('Check Settings', 'event_espresso'), |
|
| 107 | + 'filename' => 'payment_methods_overview_check' |
|
| 108 | + ), |
|
| 109 | + ); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * For adding any html output ab ove the payment overview. |
|
| 116 | - * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
| 117 | - * Other gateways may want to override this, such as offline gateways. |
|
| 118 | - * |
|
| 119 | - * @param EE_Payment $payment |
|
| 120 | - * @return string |
|
| 121 | - * @throws EE_Error |
|
| 122 | - * @throws ReflectionException |
|
| 123 | - */ |
|
| 124 | - public function payment_overview_content(EE_Payment $payment) |
|
| 125 | - { |
|
| 126 | - $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array(); |
|
| 127 | - $template_vars = array_merge( |
|
| 128 | - array( |
|
| 129 | - 'payment_method' => $this->_pm_instance, |
|
| 130 | - 'payment' => $payment, |
|
| 131 | - 'check_title' => '', |
|
| 132 | - 'payment_instructions' => '', |
|
| 133 | - 'payable_to' => '', |
|
| 134 | - 'address_to_send_payment' => '', |
|
| 135 | - ), |
|
| 136 | - $extra_meta_for_payment_method |
|
| 137 | - ); |
|
| 138 | - return EEH_Template::locate_template( |
|
| 139 | - 'payment_methods/Check/templates/check_payment_details_content.template.php', |
|
| 140 | - $template_vars |
|
| 141 | - ); |
|
| 142 | - } |
|
| 114 | + /** |
|
| 115 | + * For adding any html output ab ove the payment overview. |
|
| 116 | + * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
| 117 | + * Other gateways may want to override this, such as offline gateways. |
|
| 118 | + * |
|
| 119 | + * @param EE_Payment $payment |
|
| 120 | + * @return string |
|
| 121 | + * @throws EE_Error |
|
| 122 | + * @throws ReflectionException |
|
| 123 | + */ |
|
| 124 | + public function payment_overview_content(EE_Payment $payment) |
|
| 125 | + { |
|
| 126 | + $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array(); |
|
| 127 | + $template_vars = array_merge( |
|
| 128 | + array( |
|
| 129 | + 'payment_method' => $this->_pm_instance, |
|
| 130 | + 'payment' => $payment, |
|
| 131 | + 'check_title' => '', |
|
| 132 | + 'payment_instructions' => '', |
|
| 133 | + 'payable_to' => '', |
|
| 134 | + 'address_to_send_payment' => '', |
|
| 135 | + ), |
|
| 136 | + $extra_meta_for_payment_method |
|
| 137 | + ); |
|
| 138 | + return EEH_Template::locate_template( |
|
| 139 | + 'payment_methods/Check/templates/check_payment_details_content.template.php', |
|
| 140 | + $template_vars |
|
| 141 | + ); |
|
| 142 | + } |
|
| 143 | 143 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $this->_pretty_name = esc_html__("Check", 'event_espresso'); |
| 24 | 24 | $this->_default_description = esc_html__('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso'); |
| 25 | 25 | parent::__construct($pm_instance); |
| 26 | - $this->_default_button_url = $this->file_url() . 'lib/check-logo.png'; |
|
| 26 | + $this->_default_button_url = $this->file_url().'lib/check-logo.png'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | if (MaintenanceStatus::isNotFullSite()) { |
| 54 | 54 | $organization = EE_Registry::instance()->CFG->organization; |
| 55 | 55 | $organization_name = $organization->get_pretty('name'); |
| 56 | - $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : ''; |
|
| 57 | - $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : ''; |
|
| 56 | + $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1').'<br />' : ''; |
|
| 57 | + $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2').'<br />' : ''; |
|
| 58 | 58 | $default_address .= $organization->city != '' ? $organization->get_pretty('city') : ''; |
| 59 | - $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />'; |
|
| 59 | + $default_address .= ($organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />'; |
|
| 60 | 60 | $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
| 61 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ; |
|
| 62 | - $default_address .= $state ? $state->name() . '<br />' : ''; |
|
| 63 | - $default_address .= $country ? $country->name() . '<br />' : ''; |
|
| 61 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO); |
|
| 62 | + $default_address .= $state ? $state->name().'<br />' : ''; |
|
| 63 | + $default_address .= $country ? $country->name().'<br />' : ''; |
|
| 64 | 64 | $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : ''; |
| 65 | 65 | } else { |
| 66 | 66 | $default_address = 'unknown'; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'payment_instructions' => new EE_Text_Area_Input(array( |
| 76 | 76 | 'html_label_text' => sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()), |
| 77 | 77 | 'default' => esc_html__("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'), |
| 78 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
| 78 | + 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()), |
|
| 79 | 79 | )), |
| 80 | 80 | 'payable_to' => new EE_Text_Input(array( |
| 81 | 81 | 'html_label_text' => sprintf(esc_html__("Payable To %s", "event_espresso"), $this->get_help_tab_link()), |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | 'address_to_send_payment' => new EE_Text_Area_Input(array( |
| 85 | 85 | 'html_label_text' => sprintf(esc_html__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()), |
| 86 | 86 | 'default' => $default_address, |
| 87 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
| 87 | + 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()), |
|
| 88 | 88 | )), |
| 89 | 89 | ), |
| 90 | 90 | 'exclude' => array('PMD_debug_mode') |