@@ -12,380 +12,380 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Initial setup of data (called by parent). |
|
| 17 | - */ |
|
| 18 | - protected function _setup_data() |
|
| 19 | - { |
|
| 20 | - $this->_data = $this->_view !== 'trash' |
|
| 21 | - ? $this->_admin_page->get_attendees($this->_per_page) |
|
| 22 | - : $this->_admin_page->get_attendees($this->_per_page, false, true); |
|
| 23 | - $this->_all_data_count = $this->_view !== 'trash' |
|
| 24 | - ? $this->_admin_page->get_attendees($this->_per_page, true) |
|
| 25 | - : $this->_admin_page->get_attendees($this->_per_page, true, true); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Initial setup of properties. |
|
| 31 | - */ |
|
| 32 | - protected function _set_properties() |
|
| 33 | - { |
|
| 34 | - $this->_wp_list_args = array( |
|
| 35 | - 'singular' => esc_html__('attendee', 'event_espresso'), |
|
| 36 | - 'plural' => esc_html__('attendees', 'event_espresso'), |
|
| 37 | - 'ajax' => true, |
|
| 38 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 39 | - ); |
|
| 40 | - |
|
| 41 | - $this->_columns = array( |
|
| 42 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 43 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
| 44 | - 'ATT_fname' => esc_html__('First Name', 'event_espresso'), |
|
| 45 | - 'ATT_lname' => esc_html__('Last Name', 'event_espresso'), |
|
| 46 | - 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
| 47 | - 'Registration_Count' => esc_html__('# Registrations', 'event_espresso'), |
|
| 48 | - 'ATT_phone' => esc_html__('Phone', 'event_espresso'), |
|
| 49 | - 'ATT_address' => esc_html__('Address', 'event_espresso'), |
|
| 50 | - 'ATT_city' => esc_html__('City', 'event_espresso'), |
|
| 51 | - 'STA_ID' => esc_html__('State/Province', 'event_espresso'), |
|
| 52 | - 'CNT_ISO' => esc_html__('Country', 'event_espresso'), |
|
| 53 | - ); |
|
| 54 | - |
|
| 55 | - $this->_sortable_columns = array( |
|
| 56 | - 'id' => array('id' => false), |
|
| 57 | - 'ATT_lname' => array('ATT_lname' => true), // true means its already sorted |
|
| 58 | - 'ATT_fname' => array('ATT_fname' => false), |
|
| 59 | - 'ATT_email' => array('ATT_email' => false), |
|
| 60 | - 'Registration_Count' => array('Registration_Count' => false), |
|
| 61 | - 'ATT_city' => array('ATT_city' => false), |
|
| 62 | - 'STA_ID' => array('STA_ID' => false), |
|
| 63 | - 'CNT_ISO' => array('CNT_ISO' => false), |
|
| 64 | - ); |
|
| 65 | - |
|
| 66 | - $this->_hidden_columns = array( |
|
| 67 | - 'ATT_phone', |
|
| 68 | - 'ATT_address', |
|
| 69 | - 'ATT_city', |
|
| 70 | - 'STA_ID', |
|
| 71 | - 'CNT_ISO', |
|
| 72 | - ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Initial setup of filters |
|
| 78 | - * |
|
| 79 | - * @return array |
|
| 80 | - */ |
|
| 81 | - protected function _get_table_filters() |
|
| 82 | - { |
|
| 83 | - return array(); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Initial setup of counts for views |
|
| 89 | - * |
|
| 90 | - * @throws InvalidArgumentException |
|
| 91 | - * @throws InvalidDataTypeException |
|
| 92 | - * @throws InvalidInterfaceException |
|
| 93 | - */ |
|
| 94 | - protected function _add_view_counts() |
|
| 95 | - { |
|
| 96 | - $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true); |
|
| 97 | - if ( |
|
| 98 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 99 | - 'ee_delete_contacts', |
|
| 100 | - 'espresso_registrations_delete_registration' |
|
| 101 | - ) |
|
| 102 | - ) { |
|
| 103 | - $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Get count of attendees. |
|
| 110 | - * |
|
| 111 | - * @return int |
|
| 112 | - * @throws EE_Error |
|
| 113 | - * @throws InvalidArgumentException |
|
| 114 | - * @throws InvalidDataTypeException |
|
| 115 | - * @throws InvalidInterfaceException |
|
| 116 | - */ |
|
| 117 | - protected function _get_attendees_count() |
|
| 118 | - { |
|
| 119 | - return EEM_Attendee::instance()->count(); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Checkbox column |
|
| 125 | - * |
|
| 126 | - * @param EE_Attendee $attendee Unable to typehint this method because overrides parent. |
|
| 127 | - * @return string |
|
| 128 | - * @throws EE_Error |
|
| 129 | - */ |
|
| 130 | - public function column_cb($attendee) |
|
| 131 | - { |
|
| 132 | - if (! $attendee instanceof EE_Attendee) { |
|
| 133 | - return ''; |
|
| 134 | - } |
|
| 135 | - return sprintf( |
|
| 136 | - '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
| 137 | - $attendee->ID() |
|
| 138 | - ); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @param EE_Attendee $attendee |
|
| 144 | - * @return string |
|
| 145 | - * @throws EE_Error |
|
| 146 | - */ |
|
| 147 | - public function column_id(EE_Attendee $attendee) |
|
| 148 | - { |
|
| 149 | - $content = $attendee->ID(); |
|
| 150 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 151 | - $content .= ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 152 | - return $this->columnContent('id', $content, 'center'); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * ATT_lname column |
|
| 158 | - * |
|
| 159 | - * @param EE_Attendee $attendee |
|
| 160 | - * @return string |
|
| 161 | - * @throws InvalidArgumentException |
|
| 162 | - * @throws InvalidDataTypeException |
|
| 163 | - * @throws InvalidInterfaceException |
|
| 164 | - * @throws EE_Error |
|
| 165 | - */ |
|
| 166 | - public function column_ATT_lname(EE_Attendee $attendee) |
|
| 167 | - { |
|
| 168 | - // edit attendee link |
|
| 169 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 170 | - array( |
|
| 171 | - 'action' => 'edit_attendee', |
|
| 172 | - 'post' => $attendee->ID(), |
|
| 173 | - ), |
|
| 174 | - REG_ADMIN_URL |
|
| 175 | - ); |
|
| 176 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 177 | - 'ee_edit_contacts', |
|
| 178 | - 'espresso_registrations_edit_attendee' |
|
| 179 | - ) |
|
| 180 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 181 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 182 | - . $attendee->lname() . '</a>' |
|
| 183 | - : $attendee->lname(); |
|
| 184 | - return $name_link; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * ATT_fname column |
|
| 190 | - * |
|
| 191 | - * @param EE_Attendee $attendee |
|
| 192 | - * @return string |
|
| 193 | - * @throws InvalidArgumentException |
|
| 194 | - * @throws InvalidDataTypeException |
|
| 195 | - * @throws InvalidInterfaceException |
|
| 196 | - * @throws EE_Error |
|
| 197 | - */ |
|
| 198 | - public function column_ATT_fname(EE_Attendee $attendee) |
|
| 199 | - { |
|
| 200 | - // Build row actions |
|
| 201 | - $actions = array(); |
|
| 202 | - // edit attendee link |
|
| 203 | - if ( |
|
| 204 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 205 | - 'ee_edit_contacts', |
|
| 206 | - 'espresso_registrations_edit_attendee' |
|
| 207 | - ) |
|
| 208 | - ) { |
|
| 209 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 210 | - array( |
|
| 211 | - 'action' => 'edit_attendee', |
|
| 212 | - 'post' => $attendee->ID(), |
|
| 213 | - ), |
|
| 214 | - REG_ADMIN_URL |
|
| 215 | - ); |
|
| 216 | - $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
| 217 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 218 | - . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - if ($this->_view === 'in_use') { |
|
| 222 | - // trash attendee link |
|
| 223 | - if ( |
|
| 224 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 225 | - 'ee_delete_contacts', |
|
| 226 | - 'espresso_registrations_trash_attendees' |
|
| 227 | - ) |
|
| 228 | - ) { |
|
| 229 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 230 | - array( |
|
| 231 | - 'action' => 'trash_attendee', |
|
| 232 | - 'ATT_ID' => $attendee->ID(), |
|
| 233 | - ), |
|
| 234 | - REG_ADMIN_URL |
|
| 235 | - ); |
|
| 236 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
| 237 | - . esc_attr__('Move Contact to Trash', 'event_espresso') |
|
| 238 | - . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
| 239 | - } |
|
| 240 | - } else { |
|
| 241 | - if ( |
|
| 242 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 243 | - 'ee_delete_contacts', |
|
| 244 | - 'espresso_registrations_restore_attendees' |
|
| 245 | - ) |
|
| 246 | - ) { |
|
| 247 | - // restore attendee link |
|
| 248 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 249 | - array( |
|
| 250 | - 'action' => 'restore_attendees', |
|
| 251 | - 'ATT_ID' => $attendee->ID(), |
|
| 252 | - ), |
|
| 253 | - REG_ADMIN_URL |
|
| 254 | - ); |
|
| 255 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
| 256 | - . esc_attr__('Restore Contact', 'event_espresso') . '">' |
|
| 257 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 262 | - array( |
|
| 263 | - 'action' => 'edit_attendee', |
|
| 264 | - 'post' => $attendee->ID(), |
|
| 265 | - ), |
|
| 266 | - REG_ADMIN_URL |
|
| 267 | - ); |
|
| 268 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 269 | - 'ee_edit_contacts', |
|
| 270 | - 'espresso_registrations_edit_attendee' |
|
| 271 | - ) |
|
| 272 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 273 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>' |
|
| 274 | - : $attendee->fname(); |
|
| 275 | - |
|
| 276 | - // Return the name contents |
|
| 277 | - return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * Email Column |
|
| 283 | - * |
|
| 284 | - * @param EE_Attendee $attendee |
|
| 285 | - * @return string |
|
| 286 | - * @throws EE_Error |
|
| 287 | - */ |
|
| 288 | - public function column_ATT_email(EE_Attendee $attendee) |
|
| 289 | - { |
|
| 290 | - return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>'; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * Column displaying count of registrations attached to Attendee. |
|
| 296 | - * |
|
| 297 | - * @param EE_Attendee $attendee |
|
| 298 | - * @return string |
|
| 299 | - * @throws EE_Error |
|
| 300 | - */ |
|
| 301 | - public function column_Registration_Count(EE_Attendee $attendee) |
|
| 302 | - { |
|
| 303 | - $link = EEH_URL::add_query_args_and_nonce( |
|
| 304 | - array( |
|
| 305 | - 'action' => 'default', |
|
| 306 | - 'ATT_ID' => $attendee->ID(), |
|
| 307 | - ), |
|
| 308 | - REG_ADMIN_URL |
|
| 309 | - ); |
|
| 310 | - return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>'; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * ATT_address column |
|
| 316 | - * |
|
| 317 | - * @param EE_Attendee $attendee |
|
| 318 | - * @return mixed |
|
| 319 | - * @throws EE_Error |
|
| 320 | - */ |
|
| 321 | - public function column_ATT_address(EE_Attendee $attendee) |
|
| 322 | - { |
|
| 323 | - return $attendee->address(); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * ATT_city column |
|
| 329 | - * |
|
| 330 | - * @param EE_Attendee $attendee |
|
| 331 | - * @return mixed |
|
| 332 | - * @throws EE_Error |
|
| 333 | - */ |
|
| 334 | - public function column_ATT_city(EE_Attendee $attendee) |
|
| 335 | - { |
|
| 336 | - return $attendee->city(); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * State Column |
|
| 342 | - * |
|
| 343 | - * @param EE_Attendee $attendee |
|
| 344 | - * @return string |
|
| 345 | - * @throws EE_Error |
|
| 346 | - * @throws InvalidArgumentException |
|
| 347 | - * @throws InvalidDataTypeException |
|
| 348 | - * @throws InvalidInterfaceException |
|
| 349 | - */ |
|
| 350 | - public function column_STA_ID(EE_Attendee $attendee) |
|
| 351 | - { |
|
| 352 | - $states = EEM_State::instance()->get_all_states(); |
|
| 353 | - $state = isset($states[ $attendee->state_ID() ]) |
|
| 354 | - ? $states[ $attendee->state_ID() ]->get('STA_name') |
|
| 355 | - : $attendee->state_ID(); |
|
| 356 | - return ! is_numeric($state) ? $state : ''; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Country Column |
|
| 362 | - * |
|
| 363 | - * @param EE_Attendee $attendee |
|
| 364 | - * @return string |
|
| 365 | - * @throws EE_Error |
|
| 366 | - * @throws InvalidArgumentException |
|
| 367 | - * @throws InvalidDataTypeException |
|
| 368 | - * @throws InvalidInterfaceException |
|
| 369 | - */ |
|
| 370 | - public function column_CNT_ISO(EE_Attendee $attendee) |
|
| 371 | - { |
|
| 372 | - $countries = EEM_Country::instance()->get_all_countries(); |
|
| 373 | - $country = isset($countries[ $attendee->country_ID() ]) |
|
| 374 | - ? $countries[ $attendee->country_ID() ]->get('CNT_name') |
|
| 375 | - : $attendee->country_ID(); |
|
| 376 | - return ! is_numeric($country) ? $country : ''; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Phone Number column |
|
| 382 | - * |
|
| 383 | - * @param EE_Attendee $attendee |
|
| 384 | - * @return mixed |
|
| 385 | - * @throws EE_Error |
|
| 386 | - */ |
|
| 387 | - public function column_ATT_phone(EE_Attendee $attendee) |
|
| 388 | - { |
|
| 389 | - return $attendee->phone(); |
|
| 390 | - } |
|
| 15 | + /** |
|
| 16 | + * Initial setup of data (called by parent). |
|
| 17 | + */ |
|
| 18 | + protected function _setup_data() |
|
| 19 | + { |
|
| 20 | + $this->_data = $this->_view !== 'trash' |
|
| 21 | + ? $this->_admin_page->get_attendees($this->_per_page) |
|
| 22 | + : $this->_admin_page->get_attendees($this->_per_page, false, true); |
|
| 23 | + $this->_all_data_count = $this->_view !== 'trash' |
|
| 24 | + ? $this->_admin_page->get_attendees($this->_per_page, true) |
|
| 25 | + : $this->_admin_page->get_attendees($this->_per_page, true, true); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Initial setup of properties. |
|
| 31 | + */ |
|
| 32 | + protected function _set_properties() |
|
| 33 | + { |
|
| 34 | + $this->_wp_list_args = array( |
|
| 35 | + 'singular' => esc_html__('attendee', 'event_espresso'), |
|
| 36 | + 'plural' => esc_html__('attendees', 'event_espresso'), |
|
| 37 | + 'ajax' => true, |
|
| 38 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 39 | + ); |
|
| 40 | + |
|
| 41 | + $this->_columns = array( |
|
| 42 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 43 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
| 44 | + 'ATT_fname' => esc_html__('First Name', 'event_espresso'), |
|
| 45 | + 'ATT_lname' => esc_html__('Last Name', 'event_espresso'), |
|
| 46 | + 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
| 47 | + 'Registration_Count' => esc_html__('# Registrations', 'event_espresso'), |
|
| 48 | + 'ATT_phone' => esc_html__('Phone', 'event_espresso'), |
|
| 49 | + 'ATT_address' => esc_html__('Address', 'event_espresso'), |
|
| 50 | + 'ATT_city' => esc_html__('City', 'event_espresso'), |
|
| 51 | + 'STA_ID' => esc_html__('State/Province', 'event_espresso'), |
|
| 52 | + 'CNT_ISO' => esc_html__('Country', 'event_espresso'), |
|
| 53 | + ); |
|
| 54 | + |
|
| 55 | + $this->_sortable_columns = array( |
|
| 56 | + 'id' => array('id' => false), |
|
| 57 | + 'ATT_lname' => array('ATT_lname' => true), // true means its already sorted |
|
| 58 | + 'ATT_fname' => array('ATT_fname' => false), |
|
| 59 | + 'ATT_email' => array('ATT_email' => false), |
|
| 60 | + 'Registration_Count' => array('Registration_Count' => false), |
|
| 61 | + 'ATT_city' => array('ATT_city' => false), |
|
| 62 | + 'STA_ID' => array('STA_ID' => false), |
|
| 63 | + 'CNT_ISO' => array('CNT_ISO' => false), |
|
| 64 | + ); |
|
| 65 | + |
|
| 66 | + $this->_hidden_columns = array( |
|
| 67 | + 'ATT_phone', |
|
| 68 | + 'ATT_address', |
|
| 69 | + 'ATT_city', |
|
| 70 | + 'STA_ID', |
|
| 71 | + 'CNT_ISO', |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Initial setup of filters |
|
| 78 | + * |
|
| 79 | + * @return array |
|
| 80 | + */ |
|
| 81 | + protected function _get_table_filters() |
|
| 82 | + { |
|
| 83 | + return array(); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Initial setup of counts for views |
|
| 89 | + * |
|
| 90 | + * @throws InvalidArgumentException |
|
| 91 | + * @throws InvalidDataTypeException |
|
| 92 | + * @throws InvalidInterfaceException |
|
| 93 | + */ |
|
| 94 | + protected function _add_view_counts() |
|
| 95 | + { |
|
| 96 | + $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true); |
|
| 97 | + if ( |
|
| 98 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 99 | + 'ee_delete_contacts', |
|
| 100 | + 'espresso_registrations_delete_registration' |
|
| 101 | + ) |
|
| 102 | + ) { |
|
| 103 | + $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Get count of attendees. |
|
| 110 | + * |
|
| 111 | + * @return int |
|
| 112 | + * @throws EE_Error |
|
| 113 | + * @throws InvalidArgumentException |
|
| 114 | + * @throws InvalidDataTypeException |
|
| 115 | + * @throws InvalidInterfaceException |
|
| 116 | + */ |
|
| 117 | + protected function _get_attendees_count() |
|
| 118 | + { |
|
| 119 | + return EEM_Attendee::instance()->count(); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Checkbox column |
|
| 125 | + * |
|
| 126 | + * @param EE_Attendee $attendee Unable to typehint this method because overrides parent. |
|
| 127 | + * @return string |
|
| 128 | + * @throws EE_Error |
|
| 129 | + */ |
|
| 130 | + public function column_cb($attendee) |
|
| 131 | + { |
|
| 132 | + if (! $attendee instanceof EE_Attendee) { |
|
| 133 | + return ''; |
|
| 134 | + } |
|
| 135 | + return sprintf( |
|
| 136 | + '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', |
|
| 137 | + $attendee->ID() |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @param EE_Attendee $attendee |
|
| 144 | + * @return string |
|
| 145 | + * @throws EE_Error |
|
| 146 | + */ |
|
| 147 | + public function column_id(EE_Attendee $attendee) |
|
| 148 | + { |
|
| 149 | + $content = $attendee->ID(); |
|
| 150 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 151 | + $content .= ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 152 | + return $this->columnContent('id', $content, 'center'); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * ATT_lname column |
|
| 158 | + * |
|
| 159 | + * @param EE_Attendee $attendee |
|
| 160 | + * @return string |
|
| 161 | + * @throws InvalidArgumentException |
|
| 162 | + * @throws InvalidDataTypeException |
|
| 163 | + * @throws InvalidInterfaceException |
|
| 164 | + * @throws EE_Error |
|
| 165 | + */ |
|
| 166 | + public function column_ATT_lname(EE_Attendee $attendee) |
|
| 167 | + { |
|
| 168 | + // edit attendee link |
|
| 169 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 170 | + array( |
|
| 171 | + 'action' => 'edit_attendee', |
|
| 172 | + 'post' => $attendee->ID(), |
|
| 173 | + ), |
|
| 174 | + REG_ADMIN_URL |
|
| 175 | + ); |
|
| 176 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 177 | + 'ee_edit_contacts', |
|
| 178 | + 'espresso_registrations_edit_attendee' |
|
| 179 | + ) |
|
| 180 | + ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 181 | + . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 182 | + . $attendee->lname() . '</a>' |
|
| 183 | + : $attendee->lname(); |
|
| 184 | + return $name_link; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * ATT_fname column |
|
| 190 | + * |
|
| 191 | + * @param EE_Attendee $attendee |
|
| 192 | + * @return string |
|
| 193 | + * @throws InvalidArgumentException |
|
| 194 | + * @throws InvalidDataTypeException |
|
| 195 | + * @throws InvalidInterfaceException |
|
| 196 | + * @throws EE_Error |
|
| 197 | + */ |
|
| 198 | + public function column_ATT_fname(EE_Attendee $attendee) |
|
| 199 | + { |
|
| 200 | + // Build row actions |
|
| 201 | + $actions = array(); |
|
| 202 | + // edit attendee link |
|
| 203 | + if ( |
|
| 204 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 205 | + 'ee_edit_contacts', |
|
| 206 | + 'espresso_registrations_edit_attendee' |
|
| 207 | + ) |
|
| 208 | + ) { |
|
| 209 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 210 | + array( |
|
| 211 | + 'action' => 'edit_attendee', |
|
| 212 | + 'post' => $attendee->ID(), |
|
| 213 | + ), |
|
| 214 | + REG_ADMIN_URL |
|
| 215 | + ); |
|
| 216 | + $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
| 217 | + . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 218 | + . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + if ($this->_view === 'in_use') { |
|
| 222 | + // trash attendee link |
|
| 223 | + if ( |
|
| 224 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 225 | + 'ee_delete_contacts', |
|
| 226 | + 'espresso_registrations_trash_attendees' |
|
| 227 | + ) |
|
| 228 | + ) { |
|
| 229 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 230 | + array( |
|
| 231 | + 'action' => 'trash_attendee', |
|
| 232 | + 'ATT_ID' => $attendee->ID(), |
|
| 233 | + ), |
|
| 234 | + REG_ADMIN_URL |
|
| 235 | + ); |
|
| 236 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
| 237 | + . esc_attr__('Move Contact to Trash', 'event_espresso') |
|
| 238 | + . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
| 239 | + } |
|
| 240 | + } else { |
|
| 241 | + if ( |
|
| 242 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 243 | + 'ee_delete_contacts', |
|
| 244 | + 'espresso_registrations_restore_attendees' |
|
| 245 | + ) |
|
| 246 | + ) { |
|
| 247 | + // restore attendee link |
|
| 248 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 249 | + array( |
|
| 250 | + 'action' => 'restore_attendees', |
|
| 251 | + 'ATT_ID' => $attendee->ID(), |
|
| 252 | + ), |
|
| 253 | + REG_ADMIN_URL |
|
| 254 | + ); |
|
| 255 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
| 256 | + . esc_attr__('Restore Contact', 'event_espresso') . '">' |
|
| 257 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 262 | + array( |
|
| 263 | + 'action' => 'edit_attendee', |
|
| 264 | + 'post' => $attendee->ID(), |
|
| 265 | + ), |
|
| 266 | + REG_ADMIN_URL |
|
| 267 | + ); |
|
| 268 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 269 | + 'ee_edit_contacts', |
|
| 270 | + 'espresso_registrations_edit_attendee' |
|
| 271 | + ) |
|
| 272 | + ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 273 | + . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>' |
|
| 274 | + : $attendee->fname(); |
|
| 275 | + |
|
| 276 | + // Return the name contents |
|
| 277 | + return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * Email Column |
|
| 283 | + * |
|
| 284 | + * @param EE_Attendee $attendee |
|
| 285 | + * @return string |
|
| 286 | + * @throws EE_Error |
|
| 287 | + */ |
|
| 288 | + public function column_ATT_email(EE_Attendee $attendee) |
|
| 289 | + { |
|
| 290 | + return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>'; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * Column displaying count of registrations attached to Attendee. |
|
| 296 | + * |
|
| 297 | + * @param EE_Attendee $attendee |
|
| 298 | + * @return string |
|
| 299 | + * @throws EE_Error |
|
| 300 | + */ |
|
| 301 | + public function column_Registration_Count(EE_Attendee $attendee) |
|
| 302 | + { |
|
| 303 | + $link = EEH_URL::add_query_args_and_nonce( |
|
| 304 | + array( |
|
| 305 | + 'action' => 'default', |
|
| 306 | + 'ATT_ID' => $attendee->ID(), |
|
| 307 | + ), |
|
| 308 | + REG_ADMIN_URL |
|
| 309 | + ); |
|
| 310 | + return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>'; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * ATT_address column |
|
| 316 | + * |
|
| 317 | + * @param EE_Attendee $attendee |
|
| 318 | + * @return mixed |
|
| 319 | + * @throws EE_Error |
|
| 320 | + */ |
|
| 321 | + public function column_ATT_address(EE_Attendee $attendee) |
|
| 322 | + { |
|
| 323 | + return $attendee->address(); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * ATT_city column |
|
| 329 | + * |
|
| 330 | + * @param EE_Attendee $attendee |
|
| 331 | + * @return mixed |
|
| 332 | + * @throws EE_Error |
|
| 333 | + */ |
|
| 334 | + public function column_ATT_city(EE_Attendee $attendee) |
|
| 335 | + { |
|
| 336 | + return $attendee->city(); |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * State Column |
|
| 342 | + * |
|
| 343 | + * @param EE_Attendee $attendee |
|
| 344 | + * @return string |
|
| 345 | + * @throws EE_Error |
|
| 346 | + * @throws InvalidArgumentException |
|
| 347 | + * @throws InvalidDataTypeException |
|
| 348 | + * @throws InvalidInterfaceException |
|
| 349 | + */ |
|
| 350 | + public function column_STA_ID(EE_Attendee $attendee) |
|
| 351 | + { |
|
| 352 | + $states = EEM_State::instance()->get_all_states(); |
|
| 353 | + $state = isset($states[ $attendee->state_ID() ]) |
|
| 354 | + ? $states[ $attendee->state_ID() ]->get('STA_name') |
|
| 355 | + : $attendee->state_ID(); |
|
| 356 | + return ! is_numeric($state) ? $state : ''; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Country Column |
|
| 362 | + * |
|
| 363 | + * @param EE_Attendee $attendee |
|
| 364 | + * @return string |
|
| 365 | + * @throws EE_Error |
|
| 366 | + * @throws InvalidArgumentException |
|
| 367 | + * @throws InvalidDataTypeException |
|
| 368 | + * @throws InvalidInterfaceException |
|
| 369 | + */ |
|
| 370 | + public function column_CNT_ISO(EE_Attendee $attendee) |
|
| 371 | + { |
|
| 372 | + $countries = EEM_Country::instance()->get_all_countries(); |
|
| 373 | + $country = isset($countries[ $attendee->country_ID() ]) |
|
| 374 | + ? $countries[ $attendee->country_ID() ]->get('CNT_name') |
|
| 375 | + : $attendee->country_ID(); |
|
| 376 | + return ! is_numeric($country) ? $country : ''; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Phone Number column |
|
| 382 | + * |
|
| 383 | + * @param EE_Attendee $attendee |
|
| 384 | + * @return mixed |
|
| 385 | + * @throws EE_Error |
|
| 386 | + */ |
|
| 387 | + public function column_ATT_phone(EE_Attendee $attendee) |
|
| 388 | + { |
|
| 389 | + return $attendee->phone(); |
|
| 390 | + } |
|
| 391 | 391 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function column_cb($attendee) |
| 131 | 131 | { |
| 132 | - if (! $attendee instanceof EE_Attendee) { |
|
| 132 | + if ( ! $attendee instanceof EE_Attendee) { |
|
| 133 | 133 | return ''; |
| 134 | 134 | } |
| 135 | 135 | return sprintf( |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $content = $attendee->ID(); |
| 150 | 150 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
| 151 | - $content .= ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 151 | + $content .= ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
| 152 | 152 | return $this->columnContent('id', $content, 'center'); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | 'ee_edit_contacts', |
| 178 | 178 | 'espresso_registrations_edit_attendee' |
| 179 | 179 | ) |
| 180 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 181 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 182 | - . $attendee->lname() . '</a>' |
|
| 180 | + ? '<a href="'.$edit_lnk_url.'" title="' |
|
| 181 | + . esc_attr__('Edit Contact', 'event_espresso').'">' |
|
| 182 | + . $attendee->lname().'</a>' |
|
| 183 | 183 | : $attendee->lname(); |
| 184 | 184 | return $name_link; |
| 185 | 185 | } |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | ), |
| 214 | 214 | REG_ADMIN_URL |
| 215 | 215 | ); |
| 216 | - $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="' |
|
| 217 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' |
|
| 218 | - . esc_html__('Edit', 'event_espresso') . '</a>'; |
|
| 216 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' |
|
| 217 | + . esc_attr__('Edit Contact', 'event_espresso').'">' |
|
| 218 | + . esc_html__('Edit', 'event_espresso').'</a>'; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | if ($this->_view === 'in_use') { |
@@ -233,9 +233,9 @@ discard block |
||
| 233 | 233 | ), |
| 234 | 234 | REG_ADMIN_URL |
| 235 | 235 | ); |
| 236 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' |
|
| 236 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' |
|
| 237 | 237 | . esc_attr__('Move Contact to Trash', 'event_espresso') |
| 238 | - . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
| 238 | + . '">'.esc_html__('Trash', 'event_espresso').'</a>'; |
|
| 239 | 239 | } |
| 240 | 240 | } else { |
| 241 | 241 | if ( |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | ), |
| 253 | 253 | REG_ADMIN_URL |
| 254 | 254 | ); |
| 255 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' |
|
| 256 | - . esc_attr__('Restore Contact', 'event_espresso') . '">' |
|
| 257 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
| 255 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' |
|
| 256 | + . esc_attr__('Restore Contact', 'event_espresso').'">' |
|
| 257 | + . esc_html__('Restore', 'event_espresso').'</a>'; |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | 'ee_edit_contacts', |
| 270 | 270 | 'espresso_registrations_edit_attendee' |
| 271 | 271 | ) |
| 272 | - ? '<a href="' . $edit_lnk_url . '" title="' |
|
| 273 | - . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>' |
|
| 272 | + ? '<a href="'.$edit_lnk_url.'" title="' |
|
| 273 | + . esc_attr__('Edit Contact', 'event_espresso').'">'.$attendee->fname().'</a>' |
|
| 274 | 274 | : $attendee->fname(); |
| 275 | 275 | |
| 276 | 276 | // Return the name contents |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public function column_ATT_email(EE_Attendee $attendee) |
| 289 | 289 | { |
| 290 | - return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>'; |
|
| 290 | + return '<a href="mailto:'.$attendee->email().'">'.$attendee->email().'</a>'; |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | ), |
| 308 | 308 | REG_ADMIN_URL |
| 309 | 309 | ); |
| 310 | - return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>'; |
|
| 310 | + return '<a href="'.$link.'">'.$attendee->getCustomSelect('Registration_Count').'</a>'; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | |
@@ -350,8 +350,8 @@ discard block |
||
| 350 | 350 | public function column_STA_ID(EE_Attendee $attendee) |
| 351 | 351 | { |
| 352 | 352 | $states = EEM_State::instance()->get_all_states(); |
| 353 | - $state = isset($states[ $attendee->state_ID() ]) |
|
| 354 | - ? $states[ $attendee->state_ID() ]->get('STA_name') |
|
| 353 | + $state = isset($states[$attendee->state_ID()]) |
|
| 354 | + ? $states[$attendee->state_ID()]->get('STA_name') |
|
| 355 | 355 | : $attendee->state_ID(); |
| 356 | 356 | return ! is_numeric($state) ? $state : ''; |
| 357 | 357 | } |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | public function column_CNT_ISO(EE_Attendee $attendee) |
| 371 | 371 | { |
| 372 | 372 | $countries = EEM_Country::instance()->get_all_countries(); |
| 373 | - $country = isset($countries[ $attendee->country_ID() ]) |
|
| 374 | - ? $countries[ $attendee->country_ID() ]->get('CNT_name') |
|
| 373 | + $country = isset($countries[$attendee->country_ID()]) |
|
| 374 | + ? $countries[$attendee->country_ID()]->get('CNT_name') |
|
| 375 | 375 | : $attendee->country_ID(); |
| 376 | 376 | return ! is_numeric($country) ? $country : ''; |
| 377 | 377 | } |
@@ -12,441 +12,441 @@ |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @return Messages_Admin_Page |
|
| 17 | - */ |
|
| 18 | - public function get_admin_page() |
|
| 19 | - { |
|
| 20 | - return $this->_admin_page; |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - protected function _setup_data() |
|
| 25 | - { |
|
| 26 | - $this->_data = $this->_get_messages($this->_per_page, $this->_view); |
|
| 27 | - $this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - |
|
| 31 | - protected function _set_properties() |
|
| 32 | - { |
|
| 33 | - $this->_wp_list_args = array( |
|
| 34 | - 'singular' => esc_html__('Message', 'event_espresso'), |
|
| 35 | - 'plural' => esc_html__('Messages', 'event_espresso'), |
|
| 36 | - 'ajax' => true, |
|
| 37 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
| 38 | - ); |
|
| 39 | - |
|
| 40 | - $this->_columns = array( |
|
| 41 | - 'cb' => '<input type="checkbox" />', |
|
| 42 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
| 43 | - 'to' => esc_html__('To', 'event_espresso'), |
|
| 44 | - 'context' => esc_html__('Recipient', 'event_espresso'), |
|
| 45 | - 'message_type' => esc_html__('Message Type', 'event_espresso'), |
|
| 46 | - 'messenger' => esc_html__('Messenger', 'event_espresso'), |
|
| 47 | - 'from' => esc_html__('From', 'event_espresso'), |
|
| 48 | - 'modified' => esc_html__('Modified', 'event_espresso'), |
|
| 49 | - 'actions' => $this->actionsColumnHeader(), |
|
| 50 | - ); |
|
| 51 | - |
|
| 52 | - $this->_sortable_columns = array( |
|
| 53 | - 'modified' => array('MSG_modified' => true), |
|
| 54 | - 'message_type' => array('MSG_message_type' => false), |
|
| 55 | - 'messenger' => array('MSG_messenger' => false), |
|
| 56 | - 'to' => array('MSG_to' => false), |
|
| 57 | - 'from' => array('MSG_from' => false), |
|
| 58 | - 'context' => array('MSG_context' => false), |
|
| 59 | - 'id' => array('MSG_ID', false), |
|
| 60 | - ); |
|
| 61 | - |
|
| 62 | - $this->_primary_column = 'to'; |
|
| 63 | - |
|
| 64 | - $this->_hidden_columns = array( |
|
| 65 | - 'id', |
|
| 66 | - ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * This simply sets up the row class for the table rows. |
|
| 72 | - * Allows for easier overriding of child methods for setting up sorting. |
|
| 73 | - * |
|
| 74 | - * @param object $item the current item |
|
| 75 | - * @return string |
|
| 76 | - */ |
|
| 77 | - protected function _get_row_class($item) |
|
| 78 | - { |
|
| 79 | - $class = parent::_get_row_class($item); |
|
| 80 | - // add status class |
|
| 81 | - $class .= ' msg-status-' . $item->STS_ID(); |
|
| 82 | - if ($this->_has_checkbox_column) { |
|
| 83 | - $class .= ' has-checkbox-column'; |
|
| 84 | - } |
|
| 85 | - return $class; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * _get_table_filters |
|
| 91 | - * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
| 92 | - * get's shown in the table. |
|
| 93 | - * |
|
| 94 | - * @abstract |
|
| 95 | - * @access protected |
|
| 96 | - * @return string |
|
| 97 | - * @throws \EE_Error |
|
| 98 | - */ |
|
| 99 | - protected function _get_table_filters() |
|
| 100 | - { |
|
| 101 | - $filters = array(); |
|
| 102 | - |
|
| 103 | - // get select_inputs |
|
| 104 | - $select_inputs = array( |
|
| 105 | - $this->_get_messengers_dropdown_filter(), |
|
| 106 | - $this->_get_message_types_dropdown_filter(), |
|
| 107 | - $this->_get_contexts_for_message_types_dropdown_filter(), |
|
| 108 | - ); |
|
| 109 | - |
|
| 110 | - // set filters to select inputs if they aren't empty |
|
| 111 | - foreach ($select_inputs as $select_input) { |
|
| 112 | - if ($select_input) { |
|
| 113 | - $filters[] = $select_input; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - return $filters; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - protected function _add_view_counts() |
|
| 121 | - { |
|
| 122 | - foreach ($this->_views as $view => $args) { |
|
| 123 | - $this->_views[ $view ]['count'] = $this->_get_messages($this->_per_page, $view, true, true); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @param EE_Message $message |
|
| 130 | - * @return string checkbox |
|
| 131 | - * @throws EE_Error |
|
| 132 | - */ |
|
| 133 | - public function column_cb($message) |
|
| 134 | - { |
|
| 135 | - return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID()); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @param EE_Message $message |
|
| 141 | - * @return string |
|
| 142 | - * @throws \EE_Error |
|
| 143 | - */ |
|
| 144 | - public function column_id(EE_Message $message) |
|
| 145 | - { |
|
| 146 | - return $this->columnContent('id', $message->ID(), 'center'); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @param EE_Message $message |
|
| 152 | - * @return string The recipient of the message |
|
| 153 | - * @throws \EE_Error |
|
| 154 | - */ |
|
| 155 | - public function column_to(EE_Message $message) |
|
| 156 | - { |
|
| 157 | - $delete_url = EEH_URL::add_query_args_and_nonce( |
|
| 158 | - [ |
|
| 159 | - 'page' => 'espresso_messages', |
|
| 160 | - 'action' => 'delete_ee_message', |
|
| 161 | - 'MSG_ID' => $message->ID(), |
|
| 162 | - ], |
|
| 163 | - admin_url('admin.php') |
|
| 164 | - ); |
|
| 165 | - $actions = [ |
|
| 166 | - 'delete' => '<a href="' . $delete_url . '">' . esc_html__('Delete', 'event_espresso') . '</a>' |
|
| 167 | - ]; |
|
| 168 | - $status = esc_attr($message->STS_ID()); |
|
| 169 | - $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
| 170 | - return ' |
|
| 15 | + /** |
|
| 16 | + * @return Messages_Admin_Page |
|
| 17 | + */ |
|
| 18 | + public function get_admin_page() |
|
| 19 | + { |
|
| 20 | + return $this->_admin_page; |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + protected function _setup_data() |
|
| 25 | + { |
|
| 26 | + $this->_data = $this->_get_messages($this->_per_page, $this->_view); |
|
| 27 | + $this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + |
|
| 31 | + protected function _set_properties() |
|
| 32 | + { |
|
| 33 | + $this->_wp_list_args = array( |
|
| 34 | + 'singular' => esc_html__('Message', 'event_espresso'), |
|
| 35 | + 'plural' => esc_html__('Messages', 'event_espresso'), |
|
| 36 | + 'ajax' => true, |
|
| 37 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
| 38 | + ); |
|
| 39 | + |
|
| 40 | + $this->_columns = array( |
|
| 41 | + 'cb' => '<input type="checkbox" />', |
|
| 42 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
| 43 | + 'to' => esc_html__('To', 'event_espresso'), |
|
| 44 | + 'context' => esc_html__('Recipient', 'event_espresso'), |
|
| 45 | + 'message_type' => esc_html__('Message Type', 'event_espresso'), |
|
| 46 | + 'messenger' => esc_html__('Messenger', 'event_espresso'), |
|
| 47 | + 'from' => esc_html__('From', 'event_espresso'), |
|
| 48 | + 'modified' => esc_html__('Modified', 'event_espresso'), |
|
| 49 | + 'actions' => $this->actionsColumnHeader(), |
|
| 50 | + ); |
|
| 51 | + |
|
| 52 | + $this->_sortable_columns = array( |
|
| 53 | + 'modified' => array('MSG_modified' => true), |
|
| 54 | + 'message_type' => array('MSG_message_type' => false), |
|
| 55 | + 'messenger' => array('MSG_messenger' => false), |
|
| 56 | + 'to' => array('MSG_to' => false), |
|
| 57 | + 'from' => array('MSG_from' => false), |
|
| 58 | + 'context' => array('MSG_context' => false), |
|
| 59 | + 'id' => array('MSG_ID', false), |
|
| 60 | + ); |
|
| 61 | + |
|
| 62 | + $this->_primary_column = 'to'; |
|
| 63 | + |
|
| 64 | + $this->_hidden_columns = array( |
|
| 65 | + 'id', |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * This simply sets up the row class for the table rows. |
|
| 72 | + * Allows for easier overriding of child methods for setting up sorting. |
|
| 73 | + * |
|
| 74 | + * @param object $item the current item |
|
| 75 | + * @return string |
|
| 76 | + */ |
|
| 77 | + protected function _get_row_class($item) |
|
| 78 | + { |
|
| 79 | + $class = parent::_get_row_class($item); |
|
| 80 | + // add status class |
|
| 81 | + $class .= ' msg-status-' . $item->STS_ID(); |
|
| 82 | + if ($this->_has_checkbox_column) { |
|
| 83 | + $class .= ' has-checkbox-column'; |
|
| 84 | + } |
|
| 85 | + return $class; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * _get_table_filters |
|
| 91 | + * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
| 92 | + * get's shown in the table. |
|
| 93 | + * |
|
| 94 | + * @abstract |
|
| 95 | + * @access protected |
|
| 96 | + * @return string |
|
| 97 | + * @throws \EE_Error |
|
| 98 | + */ |
|
| 99 | + protected function _get_table_filters() |
|
| 100 | + { |
|
| 101 | + $filters = array(); |
|
| 102 | + |
|
| 103 | + // get select_inputs |
|
| 104 | + $select_inputs = array( |
|
| 105 | + $this->_get_messengers_dropdown_filter(), |
|
| 106 | + $this->_get_message_types_dropdown_filter(), |
|
| 107 | + $this->_get_contexts_for_message_types_dropdown_filter(), |
|
| 108 | + ); |
|
| 109 | + |
|
| 110 | + // set filters to select inputs if they aren't empty |
|
| 111 | + foreach ($select_inputs as $select_input) { |
|
| 112 | + if ($select_input) { |
|
| 113 | + $filters[] = $select_input; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + return $filters; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + protected function _add_view_counts() |
|
| 121 | + { |
|
| 122 | + foreach ($this->_views as $view => $args) { |
|
| 123 | + $this->_views[ $view ]['count'] = $this->_get_messages($this->_per_page, $view, true, true); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @param EE_Message $message |
|
| 130 | + * @return string checkbox |
|
| 131 | + * @throws EE_Error |
|
| 132 | + */ |
|
| 133 | + public function column_cb($message) |
|
| 134 | + { |
|
| 135 | + return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID()); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @param EE_Message $message |
|
| 141 | + * @return string |
|
| 142 | + * @throws \EE_Error |
|
| 143 | + */ |
|
| 144 | + public function column_id(EE_Message $message) |
|
| 145 | + { |
|
| 146 | + return $this->columnContent('id', $message->ID(), 'center'); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @param EE_Message $message |
|
| 152 | + * @return string The recipient of the message |
|
| 153 | + * @throws \EE_Error |
|
| 154 | + */ |
|
| 155 | + public function column_to(EE_Message $message) |
|
| 156 | + { |
|
| 157 | + $delete_url = EEH_URL::add_query_args_and_nonce( |
|
| 158 | + [ |
|
| 159 | + 'page' => 'espresso_messages', |
|
| 160 | + 'action' => 'delete_ee_message', |
|
| 161 | + 'MSG_ID' => $message->ID(), |
|
| 162 | + ], |
|
| 163 | + admin_url('admin.php') |
|
| 164 | + ); |
|
| 165 | + $actions = [ |
|
| 166 | + 'delete' => '<a href="' . $delete_url . '">' . esc_html__('Delete', 'event_espresso') . '</a>' |
|
| 167 | + ]; |
|
| 168 | + $status = esc_attr($message->STS_ID()); |
|
| 169 | + $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
|
| 170 | + return ' |
|
| 171 | 171 | <div class="ee-layout-row"> |
| 172 | 172 | <span class="row-title status-' . $status . ' ee-aria-tooltip" aria-label="' . $pretty_status . '"> |
| 173 | 173 | <span class="ee-status-dot ee-status-dot--' . $status . '"></span> |
| 174 | 174 | ' . esc_html($message->to()) . ' |
| 175 | 175 | </span> |
| 176 | 176 | </div>' . $this->row_actions($actions); |
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @param EE_Message $message |
|
| 182 | - * @return string The sender of the message |
|
| 183 | - */ |
|
| 184 | - public function column_from(EE_Message $message) |
|
| 185 | - { |
|
| 186 | - return esc_html($message->from()); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @param EE_Message $message |
|
| 192 | - * @return string The messenger used to send the message. |
|
| 193 | - */ |
|
| 194 | - public function column_messenger(EE_Message $message) |
|
| 195 | - { |
|
| 196 | - return ucwords($message->messenger_label()); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * @param EE_Message $message |
|
| 202 | - * @return string The message type used to generate the message. |
|
| 203 | - */ |
|
| 204 | - public function column_message_type(EE_Message $message) |
|
| 205 | - { |
|
| 206 | - return ucwords($message->message_type_label()); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * @param EE_Message $message |
|
| 212 | - * @return string The context the message was generated for. |
|
| 213 | - */ |
|
| 214 | - public function column_context(EE_Message $message) |
|
| 215 | - { |
|
| 216 | - return $message->context_label(); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @param EE_Message $message |
|
| 222 | - * @return string The timestamp when this message was last modified. |
|
| 223 | - */ |
|
| 224 | - public function column_modified(EE_Message $message) |
|
| 225 | - { |
|
| 226 | - return $message->modified(); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @param EE_Message $message |
|
| 232 | - * @return string Actions that can be done on the current message. |
|
| 233 | - */ |
|
| 234 | - public function column_actions(EE_Message $message) |
|
| 235 | - { |
|
| 236 | - $action_links = array( |
|
| 237 | - 'view' => EEH_MSG_Template::get_message_action_link('view', $message), |
|
| 238 | - 'error' => EEH_MSG_Template::get_message_action_link('error', $message), |
|
| 239 | - 'generate_now' => EEH_MSG_Template::get_message_action_link('generate_now', $message), |
|
| 240 | - 'send_now' => EEH_MSG_Template::get_message_action_link('send_now', $message), |
|
| 241 | - 'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message), |
|
| 242 | - 'view_transaction' => EEH_MSG_Template::get_message_action_link('view_transaction', $message), |
|
| 243 | - ); |
|
| 244 | - $content = ''; |
|
| 245 | - switch ($message->STS_ID()) { |
|
| 246 | - case EEM_Message::status_sent: |
|
| 247 | - $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction']; |
|
| 248 | - break; |
|
| 249 | - case EEM_Message::status_idle: |
|
| 250 | - case EEM_Message::status_resend: |
|
| 251 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction']; |
|
| 252 | - break; |
|
| 253 | - case EEM_Message::status_retry: |
|
| 254 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction']; |
|
| 255 | - break; |
|
| 256 | - case EEM_Message::status_failed: |
|
| 257 | - case EEM_Message::status_debug_only: |
|
| 258 | - $content = $action_links['error'] . $action_links['view_transaction']; |
|
| 259 | - break; |
|
| 260 | - case EEM_Message::status_incomplete: |
|
| 261 | - $content = $action_links['generate_now'] . $action_links['view_transaction']; |
|
| 262 | - break; |
|
| 263 | - } |
|
| 264 | - return $this->actionsModalMenu($content); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * Retrieve the EE_Message objects for the list table. |
|
| 270 | - * |
|
| 271 | - * @param int $perpage The number of items per page |
|
| 272 | - * @param string $view The view items are being retrieved for |
|
| 273 | - * @param bool $count Whether to just return a count or not. |
|
| 274 | - * @param bool $all Disregard any paging info (no limit on data returned). |
|
| 275 | - * @return int|EE_Message[] |
|
| 276 | - * @throws \EE_Error |
|
| 277 | - */ |
|
| 278 | - protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false) |
|
| 279 | - { |
|
| 280 | - |
|
| 281 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 282 | - ? $this->_req_data['paged'] |
|
| 283 | - : 1; |
|
| 284 | - |
|
| 285 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 286 | - ? $this->_req_data['perpage'] |
|
| 287 | - : $perpage; |
|
| 288 | - |
|
| 289 | - $offset = ($current_page - 1) * $per_page; |
|
| 290 | - $limit = $all || $count ? null : array($offset, $per_page); |
|
| 291 | - $query_params = array( |
|
| 292 | - 'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'], |
|
| 293 | - 'order' => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'], |
|
| 294 | - 'limit' => $limit, |
|
| 295 | - ); |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Any filters coming in from other routes? |
|
| 299 | - */ |
|
| 300 | - if (isset($this->_req_data['filterby'])) { |
|
| 301 | - $query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params()); |
|
| 302 | - if (! $count) { |
|
| 303 | - $query_params['group_by'] = 'MSG_ID'; |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - // view conditionals |
|
| 308 | - if ($view !== 'all' && $count && $all) { |
|
| 309 | - $query_params[0]['AND*view_conditional'] = array( |
|
| 310 | - 'STS_ID' => strtoupper($view), |
|
| 311 | - ); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') { |
|
| 315 | - $query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed |
|
| 316 | - ? array( |
|
| 317 | - 'STS_ID' => array( |
|
| 318 | - 'IN', |
|
| 319 | - array(EEM_Message::status_failed, EEM_Message::status_messenger_executing), |
|
| 320 | - ), |
|
| 321 | - ) |
|
| 322 | - : array('STS_ID' => strtoupper($this->_req_data['status'])); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - if (! $all && ! empty($this->_req_data['s'])) { |
|
| 326 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 327 | - $query_params[0]['OR'] = array( |
|
| 328 | - 'MSG_to' => array('LIKE', $search_string), |
|
| 329 | - 'MSG_from' => array('LIKE', $search_string), |
|
| 330 | - 'MSG_subject' => array('LIKE', $search_string), |
|
| 331 | - 'MSG_content' => array('LIKE', $search_string), |
|
| 332 | - ); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - // account for debug only status. We don't show Messages with the EEM_Message::status_debug_only to clients when |
|
| 336 | - // the messages system is in debug mode. |
|
| 337 | - // Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only |
|
| 338 | - // messages in the database. |
|
| 339 | - if (! EEM_Message::debug()) { |
|
| 340 | - $query_params[0]['AND*debug_only_conditional'] = array( |
|
| 341 | - 'STS_ID' => array('!=', EEM_Message::status_debug_only), |
|
| 342 | - ); |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - // account for filters |
|
| 346 | - if ( |
|
| 347 | - ! $all |
|
| 348 | - && isset($this->_req_data['ee_messenger_filter_by']) |
|
| 349 | - && $this->_req_data['ee_messenger_filter_by'] !== 'none_selected' |
|
| 350 | - ) { |
|
| 351 | - $query_params[0]['AND*messenger_filter'] = array( |
|
| 352 | - 'MSG_messenger' => $this->_req_data['ee_messenger_filter_by'], |
|
| 353 | - ); |
|
| 354 | - } |
|
| 355 | - if ( |
|
| 356 | - ! $all |
|
| 357 | - && ! empty($this->_req_data['ee_message_type_filter_by']) |
|
| 358 | - && $this->_req_data['ee_message_type_filter_by'] !== 'none_selected' |
|
| 359 | - ) { |
|
| 360 | - $query_params[0]['AND*message_type_filter'] = array( |
|
| 361 | - 'MSG_message_type' => $this->_req_data['ee_message_type_filter_by'], |
|
| 362 | - ); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - if ( |
|
| 366 | - ! $all |
|
| 367 | - && ! empty($this->_req_data['ee_context_filter_by']) |
|
| 368 | - && $this->_req_data['ee_context_filter_by'] !== 'none_selected' |
|
| 369 | - ) { |
|
| 370 | - $query_params[0]['AND*context_filter'] = array( |
|
| 371 | - 'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by'])), |
|
| 372 | - ); |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - return $count |
|
| 376 | - /** @type int */ |
|
| 377 | - ? EEM_Message::instance()->count($query_params, null, true) |
|
| 378 | - /** @type EE_Message[] */ |
|
| 379 | - : EEM_Message::instance()->get_all($query_params); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * Generate dropdown filter select input for messengers. |
|
| 385 | - * |
|
| 386 | - * @return string |
|
| 387 | - */ |
|
| 388 | - protected function _get_messengers_dropdown_filter() |
|
| 389 | - { |
|
| 390 | - $messenger_options = array(); |
|
| 391 | - $active_messages_grouped_by_messenger = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger')); |
|
| 392 | - |
|
| 393 | - // setup array of messenger options |
|
| 394 | - foreach ($active_messages_grouped_by_messenger as $active_message) { |
|
| 395 | - if ($active_message instanceof EE_Message) { |
|
| 396 | - $messenger_options[ $active_message->messenger() ] = ucwords($active_message->messenger_label()); |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - |
|
| 403 | - /** |
|
| 404 | - * Generate dropdown filter select input for message types |
|
| 405 | - * |
|
| 406 | - * @return string |
|
| 407 | - */ |
|
| 408 | - protected function _get_message_types_dropdown_filter() |
|
| 409 | - { |
|
| 410 | - $message_type_options = array(); |
|
| 411 | - $active_messages_grouped_by_message_type = EEM_Message::instance()->get_all( |
|
| 412 | - array('group_by' => 'MSG_message_type') |
|
| 413 | - ); |
|
| 414 | - |
|
| 415 | - // setup array of message type options |
|
| 416 | - foreach ($active_messages_grouped_by_message_type as $active_message) { |
|
| 417 | - if ($active_message instanceof EE_Message) { |
|
| 418 | - $message_type_options[ $active_message->message_type() ] = ucwords( |
|
| 419 | - $active_message->message_type_label() |
|
| 420 | - ); |
|
| 421 | - } |
|
| 422 | - } |
|
| 423 | - return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - |
|
| 427 | - /** |
|
| 428 | - * Generate dropdown filter select input for message type contexts |
|
| 429 | - * |
|
| 430 | - * @return string |
|
| 431 | - */ |
|
| 432 | - protected function _get_contexts_for_message_types_dropdown_filter() |
|
| 433 | - { |
|
| 434 | - $context_options = array(); |
|
| 435 | - $active_messages_grouped_by_context = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context')); |
|
| 436 | - |
|
| 437 | - // setup array of context options |
|
| 438 | - foreach ($active_messages_grouped_by_context as $active_message) { |
|
| 439 | - if ($active_message instanceof EE_Message) { |
|
| 440 | - $message_type = $active_message->message_type_object(); |
|
| 441 | - if ($message_type instanceof EE_message_type) { |
|
| 442 | - foreach ($message_type->get_contexts() as $context => $context_details) { |
|
| 443 | - if (isset($context_details['label'])) { |
|
| 444 | - $context_options[ $context ] = $context_details['label']; |
|
| 445 | - } |
|
| 446 | - } |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - return $this->get_admin_page()->get_contexts_for_message_types_select_input($context_options); |
|
| 451 | - } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * @param EE_Message $message |
|
| 182 | + * @return string The sender of the message |
|
| 183 | + */ |
|
| 184 | + public function column_from(EE_Message $message) |
|
| 185 | + { |
|
| 186 | + return esc_html($message->from()); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @param EE_Message $message |
|
| 192 | + * @return string The messenger used to send the message. |
|
| 193 | + */ |
|
| 194 | + public function column_messenger(EE_Message $message) |
|
| 195 | + { |
|
| 196 | + return ucwords($message->messenger_label()); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * @param EE_Message $message |
|
| 202 | + * @return string The message type used to generate the message. |
|
| 203 | + */ |
|
| 204 | + public function column_message_type(EE_Message $message) |
|
| 205 | + { |
|
| 206 | + return ucwords($message->message_type_label()); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * @param EE_Message $message |
|
| 212 | + * @return string The context the message was generated for. |
|
| 213 | + */ |
|
| 214 | + public function column_context(EE_Message $message) |
|
| 215 | + { |
|
| 216 | + return $message->context_label(); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @param EE_Message $message |
|
| 222 | + * @return string The timestamp when this message was last modified. |
|
| 223 | + */ |
|
| 224 | + public function column_modified(EE_Message $message) |
|
| 225 | + { |
|
| 226 | + return $message->modified(); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @param EE_Message $message |
|
| 232 | + * @return string Actions that can be done on the current message. |
|
| 233 | + */ |
|
| 234 | + public function column_actions(EE_Message $message) |
|
| 235 | + { |
|
| 236 | + $action_links = array( |
|
| 237 | + 'view' => EEH_MSG_Template::get_message_action_link('view', $message), |
|
| 238 | + 'error' => EEH_MSG_Template::get_message_action_link('error', $message), |
|
| 239 | + 'generate_now' => EEH_MSG_Template::get_message_action_link('generate_now', $message), |
|
| 240 | + 'send_now' => EEH_MSG_Template::get_message_action_link('send_now', $message), |
|
| 241 | + 'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message), |
|
| 242 | + 'view_transaction' => EEH_MSG_Template::get_message_action_link('view_transaction', $message), |
|
| 243 | + ); |
|
| 244 | + $content = ''; |
|
| 245 | + switch ($message->STS_ID()) { |
|
| 246 | + case EEM_Message::status_sent: |
|
| 247 | + $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction']; |
|
| 248 | + break; |
|
| 249 | + case EEM_Message::status_idle: |
|
| 250 | + case EEM_Message::status_resend: |
|
| 251 | + $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction']; |
|
| 252 | + break; |
|
| 253 | + case EEM_Message::status_retry: |
|
| 254 | + $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction']; |
|
| 255 | + break; |
|
| 256 | + case EEM_Message::status_failed: |
|
| 257 | + case EEM_Message::status_debug_only: |
|
| 258 | + $content = $action_links['error'] . $action_links['view_transaction']; |
|
| 259 | + break; |
|
| 260 | + case EEM_Message::status_incomplete: |
|
| 261 | + $content = $action_links['generate_now'] . $action_links['view_transaction']; |
|
| 262 | + break; |
|
| 263 | + } |
|
| 264 | + return $this->actionsModalMenu($content); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * Retrieve the EE_Message objects for the list table. |
|
| 270 | + * |
|
| 271 | + * @param int $perpage The number of items per page |
|
| 272 | + * @param string $view The view items are being retrieved for |
|
| 273 | + * @param bool $count Whether to just return a count or not. |
|
| 274 | + * @param bool $all Disregard any paging info (no limit on data returned). |
|
| 275 | + * @return int|EE_Message[] |
|
| 276 | + * @throws \EE_Error |
|
| 277 | + */ |
|
| 278 | + protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false) |
|
| 279 | + { |
|
| 280 | + |
|
| 281 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 282 | + ? $this->_req_data['paged'] |
|
| 283 | + : 1; |
|
| 284 | + |
|
| 285 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 286 | + ? $this->_req_data['perpage'] |
|
| 287 | + : $perpage; |
|
| 288 | + |
|
| 289 | + $offset = ($current_page - 1) * $per_page; |
|
| 290 | + $limit = $all || $count ? null : array($offset, $per_page); |
|
| 291 | + $query_params = array( |
|
| 292 | + 'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'], |
|
| 293 | + 'order' => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'], |
|
| 294 | + 'limit' => $limit, |
|
| 295 | + ); |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Any filters coming in from other routes? |
|
| 299 | + */ |
|
| 300 | + if (isset($this->_req_data['filterby'])) { |
|
| 301 | + $query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params()); |
|
| 302 | + if (! $count) { |
|
| 303 | + $query_params['group_by'] = 'MSG_ID'; |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + // view conditionals |
|
| 308 | + if ($view !== 'all' && $count && $all) { |
|
| 309 | + $query_params[0]['AND*view_conditional'] = array( |
|
| 310 | + 'STS_ID' => strtoupper($view), |
|
| 311 | + ); |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') { |
|
| 315 | + $query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed |
|
| 316 | + ? array( |
|
| 317 | + 'STS_ID' => array( |
|
| 318 | + 'IN', |
|
| 319 | + array(EEM_Message::status_failed, EEM_Message::status_messenger_executing), |
|
| 320 | + ), |
|
| 321 | + ) |
|
| 322 | + : array('STS_ID' => strtoupper($this->_req_data['status'])); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + if (! $all && ! empty($this->_req_data['s'])) { |
|
| 326 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 327 | + $query_params[0]['OR'] = array( |
|
| 328 | + 'MSG_to' => array('LIKE', $search_string), |
|
| 329 | + 'MSG_from' => array('LIKE', $search_string), |
|
| 330 | + 'MSG_subject' => array('LIKE', $search_string), |
|
| 331 | + 'MSG_content' => array('LIKE', $search_string), |
|
| 332 | + ); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + // account for debug only status. We don't show Messages with the EEM_Message::status_debug_only to clients when |
|
| 336 | + // the messages system is in debug mode. |
|
| 337 | + // Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only |
|
| 338 | + // messages in the database. |
|
| 339 | + if (! EEM_Message::debug()) { |
|
| 340 | + $query_params[0]['AND*debug_only_conditional'] = array( |
|
| 341 | + 'STS_ID' => array('!=', EEM_Message::status_debug_only), |
|
| 342 | + ); |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + // account for filters |
|
| 346 | + if ( |
|
| 347 | + ! $all |
|
| 348 | + && isset($this->_req_data['ee_messenger_filter_by']) |
|
| 349 | + && $this->_req_data['ee_messenger_filter_by'] !== 'none_selected' |
|
| 350 | + ) { |
|
| 351 | + $query_params[0]['AND*messenger_filter'] = array( |
|
| 352 | + 'MSG_messenger' => $this->_req_data['ee_messenger_filter_by'], |
|
| 353 | + ); |
|
| 354 | + } |
|
| 355 | + if ( |
|
| 356 | + ! $all |
|
| 357 | + && ! empty($this->_req_data['ee_message_type_filter_by']) |
|
| 358 | + && $this->_req_data['ee_message_type_filter_by'] !== 'none_selected' |
|
| 359 | + ) { |
|
| 360 | + $query_params[0]['AND*message_type_filter'] = array( |
|
| 361 | + 'MSG_message_type' => $this->_req_data['ee_message_type_filter_by'], |
|
| 362 | + ); |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + if ( |
|
| 366 | + ! $all |
|
| 367 | + && ! empty($this->_req_data['ee_context_filter_by']) |
|
| 368 | + && $this->_req_data['ee_context_filter_by'] !== 'none_selected' |
|
| 369 | + ) { |
|
| 370 | + $query_params[0]['AND*context_filter'] = array( |
|
| 371 | + 'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by'])), |
|
| 372 | + ); |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + return $count |
|
| 376 | + /** @type int */ |
|
| 377 | + ? EEM_Message::instance()->count($query_params, null, true) |
|
| 378 | + /** @type EE_Message[] */ |
|
| 379 | + : EEM_Message::instance()->get_all($query_params); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + |
|
| 383 | + /** |
|
| 384 | + * Generate dropdown filter select input for messengers. |
|
| 385 | + * |
|
| 386 | + * @return string |
|
| 387 | + */ |
|
| 388 | + protected function _get_messengers_dropdown_filter() |
|
| 389 | + { |
|
| 390 | + $messenger_options = array(); |
|
| 391 | + $active_messages_grouped_by_messenger = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger')); |
|
| 392 | + |
|
| 393 | + // setup array of messenger options |
|
| 394 | + foreach ($active_messages_grouped_by_messenger as $active_message) { |
|
| 395 | + if ($active_message instanceof EE_Message) { |
|
| 396 | + $messenger_options[ $active_message->messenger() ] = ucwords($active_message->messenger_label()); |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + |
|
| 403 | + /** |
|
| 404 | + * Generate dropdown filter select input for message types |
|
| 405 | + * |
|
| 406 | + * @return string |
|
| 407 | + */ |
|
| 408 | + protected function _get_message_types_dropdown_filter() |
|
| 409 | + { |
|
| 410 | + $message_type_options = array(); |
|
| 411 | + $active_messages_grouped_by_message_type = EEM_Message::instance()->get_all( |
|
| 412 | + array('group_by' => 'MSG_message_type') |
|
| 413 | + ); |
|
| 414 | + |
|
| 415 | + // setup array of message type options |
|
| 416 | + foreach ($active_messages_grouped_by_message_type as $active_message) { |
|
| 417 | + if ($active_message instanceof EE_Message) { |
|
| 418 | + $message_type_options[ $active_message->message_type() ] = ucwords( |
|
| 419 | + $active_message->message_type_label() |
|
| 420 | + ); |
|
| 421 | + } |
|
| 422 | + } |
|
| 423 | + return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * Generate dropdown filter select input for message type contexts |
|
| 429 | + * |
|
| 430 | + * @return string |
|
| 431 | + */ |
|
| 432 | + protected function _get_contexts_for_message_types_dropdown_filter() |
|
| 433 | + { |
|
| 434 | + $context_options = array(); |
|
| 435 | + $active_messages_grouped_by_context = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context')); |
|
| 436 | + |
|
| 437 | + // setup array of context options |
|
| 438 | + foreach ($active_messages_grouped_by_context as $active_message) { |
|
| 439 | + if ($active_message instanceof EE_Message) { |
|
| 440 | + $message_type = $active_message->message_type_object(); |
|
| 441 | + if ($message_type instanceof EE_message_type) { |
|
| 442 | + foreach ($message_type->get_contexts() as $context => $context_details) { |
|
| 443 | + if (isset($context_details['label'])) { |
|
| 444 | + $context_options[ $context ] = $context_details['label']; |
|
| 445 | + } |
|
| 446 | + } |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + return $this->get_admin_page()->get_contexts_for_message_types_select_input($context_options); |
|
| 451 | + } |
|
| 452 | 452 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $class = parent::_get_row_class($item); |
| 80 | 80 | // add status class |
| 81 | - $class .= ' msg-status-' . $item->STS_ID(); |
|
| 81 | + $class .= ' msg-status-'.$item->STS_ID(); |
|
| 82 | 82 | if ($this->_has_checkbox_column) { |
| 83 | 83 | $class .= ' has-checkbox-column'; |
| 84 | 84 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | protected function _add_view_counts() |
| 121 | 121 | { |
| 122 | 122 | foreach ($this->_views as $view => $args) { |
| 123 | - $this->_views[ $view ]['count'] = $this->_get_messages($this->_per_page, $view, true, true); |
|
| 123 | + $this->_views[$view]['count'] = $this->_get_messages($this->_per_page, $view, true, true); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -163,15 +163,15 @@ discard block |
||
| 163 | 163 | admin_url('admin.php') |
| 164 | 164 | ); |
| 165 | 165 | $actions = [ |
| 166 | - 'delete' => '<a href="' . $delete_url . '">' . esc_html__('Delete', 'event_espresso') . '</a>' |
|
| 166 | + 'delete' => '<a href="'.$delete_url.'">'.esc_html__('Delete', 'event_espresso').'</a>' |
|
| 167 | 167 | ]; |
| 168 | 168 | $status = esc_attr($message->STS_ID()); |
| 169 | 169 | $pretty_status = EEH_Template::pretty_status($status, false, 'sentence'); |
| 170 | 170 | return ' |
| 171 | 171 | <div class="ee-layout-row"> |
| 172 | - <span class="row-title status-' . $status . ' ee-aria-tooltip" aria-label="' . $pretty_status . '"> |
|
| 173 | - <span class="ee-status-dot ee-status-dot--' . $status . '"></span> |
|
| 174 | - ' . esc_html($message->to()) . ' |
|
| 172 | + <span class="row-title status-' . $status.' ee-aria-tooltip" aria-label="'.$pretty_status.'"> |
|
| 173 | + <span class="ee-status-dot ee-status-dot--' . $status.'"></span> |
|
| 174 | + ' . esc_html($message->to()).' |
|
| 175 | 175 | </span> |
| 176 | 176 | </div>' . $this->row_actions($actions); |
| 177 | 177 | } |
@@ -244,21 +244,21 @@ discard block |
||
| 244 | 244 | $content = ''; |
| 245 | 245 | switch ($message->STS_ID()) { |
| 246 | 246 | case EEM_Message::status_sent: |
| 247 | - $content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction']; |
|
| 247 | + $content = $action_links['view'].$action_links['queue_for_resending'].$action_links['view_transaction']; |
|
| 248 | 248 | break; |
| 249 | 249 | case EEM_Message::status_idle: |
| 250 | 250 | case EEM_Message::status_resend: |
| 251 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction']; |
|
| 251 | + $content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction']; |
|
| 252 | 252 | break; |
| 253 | 253 | case EEM_Message::status_retry: |
| 254 | - $content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction']; |
|
| 254 | + $content = $action_links['view'].$action_links['send_now'].$action_links['error'].$action_links['view_transaction']; |
|
| 255 | 255 | break; |
| 256 | 256 | case EEM_Message::status_failed: |
| 257 | 257 | case EEM_Message::status_debug_only: |
| 258 | - $content = $action_links['error'] . $action_links['view_transaction']; |
|
| 258 | + $content = $action_links['error'].$action_links['view_transaction']; |
|
| 259 | 259 | break; |
| 260 | 260 | case EEM_Message::status_incomplete: |
| 261 | - $content = $action_links['generate_now'] . $action_links['view_transaction']; |
|
| 261 | + $content = $action_links['generate_now'].$action_links['view_transaction']; |
|
| 262 | 262 | break; |
| 263 | 263 | } |
| 264 | 264 | return $this->actionsModalMenu($content); |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | if (isset($this->_req_data['filterby'])) { |
| 301 | 301 | $query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params()); |
| 302 | - if (! $count) { |
|
| 302 | + if ( ! $count) { |
|
| 303 | 303 | $query_params['group_by'] = 'MSG_ID'; |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | ); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if (! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') { |
|
| 314 | + if ( ! $all && ! empty($this->_req_data['status']) && $this->_req_data['status'] !== 'all') { |
|
| 315 | 315 | $query_params[0]['AND*view_conditional'] = $this->_req_data === EEM_Message::status_failed |
| 316 | 316 | ? array( |
| 317 | 317 | 'STS_ID' => array( |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | : array('STS_ID' => strtoupper($this->_req_data['status'])); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - if (! $all && ! empty($this->_req_data['s'])) { |
|
| 326 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 325 | + if ( ! $all && ! empty($this->_req_data['s'])) { |
|
| 326 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
| 327 | 327 | $query_params[0]['OR'] = array( |
| 328 | 328 | 'MSG_to' => array('LIKE', $search_string), |
| 329 | 329 | 'MSG_from' => array('LIKE', $search_string), |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | // the messages system is in debug mode. |
| 337 | 337 | // Note: for backward compat with previous iterations, this is necessary because there may be EEM_Message::status_debug_only |
| 338 | 338 | // messages in the database. |
| 339 | - if (! EEM_Message::debug()) { |
|
| 339 | + if ( ! EEM_Message::debug()) { |
|
| 340 | 340 | $query_params[0]['AND*debug_only_conditional'] = array( |
| 341 | 341 | 'STS_ID' => array('!=', EEM_Message::status_debug_only), |
| 342 | 342 | ); |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | // setup array of messenger options |
| 394 | 394 | foreach ($active_messages_grouped_by_messenger as $active_message) { |
| 395 | 395 | if ($active_message instanceof EE_Message) { |
| 396 | - $messenger_options[ $active_message->messenger() ] = ucwords($active_message->messenger_label()); |
|
| 396 | + $messenger_options[$active_message->messenger()] = ucwords($active_message->messenger_label()); |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | // setup array of message type options |
| 416 | 416 | foreach ($active_messages_grouped_by_message_type as $active_message) { |
| 417 | 417 | if ($active_message instanceof EE_Message) { |
| 418 | - $message_type_options[ $active_message->message_type() ] = ucwords( |
|
| 418 | + $message_type_options[$active_message->message_type()] = ucwords( |
|
| 419 | 419 | $active_message->message_type_label() |
| 420 | 420 | ); |
| 421 | 421 | } |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | if ($message_type instanceof EE_message_type) { |
| 442 | 442 | foreach ($message_type->get_contexts() as $context => $context_details) { |
| 443 | 443 | if (isset($context_details['label'])) { |
| 444 | - $context_options[ $context ] = $context_details['label']; |
|
| 444 | + $context_options[$context] = $context_details['label']; |
|
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | } |
@@ -13,121 +13,121 @@ |
||
| 13 | 13 | class Extend_EE_Registrations_List_Table extends EE_Registrations_List_Table |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @param EE_Registration $item |
|
| 18 | - * @return string |
|
| 19 | - * @throws EE_Error |
|
| 20 | - * @throws InvalidArgumentException |
|
| 21 | - * @throws ReflectionException |
|
| 22 | - * @throws InvalidDataTypeException |
|
| 23 | - * @throws InvalidInterfaceException |
|
| 24 | - */ |
|
| 25 | - public function column__REG_date(EE_Registration $item) |
|
| 26 | - { |
|
| 27 | - $date_linked = parent::column__REG_date($item); |
|
| 28 | - $actions = array(); |
|
| 29 | - // Build row actions |
|
| 30 | - $check_in_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 31 | - 'action' => 'event_registrations', |
|
| 32 | - 'event_id' => $item->event_ID(), |
|
| 33 | - ), REG_ADMIN_URL); |
|
| 34 | - $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can( |
|
| 35 | - 'ee_read_registration', |
|
| 36 | - 'espresso_registrations_registration_checkins', |
|
| 37 | - $item->ID() |
|
| 38 | - ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 39 | - 'ee_read_checkins', |
|
| 40 | - 'espresso_registrations_registration_checkins' |
|
| 41 | - ) |
|
| 42 | - ? '<a class="ee-aria-tooltip" href="' . $check_in_url . '"' |
|
| 43 | - . ' aria-label="' . esc_attr__( |
|
| 44 | - 'The Check-In List allows you to easily toggle check-in status for this event', |
|
| 45 | - 'event_espresso' |
|
| 46 | - ) |
|
| 47 | - . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
| 48 | - : esc_html__('View Check-ins', 'event_espresso'); |
|
| 16 | + /** |
|
| 17 | + * @param EE_Registration $item |
|
| 18 | + * @return string |
|
| 19 | + * @throws EE_Error |
|
| 20 | + * @throws InvalidArgumentException |
|
| 21 | + * @throws ReflectionException |
|
| 22 | + * @throws InvalidDataTypeException |
|
| 23 | + * @throws InvalidInterfaceException |
|
| 24 | + */ |
|
| 25 | + public function column__REG_date(EE_Registration $item) |
|
| 26 | + { |
|
| 27 | + $date_linked = parent::column__REG_date($item); |
|
| 28 | + $actions = array(); |
|
| 29 | + // Build row actions |
|
| 30 | + $check_in_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 31 | + 'action' => 'event_registrations', |
|
| 32 | + 'event_id' => $item->event_ID(), |
|
| 33 | + ), REG_ADMIN_URL); |
|
| 34 | + $actions['check_in'] = EE_Registry::instance()->CAP->current_user_can( |
|
| 35 | + 'ee_read_registration', |
|
| 36 | + 'espresso_registrations_registration_checkins', |
|
| 37 | + $item->ID() |
|
| 38 | + ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 39 | + 'ee_read_checkins', |
|
| 40 | + 'espresso_registrations_registration_checkins' |
|
| 41 | + ) |
|
| 42 | + ? '<a class="ee-aria-tooltip" href="' . $check_in_url . '"' |
|
| 43 | + . ' aria-label="' . esc_attr__( |
|
| 44 | + 'The Check-In List allows you to easily toggle check-in status for this event', |
|
| 45 | + 'event_espresso' |
|
| 46 | + ) |
|
| 47 | + . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
| 48 | + : esc_html__('View Check-ins', 'event_espresso'); |
|
| 49 | 49 | |
| 50 | - $content = sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
|
| 51 | - return $this->columnContent('_REG_date', $content); |
|
| 52 | - } |
|
| 50 | + $content = sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
|
| 51 | + return $this->columnContent('_REG_date', $content); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * column_default |
|
| 57 | - * |
|
| 58 | - * @param \EE_Registration $item |
|
| 59 | - * @return string |
|
| 60 | - * @throws EE_Error |
|
| 61 | - * @throws InvalidArgumentException |
|
| 62 | - * @throws InvalidDataTypeException |
|
| 63 | - * @throws InvalidInterfaceException |
|
| 64 | - * @throws ReflectionException |
|
| 65 | - */ |
|
| 66 | - public function column_DTT_EVT_start(EE_Registration $item) |
|
| 67 | - { |
|
| 68 | - $remove_defaults = array('default_where_conditions' => 'none'); |
|
| 69 | - $ticket = $item->ticket(); |
|
| 70 | - $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array(); |
|
| 71 | - $EVT_ID = $item->event_ID(); |
|
| 72 | - $datetimes_for_display = array(); |
|
| 73 | - foreach ($datetimes as $datetime) { |
|
| 74 | - $datetime_string = ''; |
|
| 75 | - if ( |
|
| 76 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 77 | - 'ee_read_checkin', |
|
| 78 | - 'espresso_registrations_registration_checkins', |
|
| 79 | - $item->ID() |
|
| 80 | - ) |
|
| 81 | - ) { |
|
| 82 | - // open "a" tag and "href" |
|
| 83 | - $datetime_string .= '<a class="ee-aria-tooltip" href="'; |
|
| 84 | - // checkin URL |
|
| 85 | - $datetime_string .= EE_Admin_Page::add_query_args_and_nonce( |
|
| 86 | - array( |
|
| 87 | - 'action' => 'event_registrations', |
|
| 88 | - 'event_id' => $EVT_ID, |
|
| 89 | - 'DTT_ID' => $datetime->ID(), |
|
| 90 | - ), |
|
| 91 | - REG_ADMIN_URL |
|
| 92 | - ); |
|
| 93 | - // close "href" |
|
| 94 | - $datetime_string .= '"'; |
|
| 95 | - // open "title" tag |
|
| 96 | - $datetime_string .= ' aria-label="'; |
|
| 97 | - // link title text |
|
| 98 | - $datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso'); |
|
| 99 | - // close "title" tag and end of "a" tag opening |
|
| 100 | - $datetime_string .= '">'; |
|
| 101 | - // link text |
|
| 102 | - $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
| 103 | - // close "a" tag |
|
| 104 | - $datetime_string .= '</a>'; |
|
| 105 | - } else { |
|
| 106 | - $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
| 107 | - } |
|
| 108 | - // add a "View Registrations" link that filters list by event AND datetime |
|
| 109 | - $datetime_string .= $this->row_actions( |
|
| 110 | - array( |
|
| 111 | - 'event_datetime_filter' => '<a class="ee-aria-tooltip" href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 112 | - array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
|
| 113 | - REG_ADMIN_URL |
|
| 114 | - ) |
|
| 115 | - . '" aria-label="' . sprintf( |
|
| 116 | - esc_attr__( |
|
| 117 | - 'Filter this list to only show registrations for this datetime %s', |
|
| 118 | - 'event_espresso' |
|
| 119 | - ), |
|
| 120 | - $datetime->name() |
|
| 121 | - ) . '">' |
|
| 122 | - . esc_html__('View Registrations', 'event_espresso') |
|
| 123 | - . '</a>', |
|
| 124 | - ) |
|
| 125 | - ); |
|
| 126 | - $datetimes_for_display[] = $datetime_string; |
|
| 127 | - } |
|
| 128 | - return $this->columnContent( |
|
| 129 | - 'DTT_EVT_start', |
|
| 130 | - $this->generateDisplayForDateTimes($datetimes_for_display) |
|
| 131 | - ); |
|
| 132 | - } |
|
| 55 | + /** |
|
| 56 | + * column_default |
|
| 57 | + * |
|
| 58 | + * @param \EE_Registration $item |
|
| 59 | + * @return string |
|
| 60 | + * @throws EE_Error |
|
| 61 | + * @throws InvalidArgumentException |
|
| 62 | + * @throws InvalidDataTypeException |
|
| 63 | + * @throws InvalidInterfaceException |
|
| 64 | + * @throws ReflectionException |
|
| 65 | + */ |
|
| 66 | + public function column_DTT_EVT_start(EE_Registration $item) |
|
| 67 | + { |
|
| 68 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
| 69 | + $ticket = $item->ticket(); |
|
| 70 | + $datetimes = $ticket instanceof EE_Ticket ? $ticket->datetimes($remove_defaults) : array(); |
|
| 71 | + $EVT_ID = $item->event_ID(); |
|
| 72 | + $datetimes_for_display = array(); |
|
| 73 | + foreach ($datetimes as $datetime) { |
|
| 74 | + $datetime_string = ''; |
|
| 75 | + if ( |
|
| 76 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 77 | + 'ee_read_checkin', |
|
| 78 | + 'espresso_registrations_registration_checkins', |
|
| 79 | + $item->ID() |
|
| 80 | + ) |
|
| 81 | + ) { |
|
| 82 | + // open "a" tag and "href" |
|
| 83 | + $datetime_string .= '<a class="ee-aria-tooltip" href="'; |
|
| 84 | + // checkin URL |
|
| 85 | + $datetime_string .= EE_Admin_Page::add_query_args_and_nonce( |
|
| 86 | + array( |
|
| 87 | + 'action' => 'event_registrations', |
|
| 88 | + 'event_id' => $EVT_ID, |
|
| 89 | + 'DTT_ID' => $datetime->ID(), |
|
| 90 | + ), |
|
| 91 | + REG_ADMIN_URL |
|
| 92 | + ); |
|
| 93 | + // close "href" |
|
| 94 | + $datetime_string .= '"'; |
|
| 95 | + // open "title" tag |
|
| 96 | + $datetime_string .= ' aria-label="'; |
|
| 97 | + // link title text |
|
| 98 | + $datetime_string .= esc_attr__('View Checkins for this Event', 'event_espresso'); |
|
| 99 | + // close "title" tag and end of "a" tag opening |
|
| 100 | + $datetime_string .= '">'; |
|
| 101 | + // link text |
|
| 102 | + $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
| 103 | + // close "a" tag |
|
| 104 | + $datetime_string .= '</a>'; |
|
| 105 | + } else { |
|
| 106 | + $datetime_string .= $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a'); |
|
| 107 | + } |
|
| 108 | + // add a "View Registrations" link that filters list by event AND datetime |
|
| 109 | + $datetime_string .= $this->row_actions( |
|
| 110 | + array( |
|
| 111 | + 'event_datetime_filter' => '<a class="ee-aria-tooltip" href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 112 | + array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
|
| 113 | + REG_ADMIN_URL |
|
| 114 | + ) |
|
| 115 | + . '" aria-label="' . sprintf( |
|
| 116 | + esc_attr__( |
|
| 117 | + 'Filter this list to only show registrations for this datetime %s', |
|
| 118 | + 'event_espresso' |
|
| 119 | + ), |
|
| 120 | + $datetime->name() |
|
| 121 | + ) . '">' |
|
| 122 | + . esc_html__('View Registrations', 'event_espresso') |
|
| 123 | + . '</a>', |
|
| 124 | + ) |
|
| 125 | + ); |
|
| 126 | + $datetimes_for_display[] = $datetime_string; |
|
| 127 | + } |
|
| 128 | + return $this->columnContent( |
|
| 129 | + 'DTT_EVT_start', |
|
| 130 | + $this->generateDisplayForDateTimes($datetimes_for_display) |
|
| 131 | + ); |
|
| 132 | + } |
|
| 133 | 133 | } |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | 'ee_read_checkins', |
| 40 | 40 | 'espresso_registrations_registration_checkins' |
| 41 | 41 | ) |
| 42 | - ? '<a class="ee-aria-tooltip" href="' . $check_in_url . '"' |
|
| 43 | - . ' aria-label="' . esc_attr__( |
|
| 42 | + ? '<a class="ee-aria-tooltip" href="'.$check_in_url.'"' |
|
| 43 | + . ' aria-label="'.esc_attr__( |
|
| 44 | 44 | 'The Check-In List allows you to easily toggle check-in status for this event', |
| 45 | 45 | 'event_espresso' |
| 46 | 46 | ) |
| 47 | - . '">' . esc_html__('View Check-ins', 'event_espresso') . '</a>' |
|
| 47 | + . '">'.esc_html__('View Check-ins', 'event_espresso').'</a>' |
|
| 48 | 48 | : esc_html__('View Check-ins', 'event_espresso'); |
| 49 | 49 | |
| 50 | 50 | $content = sprintf('%1$s %2$s', $date_linked, $this->row_actions($actions)); |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | // add a "View Registrations" link that filters list by event AND datetime |
| 109 | 109 | $datetime_string .= $this->row_actions( |
| 110 | 110 | array( |
| 111 | - 'event_datetime_filter' => '<a class="ee-aria-tooltip" href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 111 | + 'event_datetime_filter' => '<a class="ee-aria-tooltip" href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
| 112 | 112 | array('event_id' => $EVT_ID, 'datetime_id' => $datetime->ID()), |
| 113 | 113 | REG_ADMIN_URL |
| 114 | 114 | ) |
| 115 | - . '" aria-label="' . sprintf( |
|
| 115 | + . '" aria-label="'.sprintf( |
|
| 116 | 116 | esc_attr__( |
| 117 | 117 | 'Filter this list to only show registrations for this datetime %s', |
| 118 | 118 | 'event_espresso' |
| 119 | 119 | ), |
| 120 | 120 | $datetime->name() |
| 121 | - ) . '">' |
|
| 121 | + ).'">' |
|
| 122 | 122 | . esc_html__('View Registrations', 'event_espresso') |
| 123 | 123 | . '</a>', |
| 124 | 124 | ) |
@@ -12,581 +12,581 @@ |
||
| 12 | 12 | class EE_Event_Registrations_List_Table extends EE_Admin_List_Table |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
| 17 | - * |
|
| 18 | - * @var EE_Datetime[] |
|
| 19 | - */ |
|
| 20 | - protected $_dtts_for_event = array(); |
|
| 21 | - |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * The event if one is specified in the request |
|
| 25 | - * |
|
| 26 | - * @var EE_Event |
|
| 27 | - */ |
|
| 28 | - protected $_evt = null; |
|
| 29 | - |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The DTT_ID if the current view has a specified datetime. |
|
| 33 | - * |
|
| 34 | - * @var int $_cur_dtt_id |
|
| 35 | - */ |
|
| 36 | - protected $_cur_dtt_id = 0; |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * EE_Event_Registrations_List_Table constructor. |
|
| 41 | - * |
|
| 42 | - * @param \Registrations_Admin_Page $admin_page |
|
| 43 | - */ |
|
| 44 | - public function __construct($admin_page) |
|
| 45 | - { |
|
| 46 | - parent::__construct($admin_page); |
|
| 47 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - protected function _setup_data() |
|
| 52 | - { |
|
| 53 | - $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
| 54 | - : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
| 55 | - $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
|
| 56 | - $this->_per_page, |
|
| 57 | - true |
|
| 58 | - ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - protected function _set_properties() |
|
| 63 | - { |
|
| 64 | - $return_url = $this->getReturnUrl(); |
|
| 65 | - |
|
| 66 | - $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 67 | - $this->_wp_list_args = array( |
|
| 68 | - 'singular' => esc_html__('registrant', 'event_espresso'), |
|
| 69 | - 'plural' => esc_html__('registrants', 'event_espresso'), |
|
| 70 | - 'ajax' => true, |
|
| 71 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 72 | - ); |
|
| 73 | - $columns = array(); |
|
| 74 | - $this->_columns = array( |
|
| 75 | - '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
| 76 | - 'status' => '', |
|
| 77 | - 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
| 78 | - 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
| 79 | - 'Event' => esc_html__('Event', 'event_espresso'), |
|
| 80 | - 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
| 81 | - '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
| 82 | - 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 83 | - 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
| 84 | - ); |
|
| 85 | - // Add/remove columns when an event has been selected |
|
| 86 | - if (! empty($evt_id)) { |
|
| 87 | - // Render a checkbox column |
|
| 88 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 89 | - $this->_has_checkbox_column = true; |
|
| 90 | - // Remove the 'Event' column |
|
| 91 | - unset($this->_columns['Event']); |
|
| 92 | - } |
|
| 93 | - $this->_columns = array_merge($columns, $this->_columns); |
|
| 94 | - $this->_primary_column = '_REG_att_checked_in'; |
|
| 95 | - if ( |
|
| 96 | - ! empty($evt_id) |
|
| 97 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 98 | - 'ee_read_registrations', |
|
| 99 | - 'espresso_registrations_registrations_reports', |
|
| 100 | - $evt_id |
|
| 101 | - ) |
|
| 102 | - ) { |
|
| 103 | - $this->_bottom_buttons = array( |
|
| 104 | - 'report' => array( |
|
| 105 | - 'route' => 'registrations_report', |
|
| 106 | - 'extra_request' => |
|
| 107 | - array( |
|
| 108 | - 'EVT_ID' => $evt_id, |
|
| 109 | - 'return_url' => $return_url, |
|
| 110 | - ), |
|
| 111 | - ), |
|
| 112 | - ); |
|
| 113 | - } |
|
| 114 | - $this->_bottom_buttons['report_filtered'] = array( |
|
| 115 | - 'route' => 'registrations_checkin_report', |
|
| 116 | - 'extra_request' => array( |
|
| 117 | - 'use_filters' => true, |
|
| 118 | - 'filters' => array_merge( |
|
| 119 | - array( |
|
| 120 | - 'EVT_ID' => $evt_id, |
|
| 121 | - ), |
|
| 122 | - array_diff_key( |
|
| 123 | - $this->_req_data, |
|
| 124 | - array_flip( |
|
| 125 | - array( |
|
| 126 | - 'page', |
|
| 127 | - 'action', |
|
| 128 | - 'default_nonce', |
|
| 129 | - ) |
|
| 130 | - ) |
|
| 131 | - ) |
|
| 132 | - ), |
|
| 133 | - 'return_url' => $return_url, |
|
| 134 | - ), |
|
| 135 | - ); |
|
| 136 | - $this->_sortable_columns = array( |
|
| 137 | - /** |
|
| 138 | - * Allows users to change the default sort if they wish. |
|
| 139 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 140 | - * |
|
| 141 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 142 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 143 | - * for a specific list table you can use the provided reference to this object instance. |
|
| 144 | - */ |
|
| 145 | - 'ATT_name' => array( |
|
| 146 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 147 | - true, |
|
| 148 | - $this, |
|
| 149 | - ) |
|
| 150 | - ? array('ATT_lname' => true) |
|
| 151 | - : array('ATT_fname' => true), |
|
| 152 | - 'Event' => array('Event.EVT_name' => false), |
|
| 153 | - ); |
|
| 154 | - $this->_hidden_columns = array(); |
|
| 155 | - $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
| 156 | - $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @param \EE_Registration $item |
|
| 162 | - * @return string |
|
| 163 | - */ |
|
| 164 | - protected function _get_row_class($item) |
|
| 165 | - { |
|
| 166 | - $class = parent::_get_row_class($item); |
|
| 167 | - // add status class |
|
| 168 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 169 | - if ($this->_has_checkbox_column) { |
|
| 170 | - $class .= ' has-checkbox-column'; |
|
| 171 | - } |
|
| 172 | - return $class; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @return array |
|
| 178 | - * @throws \EE_Error |
|
| 179 | - */ |
|
| 180 | - protected function _get_table_filters() |
|
| 181 | - { |
|
| 182 | - $filters = $where = array(); |
|
| 183 | - $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
| 184 | - if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
| 185 | - // this means we don't have an event so let's setup a filter dropdown for all the events to select |
|
| 186 | - // note possible capability restrictions |
|
| 187 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 188 | - $where['status**'] = array('!=', 'private'); |
|
| 189 | - } |
|
| 190 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 191 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
| 192 | - } |
|
| 193 | - $events = EEM_Event::instance()->get_all( |
|
| 194 | - array( |
|
| 195 | - $where, |
|
| 196 | - 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
| 197 | - ) |
|
| 198 | - ); |
|
| 199 | - $evts[] = array( |
|
| 200 | - 'id' => 0, |
|
| 201 | - 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
|
| 202 | - ); |
|
| 203 | - $checked = 'checked'; |
|
| 204 | - /** @var EE_Event $evt */ |
|
| 205 | - foreach ($events as $evt) { |
|
| 206 | - // any registrations for this event? |
|
| 207 | - if (! $evt->get_count_of_all_registrations()) { |
|
| 208 | - continue; |
|
| 209 | - } |
|
| 210 | - $evts[] = array( |
|
| 211 | - 'id' => $evt->ID(), |
|
| 212 | - 'text' => apply_filters( |
|
| 213 | - 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
| 214 | - $evt->get('EVT_name'), |
|
| 215 | - $evt |
|
| 216 | - ), |
|
| 217 | - 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
|
| 218 | - ); |
|
| 219 | - if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
| 220 | - $checked = ''; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - $event_filter = '<div class="ee-event-filter">'; |
|
| 224 | - $event_filter .= '<label for="event_id">'; |
|
| 225 | - $event_filter .= esc_html__('Check-in Status for', 'event_espresso'); |
|
| 226 | - $event_filter .= '</label> '; |
|
| 227 | - $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
| 228 | - $event_filter .= '<span class="ee-event-filter-toggle">'; |
|
| 229 | - $event_filter .= '<label for="js-ee-hide-expired-events">'; |
|
| 230 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
| 231 | - $event_filter .= esc_html__('Hide Expired Events', 'event_espresso'); |
|
| 232 | - $event_filter .= '</label>'; |
|
| 233 | - $event_filter .= '</span>'; |
|
| 234 | - $event_filter .= '</div>'; |
|
| 235 | - $filters[] = $event_filter; |
|
| 236 | - } |
|
| 237 | - if (! empty($this->_dtts_for_event)) { |
|
| 238 | - // DTT datetimes filter |
|
| 239 | - $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
| 240 | - if (count($this->_dtts_for_event) > 1) { |
|
| 241 | - $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
| 242 | - foreach ($this->_dtts_for_event as $dtt) { |
|
| 243 | - $datetime_string = $dtt->name(); |
|
| 244 | - $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
| 245 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
| 246 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
| 247 | - } |
|
| 248 | - $input = new EE_Select_Input( |
|
| 249 | - $dtts, |
|
| 250 | - array( |
|
| 251 | - 'html_name' => 'DTT_ID', |
|
| 252 | - 'html_id' => 'DTT_ID', |
|
| 253 | - 'default' => $this->_cur_dtt_id, |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - $filters[] = $input->get_html_for_input(); |
|
| 257 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - return $filters; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - protected function _add_view_counts() |
|
| 265 | - { |
|
| 266 | - $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * @return int |
|
| 272 | - * @throws \EE_Error |
|
| 273 | - */ |
|
| 274 | - protected function _get_total_event_attendees() |
|
| 275 | - { |
|
| 276 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 277 | - $DTT_ID = $this->_cur_dtt_id; |
|
| 278 | - $query_params = array(); |
|
| 279 | - if ($EVT_ID) { |
|
| 280 | - $query_params[0]['EVT_ID'] = $EVT_ID; |
|
| 281 | - } |
|
| 282 | - // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
| 283 | - if ($DTT_ID) { |
|
| 284 | - $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
| 285 | - } |
|
| 286 | - $status_ids_array = apply_filters( |
|
| 287 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 288 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 289 | - ); |
|
| 290 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 291 | - return EEM_Registration::instance()->count($query_params); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * column status |
|
| 297 | - * |
|
| 298 | - * @param EE_Registration $registration |
|
| 299 | - * @return string |
|
| 300 | - * @throws EE_Error |
|
| 301 | - */ |
|
| 302 | - public function column_status(EE_Registration $registration) |
|
| 303 | - { |
|
| 304 | - return ' |
|
| 15 | + /** |
|
| 16 | + * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
| 17 | + * |
|
| 18 | + * @var EE_Datetime[] |
|
| 19 | + */ |
|
| 20 | + protected $_dtts_for_event = array(); |
|
| 21 | + |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * The event if one is specified in the request |
|
| 25 | + * |
|
| 26 | + * @var EE_Event |
|
| 27 | + */ |
|
| 28 | + protected $_evt = null; |
|
| 29 | + |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The DTT_ID if the current view has a specified datetime. |
|
| 33 | + * |
|
| 34 | + * @var int $_cur_dtt_id |
|
| 35 | + */ |
|
| 36 | + protected $_cur_dtt_id = 0; |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * EE_Event_Registrations_List_Table constructor. |
|
| 41 | + * |
|
| 42 | + * @param \Registrations_Admin_Page $admin_page |
|
| 43 | + */ |
|
| 44 | + public function __construct($admin_page) |
|
| 45 | + { |
|
| 46 | + parent::__construct($admin_page); |
|
| 47 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + protected function _setup_data() |
|
| 52 | + { |
|
| 53 | + $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
| 54 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
| 55 | + $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
|
| 56 | + $this->_per_page, |
|
| 57 | + true |
|
| 58 | + ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + protected function _set_properties() |
|
| 63 | + { |
|
| 64 | + $return_url = $this->getReturnUrl(); |
|
| 65 | + |
|
| 66 | + $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 67 | + $this->_wp_list_args = array( |
|
| 68 | + 'singular' => esc_html__('registrant', 'event_espresso'), |
|
| 69 | + 'plural' => esc_html__('registrants', 'event_espresso'), |
|
| 70 | + 'ajax' => true, |
|
| 71 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 72 | + ); |
|
| 73 | + $columns = array(); |
|
| 74 | + $this->_columns = array( |
|
| 75 | + '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
| 76 | + 'status' => '', |
|
| 77 | + 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
| 78 | + 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
| 79 | + 'Event' => esc_html__('Event', 'event_espresso'), |
|
| 80 | + 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
| 81 | + '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
| 82 | + 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 83 | + 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
| 84 | + ); |
|
| 85 | + // Add/remove columns when an event has been selected |
|
| 86 | + if (! empty($evt_id)) { |
|
| 87 | + // Render a checkbox column |
|
| 88 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 89 | + $this->_has_checkbox_column = true; |
|
| 90 | + // Remove the 'Event' column |
|
| 91 | + unset($this->_columns['Event']); |
|
| 92 | + } |
|
| 93 | + $this->_columns = array_merge($columns, $this->_columns); |
|
| 94 | + $this->_primary_column = '_REG_att_checked_in'; |
|
| 95 | + if ( |
|
| 96 | + ! empty($evt_id) |
|
| 97 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 98 | + 'ee_read_registrations', |
|
| 99 | + 'espresso_registrations_registrations_reports', |
|
| 100 | + $evt_id |
|
| 101 | + ) |
|
| 102 | + ) { |
|
| 103 | + $this->_bottom_buttons = array( |
|
| 104 | + 'report' => array( |
|
| 105 | + 'route' => 'registrations_report', |
|
| 106 | + 'extra_request' => |
|
| 107 | + array( |
|
| 108 | + 'EVT_ID' => $evt_id, |
|
| 109 | + 'return_url' => $return_url, |
|
| 110 | + ), |
|
| 111 | + ), |
|
| 112 | + ); |
|
| 113 | + } |
|
| 114 | + $this->_bottom_buttons['report_filtered'] = array( |
|
| 115 | + 'route' => 'registrations_checkin_report', |
|
| 116 | + 'extra_request' => array( |
|
| 117 | + 'use_filters' => true, |
|
| 118 | + 'filters' => array_merge( |
|
| 119 | + array( |
|
| 120 | + 'EVT_ID' => $evt_id, |
|
| 121 | + ), |
|
| 122 | + array_diff_key( |
|
| 123 | + $this->_req_data, |
|
| 124 | + array_flip( |
|
| 125 | + array( |
|
| 126 | + 'page', |
|
| 127 | + 'action', |
|
| 128 | + 'default_nonce', |
|
| 129 | + ) |
|
| 130 | + ) |
|
| 131 | + ) |
|
| 132 | + ), |
|
| 133 | + 'return_url' => $return_url, |
|
| 134 | + ), |
|
| 135 | + ); |
|
| 136 | + $this->_sortable_columns = array( |
|
| 137 | + /** |
|
| 138 | + * Allows users to change the default sort if they wish. |
|
| 139 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 140 | + * |
|
| 141 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 142 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 143 | + * for a specific list table you can use the provided reference to this object instance. |
|
| 144 | + */ |
|
| 145 | + 'ATT_name' => array( |
|
| 146 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 147 | + true, |
|
| 148 | + $this, |
|
| 149 | + ) |
|
| 150 | + ? array('ATT_lname' => true) |
|
| 151 | + : array('ATT_fname' => true), |
|
| 152 | + 'Event' => array('Event.EVT_name' => false), |
|
| 153 | + ); |
|
| 154 | + $this->_hidden_columns = array(); |
|
| 155 | + $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
| 156 | + $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * @param \EE_Registration $item |
|
| 162 | + * @return string |
|
| 163 | + */ |
|
| 164 | + protected function _get_row_class($item) |
|
| 165 | + { |
|
| 166 | + $class = parent::_get_row_class($item); |
|
| 167 | + // add status class |
|
| 168 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 169 | + if ($this->_has_checkbox_column) { |
|
| 170 | + $class .= ' has-checkbox-column'; |
|
| 171 | + } |
|
| 172 | + return $class; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @return array |
|
| 178 | + * @throws \EE_Error |
|
| 179 | + */ |
|
| 180 | + protected function _get_table_filters() |
|
| 181 | + { |
|
| 182 | + $filters = $where = array(); |
|
| 183 | + $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
| 184 | + if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
| 185 | + // this means we don't have an event so let's setup a filter dropdown for all the events to select |
|
| 186 | + // note possible capability restrictions |
|
| 187 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 188 | + $where['status**'] = array('!=', 'private'); |
|
| 189 | + } |
|
| 190 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 191 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
| 192 | + } |
|
| 193 | + $events = EEM_Event::instance()->get_all( |
|
| 194 | + array( |
|
| 195 | + $where, |
|
| 196 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
| 197 | + ) |
|
| 198 | + ); |
|
| 199 | + $evts[] = array( |
|
| 200 | + 'id' => 0, |
|
| 201 | + 'text' => esc_html__(' - select an event - ', 'event_espresso'), |
|
| 202 | + ); |
|
| 203 | + $checked = 'checked'; |
|
| 204 | + /** @var EE_Event $evt */ |
|
| 205 | + foreach ($events as $evt) { |
|
| 206 | + // any registrations for this event? |
|
| 207 | + if (! $evt->get_count_of_all_registrations()) { |
|
| 208 | + continue; |
|
| 209 | + } |
|
| 210 | + $evts[] = array( |
|
| 211 | + 'id' => $evt->ID(), |
|
| 212 | + 'text' => apply_filters( |
|
| 213 | + 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
| 214 | + $evt->get('EVT_name'), |
|
| 215 | + $evt |
|
| 216 | + ), |
|
| 217 | + 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
|
| 218 | + ); |
|
| 219 | + if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
| 220 | + $checked = ''; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + $event_filter = '<div class="ee-event-filter">'; |
|
| 224 | + $event_filter .= '<label for="event_id">'; |
|
| 225 | + $event_filter .= esc_html__('Check-in Status for', 'event_espresso'); |
|
| 226 | + $event_filter .= '</label> '; |
|
| 227 | + $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
| 228 | + $event_filter .= '<span class="ee-event-filter-toggle">'; |
|
| 229 | + $event_filter .= '<label for="js-ee-hide-expired-events">'; |
|
| 230 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
| 231 | + $event_filter .= esc_html__('Hide Expired Events', 'event_espresso'); |
|
| 232 | + $event_filter .= '</label>'; |
|
| 233 | + $event_filter .= '</span>'; |
|
| 234 | + $event_filter .= '</div>'; |
|
| 235 | + $filters[] = $event_filter; |
|
| 236 | + } |
|
| 237 | + if (! empty($this->_dtts_for_event)) { |
|
| 238 | + // DTT datetimes filter |
|
| 239 | + $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
| 240 | + if (count($this->_dtts_for_event) > 1) { |
|
| 241 | + $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
| 242 | + foreach ($this->_dtts_for_event as $dtt) { |
|
| 243 | + $datetime_string = $dtt->name(); |
|
| 244 | + $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
| 245 | + $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
| 246 | + $dtts[ $dtt->ID() ] = $datetime_string; |
|
| 247 | + } |
|
| 248 | + $input = new EE_Select_Input( |
|
| 249 | + $dtts, |
|
| 250 | + array( |
|
| 251 | + 'html_name' => 'DTT_ID', |
|
| 252 | + 'html_id' => 'DTT_ID', |
|
| 253 | + 'default' => $this->_cur_dtt_id, |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + $filters[] = $input->get_html_for_input(); |
|
| 257 | + $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + return $filters; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + protected function _add_view_counts() |
|
| 265 | + { |
|
| 266 | + $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * @return int |
|
| 272 | + * @throws \EE_Error |
|
| 273 | + */ |
|
| 274 | + protected function _get_total_event_attendees() |
|
| 275 | + { |
|
| 276 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 277 | + $DTT_ID = $this->_cur_dtt_id; |
|
| 278 | + $query_params = array(); |
|
| 279 | + if ($EVT_ID) { |
|
| 280 | + $query_params[0]['EVT_ID'] = $EVT_ID; |
|
| 281 | + } |
|
| 282 | + // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
| 283 | + if ($DTT_ID) { |
|
| 284 | + $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
| 285 | + } |
|
| 286 | + $status_ids_array = apply_filters( |
|
| 287 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 288 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 289 | + ); |
|
| 290 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 291 | + return EEM_Registration::instance()->count($query_params); |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * column status |
|
| 297 | + * |
|
| 298 | + * @param EE_Registration $registration |
|
| 299 | + * @return string |
|
| 300 | + * @throws EE_Error |
|
| 301 | + */ |
|
| 302 | + public function column_status(EE_Registration $registration) |
|
| 303 | + { |
|
| 304 | + return ' |
|
| 305 | 305 | <span class="ee-status-dot ee-status-dot--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" |
| 306 | 306 | aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '"> |
| 307 | 307 | </span>'; |
| 308 | - } |
|
| 309 | - |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * @param \EE_Registration $item |
|
| 313 | - * @return string |
|
| 314 | - * @throws \EE_Error |
|
| 315 | - */ |
|
| 316 | - public function column_cb($item) |
|
| 317 | - { |
|
| 318 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * column_REG_att_checked_in |
|
| 324 | - * |
|
| 325 | - * @param EE_Registration $item |
|
| 326 | - * @return string |
|
| 327 | - * @throws EE_Error |
|
| 328 | - * @throws InvalidArgumentException |
|
| 329 | - * @throws InvalidDataTypeException |
|
| 330 | - * @throws InvalidInterfaceException |
|
| 331 | - */ |
|
| 332 | - public function column__REG_att_checked_in(EE_Registration $item) |
|
| 333 | - { |
|
| 334 | - $attendee = $item->attendee(); |
|
| 335 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 336 | - |
|
| 337 | - if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
| 338 | - $latest_related_datetime = $item->get_latest_related_datetime(); |
|
| 339 | - if ($latest_related_datetime instanceof EE_Datetime) { |
|
| 340 | - $this->_cur_dtt_id = $latest_related_datetime->ID(); |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
| 344 | - $item, |
|
| 345 | - $this->_cur_dtt_id |
|
| 346 | - ); |
|
| 347 | - $nonce = wp_create_nonce('checkin_nonce'); |
|
| 348 | - $toggle_active = ! empty($this->_cur_dtt_id) |
|
| 349 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 350 | - 'ee_edit_checkin', |
|
| 351 | - 'espresso_registrations_toggle_checkin_status', |
|
| 352 | - $item->ID() |
|
| 353 | - ) |
|
| 354 | - ? ' clickable trigger-checkin' |
|
| 355 | - : ''; |
|
| 356 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 357 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
| 358 | - . ' data-_regid="' . $item->ID() . '"' |
|
| 359 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 360 | - . ' data-nonce="' . $nonce . '">' |
|
| 361 | - . '</span>' |
|
| 362 | - . $mobile_view_content; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * @param \EE_Registration $item |
|
| 368 | - * @return mixed|string|void |
|
| 369 | - * @throws \EE_Error |
|
| 370 | - */ |
|
| 371 | - public function column_ATT_name(EE_Registration $item) |
|
| 372 | - { |
|
| 373 | - $attendee = $item->attendee(); |
|
| 374 | - if (! $attendee instanceof EE_Attendee) { |
|
| 375 | - return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
| 376 | - } |
|
| 377 | - // edit attendee link |
|
| 378 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 379 | - array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 380 | - REG_ADMIN_URL |
|
| 381 | - ); |
|
| 382 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 383 | - 'ee_edit_contacts', |
|
| 384 | - 'espresso_registrations_edit_attendee' |
|
| 385 | - ) |
|
| 386 | - ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 387 | - . $item->attendee()->full_name() |
|
| 388 | - . '</a>' |
|
| 389 | - : $item->attendee()->full_name(); |
|
| 390 | - $name_link .= $item->count() === 1 |
|
| 391 | - ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
|
| 392 | - : ''; |
|
| 393 | - // add group details |
|
| 394 | - $name_link .= ' ' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 395 | - // add regcode |
|
| 396 | - $link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 397 | - array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 398 | - REG_ADMIN_URL |
|
| 399 | - ); |
|
| 400 | - $name_link .= '<br>'; |
|
| 401 | - $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
| 402 | - 'ee_read_registration', |
|
| 403 | - 'view_registration', |
|
| 404 | - $item->ID() |
|
| 405 | - ) |
|
| 406 | - ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 407 | - . $item->reg_code() |
|
| 408 | - . '</a>' |
|
| 409 | - : $item->reg_code(); |
|
| 410 | - // status |
|
| 411 | - $name_link .= '<br><span class="ee-status-text-small">'; |
|
| 412 | - $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
| 413 | - $name_link .= '</span>'; |
|
| 414 | - $actions = array(); |
|
| 415 | - $DTT_ID = $this->_cur_dtt_id; |
|
| 416 | - $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
| 417 | - ? $item->get_latest_related_datetime() |
|
| 418 | - : null; |
|
| 419 | - $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
|
| 420 | - ? $latest_related_datetime->ID() |
|
| 421 | - : $DTT_ID; |
|
| 422 | - if ( |
|
| 423 | - ! empty($DTT_ID) |
|
| 424 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 425 | - 'ee_read_checkins', |
|
| 426 | - 'espresso_registrations_registration_checkins' |
|
| 427 | - ) |
|
| 428 | - ) { |
|
| 429 | - $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 430 | - array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
| 431 | - REG_ADMIN_URL |
|
| 432 | - ); |
|
| 433 | - // get the timestamps for this registration's checkins, related to the selected datetime |
|
| 434 | - $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
| 435 | - if (! empty($timestamps)) { |
|
| 436 | - // get the last timestamp |
|
| 437 | - $last_timestamp = end($timestamps); |
|
| 438 | - // checked in or checked out? |
|
| 439 | - $checkin_status = $last_timestamp->get('CHK_in') |
|
| 440 | - ? esc_html__('Checked In', 'event_espresso') |
|
| 441 | - : esc_html__('Checked Out', 'event_espresso'); |
|
| 442 | - // get timestamp string |
|
| 443 | - $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
| 444 | - $actions['checkin'] = '<a class="ee-aria-tooltip" href="' . $checkin_list_url . '" aria-label="' |
|
| 445 | - . esc_attr__( |
|
| 446 | - 'View this registrant\'s check-ins/checkouts for the datetime', |
|
| 447 | - 'event_espresso' |
|
| 448 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
| 449 | - } |
|
| 450 | - } |
|
| 451 | - return (! empty($DTT_ID) && ! empty($timestamps)) |
|
| 452 | - ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
| 453 | - : $name_link; |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * @param \EE_Registration $item |
|
| 459 | - * @return string |
|
| 460 | - */ |
|
| 461 | - public function column_ATT_email(EE_Registration $item) |
|
| 462 | - { |
|
| 463 | - $attendee = $item->attendee(); |
|
| 464 | - return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - |
|
| 468 | - /** |
|
| 469 | - * @param \EE_Registration $item |
|
| 470 | - * @return bool|string |
|
| 471 | - * @throws \EE_Error |
|
| 472 | - */ |
|
| 473 | - public function column_Event(EE_Registration $item) |
|
| 474 | - { |
|
| 475 | - try { |
|
| 476 | - $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
|
| 477 | - $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 478 | - array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
| 479 | - REG_ADMIN_URL |
|
| 480 | - ); |
|
| 481 | - $event_label = EE_Registry::instance()->CAP->current_user_can( |
|
| 482 | - 'ee_read_checkins', |
|
| 483 | - 'espresso_registrations_registration_checkins' |
|
| 484 | - ) ? '<a class="ee-aria-tooltip" href="' . $chkin_lnk_url . '" aria-label="' |
|
| 485 | - . esc_attr__( |
|
| 486 | - 'View Checkins for this Event', |
|
| 487 | - 'event_espresso' |
|
| 488 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 489 | - } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 490 | - $event_label = esc_html__('Unknown', 'event_espresso'); |
|
| 491 | - } |
|
| 492 | - return $event_label; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - |
|
| 496 | - /** |
|
| 497 | - * @param \EE_Registration $item |
|
| 498 | - * @return mixed|string|void |
|
| 499 | - */ |
|
| 500 | - public function column_PRC_name(EE_Registration $item) |
|
| 501 | - { |
|
| 502 | - return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso"); |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * column_REG_final_price |
|
| 508 | - * |
|
| 509 | - * @param \EE_Registration $item |
|
| 510 | - * @return string |
|
| 511 | - */ |
|
| 512 | - public function column__REG_final_price(EE_Registration $item) |
|
| 513 | - { |
|
| 514 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * column_TXN_paid |
|
| 520 | - * |
|
| 521 | - * @param \EE_Registration $item |
|
| 522 | - * @return string |
|
| 523 | - * @throws \EE_Error |
|
| 524 | - */ |
|
| 525 | - public function column_TXN_paid(EE_Registration $item) |
|
| 526 | - { |
|
| 527 | - if ($item->count() === 1) { |
|
| 528 | - if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
| 529 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 530 | - } else { |
|
| 531 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 532 | - array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
| 533 | - TXN_ADMIN_URL |
|
| 534 | - ); |
|
| 535 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 536 | - 'ee_read_transaction', |
|
| 537 | - 'espresso_transactions_view_transaction' |
|
| 538 | - ) ? ' |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * @param \EE_Registration $item |
|
| 313 | + * @return string |
|
| 314 | + * @throws \EE_Error |
|
| 315 | + */ |
|
| 316 | + public function column_cb($item) |
|
| 317 | + { |
|
| 318 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * column_REG_att_checked_in |
|
| 324 | + * |
|
| 325 | + * @param EE_Registration $item |
|
| 326 | + * @return string |
|
| 327 | + * @throws EE_Error |
|
| 328 | + * @throws InvalidArgumentException |
|
| 329 | + * @throws InvalidDataTypeException |
|
| 330 | + * @throws InvalidInterfaceException |
|
| 331 | + */ |
|
| 332 | + public function column__REG_att_checked_in(EE_Registration $item) |
|
| 333 | + { |
|
| 334 | + $attendee = $item->attendee(); |
|
| 335 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 336 | + |
|
| 337 | + if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
| 338 | + $latest_related_datetime = $item->get_latest_related_datetime(); |
|
| 339 | + if ($latest_related_datetime instanceof EE_Datetime) { |
|
| 340 | + $this->_cur_dtt_id = $latest_related_datetime->ID(); |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
| 344 | + $item, |
|
| 345 | + $this->_cur_dtt_id |
|
| 346 | + ); |
|
| 347 | + $nonce = wp_create_nonce('checkin_nonce'); |
|
| 348 | + $toggle_active = ! empty($this->_cur_dtt_id) |
|
| 349 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 350 | + 'ee_edit_checkin', |
|
| 351 | + 'espresso_registrations_toggle_checkin_status', |
|
| 352 | + $item->ID() |
|
| 353 | + ) |
|
| 354 | + ? ' clickable trigger-checkin' |
|
| 355 | + : ''; |
|
| 356 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 357 | + return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
| 358 | + . ' data-_regid="' . $item->ID() . '"' |
|
| 359 | + . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 360 | + . ' data-nonce="' . $nonce . '">' |
|
| 361 | + . '</span>' |
|
| 362 | + . $mobile_view_content; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * @param \EE_Registration $item |
|
| 368 | + * @return mixed|string|void |
|
| 369 | + * @throws \EE_Error |
|
| 370 | + */ |
|
| 371 | + public function column_ATT_name(EE_Registration $item) |
|
| 372 | + { |
|
| 373 | + $attendee = $item->attendee(); |
|
| 374 | + if (! $attendee instanceof EE_Attendee) { |
|
| 375 | + return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
| 376 | + } |
|
| 377 | + // edit attendee link |
|
| 378 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 379 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 380 | + REG_ADMIN_URL |
|
| 381 | + ); |
|
| 382 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 383 | + 'ee_edit_contacts', |
|
| 384 | + 'espresso_registrations_edit_attendee' |
|
| 385 | + ) |
|
| 386 | + ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 387 | + . $item->attendee()->full_name() |
|
| 388 | + . '</a>' |
|
| 389 | + : $item->attendee()->full_name(); |
|
| 390 | + $name_link .= $item->count() === 1 |
|
| 391 | + ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
|
| 392 | + : ''; |
|
| 393 | + // add group details |
|
| 394 | + $name_link .= ' ' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 395 | + // add regcode |
|
| 396 | + $link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 397 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 398 | + REG_ADMIN_URL |
|
| 399 | + ); |
|
| 400 | + $name_link .= '<br>'; |
|
| 401 | + $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
| 402 | + 'ee_read_registration', |
|
| 403 | + 'view_registration', |
|
| 404 | + $item->ID() |
|
| 405 | + ) |
|
| 406 | + ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 407 | + . $item->reg_code() |
|
| 408 | + . '</a>' |
|
| 409 | + : $item->reg_code(); |
|
| 410 | + // status |
|
| 411 | + $name_link .= '<br><span class="ee-status-text-small">'; |
|
| 412 | + $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
| 413 | + $name_link .= '</span>'; |
|
| 414 | + $actions = array(); |
|
| 415 | + $DTT_ID = $this->_cur_dtt_id; |
|
| 416 | + $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
| 417 | + ? $item->get_latest_related_datetime() |
|
| 418 | + : null; |
|
| 419 | + $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
|
| 420 | + ? $latest_related_datetime->ID() |
|
| 421 | + : $DTT_ID; |
|
| 422 | + if ( |
|
| 423 | + ! empty($DTT_ID) |
|
| 424 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 425 | + 'ee_read_checkins', |
|
| 426 | + 'espresso_registrations_registration_checkins' |
|
| 427 | + ) |
|
| 428 | + ) { |
|
| 429 | + $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 430 | + array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
| 431 | + REG_ADMIN_URL |
|
| 432 | + ); |
|
| 433 | + // get the timestamps for this registration's checkins, related to the selected datetime |
|
| 434 | + $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
| 435 | + if (! empty($timestamps)) { |
|
| 436 | + // get the last timestamp |
|
| 437 | + $last_timestamp = end($timestamps); |
|
| 438 | + // checked in or checked out? |
|
| 439 | + $checkin_status = $last_timestamp->get('CHK_in') |
|
| 440 | + ? esc_html__('Checked In', 'event_espresso') |
|
| 441 | + : esc_html__('Checked Out', 'event_espresso'); |
|
| 442 | + // get timestamp string |
|
| 443 | + $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
| 444 | + $actions['checkin'] = '<a class="ee-aria-tooltip" href="' . $checkin_list_url . '" aria-label="' |
|
| 445 | + . esc_attr__( |
|
| 446 | + 'View this registrant\'s check-ins/checkouts for the datetime', |
|
| 447 | + 'event_espresso' |
|
| 448 | + ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | + return (! empty($DTT_ID) && ! empty($timestamps)) |
|
| 452 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
| 453 | + : $name_link; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * @param \EE_Registration $item |
|
| 459 | + * @return string |
|
| 460 | + */ |
|
| 461 | + public function column_ATT_email(EE_Registration $item) |
|
| 462 | + { |
|
| 463 | + $attendee = $item->attendee(); |
|
| 464 | + return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + |
|
| 468 | + /** |
|
| 469 | + * @param \EE_Registration $item |
|
| 470 | + * @return bool|string |
|
| 471 | + * @throws \EE_Error |
|
| 472 | + */ |
|
| 473 | + public function column_Event(EE_Registration $item) |
|
| 474 | + { |
|
| 475 | + try { |
|
| 476 | + $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
|
| 477 | + $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 478 | + array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
| 479 | + REG_ADMIN_URL |
|
| 480 | + ); |
|
| 481 | + $event_label = EE_Registry::instance()->CAP->current_user_can( |
|
| 482 | + 'ee_read_checkins', |
|
| 483 | + 'espresso_registrations_registration_checkins' |
|
| 484 | + ) ? '<a class="ee-aria-tooltip" href="' . $chkin_lnk_url . '" aria-label="' |
|
| 485 | + . esc_attr__( |
|
| 486 | + 'View Checkins for this Event', |
|
| 487 | + 'event_espresso' |
|
| 488 | + ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 489 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 490 | + $event_label = esc_html__('Unknown', 'event_espresso'); |
|
| 491 | + } |
|
| 492 | + return $event_label; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + |
|
| 496 | + /** |
|
| 497 | + * @param \EE_Registration $item |
|
| 498 | + * @return mixed|string|void |
|
| 499 | + */ |
|
| 500 | + public function column_PRC_name(EE_Registration $item) |
|
| 501 | + { |
|
| 502 | + return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso"); |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * column_REG_final_price |
|
| 508 | + * |
|
| 509 | + * @param \EE_Registration $item |
|
| 510 | + * @return string |
|
| 511 | + */ |
|
| 512 | + public function column__REG_final_price(EE_Registration $item) |
|
| 513 | + { |
|
| 514 | + return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * column_TXN_paid |
|
| 520 | + * |
|
| 521 | + * @param \EE_Registration $item |
|
| 522 | + * @return string |
|
| 523 | + * @throws \EE_Error |
|
| 524 | + */ |
|
| 525 | + public function column_TXN_paid(EE_Registration $item) |
|
| 526 | + { |
|
| 527 | + if ($item->count() === 1) { |
|
| 528 | + if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
| 529 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 530 | + } else { |
|
| 531 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 532 | + array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
| 533 | + TXN_ADMIN_URL |
|
| 534 | + ); |
|
| 535 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 536 | + 'ee_read_transaction', |
|
| 537 | + 'espresso_transactions_view_transaction' |
|
| 538 | + ) ? ' |
|
| 539 | 539 | <span class="reg-pad-rght"> |
| 540 | 540 | <a class="ee-aria-tooltip status-' |
| 541 | - . $item->transaction()->status_ID() |
|
| 542 | - . '" href="' |
|
| 543 | - . $view_txn_lnk_url |
|
| 544 | - . '" aria-label="' |
|
| 545 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 546 | - . '"> |
|
| 541 | + . $item->transaction()->status_ID() |
|
| 542 | + . '" href="' |
|
| 543 | + . $view_txn_lnk_url |
|
| 544 | + . '" aria-label="' |
|
| 545 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 546 | + . '"> |
|
| 547 | 547 | ' |
| 548 | - . $item->transaction()->pretty_paid() |
|
| 549 | - . ' |
|
| 548 | + . $item->transaction()->pretty_paid() |
|
| 549 | + . ' |
|
| 550 | 550 | </a> |
| 551 | 551 | <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
| 552 | - } |
|
| 553 | - } else { |
|
| 554 | - return '<span class="reg-pad-rght"></span>'; |
|
| 555 | - } |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * column_TXN_total |
|
| 561 | - * |
|
| 562 | - * @param \EE_Registration $item |
|
| 563 | - * @return string |
|
| 564 | - * @throws \EE_Error |
|
| 565 | - */ |
|
| 566 | - public function column_TXN_total(EE_Registration $item) |
|
| 567 | - { |
|
| 568 | - $txn = $item->transaction(); |
|
| 569 | - $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
| 570 | - if ($item->get('REG_count') === 1) { |
|
| 571 | - $line_total_obj = $txn->total_line_item(); |
|
| 572 | - $txn_total = $line_total_obj instanceof EE_Line_Item |
|
| 573 | - ? $line_total_obj->get_pretty('LIN_total') |
|
| 574 | - : esc_html__( |
|
| 575 | - 'View Transaction', |
|
| 576 | - 'event_espresso' |
|
| 577 | - ); |
|
| 578 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 579 | - 'ee_read_transaction', |
|
| 580 | - 'espresso_transactions_view_transaction' |
|
| 581 | - ) ? '<a class="ee-aria-tooltip" href="' |
|
| 582 | - . $view_txn_url |
|
| 583 | - . '" aria-label="' |
|
| 584 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 585 | - . '"><span class="reg-pad-rght">' |
|
| 586 | - . $txn_total |
|
| 587 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 588 | - } else { |
|
| 589 | - return '<span class="reg-pad-rght"></span>'; |
|
| 590 | - } |
|
| 591 | - } |
|
| 552 | + } |
|
| 553 | + } else { |
|
| 554 | + return '<span class="reg-pad-rght"></span>'; |
|
| 555 | + } |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * column_TXN_total |
|
| 561 | + * |
|
| 562 | + * @param \EE_Registration $item |
|
| 563 | + * @return string |
|
| 564 | + * @throws \EE_Error |
|
| 565 | + */ |
|
| 566 | + public function column_TXN_total(EE_Registration $item) |
|
| 567 | + { |
|
| 568 | + $txn = $item->transaction(); |
|
| 569 | + $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
| 570 | + if ($item->get('REG_count') === 1) { |
|
| 571 | + $line_total_obj = $txn->total_line_item(); |
|
| 572 | + $txn_total = $line_total_obj instanceof EE_Line_Item |
|
| 573 | + ? $line_total_obj->get_pretty('LIN_total') |
|
| 574 | + : esc_html__( |
|
| 575 | + 'View Transaction', |
|
| 576 | + 'event_espresso' |
|
| 577 | + ); |
|
| 578 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 579 | + 'ee_read_transaction', |
|
| 580 | + 'espresso_transactions_view_transaction' |
|
| 581 | + ) ? '<a class="ee-aria-tooltip" href="' |
|
| 582 | + . $view_txn_url |
|
| 583 | + . '" aria-label="' |
|
| 584 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 585 | + . '"><span class="reg-pad-rght">' |
|
| 586 | + . $txn_total |
|
| 587 | + . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 588 | + } else { |
|
| 589 | + return '<span class="reg-pad-rght"></span>'; |
|
| 590 | + } |
|
| 591 | + } |
|
| 592 | 592 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | 'TXN_total' => esc_html__('Total', 'event_espresso'), |
| 84 | 84 | ); |
| 85 | 85 | // Add/remove columns when an event has been selected |
| 86 | - if (! empty($evt_id)) { |
|
| 86 | + if ( ! empty($evt_id)) { |
|
| 87 | 87 | // Render a checkbox column |
| 88 | 88 | $columns['cb'] = '<input type="checkbox" />'; |
| 89 | 89 | $this->_has_checkbox_column = true; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | $class = parent::_get_row_class($item); |
| 167 | 167 | // add status class |
| 168 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 168 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
| 169 | 169 | if ($this->_has_checkbox_column) { |
| 170 | 170 | $class .= ' has-checkbox-column'; |
| 171 | 171 | } |
@@ -184,10 +184,10 @@ discard block |
||
| 184 | 184 | if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
| 185 | 185 | // this means we don't have an event so let's setup a filter dropdown for all the events to select |
| 186 | 186 | // note possible capability restrictions |
| 187 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 187 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 188 | 188 | $where['status**'] = array('!=', 'private'); |
| 189 | 189 | } |
| 190 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 190 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 191 | 191 | $where['EVT_wp_user'] = get_current_user_id(); |
| 192 | 192 | } |
| 193 | 193 | $events = EEM_Event::instance()->get_all( |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | /** @var EE_Event $evt */ |
| 205 | 205 | foreach ($events as $evt) { |
| 206 | 206 | // any registrations for this event? |
| 207 | - if (! $evt->get_count_of_all_registrations()) { |
|
| 207 | + if ( ! $evt->get_count_of_all_registrations()) { |
|
| 208 | 208 | continue; |
| 209 | 209 | } |
| 210 | 210 | $evts[] = array( |
@@ -227,23 +227,23 @@ discard block |
||
| 227 | 227 | $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
| 228 | 228 | $event_filter .= '<span class="ee-event-filter-toggle">'; |
| 229 | 229 | $event_filter .= '<label for="js-ee-hide-expired-events">'; |
| 230 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
| 230 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> '; |
|
| 231 | 231 | $event_filter .= esc_html__('Hide Expired Events', 'event_espresso'); |
| 232 | 232 | $event_filter .= '</label>'; |
| 233 | 233 | $event_filter .= '</span>'; |
| 234 | 234 | $event_filter .= '</div>'; |
| 235 | 235 | $filters[] = $event_filter; |
| 236 | 236 | } |
| 237 | - if (! empty($this->_dtts_for_event)) { |
|
| 237 | + if ( ! empty($this->_dtts_for_event)) { |
|
| 238 | 238 | // DTT datetimes filter |
| 239 | 239 | $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
| 240 | 240 | if (count($this->_dtts_for_event) > 1) { |
| 241 | 241 | $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso'); |
| 242 | 242 | foreach ($this->_dtts_for_event as $dtt) { |
| 243 | 243 | $datetime_string = $dtt->name(); |
| 244 | - $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
| 245 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
| 246 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
| 244 | + $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : ''; |
|
| 245 | + $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string; |
|
| 246 | + $dtts[$dtt->ID()] = $datetime_string; |
|
| 247 | 247 | } |
| 248 | 248 | $input = new EE_Select_Input( |
| 249 | 249 | $dtts, |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | ) |
| 255 | 255 | ); |
| 256 | 256 | $filters[] = $input->get_html_for_input(); |
| 257 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
| 257 | + $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">'; |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | return $filters; |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | public function column_status(EE_Registration $registration) |
| 303 | 303 | { |
| 304 | 304 | return ' |
| 305 | - <span class="ee-status-dot ee-status-dot--' . esc_attr($registration->status_ID()) . ' ee-aria-tooltip" |
|
| 306 | - aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence') . '"> |
|
| 305 | + <span class="ee-status-dot ee-status-dot--' . esc_attr($registration->status_ID()).' ee-aria-tooltip" |
|
| 306 | + aria-label="' . EEH_Template::pretty_status($registration->status_ID(), false, 'sentence').'"> |
|
| 307 | 307 | </span>'; |
| 308 | 308 | } |
| 309 | 309 | |
@@ -353,11 +353,11 @@ discard block |
||
| 353 | 353 | ) |
| 354 | 354 | ? ' clickable trigger-checkin' |
| 355 | 355 | : ''; |
| 356 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 357 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
| 358 | - . ' data-_regid="' . $item->ID() . '"' |
|
| 359 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 360 | - . ' data-nonce="' . $nonce . '">' |
|
| 356 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
| 357 | + return '<span class="'.$checkin_status_dashicon->cssClasses().$toggle_active.'"' |
|
| 358 | + . ' data-_regid="'.$item->ID().'"' |
|
| 359 | + . ' data-dttid="'.$this->_cur_dtt_id.'"' |
|
| 360 | + . ' data-nonce="'.$nonce.'">' |
|
| 361 | 361 | . '</span>' |
| 362 | 362 | . $mobile_view_content; |
| 363 | 363 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | public function column_ATT_name(EE_Registration $item) |
| 372 | 372 | { |
| 373 | 373 | $attendee = $item->attendee(); |
| 374 | - if (! $attendee instanceof EE_Attendee) { |
|
| 374 | + if ( ! $attendee instanceof EE_Attendee) { |
|
| 375 | 375 | return esc_html__('No contact record for this registration.', 'event_espresso'); |
| 376 | 376 | } |
| 377 | 377 | // edit attendee link |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | 'ee_edit_contacts', |
| 384 | 384 | 'espresso_registrations_edit_attendee' |
| 385 | 385 | ) |
| 386 | - ? '<a class="ee-aria-tooltip" href="' . $edit_lnk_url . '" aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 386 | + ? '<a class="ee-aria-tooltip" href="'.$edit_lnk_url.'" aria-label="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
| 387 | 387 | . $item->attendee()->full_name() |
| 388 | 388 | . '</a>' |
| 389 | 389 | : $item->attendee()->full_name(); |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | ? ' <sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup> ' |
| 392 | 392 | : ''; |
| 393 | 393 | // add group details |
| 394 | - $name_link .= ' ' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 394 | + $name_link .= ' '.sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 395 | 395 | // add regcode |
| 396 | 396 | $link = EE_Admin_Page::add_query_args_and_nonce( |
| 397 | 397 | array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | 'view_registration', |
| 404 | 404 | $item->ID() |
| 405 | 405 | ) |
| 406 | - ? '<a class="ee-aria-tooltip" href="' . $link . '" aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 406 | + ? '<a class="ee-aria-tooltip" href="'.$link.'" aria-label="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
| 407 | 407 | . $item->reg_code() |
| 408 | 408 | . '</a>' |
| 409 | 409 | : $item->reg_code(); |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | ); |
| 433 | 433 | // get the timestamps for this registration's checkins, related to the selected datetime |
| 434 | 434 | $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
| 435 | - if (! empty($timestamps)) { |
|
| 435 | + if ( ! empty($timestamps)) { |
|
| 436 | 436 | // get the last timestamp |
| 437 | 437 | $last_timestamp = end($timestamps); |
| 438 | 438 | // checked in or checked out? |
@@ -441,14 +441,14 @@ discard block |
||
| 441 | 441 | : esc_html__('Checked Out', 'event_espresso'); |
| 442 | 442 | // get timestamp string |
| 443 | 443 | $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
| 444 | - $actions['checkin'] = '<a class="ee-aria-tooltip" href="' . $checkin_list_url . '" aria-label="' |
|
| 444 | + $actions['checkin'] = '<a class="ee-aria-tooltip" href="'.$checkin_list_url.'" aria-label="' |
|
| 445 | 445 | . esc_attr__( |
| 446 | 446 | 'View this registrant\'s check-ins/checkouts for the datetime', |
| 447 | 447 | 'event_espresso' |
| 448 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
| 448 | + ).'">'.$checkin_status.': '.$timestamp_string.'</a>'; |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | - return (! empty($DTT_ID) && ! empty($timestamps)) |
|
| 451 | + return ( ! empty($DTT_ID) && ! empty($timestamps)) |
|
| 452 | 452 | ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
| 453 | 453 | : $name_link; |
| 454 | 454 | } |
@@ -481,11 +481,11 @@ discard block |
||
| 481 | 481 | $event_label = EE_Registry::instance()->CAP->current_user_can( |
| 482 | 482 | 'ee_read_checkins', |
| 483 | 483 | 'espresso_registrations_registration_checkins' |
| 484 | - ) ? '<a class="ee-aria-tooltip" href="' . $chkin_lnk_url . '" aria-label="' |
|
| 484 | + ) ? '<a class="ee-aria-tooltip" href="'.$chkin_lnk_url.'" aria-label="' |
|
| 485 | 485 | . esc_attr__( |
| 486 | 486 | 'View Checkins for this Event', |
| 487 | 487 | 'event_espresso' |
| 488 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 488 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
| 489 | 489 | } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
| 490 | 490 | $event_label = esc_html__('Unknown', 'event_espresso'); |
| 491 | 491 | } |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | */ |
| 512 | 512 | public function column__REG_final_price(EE_Registration $item) |
| 513 | 513 | { |
| 514 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
| 514 | + return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>'; |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | . $item->transaction()->pretty_paid() |
| 549 | 549 | . ' |
| 550 | 550 | </a> |
| 551 | - <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 551 | + <span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
| 552 | 552 | } |
| 553 | 553 | } else { |
| 554 | 554 | return '<span class="reg-pad-rght"></span>'; |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | . esc_attr__('View Transaction', 'event_espresso') |
| 585 | 585 | . '"><span class="reg-pad-rght">' |
| 586 | 586 | . $txn_total |
| 587 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 587 | + . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>'; |
|
| 588 | 588 | } else { |
| 589 | 589 | return '<span class="reg-pad-rght"></span>'; |
| 590 | 590 | } |
@@ -16,1278 +16,1278 @@ |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * This is used to hold the reports template data which is setup early in the request. |
|
| 21 | - * |
|
| 22 | - * @type array |
|
| 23 | - */ |
|
| 24 | - protected $_reports_template_data = array(); |
|
| 19 | + /** |
|
| 20 | + * This is used to hold the reports template data which is setup early in the request. |
|
| 21 | + * |
|
| 22 | + * @type array |
|
| 23 | + */ |
|
| 24 | + protected $_reports_template_data = array(); |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Extend_Registrations_Admin_Page constructor. |
|
| 29 | - * |
|
| 30 | - * @param bool $routing |
|
| 31 | - */ |
|
| 32 | - public function __construct($routing = true) |
|
| 33 | - { |
|
| 34 | - parent::__construct($routing); |
|
| 35 | - if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 36 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 37 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 38 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 39 | - } |
|
| 40 | - } |
|
| 27 | + /** |
|
| 28 | + * Extend_Registrations_Admin_Page constructor. |
|
| 29 | + * |
|
| 30 | + * @param bool $routing |
|
| 31 | + */ |
|
| 32 | + public function __construct($routing = true) |
|
| 33 | + { |
|
| 34 | + parent::__construct($routing); |
|
| 35 | + if (! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 36 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 37 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 38 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Extending page configuration. |
|
| 45 | - */ |
|
| 46 | - protected function _extend_page_config() |
|
| 47 | - { |
|
| 48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 49 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 50 | - ? $this->_req_data['_REG_ID'] |
|
| 51 | - : 0; |
|
| 52 | - $new_page_routes = array( |
|
| 53 | - 'reports' => array( |
|
| 54 | - 'func' => '_registration_reports', |
|
| 55 | - 'capability' => 'ee_read_registrations', |
|
| 56 | - ), |
|
| 57 | - 'registration_checkins' => array( |
|
| 58 | - 'func' => '_registration_checkin_list_table', |
|
| 59 | - 'capability' => 'ee_read_checkins', |
|
| 60 | - ), |
|
| 61 | - 'newsletter_selected_send' => array( |
|
| 62 | - 'func' => '_newsletter_selected_send', |
|
| 63 | - 'noheader' => true, |
|
| 64 | - 'capability' => 'ee_send_message', |
|
| 65 | - ), |
|
| 66 | - 'delete_checkin_rows' => array( |
|
| 67 | - 'func' => '_delete_checkin_rows', |
|
| 68 | - 'noheader' => true, |
|
| 69 | - 'capability' => 'ee_delete_checkins', |
|
| 70 | - ), |
|
| 71 | - 'delete_checkin_row' => array( |
|
| 72 | - 'func' => '_delete_checkin_row', |
|
| 73 | - 'noheader' => true, |
|
| 74 | - 'capability' => 'ee_delete_checkin', |
|
| 75 | - 'obj_id' => $reg_id, |
|
| 76 | - ), |
|
| 77 | - 'toggle_checkin_status' => array( |
|
| 78 | - 'func' => '_toggle_checkin_status', |
|
| 79 | - 'noheader' => true, |
|
| 80 | - 'capability' => 'ee_edit_checkin', |
|
| 81 | - 'obj_id' => $reg_id, |
|
| 82 | - ), |
|
| 83 | - 'toggle_checkin_status_bulk' => array( |
|
| 84 | - 'func' => '_toggle_checkin_status', |
|
| 85 | - 'noheader' => true, |
|
| 86 | - 'capability' => 'ee_edit_checkins', |
|
| 87 | - ), |
|
| 88 | - 'event_registrations' => array( |
|
| 89 | - 'func' => '_event_registrations_list_table', |
|
| 90 | - 'capability' => 'ee_read_checkins', |
|
| 91 | - ), |
|
| 92 | - 'registrations_checkin_report' => array( |
|
| 93 | - 'func' => '_registrations_checkin_report', |
|
| 94 | - 'noheader' => true, |
|
| 95 | - 'capability' => 'ee_read_registrations', |
|
| 96 | - ), |
|
| 97 | - ); |
|
| 98 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 99 | - $new_page_config = array( |
|
| 100 | - 'reports' => array( |
|
| 101 | - 'nav' => array( |
|
| 102 | - 'label' => esc_html__('Reports', 'event_espresso'), |
|
| 103 | - 'order' => 30, |
|
| 104 | - ), |
|
| 105 | - 'help_tabs' => array( |
|
| 106 | - 'registrations_reports_help_tab' => array( |
|
| 107 | - 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
| 108 | - 'filename' => 'registrations_reports', |
|
| 109 | - ), |
|
| 110 | - ), |
|
| 111 | - /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
| 112 | - 'require_nonce' => false, |
|
| 113 | - ), |
|
| 114 | - 'event_registrations' => array( |
|
| 115 | - 'nav' => array( |
|
| 116 | - 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
| 117 | - 'order' => 10, |
|
| 118 | - 'persistent' => true, |
|
| 119 | - ), |
|
| 120 | - 'help_tabs' => array( |
|
| 121 | - 'registrations_event_checkin_help_tab' => array( |
|
| 122 | - 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
| 123 | - 'filename' => 'registrations_event_checkin', |
|
| 124 | - ), |
|
| 125 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 126 | - 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 127 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 128 | - ), |
|
| 129 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
| 130 | - 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
| 131 | - 'filename' => 'registrations_event_checkin_filters', |
|
| 132 | - ), |
|
| 133 | - 'registrations_event_checkin_views_help_tab' => array( |
|
| 134 | - 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
| 135 | - 'filename' => 'registrations_event_checkin_views', |
|
| 136 | - ), |
|
| 137 | - 'registrations_event_checkin_other_help_tab' => array( |
|
| 138 | - 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
| 139 | - 'filename' => 'registrations_event_checkin_other', |
|
| 140 | - ), |
|
| 141 | - ), |
|
| 142 | - // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 143 | - // 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
| 144 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 145 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 146 | - 'metaboxes' => array(), |
|
| 147 | - 'require_nonce' => false, |
|
| 148 | - ), |
|
| 149 | - 'registration_checkins' => array( |
|
| 150 | - 'nav' => array( |
|
| 151 | - 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
| 152 | - 'order' => 15, |
|
| 153 | - 'persistent' => false, |
|
| 154 | - 'url' => '', |
|
| 155 | - ), |
|
| 156 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 157 | - // 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
| 158 | - 'metaboxes' => array(), |
|
| 159 | - 'require_nonce' => false, |
|
| 160 | - ), |
|
| 161 | - ); |
|
| 162 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 163 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 164 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 165 | - } |
|
| 43 | + /** |
|
| 44 | + * Extending page configuration. |
|
| 45 | + */ |
|
| 46 | + protected function _extend_page_config() |
|
| 47 | + { |
|
| 48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 49 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 50 | + ? $this->_req_data['_REG_ID'] |
|
| 51 | + : 0; |
|
| 52 | + $new_page_routes = array( |
|
| 53 | + 'reports' => array( |
|
| 54 | + 'func' => '_registration_reports', |
|
| 55 | + 'capability' => 'ee_read_registrations', |
|
| 56 | + ), |
|
| 57 | + 'registration_checkins' => array( |
|
| 58 | + 'func' => '_registration_checkin_list_table', |
|
| 59 | + 'capability' => 'ee_read_checkins', |
|
| 60 | + ), |
|
| 61 | + 'newsletter_selected_send' => array( |
|
| 62 | + 'func' => '_newsletter_selected_send', |
|
| 63 | + 'noheader' => true, |
|
| 64 | + 'capability' => 'ee_send_message', |
|
| 65 | + ), |
|
| 66 | + 'delete_checkin_rows' => array( |
|
| 67 | + 'func' => '_delete_checkin_rows', |
|
| 68 | + 'noheader' => true, |
|
| 69 | + 'capability' => 'ee_delete_checkins', |
|
| 70 | + ), |
|
| 71 | + 'delete_checkin_row' => array( |
|
| 72 | + 'func' => '_delete_checkin_row', |
|
| 73 | + 'noheader' => true, |
|
| 74 | + 'capability' => 'ee_delete_checkin', |
|
| 75 | + 'obj_id' => $reg_id, |
|
| 76 | + ), |
|
| 77 | + 'toggle_checkin_status' => array( |
|
| 78 | + 'func' => '_toggle_checkin_status', |
|
| 79 | + 'noheader' => true, |
|
| 80 | + 'capability' => 'ee_edit_checkin', |
|
| 81 | + 'obj_id' => $reg_id, |
|
| 82 | + ), |
|
| 83 | + 'toggle_checkin_status_bulk' => array( |
|
| 84 | + 'func' => '_toggle_checkin_status', |
|
| 85 | + 'noheader' => true, |
|
| 86 | + 'capability' => 'ee_edit_checkins', |
|
| 87 | + ), |
|
| 88 | + 'event_registrations' => array( |
|
| 89 | + 'func' => '_event_registrations_list_table', |
|
| 90 | + 'capability' => 'ee_read_checkins', |
|
| 91 | + ), |
|
| 92 | + 'registrations_checkin_report' => array( |
|
| 93 | + 'func' => '_registrations_checkin_report', |
|
| 94 | + 'noheader' => true, |
|
| 95 | + 'capability' => 'ee_read_registrations', |
|
| 96 | + ), |
|
| 97 | + ); |
|
| 98 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 99 | + $new_page_config = array( |
|
| 100 | + 'reports' => array( |
|
| 101 | + 'nav' => array( |
|
| 102 | + 'label' => esc_html__('Reports', 'event_espresso'), |
|
| 103 | + 'order' => 30, |
|
| 104 | + ), |
|
| 105 | + 'help_tabs' => array( |
|
| 106 | + 'registrations_reports_help_tab' => array( |
|
| 107 | + 'title' => esc_html__('Registration Reports', 'event_espresso'), |
|
| 108 | + 'filename' => 'registrations_reports', |
|
| 109 | + ), |
|
| 110 | + ), |
|
| 111 | + /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
| 112 | + 'require_nonce' => false, |
|
| 113 | + ), |
|
| 114 | + 'event_registrations' => array( |
|
| 115 | + 'nav' => array( |
|
| 116 | + 'label' => esc_html__('Event Check-In', 'event_espresso'), |
|
| 117 | + 'order' => 10, |
|
| 118 | + 'persistent' => true, |
|
| 119 | + ), |
|
| 120 | + 'help_tabs' => array( |
|
| 121 | + 'registrations_event_checkin_help_tab' => array( |
|
| 122 | + 'title' => esc_html__('Registrations Event Check-In', 'event_espresso'), |
|
| 123 | + 'filename' => 'registrations_event_checkin', |
|
| 124 | + ), |
|
| 125 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 126 | + 'title' => esc_html__('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 127 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 128 | + ), |
|
| 129 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
| 130 | + 'title' => esc_html__('Event Check-In Filters', 'event_espresso'), |
|
| 131 | + 'filename' => 'registrations_event_checkin_filters', |
|
| 132 | + ), |
|
| 133 | + 'registrations_event_checkin_views_help_tab' => array( |
|
| 134 | + 'title' => esc_html__('Event Check-In Views', 'event_espresso'), |
|
| 135 | + 'filename' => 'registrations_event_checkin_views', |
|
| 136 | + ), |
|
| 137 | + 'registrations_event_checkin_other_help_tab' => array( |
|
| 138 | + 'title' => esc_html__('Event Check-In Other', 'event_espresso'), |
|
| 139 | + 'filename' => 'registrations_event_checkin_other', |
|
| 140 | + ), |
|
| 141 | + ), |
|
| 142 | + // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836 |
|
| 143 | + // 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
| 144 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 145 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 146 | + 'metaboxes' => array(), |
|
| 147 | + 'require_nonce' => false, |
|
| 148 | + ), |
|
| 149 | + 'registration_checkins' => array( |
|
| 150 | + 'nav' => array( |
|
| 151 | + 'label' => esc_html__('Check-In Records', 'event_espresso'), |
|
| 152 | + 'order' => 15, |
|
| 153 | + 'persistent' => false, |
|
| 154 | + 'url' => '', |
|
| 155 | + ), |
|
| 156 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 157 | + // 'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
| 158 | + 'metaboxes' => array(), |
|
| 159 | + 'require_nonce' => false, |
|
| 160 | + ), |
|
| 161 | + ); |
|
| 162 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 163 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 164 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Ajax hooks for all routes in this page. |
|
| 170 | - */ |
|
| 171 | - protected function _ajax_hooks() |
|
| 172 | - { |
|
| 173 | - parent::_ajax_hooks(); |
|
| 174 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 175 | - } |
|
| 168 | + /** |
|
| 169 | + * Ajax hooks for all routes in this page. |
|
| 170 | + */ |
|
| 171 | + protected function _ajax_hooks() |
|
| 172 | + { |
|
| 173 | + parent::_ajax_hooks(); |
|
| 174 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Global scripts for all routes in this page. |
|
| 180 | - */ |
|
| 181 | - public function load_scripts_styles() |
|
| 182 | - { |
|
| 183 | - parent::load_scripts_styles(); |
|
| 184 | - // if newsletter message type is active then let's add filter and load js for it. |
|
| 185 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 186 | - // enqueue newsletter js |
|
| 187 | - wp_enqueue_script( |
|
| 188 | - 'ee-newsletter-trigger', |
|
| 189 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 190 | - array('ee-dialog'), |
|
| 191 | - EVENT_ESPRESSO_VERSION, |
|
| 192 | - true |
|
| 193 | - ); |
|
| 194 | - wp_enqueue_style( |
|
| 195 | - 'ee-newsletter-trigger-css', |
|
| 196 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 197 | - array(), |
|
| 198 | - EVENT_ESPRESSO_VERSION |
|
| 199 | - ); |
|
| 200 | - // hook in buttons for newsletter message type trigger. |
|
| 201 | - add_action( |
|
| 202 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 203 | - array($this, 'add_newsletter_action_buttons'), |
|
| 204 | - 10 |
|
| 205 | - ); |
|
| 206 | - } |
|
| 207 | - } |
|
| 178 | + /** |
|
| 179 | + * Global scripts for all routes in this page. |
|
| 180 | + */ |
|
| 181 | + public function load_scripts_styles() |
|
| 182 | + { |
|
| 183 | + parent::load_scripts_styles(); |
|
| 184 | + // if newsletter message type is active then let's add filter and load js for it. |
|
| 185 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 186 | + // enqueue newsletter js |
|
| 187 | + wp_enqueue_script( |
|
| 188 | + 'ee-newsletter-trigger', |
|
| 189 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 190 | + array('ee-dialog'), |
|
| 191 | + EVENT_ESPRESSO_VERSION, |
|
| 192 | + true |
|
| 193 | + ); |
|
| 194 | + wp_enqueue_style( |
|
| 195 | + 'ee-newsletter-trigger-css', |
|
| 196 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 197 | + array(), |
|
| 198 | + EVENT_ESPRESSO_VERSION |
|
| 199 | + ); |
|
| 200 | + // hook in buttons for newsletter message type trigger. |
|
| 201 | + add_action( |
|
| 202 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 203 | + array($this, 'add_newsletter_action_buttons'), |
|
| 204 | + 10 |
|
| 205 | + ); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Scripts and styles for just the reports route. |
|
| 212 | - */ |
|
| 213 | - public function load_scripts_styles_reports() |
|
| 214 | - { |
|
| 215 | - wp_register_script( |
|
| 216 | - 'ee-reg-reports-js', |
|
| 217 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 218 | - array('google-charts'), |
|
| 219 | - EVENT_ESPRESSO_VERSION, |
|
| 220 | - true |
|
| 221 | - ); |
|
| 222 | - wp_enqueue_script('ee-reg-reports-js'); |
|
| 223 | - $this->_registration_reports_js_setup(); |
|
| 224 | - } |
|
| 210 | + /** |
|
| 211 | + * Scripts and styles for just the reports route. |
|
| 212 | + */ |
|
| 213 | + public function load_scripts_styles_reports() |
|
| 214 | + { |
|
| 215 | + wp_register_script( |
|
| 216 | + 'ee-reg-reports-js', |
|
| 217 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 218 | + array('google-charts'), |
|
| 219 | + EVENT_ESPRESSO_VERSION, |
|
| 220 | + true |
|
| 221 | + ); |
|
| 222 | + wp_enqueue_script('ee-reg-reports-js'); |
|
| 223 | + $this->_registration_reports_js_setup(); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * Register screen options for event_registrations route. |
|
| 229 | - */ |
|
| 230 | - protected function _add_screen_options_event_registrations() |
|
| 231 | - { |
|
| 232 | - $this->_per_page_screen_option(); |
|
| 233 | - } |
|
| 227 | + /** |
|
| 228 | + * Register screen options for event_registrations route. |
|
| 229 | + */ |
|
| 230 | + protected function _add_screen_options_event_registrations() |
|
| 231 | + { |
|
| 232 | + $this->_per_page_screen_option(); |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Register screen options for registration_checkins route |
|
| 238 | - */ |
|
| 239 | - protected function _add_screen_options_registration_checkins() |
|
| 240 | - { |
|
| 241 | - $page_title = $this->_admin_page_title; |
|
| 242 | - $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
| 243 | - $this->_per_page_screen_option(); |
|
| 244 | - $this->_admin_page_title = $page_title; |
|
| 245 | - } |
|
| 236 | + /** |
|
| 237 | + * Register screen options for registration_checkins route |
|
| 238 | + */ |
|
| 239 | + protected function _add_screen_options_registration_checkins() |
|
| 240 | + { |
|
| 241 | + $page_title = $this->_admin_page_title; |
|
| 242 | + $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso'); |
|
| 243 | + $this->_per_page_screen_option(); |
|
| 244 | + $this->_admin_page_title = $page_title; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | |
| 248 | - /** |
|
| 249 | - * Set views property for event_registrations route. |
|
| 250 | - */ |
|
| 251 | - protected function _set_list_table_views_event_registrations() |
|
| 252 | - { |
|
| 253 | - $this->_views = array( |
|
| 254 | - 'all' => array( |
|
| 255 | - 'slug' => 'all', |
|
| 256 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 257 | - 'count' => 0, |
|
| 258 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 259 | - ? array() |
|
| 260 | - : array( |
|
| 261 | - 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
| 262 | - ), |
|
| 263 | - ), |
|
| 264 | - ); |
|
| 265 | - } |
|
| 248 | + /** |
|
| 249 | + * Set views property for event_registrations route. |
|
| 250 | + */ |
|
| 251 | + protected function _set_list_table_views_event_registrations() |
|
| 252 | + { |
|
| 253 | + $this->_views = array( |
|
| 254 | + 'all' => array( |
|
| 255 | + 'slug' => 'all', |
|
| 256 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 257 | + 'count' => 0, |
|
| 258 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 259 | + ? array() |
|
| 260 | + : array( |
|
| 261 | + 'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'), |
|
| 262 | + ), |
|
| 263 | + ), |
|
| 264 | + ); |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | 267 | |
| 268 | - /** |
|
| 269 | - * Set views property for registration_checkins route. |
|
| 270 | - */ |
|
| 271 | - protected function _set_list_table_views_registration_checkins() |
|
| 272 | - { |
|
| 273 | - $this->_views = array( |
|
| 274 | - 'all' => array( |
|
| 275 | - 'slug' => 'all', |
|
| 276 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 277 | - 'count' => 0, |
|
| 278 | - 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
| 279 | - ), |
|
| 280 | - ); |
|
| 281 | - } |
|
| 268 | + /** |
|
| 269 | + * Set views property for registration_checkins route. |
|
| 270 | + */ |
|
| 271 | + protected function _set_list_table_views_registration_checkins() |
|
| 272 | + { |
|
| 273 | + $this->_views = array( |
|
| 274 | + 'all' => array( |
|
| 275 | + 'slug' => 'all', |
|
| 276 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 277 | + 'count' => 0, |
|
| 278 | + 'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')), |
|
| 279 | + ), |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | |
| 284 | - /** |
|
| 285 | - * callback for ajax action. |
|
| 286 | - * |
|
| 287 | - * @since 4.3.0 |
|
| 288 | - * @return void (JSON) |
|
| 289 | - * @throws EE_Error |
|
| 290 | - * @throws InvalidArgumentException |
|
| 291 | - * @throws InvalidDataTypeException |
|
| 292 | - * @throws InvalidInterfaceException |
|
| 293 | - */ |
|
| 294 | - public function get_newsletter_form_content() |
|
| 295 | - { |
|
| 296 | - // do a nonce check cause we're not coming in from an normal route here. |
|
| 297 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 298 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 299 | - ) : ''; |
|
| 300 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 301 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 302 | - // let's get the mtp for the incoming MTP_ ID |
|
| 303 | - if (! isset($this->_req_data['GRP_ID'])) { |
|
| 304 | - EE_Error::add_error( |
|
| 305 | - esc_html__( |
|
| 306 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
| 307 | - 'event_espresso' |
|
| 308 | - ), |
|
| 309 | - __FILE__, |
|
| 310 | - __FUNCTION__, |
|
| 311 | - __LINE__ |
|
| 312 | - ); |
|
| 313 | - $this->_template_args['success'] = false; |
|
| 314 | - $this->_template_args['error'] = true; |
|
| 315 | - $this->_return_json(); |
|
| 316 | - } |
|
| 317 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 318 | - if (! $MTPG instanceof EE_Message_Template_Group) { |
|
| 319 | - EE_Error::add_error( |
|
| 320 | - sprintf( |
|
| 321 | - esc_html__( |
|
| 322 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 323 | - 'event_espresso' |
|
| 324 | - ), |
|
| 325 | - $this->_req_data['GRP_ID'] |
|
| 326 | - ), |
|
| 327 | - __FILE__, |
|
| 328 | - __FUNCTION__, |
|
| 329 | - __LINE__ |
|
| 330 | - ); |
|
| 331 | - $this->_template_args['success'] = false; |
|
| 332 | - $this->_template_args['error'] = true; |
|
| 333 | - $this->_return_json(); |
|
| 334 | - } |
|
| 335 | - $MTPs = $MTPG->context_templates(); |
|
| 336 | - $MTPs = $MTPs['attendee']; |
|
| 337 | - $template_fields = array(); |
|
| 338 | - /** @var EE_Message_Template $MTP */ |
|
| 339 | - foreach ($MTPs as $MTP) { |
|
| 340 | - $field = $MTP->get('MTP_template_field'); |
|
| 341 | - if ($field === 'content') { |
|
| 342 | - $content = $MTP->get('MTP_content'); |
|
| 343 | - if (! empty($content['newsletter_content'])) { |
|
| 344 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 345 | - } |
|
| 346 | - continue; |
|
| 347 | - } |
|
| 348 | - $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
| 349 | - } |
|
| 350 | - $this->_template_args['success'] = true; |
|
| 351 | - $this->_template_args['error'] = false; |
|
| 352 | - $this->_template_args['data'] = array( |
|
| 353 | - 'batch_message_from' => isset($template_fields['from']) |
|
| 354 | - ? $template_fields['from'] |
|
| 355 | - : '', |
|
| 356 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
| 357 | - ? $template_fields['subject'] |
|
| 358 | - : '', |
|
| 359 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 360 | - ? $template_fields['newsletter_content'] |
|
| 361 | - : '', |
|
| 362 | - ); |
|
| 363 | - $this->_return_json(); |
|
| 364 | - } |
|
| 284 | + /** |
|
| 285 | + * callback for ajax action. |
|
| 286 | + * |
|
| 287 | + * @since 4.3.0 |
|
| 288 | + * @return void (JSON) |
|
| 289 | + * @throws EE_Error |
|
| 290 | + * @throws InvalidArgumentException |
|
| 291 | + * @throws InvalidDataTypeException |
|
| 292 | + * @throws InvalidInterfaceException |
|
| 293 | + */ |
|
| 294 | + public function get_newsletter_form_content() |
|
| 295 | + { |
|
| 296 | + // do a nonce check cause we're not coming in from an normal route here. |
|
| 297 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 298 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 299 | + ) : ''; |
|
| 300 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 301 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 302 | + // let's get the mtp for the incoming MTP_ ID |
|
| 303 | + if (! isset($this->_req_data['GRP_ID'])) { |
|
| 304 | + EE_Error::add_error( |
|
| 305 | + esc_html__( |
|
| 306 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
| 307 | + 'event_espresso' |
|
| 308 | + ), |
|
| 309 | + __FILE__, |
|
| 310 | + __FUNCTION__, |
|
| 311 | + __LINE__ |
|
| 312 | + ); |
|
| 313 | + $this->_template_args['success'] = false; |
|
| 314 | + $this->_template_args['error'] = true; |
|
| 315 | + $this->_return_json(); |
|
| 316 | + } |
|
| 317 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 318 | + if (! $MTPG instanceof EE_Message_Template_Group) { |
|
| 319 | + EE_Error::add_error( |
|
| 320 | + sprintf( |
|
| 321 | + esc_html__( |
|
| 322 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 323 | + 'event_espresso' |
|
| 324 | + ), |
|
| 325 | + $this->_req_data['GRP_ID'] |
|
| 326 | + ), |
|
| 327 | + __FILE__, |
|
| 328 | + __FUNCTION__, |
|
| 329 | + __LINE__ |
|
| 330 | + ); |
|
| 331 | + $this->_template_args['success'] = false; |
|
| 332 | + $this->_template_args['error'] = true; |
|
| 333 | + $this->_return_json(); |
|
| 334 | + } |
|
| 335 | + $MTPs = $MTPG->context_templates(); |
|
| 336 | + $MTPs = $MTPs['attendee']; |
|
| 337 | + $template_fields = array(); |
|
| 338 | + /** @var EE_Message_Template $MTP */ |
|
| 339 | + foreach ($MTPs as $MTP) { |
|
| 340 | + $field = $MTP->get('MTP_template_field'); |
|
| 341 | + if ($field === 'content') { |
|
| 342 | + $content = $MTP->get('MTP_content'); |
|
| 343 | + if (! empty($content['newsletter_content'])) { |
|
| 344 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 345 | + } |
|
| 346 | + continue; |
|
| 347 | + } |
|
| 348 | + $template_fields[ $MTP->get('MTP_template_field') ] = $MTP->get('MTP_content'); |
|
| 349 | + } |
|
| 350 | + $this->_template_args['success'] = true; |
|
| 351 | + $this->_template_args['error'] = false; |
|
| 352 | + $this->_template_args['data'] = array( |
|
| 353 | + 'batch_message_from' => isset($template_fields['from']) |
|
| 354 | + ? $template_fields['from'] |
|
| 355 | + : '', |
|
| 356 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
| 357 | + ? $template_fields['subject'] |
|
| 358 | + : '', |
|
| 359 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 360 | + ? $template_fields['newsletter_content'] |
|
| 361 | + : '', |
|
| 362 | + ); |
|
| 363 | + $this->_return_json(); |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | 366 | |
| 367 | - /** |
|
| 368 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 369 | - * |
|
| 370 | - * @since 4.3.0 |
|
| 371 | - * @param EE_Admin_List_Table $list_table |
|
| 372 | - * @return void |
|
| 373 | - * @throws InvalidArgumentException |
|
| 374 | - * @throws InvalidDataTypeException |
|
| 375 | - * @throws InvalidInterfaceException |
|
| 376 | - */ |
|
| 377 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 378 | - { |
|
| 379 | - if ( |
|
| 380 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
| 381 | - 'ee_send_message', |
|
| 382 | - 'espresso_registrations_newsletter_selected_send' |
|
| 383 | - ) |
|
| 384 | - ) { |
|
| 385 | - return; |
|
| 386 | - } |
|
| 387 | - $routes_to_add_to = array( |
|
| 388 | - 'contact_list', |
|
| 389 | - 'event_registrations', |
|
| 390 | - 'default', |
|
| 391 | - ); |
|
| 392 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 393 | - if ( |
|
| 394 | - ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 395 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 396 | - ) { |
|
| 397 | - echo ''; |
|
| 398 | - } else { |
|
| 399 | - $button_text = sprintf( |
|
| 400 | - esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 401 | - '<span class="send-selected-newsletter-count">0</span>' |
|
| 402 | - ); |
|
| 403 | - echo '<button id="selected-batch-send-trigger" class="button button--secondary">' |
|
| 404 | - . '<span class="dashicons dashicons-email "></span>' |
|
| 405 | - . $button_text |
|
| 406 | - . '</button>'; |
|
| 407 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - } |
|
| 367 | + /** |
|
| 368 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 369 | + * |
|
| 370 | + * @since 4.3.0 |
|
| 371 | + * @param EE_Admin_List_Table $list_table |
|
| 372 | + * @return void |
|
| 373 | + * @throws InvalidArgumentException |
|
| 374 | + * @throws InvalidDataTypeException |
|
| 375 | + * @throws InvalidInterfaceException |
|
| 376 | + */ |
|
| 377 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 378 | + { |
|
| 379 | + if ( |
|
| 380 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
| 381 | + 'ee_send_message', |
|
| 382 | + 'espresso_registrations_newsletter_selected_send' |
|
| 383 | + ) |
|
| 384 | + ) { |
|
| 385 | + return; |
|
| 386 | + } |
|
| 387 | + $routes_to_add_to = array( |
|
| 388 | + 'contact_list', |
|
| 389 | + 'event_registrations', |
|
| 390 | + 'default', |
|
| 391 | + ); |
|
| 392 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 393 | + if ( |
|
| 394 | + ($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 395 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 396 | + ) { |
|
| 397 | + echo ''; |
|
| 398 | + } else { |
|
| 399 | + $button_text = sprintf( |
|
| 400 | + esc_html__('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 401 | + '<span class="send-selected-newsletter-count">0</span>' |
|
| 402 | + ); |
|
| 403 | + echo '<button id="selected-batch-send-trigger" class="button button--secondary">' |
|
| 404 | + . '<span class="dashicons dashicons-email "></span>' |
|
| 405 | + . $button_text |
|
| 406 | + . '</button>'; |
|
| 407 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * @throws DomainException |
|
| 415 | - * @throws EE_Error |
|
| 416 | - * @throws InvalidArgumentException |
|
| 417 | - * @throws InvalidDataTypeException |
|
| 418 | - * @throws InvalidInterfaceException |
|
| 419 | - */ |
|
| 420 | - public function newsletter_send_form_skeleton() |
|
| 421 | - { |
|
| 422 | - $list_table = $this->_list_table_object; |
|
| 423 | - $codes = array(); |
|
| 424 | - // need to templates for the newsletter message type for the template selector. |
|
| 425 | - $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 426 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 427 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 428 | - ); |
|
| 429 | - foreach ($mtps as $mtp) { |
|
| 430 | - $name = $mtp->name(); |
|
| 431 | - $values[] = array( |
|
| 432 | - 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
| 433 | - 'id' => $mtp->ID(), |
|
| 434 | - ); |
|
| 435 | - } |
|
| 436 | - // need to get a list of shortcodes that are available for the newsletter message type. |
|
| 437 | - $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
| 438 | - 'newsletter', |
|
| 439 | - 'email', |
|
| 440 | - array(), |
|
| 441 | - 'attendee', |
|
| 442 | - false |
|
| 443 | - ); |
|
| 444 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
| 445 | - $available_shortcodes = array(); |
|
| 446 | - foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
| 447 | - $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
| 448 | - ? 'content' |
|
| 449 | - : $field; |
|
| 450 | - $field_id = 'batch-message-' . strtolower($field_id); |
|
| 451 | - $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
| 452 | - . $shortcode |
|
| 453 | - . '" data-linked-input-id="' . $field_id . '">' |
|
| 454 | - . $shortcode |
|
| 455 | - . '</span>'; |
|
| 456 | - } |
|
| 457 | - $codes[ $field ] = implode(', ', $available_shortcodes); |
|
| 458 | - } |
|
| 459 | - $shortcodes = $codes; |
|
| 460 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 461 | - $form_template_args = array( |
|
| 462 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 463 | - 'form_route' => 'newsletter_selected_send', |
|
| 464 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 465 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 466 | - 'redirect_back_to' => $this->_req_action, |
|
| 467 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 468 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 469 | - 'shortcodes' => $shortcodes, |
|
| 470 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 471 | - ); |
|
| 472 | - EEH_Template::display_template($form_template, $form_template_args); |
|
| 473 | - } |
|
| 413 | + /** |
|
| 414 | + * @throws DomainException |
|
| 415 | + * @throws EE_Error |
|
| 416 | + * @throws InvalidArgumentException |
|
| 417 | + * @throws InvalidDataTypeException |
|
| 418 | + * @throws InvalidInterfaceException |
|
| 419 | + */ |
|
| 420 | + public function newsletter_send_form_skeleton() |
|
| 421 | + { |
|
| 422 | + $list_table = $this->_list_table_object; |
|
| 423 | + $codes = array(); |
|
| 424 | + // need to templates for the newsletter message type for the template selector. |
|
| 425 | + $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 426 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 427 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 428 | + ); |
|
| 429 | + foreach ($mtps as $mtp) { |
|
| 430 | + $name = $mtp->name(); |
|
| 431 | + $values[] = array( |
|
| 432 | + 'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name, |
|
| 433 | + 'id' => $mtp->ID(), |
|
| 434 | + ); |
|
| 435 | + } |
|
| 436 | + // need to get a list of shortcodes that are available for the newsletter message type. |
|
| 437 | + $shortcodes = EEH_MSG_Template::get_shortcodes( |
|
| 438 | + 'newsletter', |
|
| 439 | + 'email', |
|
| 440 | + array(), |
|
| 441 | + 'attendee', |
|
| 442 | + false |
|
| 443 | + ); |
|
| 444 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
| 445 | + $available_shortcodes = array(); |
|
| 446 | + foreach ($shortcode_array as $shortcode => $shortcode_details) { |
|
| 447 | + $field_id = $field === '[NEWSLETTER_CONTENT]' |
|
| 448 | + ? 'content' |
|
| 449 | + : $field; |
|
| 450 | + $field_id = 'batch-message-' . strtolower($field_id); |
|
| 451 | + $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="' |
|
| 452 | + . $shortcode |
|
| 453 | + . '" data-linked-input-id="' . $field_id . '">' |
|
| 454 | + . $shortcode |
|
| 455 | + . '</span>'; |
|
| 456 | + } |
|
| 457 | + $codes[ $field ] = implode(', ', $available_shortcodes); |
|
| 458 | + } |
|
| 459 | + $shortcodes = $codes; |
|
| 460 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 461 | + $form_template_args = array( |
|
| 462 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 463 | + 'form_route' => 'newsletter_selected_send', |
|
| 464 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 465 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 466 | + 'redirect_back_to' => $this->_req_action, |
|
| 467 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 468 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 469 | + 'shortcodes' => $shortcodes, |
|
| 470 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 471 | + ); |
|
| 472 | + EEH_Template::display_template($form_template, $form_template_args); |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * Handles sending selected registrations/contacts a newsletter. |
|
| 478 | - * |
|
| 479 | - * @since 4.3.0 |
|
| 480 | - * @return void |
|
| 481 | - * @throws EE_Error |
|
| 482 | - * @throws InvalidArgumentException |
|
| 483 | - * @throws InvalidDataTypeException |
|
| 484 | - * @throws InvalidInterfaceException |
|
| 485 | - */ |
|
| 486 | - protected function _newsletter_selected_send() |
|
| 487 | - { |
|
| 488 | - $success = true; |
|
| 489 | - // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 490 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 491 | - EE_Error::add_error( |
|
| 492 | - esc_html__( |
|
| 493 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 494 | - 'event_espresso' |
|
| 495 | - ), |
|
| 496 | - __FILE__, |
|
| 497 | - __FUNCTION__, |
|
| 498 | - __LINE__ |
|
| 499 | - ); |
|
| 500 | - $success = false; |
|
| 501 | - } |
|
| 502 | - if ($success) { |
|
| 503 | - // update Message template in case there are any changes |
|
| 504 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 505 | - $this->_req_data['newsletter_mtp_selected'] |
|
| 506 | - ); |
|
| 507 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 508 | - ? $Message_Template_Group->context_templates() |
|
| 509 | - : array(); |
|
| 510 | - if (empty($Message_Templates)) { |
|
| 511 | - EE_Error::add_error( |
|
| 512 | - esc_html__( |
|
| 513 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 514 | - 'event_espresso' |
|
| 515 | - ), |
|
| 516 | - __FILE__, |
|
| 517 | - __FUNCTION__, |
|
| 518 | - __LINE__ |
|
| 519 | - ); |
|
| 520 | - } |
|
| 521 | - // let's just update the specific fields |
|
| 522 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 523 | - if ($Message_Template instanceof EE_Message_Template) { |
|
| 524 | - $field = $Message_Template->get('MTP_template_field'); |
|
| 525 | - $content = $Message_Template->get('MTP_content'); |
|
| 526 | - $new_content = $content; |
|
| 527 | - switch ($field) { |
|
| 528 | - case 'from': |
|
| 529 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 530 | - ? $this->_req_data['batch_message']['from'] |
|
| 531 | - : $content; |
|
| 532 | - break; |
|
| 533 | - case 'subject': |
|
| 534 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 535 | - ? $this->_req_data['batch_message']['subject'] |
|
| 536 | - : $content; |
|
| 537 | - break; |
|
| 538 | - case 'content': |
|
| 539 | - $new_content = $content; |
|
| 540 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 541 | - ? $this->_req_data['batch_message']['content'] |
|
| 542 | - : $content['newsletter_content']; |
|
| 543 | - break; |
|
| 544 | - default: |
|
| 545 | - // continue the foreach loop, we don't want to set $new_content nor save. |
|
| 546 | - continue 2; |
|
| 547 | - } |
|
| 548 | - $Message_Template->set('MTP_content', $new_content); |
|
| 549 | - $Message_Template->save(); |
|
| 550 | - } |
|
| 551 | - } |
|
| 552 | - // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 553 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 554 | - ? $this->_req_data['batch_message']['id_type'] |
|
| 555 | - : 'registration'; |
|
| 556 | - // id_type will affect how we assemble the ids. |
|
| 557 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 558 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 559 | - : array(); |
|
| 560 | - $registrations_used_for_contact_data = array(); |
|
| 561 | - // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 562 | - switch ($id_type) { |
|
| 563 | - case 'registration': |
|
| 564 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 565 | - array( |
|
| 566 | - array( |
|
| 567 | - 'REG_ID' => array('IN', $ids), |
|
| 568 | - ), |
|
| 569 | - ) |
|
| 570 | - ); |
|
| 571 | - break; |
|
| 572 | - case 'contact': |
|
| 573 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 574 | - ->get_latest_registration_for_each_of_given_contacts( |
|
| 575 | - $ids |
|
| 576 | - ); |
|
| 577 | - break; |
|
| 578 | - } |
|
| 579 | - do_action_ref_array( |
|
| 580 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 581 | - array( |
|
| 582 | - $registrations_used_for_contact_data, |
|
| 583 | - $Message_Template_Group->ID(), |
|
| 584 | - ) |
|
| 585 | - ); |
|
| 586 | - // kept for backward compat, internally we no longer use this action. |
|
| 587 | - // @deprecated 4.8.36.rc.002 |
|
| 588 | - $contacts = $id_type === 'registration' |
|
| 589 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 590 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 591 | - do_action_ref_array( |
|
| 592 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 593 | - array( |
|
| 594 | - $contacts, |
|
| 595 | - $Message_Template_Group->ID(), |
|
| 596 | - ) |
|
| 597 | - ); |
|
| 598 | - } |
|
| 599 | - $query_args = array( |
|
| 600 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 601 | - ? $this->_req_data['redirect_back_to'] |
|
| 602 | - : 'default', |
|
| 603 | - ); |
|
| 604 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 605 | - } |
|
| 476 | + /** |
|
| 477 | + * Handles sending selected registrations/contacts a newsletter. |
|
| 478 | + * |
|
| 479 | + * @since 4.3.0 |
|
| 480 | + * @return void |
|
| 481 | + * @throws EE_Error |
|
| 482 | + * @throws InvalidArgumentException |
|
| 483 | + * @throws InvalidDataTypeException |
|
| 484 | + * @throws InvalidInterfaceException |
|
| 485 | + */ |
|
| 486 | + protected function _newsletter_selected_send() |
|
| 487 | + { |
|
| 488 | + $success = true; |
|
| 489 | + // first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 490 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 491 | + EE_Error::add_error( |
|
| 492 | + esc_html__( |
|
| 493 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 494 | + 'event_espresso' |
|
| 495 | + ), |
|
| 496 | + __FILE__, |
|
| 497 | + __FUNCTION__, |
|
| 498 | + __LINE__ |
|
| 499 | + ); |
|
| 500 | + $success = false; |
|
| 501 | + } |
|
| 502 | + if ($success) { |
|
| 503 | + // update Message template in case there are any changes |
|
| 504 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 505 | + $this->_req_data['newsletter_mtp_selected'] |
|
| 506 | + ); |
|
| 507 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 508 | + ? $Message_Template_Group->context_templates() |
|
| 509 | + : array(); |
|
| 510 | + if (empty($Message_Templates)) { |
|
| 511 | + EE_Error::add_error( |
|
| 512 | + esc_html__( |
|
| 513 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 514 | + 'event_espresso' |
|
| 515 | + ), |
|
| 516 | + __FILE__, |
|
| 517 | + __FUNCTION__, |
|
| 518 | + __LINE__ |
|
| 519 | + ); |
|
| 520 | + } |
|
| 521 | + // let's just update the specific fields |
|
| 522 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 523 | + if ($Message_Template instanceof EE_Message_Template) { |
|
| 524 | + $field = $Message_Template->get('MTP_template_field'); |
|
| 525 | + $content = $Message_Template->get('MTP_content'); |
|
| 526 | + $new_content = $content; |
|
| 527 | + switch ($field) { |
|
| 528 | + case 'from': |
|
| 529 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 530 | + ? $this->_req_data['batch_message']['from'] |
|
| 531 | + : $content; |
|
| 532 | + break; |
|
| 533 | + case 'subject': |
|
| 534 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 535 | + ? $this->_req_data['batch_message']['subject'] |
|
| 536 | + : $content; |
|
| 537 | + break; |
|
| 538 | + case 'content': |
|
| 539 | + $new_content = $content; |
|
| 540 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 541 | + ? $this->_req_data['batch_message']['content'] |
|
| 542 | + : $content['newsletter_content']; |
|
| 543 | + break; |
|
| 544 | + default: |
|
| 545 | + // continue the foreach loop, we don't want to set $new_content nor save. |
|
| 546 | + continue 2; |
|
| 547 | + } |
|
| 548 | + $Message_Template->set('MTP_content', $new_content); |
|
| 549 | + $Message_Template->save(); |
|
| 550 | + } |
|
| 551 | + } |
|
| 552 | + // great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 553 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 554 | + ? $this->_req_data['batch_message']['id_type'] |
|
| 555 | + : 'registration'; |
|
| 556 | + // id_type will affect how we assemble the ids. |
|
| 557 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 558 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 559 | + : array(); |
|
| 560 | + $registrations_used_for_contact_data = array(); |
|
| 561 | + // using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 562 | + switch ($id_type) { |
|
| 563 | + case 'registration': |
|
| 564 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 565 | + array( |
|
| 566 | + array( |
|
| 567 | + 'REG_ID' => array('IN', $ids), |
|
| 568 | + ), |
|
| 569 | + ) |
|
| 570 | + ); |
|
| 571 | + break; |
|
| 572 | + case 'contact': |
|
| 573 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 574 | + ->get_latest_registration_for_each_of_given_contacts( |
|
| 575 | + $ids |
|
| 576 | + ); |
|
| 577 | + break; |
|
| 578 | + } |
|
| 579 | + do_action_ref_array( |
|
| 580 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 581 | + array( |
|
| 582 | + $registrations_used_for_contact_data, |
|
| 583 | + $Message_Template_Group->ID(), |
|
| 584 | + ) |
|
| 585 | + ); |
|
| 586 | + // kept for backward compat, internally we no longer use this action. |
|
| 587 | + // @deprecated 4.8.36.rc.002 |
|
| 588 | + $contacts = $id_type === 'registration' |
|
| 589 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 590 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 591 | + do_action_ref_array( |
|
| 592 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 593 | + array( |
|
| 594 | + $contacts, |
|
| 595 | + $Message_Template_Group->ID(), |
|
| 596 | + ) |
|
| 597 | + ); |
|
| 598 | + } |
|
| 599 | + $query_args = array( |
|
| 600 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 601 | + ? $this->_req_data['redirect_back_to'] |
|
| 602 | + : 'default', |
|
| 603 | + ); |
|
| 604 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | 607 | |
| 608 | - /** |
|
| 609 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 610 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 611 | - */ |
|
| 612 | - protected function _registration_reports_js_setup() |
|
| 613 | - { |
|
| 614 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 615 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 616 | - } |
|
| 608 | + /** |
|
| 609 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 610 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 611 | + */ |
|
| 612 | + protected function _registration_reports_js_setup() |
|
| 613 | + { |
|
| 614 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 615 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | 618 | |
| 619 | - /** |
|
| 620 | - * generates Business Reports regarding Registrations |
|
| 621 | - * |
|
| 622 | - * @access protected |
|
| 623 | - * @return void |
|
| 624 | - * @throws DomainException |
|
| 625 | - */ |
|
| 626 | - protected function _registration_reports() |
|
| 627 | - { |
|
| 628 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 629 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 630 | - $template_path, |
|
| 631 | - $this->_reports_template_data, |
|
| 632 | - true |
|
| 633 | - ); |
|
| 634 | - // the final template wrapper |
|
| 635 | - $this->display_admin_page_with_no_sidebar(); |
|
| 636 | - } |
|
| 619 | + /** |
|
| 620 | + * generates Business Reports regarding Registrations |
|
| 621 | + * |
|
| 622 | + * @access protected |
|
| 623 | + * @return void |
|
| 624 | + * @throws DomainException |
|
| 625 | + */ |
|
| 626 | + protected function _registration_reports() |
|
| 627 | + { |
|
| 628 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 629 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 630 | + $template_path, |
|
| 631 | + $this->_reports_template_data, |
|
| 632 | + true |
|
| 633 | + ); |
|
| 634 | + // the final template wrapper |
|
| 635 | + $this->display_admin_page_with_no_sidebar(); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | 638 | |
| 639 | - /** |
|
| 640 | - * Generates Business Report showing total registrations per day. |
|
| 641 | - * |
|
| 642 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 643 | - * @return string |
|
| 644 | - * @throws EE_Error |
|
| 645 | - * @throws InvalidArgumentException |
|
| 646 | - * @throws InvalidDataTypeException |
|
| 647 | - * @throws InvalidInterfaceException |
|
| 648 | - */ |
|
| 649 | - private function _registrations_per_day_report($period = '-1 month') |
|
| 650 | - { |
|
| 651 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 652 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 653 | - $results = (array) $results; |
|
| 654 | - $regs = array(); |
|
| 655 | - $subtitle = ''; |
|
| 656 | - if ($results) { |
|
| 657 | - $column_titles = array(); |
|
| 658 | - $tracker = 0; |
|
| 659 | - foreach ($results as $result) { |
|
| 660 | - $report_column_values = array(); |
|
| 661 | - foreach ($result as $property_name => $property_value) { |
|
| 662 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 663 | - : (int) $property_value; |
|
| 664 | - $report_column_values[] = $property_value; |
|
| 665 | - if ($tracker === 0) { |
|
| 666 | - if ($property_name === 'Registration_REG_date') { |
|
| 667 | - $column_titles[] = esc_html__( |
|
| 668 | - 'Date (only days with registrations are shown)', |
|
| 669 | - 'event_espresso' |
|
| 670 | - ); |
|
| 671 | - } else { |
|
| 672 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - } |
|
| 676 | - $tracker++; |
|
| 677 | - $regs[] = $report_column_values; |
|
| 678 | - } |
|
| 679 | - // make sure the column_titles is pushed to the beginning of the array |
|
| 680 | - array_unshift($regs, $column_titles); |
|
| 681 | - // setup the date range. |
|
| 682 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 683 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 684 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 685 | - $subtitle = sprintf( |
|
| 686 | - wp_strip_all_tags( |
|
| 687 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
| 688 | - ), |
|
| 689 | - $beginning_date->format('Y-m-d'), |
|
| 690 | - $ending_date->format('Y-m-d') |
|
| 691 | - ); |
|
| 692 | - } |
|
| 693 | - $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
| 694 | - $report_params = array( |
|
| 695 | - 'title' => $report_title, |
|
| 696 | - 'subtitle' => $subtitle, |
|
| 697 | - 'id' => $report_ID, |
|
| 698 | - 'regs' => $regs, |
|
| 699 | - 'noResults' => empty($regs), |
|
| 700 | - 'noRegsMsg' => sprintf( |
|
| 701 | - wp_strip_all_tags( |
|
| 702 | - __( |
|
| 703 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 704 | - 'event_espresso' |
|
| 705 | - ) |
|
| 706 | - ), |
|
| 707 | - '<h2>' . $report_title . '</h2><p>', |
|
| 708 | - '</p>' |
|
| 709 | - ), |
|
| 710 | - ); |
|
| 711 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 712 | - return $report_ID; |
|
| 713 | - } |
|
| 639 | + /** |
|
| 640 | + * Generates Business Report showing total registrations per day. |
|
| 641 | + * |
|
| 642 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 643 | + * @return string |
|
| 644 | + * @throws EE_Error |
|
| 645 | + * @throws InvalidArgumentException |
|
| 646 | + * @throws InvalidDataTypeException |
|
| 647 | + * @throws InvalidInterfaceException |
|
| 648 | + */ |
|
| 649 | + private function _registrations_per_day_report($period = '-1 month') |
|
| 650 | + { |
|
| 651 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 652 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 653 | + $results = (array) $results; |
|
| 654 | + $regs = array(); |
|
| 655 | + $subtitle = ''; |
|
| 656 | + if ($results) { |
|
| 657 | + $column_titles = array(); |
|
| 658 | + $tracker = 0; |
|
| 659 | + foreach ($results as $result) { |
|
| 660 | + $report_column_values = array(); |
|
| 661 | + foreach ($result as $property_name => $property_value) { |
|
| 662 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 663 | + : (int) $property_value; |
|
| 664 | + $report_column_values[] = $property_value; |
|
| 665 | + if ($tracker === 0) { |
|
| 666 | + if ($property_name === 'Registration_REG_date') { |
|
| 667 | + $column_titles[] = esc_html__( |
|
| 668 | + 'Date (only days with registrations are shown)', |
|
| 669 | + 'event_espresso' |
|
| 670 | + ); |
|
| 671 | + } else { |
|
| 672 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + } |
|
| 676 | + $tracker++; |
|
| 677 | + $regs[] = $report_column_values; |
|
| 678 | + } |
|
| 679 | + // make sure the column_titles is pushed to the beginning of the array |
|
| 680 | + array_unshift($regs, $column_titles); |
|
| 681 | + // setup the date range. |
|
| 682 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 683 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 684 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 685 | + $subtitle = sprintf( |
|
| 686 | + wp_strip_all_tags( |
|
| 687 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
| 688 | + ), |
|
| 689 | + $beginning_date->format('Y-m-d'), |
|
| 690 | + $ending_date->format('Y-m-d') |
|
| 691 | + ); |
|
| 692 | + } |
|
| 693 | + $report_title = wp_strip_all_tags(__('Total Registrations per Day', 'event_espresso')); |
|
| 694 | + $report_params = array( |
|
| 695 | + 'title' => $report_title, |
|
| 696 | + 'subtitle' => $subtitle, |
|
| 697 | + 'id' => $report_ID, |
|
| 698 | + 'regs' => $regs, |
|
| 699 | + 'noResults' => empty($regs), |
|
| 700 | + 'noRegsMsg' => sprintf( |
|
| 701 | + wp_strip_all_tags( |
|
| 702 | + __( |
|
| 703 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 704 | + 'event_espresso' |
|
| 705 | + ) |
|
| 706 | + ), |
|
| 707 | + '<h2>' . $report_title . '</h2><p>', |
|
| 708 | + '</p>' |
|
| 709 | + ), |
|
| 710 | + ); |
|
| 711 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 712 | + return $report_ID; |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | 715 | |
| 716 | - /** |
|
| 717 | - * Generates Business Report showing total registrations per event. |
|
| 718 | - * |
|
| 719 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 720 | - * @return string |
|
| 721 | - * @throws EE_Error |
|
| 722 | - * @throws InvalidArgumentException |
|
| 723 | - * @throws InvalidDataTypeException |
|
| 724 | - * @throws InvalidInterfaceException |
|
| 725 | - */ |
|
| 726 | - private function _registrations_per_event_report($period = '-1 month') |
|
| 727 | - { |
|
| 728 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 729 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 730 | - $results = (array) $results; |
|
| 731 | - $regs = array(); |
|
| 732 | - $subtitle = ''; |
|
| 733 | - if ($results) { |
|
| 734 | - $column_titles = array(); |
|
| 735 | - $tracker = 0; |
|
| 736 | - foreach ($results as $result) { |
|
| 737 | - $report_column_values = array(); |
|
| 738 | - foreach ($result as $property_name => $property_value) { |
|
| 739 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 740 | - $property_value, |
|
| 741 | - 4, |
|
| 742 | - '...' |
|
| 743 | - ) : (int) $property_value; |
|
| 744 | - $report_column_values[] = $property_value; |
|
| 745 | - if ($tracker === 0) { |
|
| 746 | - if ($property_name === 'Registration_Event') { |
|
| 747 | - $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
| 748 | - } else { |
|
| 749 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 750 | - } |
|
| 751 | - } |
|
| 752 | - } |
|
| 753 | - $tracker++; |
|
| 754 | - $regs[] = $report_column_values; |
|
| 755 | - } |
|
| 756 | - // make sure the column_titles is pushed to the beginning of the array |
|
| 757 | - array_unshift($regs, $column_titles); |
|
| 758 | - // setup the date range. |
|
| 759 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 760 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 761 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 762 | - $subtitle = sprintf( |
|
| 763 | - wp_strip_all_tags( |
|
| 764 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
| 765 | - ), |
|
| 766 | - $beginning_date->format('Y-m-d'), |
|
| 767 | - $ending_date->format('Y-m-d') |
|
| 768 | - ); |
|
| 769 | - } |
|
| 770 | - $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
| 771 | - $report_params = array( |
|
| 772 | - 'title' => $report_title, |
|
| 773 | - 'subtitle' => $subtitle, |
|
| 774 | - 'id' => $report_ID, |
|
| 775 | - 'regs' => $regs, |
|
| 776 | - 'noResults' => empty($regs), |
|
| 777 | - 'noRegsMsg' => sprintf( |
|
| 778 | - wp_strip_all_tags( |
|
| 779 | - __( |
|
| 780 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 781 | - 'event_espresso' |
|
| 782 | - ) |
|
| 783 | - ), |
|
| 784 | - '<h2>' . $report_title . '</h2><p>', |
|
| 785 | - '</p>' |
|
| 786 | - ), |
|
| 787 | - ); |
|
| 788 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 789 | - return $report_ID; |
|
| 790 | - } |
|
| 716 | + /** |
|
| 717 | + * Generates Business Report showing total registrations per event. |
|
| 718 | + * |
|
| 719 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 720 | + * @return string |
|
| 721 | + * @throws EE_Error |
|
| 722 | + * @throws InvalidArgumentException |
|
| 723 | + * @throws InvalidDataTypeException |
|
| 724 | + * @throws InvalidInterfaceException |
|
| 725 | + */ |
|
| 726 | + private function _registrations_per_event_report($period = '-1 month') |
|
| 727 | + { |
|
| 728 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 729 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 730 | + $results = (array) $results; |
|
| 731 | + $regs = array(); |
|
| 732 | + $subtitle = ''; |
|
| 733 | + if ($results) { |
|
| 734 | + $column_titles = array(); |
|
| 735 | + $tracker = 0; |
|
| 736 | + foreach ($results as $result) { |
|
| 737 | + $report_column_values = array(); |
|
| 738 | + foreach ($result as $property_name => $property_value) { |
|
| 739 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 740 | + $property_value, |
|
| 741 | + 4, |
|
| 742 | + '...' |
|
| 743 | + ) : (int) $property_value; |
|
| 744 | + $report_column_values[] = $property_value; |
|
| 745 | + if ($tracker === 0) { |
|
| 746 | + if ($property_name === 'Registration_Event') { |
|
| 747 | + $column_titles[] = esc_html__('Event', 'event_espresso'); |
|
| 748 | + } else { |
|
| 749 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 750 | + } |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | + $tracker++; |
|
| 754 | + $regs[] = $report_column_values; |
|
| 755 | + } |
|
| 756 | + // make sure the column_titles is pushed to the beginning of the array |
|
| 757 | + array_unshift($regs, $column_titles); |
|
| 758 | + // setup the date range. |
|
| 759 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 760 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 761 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 762 | + $subtitle = sprintf( |
|
| 763 | + wp_strip_all_tags( |
|
| 764 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso') |
|
| 765 | + ), |
|
| 766 | + $beginning_date->format('Y-m-d'), |
|
| 767 | + $ending_date->format('Y-m-d') |
|
| 768 | + ); |
|
| 769 | + } |
|
| 770 | + $report_title = wp_strip_all_tags(__('Total Registrations per Event', 'event_espresso')); |
|
| 771 | + $report_params = array( |
|
| 772 | + 'title' => $report_title, |
|
| 773 | + 'subtitle' => $subtitle, |
|
| 774 | + 'id' => $report_ID, |
|
| 775 | + 'regs' => $regs, |
|
| 776 | + 'noResults' => empty($regs), |
|
| 777 | + 'noRegsMsg' => sprintf( |
|
| 778 | + wp_strip_all_tags( |
|
| 779 | + __( |
|
| 780 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 781 | + 'event_espresso' |
|
| 782 | + ) |
|
| 783 | + ), |
|
| 784 | + '<h2>' . $report_title . '</h2><p>', |
|
| 785 | + '</p>' |
|
| 786 | + ), |
|
| 787 | + ); |
|
| 788 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 789 | + return $report_ID; |
|
| 790 | + } |
|
| 791 | 791 | |
| 792 | 792 | |
| 793 | - /** |
|
| 794 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 795 | - * |
|
| 796 | - * @access protected |
|
| 797 | - * @return void |
|
| 798 | - * @throws EE_Error |
|
| 799 | - * @throws InvalidArgumentException |
|
| 800 | - * @throws InvalidDataTypeException |
|
| 801 | - * @throws InvalidInterfaceException |
|
| 802 | - * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 803 | - */ |
|
| 804 | - protected function _registration_checkin_list_table() |
|
| 805 | - { |
|
| 806 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 807 | - $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
| 808 | - /** @var EE_Registration $registration */ |
|
| 809 | - $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 810 | - if (! $registration instanceof EE_Registration) { |
|
| 811 | - throw new EE_Error( |
|
| 812 | - sprintf( |
|
| 813 | - esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
| 814 | - $reg_id |
|
| 815 | - ) |
|
| 816 | - ); |
|
| 817 | - } |
|
| 818 | - $attendee = $registration->attendee(); |
|
| 819 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 820 | - 'new_registration', |
|
| 821 | - 'add-registrant', |
|
| 822 | - array('event_id' => $registration->event_ID()), |
|
| 823 | - 'add-new-h2' |
|
| 824 | - ); |
|
| 825 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
| 826 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
| 827 | - $legend_items = array( |
|
| 828 | - 'checkin' => array( |
|
| 829 | - 'class' => $checked_in->cssClasses(), |
|
| 830 | - 'desc' => $checked_in->legendLabel(), |
|
| 831 | - ), |
|
| 832 | - 'checkout' => array( |
|
| 833 | - 'class' => $checked_out->cssClasses(), |
|
| 834 | - 'desc' => $checked_out->legendLabel(), |
|
| 835 | - ), |
|
| 836 | - ); |
|
| 837 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 838 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 839 | - /** @var EE_Datetime $datetime */ |
|
| 840 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
| 841 | - $datetime_label = ''; |
|
| 842 | - if ($datetime instanceof EE_Datetime) { |
|
| 843 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
| 844 | - $datetime_label .= ! empty($datetime_label) |
|
| 845 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
| 846 | - : $datetime->get_dtt_display_name(); |
|
| 847 | - } |
|
| 848 | - $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
| 849 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 850 | - array( |
|
| 851 | - 'action' => 'event_registrations', |
|
| 852 | - 'event_id' => $registration->event_ID(), |
|
| 853 | - 'DTT_ID' => $dtt_id, |
|
| 854 | - ), |
|
| 855 | - $this->_admin_base_url |
|
| 856 | - ) |
|
| 857 | - : ''; |
|
| 858 | - $datetime_link = ! empty($datetime_link) |
|
| 859 | - ? '<a href="' . $datetime_link . '">' |
|
| 860 | - . '<span id="checkin-dtt">' |
|
| 861 | - . $datetime_label |
|
| 862 | - . '</span></a>' |
|
| 863 | - : $datetime_label; |
|
| 864 | - $attendee_name = $attendee instanceof EE_Attendee |
|
| 865 | - ? $attendee->full_name() |
|
| 866 | - : ''; |
|
| 867 | - $attendee_link = $attendee instanceof EE_Attendee |
|
| 868 | - ? $attendee->get_admin_details_link() |
|
| 869 | - : ''; |
|
| 870 | - $attendee_link = ! empty($attendee_link) |
|
| 871 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
| 872 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
| 873 | - . '<span id="checkin-attendee-name">' |
|
| 874 | - . $attendee_name |
|
| 875 | - . '</span></a>' |
|
| 876 | - : ''; |
|
| 877 | - $event_link = $registration->event() instanceof EE_Event |
|
| 878 | - ? $registration->event()->get_admin_details_link() |
|
| 879 | - : ''; |
|
| 880 | - $event_link = ! empty($event_link) |
|
| 881 | - ? '<a href="' . $event_link . '"' |
|
| 882 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
| 883 | - . '<span id="checkin-event-name">' |
|
| 884 | - . $registration->event_name() |
|
| 885 | - . '</span>' |
|
| 886 | - . '</a>' |
|
| 887 | - : ''; |
|
| 888 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 889 | - ? '<h2>' . sprintf( |
|
| 890 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
| 891 | - $attendee_link, |
|
| 892 | - $datetime_link, |
|
| 893 | - $event_link |
|
| 894 | - ) . '</h2>' |
|
| 895 | - : ''; |
|
| 896 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 897 | - ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
| 898 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 899 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 900 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 901 | - } |
|
| 793 | + /** |
|
| 794 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 795 | + * |
|
| 796 | + * @access protected |
|
| 797 | + * @return void |
|
| 798 | + * @throws EE_Error |
|
| 799 | + * @throws InvalidArgumentException |
|
| 800 | + * @throws InvalidDataTypeException |
|
| 801 | + * @throws InvalidInterfaceException |
|
| 802 | + * @throws \EventEspresso\core\exceptions\EntityNotFoundException |
|
| 803 | + */ |
|
| 804 | + protected function _registration_checkin_list_table() |
|
| 805 | + { |
|
| 806 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 807 | + $reg_id = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : null; |
|
| 808 | + /** @var EE_Registration $registration */ |
|
| 809 | + $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 810 | + if (! $registration instanceof EE_Registration) { |
|
| 811 | + throw new EE_Error( |
|
| 812 | + sprintf( |
|
| 813 | + esc_html__('An error occurred. There is no registration with ID (%d)', 'event_espresso'), |
|
| 814 | + $reg_id |
|
| 815 | + ) |
|
| 816 | + ); |
|
| 817 | + } |
|
| 818 | + $attendee = $registration->attendee(); |
|
| 819 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 820 | + 'new_registration', |
|
| 821 | + 'add-registrant', |
|
| 822 | + array('event_id' => $registration->event_ID()), |
|
| 823 | + 'add-new-h2' |
|
| 824 | + ); |
|
| 825 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
| 826 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
| 827 | + $legend_items = array( |
|
| 828 | + 'checkin' => array( |
|
| 829 | + 'class' => $checked_in->cssClasses(), |
|
| 830 | + 'desc' => $checked_in->legendLabel(), |
|
| 831 | + ), |
|
| 832 | + 'checkout' => array( |
|
| 833 | + 'class' => $checked_out->cssClasses(), |
|
| 834 | + 'desc' => $checked_out->legendLabel(), |
|
| 835 | + ), |
|
| 836 | + ); |
|
| 837 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 838 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 839 | + /** @var EE_Datetime $datetime */ |
|
| 840 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
| 841 | + $datetime_label = ''; |
|
| 842 | + if ($datetime instanceof EE_Datetime) { |
|
| 843 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
| 844 | + $datetime_label .= ! empty($datetime_label) |
|
| 845 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
| 846 | + : $datetime->get_dtt_display_name(); |
|
| 847 | + } |
|
| 848 | + $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
| 849 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 850 | + array( |
|
| 851 | + 'action' => 'event_registrations', |
|
| 852 | + 'event_id' => $registration->event_ID(), |
|
| 853 | + 'DTT_ID' => $dtt_id, |
|
| 854 | + ), |
|
| 855 | + $this->_admin_base_url |
|
| 856 | + ) |
|
| 857 | + : ''; |
|
| 858 | + $datetime_link = ! empty($datetime_link) |
|
| 859 | + ? '<a href="' . $datetime_link . '">' |
|
| 860 | + . '<span id="checkin-dtt">' |
|
| 861 | + . $datetime_label |
|
| 862 | + . '</span></a>' |
|
| 863 | + : $datetime_label; |
|
| 864 | + $attendee_name = $attendee instanceof EE_Attendee |
|
| 865 | + ? $attendee->full_name() |
|
| 866 | + : ''; |
|
| 867 | + $attendee_link = $attendee instanceof EE_Attendee |
|
| 868 | + ? $attendee->get_admin_details_link() |
|
| 869 | + : ''; |
|
| 870 | + $attendee_link = ! empty($attendee_link) |
|
| 871 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
| 872 | + . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
| 873 | + . '<span id="checkin-attendee-name">' |
|
| 874 | + . $attendee_name |
|
| 875 | + . '</span></a>' |
|
| 876 | + : ''; |
|
| 877 | + $event_link = $registration->event() instanceof EE_Event |
|
| 878 | + ? $registration->event()->get_admin_details_link() |
|
| 879 | + : ''; |
|
| 880 | + $event_link = ! empty($event_link) |
|
| 881 | + ? '<a href="' . $event_link . '"' |
|
| 882 | + . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
| 883 | + . '<span id="checkin-event-name">' |
|
| 884 | + . $registration->event_name() |
|
| 885 | + . '</span>' |
|
| 886 | + . '</a>' |
|
| 887 | + : ''; |
|
| 888 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 889 | + ? '<h2>' . sprintf( |
|
| 890 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
| 891 | + $attendee_link, |
|
| 892 | + $datetime_link, |
|
| 893 | + $event_link |
|
| 894 | + ) . '</h2>' |
|
| 895 | + : ''; |
|
| 896 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 897 | + ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : ''; |
|
| 898 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 899 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 900 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 901 | + } |
|
| 902 | 902 | |
| 903 | 903 | |
| 904 | - /** |
|
| 905 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
| 906 | - * |
|
| 907 | - * @return void (JSON) |
|
| 908 | - * @throws EE_Error |
|
| 909 | - * @throws InvalidArgumentException |
|
| 910 | - * @throws InvalidDataTypeException |
|
| 911 | - * @throws InvalidInterfaceException |
|
| 912 | - */ |
|
| 913 | - public function toggle_checkin_status() |
|
| 914 | - { |
|
| 915 | - // first make sure we have the necessary data |
|
| 916 | - if (! isset($this->_req_data['_regid'])) { |
|
| 917 | - EE_Error::add_error( |
|
| 918 | - esc_html__( |
|
| 919 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
| 920 | - 'event_espresso' |
|
| 921 | - ), |
|
| 922 | - __FILE__, |
|
| 923 | - __FUNCTION__, |
|
| 924 | - __LINE__ |
|
| 925 | - ); |
|
| 926 | - $this->_template_args['success'] = false; |
|
| 927 | - $this->_template_args['error'] = true; |
|
| 928 | - $this->_return_json(); |
|
| 929 | - }; |
|
| 930 | - // do a nonce check cause we're not coming in from an normal route here. |
|
| 931 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 932 | - : ''; |
|
| 933 | - $nonce_ref = 'checkin_nonce'; |
|
| 934 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 935 | - // beautiful! Made it this far so let's get the status. |
|
| 936 | - $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
| 937 | - // setup new class to return via ajax |
|
| 938 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
| 939 | - $this->_template_args['success'] = true; |
|
| 940 | - $this->_return_json(); |
|
| 941 | - } |
|
| 904 | + /** |
|
| 905 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
| 906 | + * |
|
| 907 | + * @return void (JSON) |
|
| 908 | + * @throws EE_Error |
|
| 909 | + * @throws InvalidArgumentException |
|
| 910 | + * @throws InvalidDataTypeException |
|
| 911 | + * @throws InvalidInterfaceException |
|
| 912 | + */ |
|
| 913 | + public function toggle_checkin_status() |
|
| 914 | + { |
|
| 915 | + // first make sure we have the necessary data |
|
| 916 | + if (! isset($this->_req_data['_regid'])) { |
|
| 917 | + EE_Error::add_error( |
|
| 918 | + esc_html__( |
|
| 919 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
| 920 | + 'event_espresso' |
|
| 921 | + ), |
|
| 922 | + __FILE__, |
|
| 923 | + __FUNCTION__, |
|
| 924 | + __LINE__ |
|
| 925 | + ); |
|
| 926 | + $this->_template_args['success'] = false; |
|
| 927 | + $this->_template_args['error'] = true; |
|
| 928 | + $this->_return_json(); |
|
| 929 | + }; |
|
| 930 | + // do a nonce check cause we're not coming in from an normal route here. |
|
| 931 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 932 | + : ''; |
|
| 933 | + $nonce_ref = 'checkin_nonce'; |
|
| 934 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 935 | + // beautiful! Made it this far so let's get the status. |
|
| 936 | + $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
| 937 | + // setup new class to return via ajax |
|
| 938 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
| 939 | + $this->_template_args['success'] = true; |
|
| 940 | + $this->_return_json(); |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | 943 | |
| 944 | - /** |
|
| 945 | - * handles toggling the checkin status for the registration, |
|
| 946 | - * |
|
| 947 | - * @access protected |
|
| 948 | - * @return int|void |
|
| 949 | - * @throws EE_Error |
|
| 950 | - * @throws InvalidArgumentException |
|
| 951 | - * @throws InvalidDataTypeException |
|
| 952 | - * @throws InvalidInterfaceException |
|
| 953 | - */ |
|
| 954 | - protected function _toggle_checkin_status() |
|
| 955 | - { |
|
| 956 | - // first let's get the query args out of the way for the redirect |
|
| 957 | - $query_args = array( |
|
| 958 | - 'action' => 'event_registrations', |
|
| 959 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 960 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 961 | - ); |
|
| 962 | - $new_status = false; |
|
| 963 | - // bulk action check in toggle |
|
| 964 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 965 | - // cycle thru checkboxes |
|
| 966 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 967 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 968 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 969 | - } |
|
| 970 | - } elseif (isset($this->_req_data['_regid'])) { |
|
| 971 | - // coming from ajax request |
|
| 972 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 973 | - $query_args['DTT_ID'] = $DTT_ID; |
|
| 974 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 975 | - } else { |
|
| 976 | - EE_Error::add_error( |
|
| 977 | - esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 978 | - __FILE__, |
|
| 979 | - __FUNCTION__, |
|
| 980 | - __LINE__ |
|
| 981 | - ); |
|
| 982 | - } |
|
| 983 | - if (defined('DOING_AJAX')) { |
|
| 984 | - return $new_status; |
|
| 985 | - } |
|
| 986 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 987 | - } |
|
| 944 | + /** |
|
| 945 | + * handles toggling the checkin status for the registration, |
|
| 946 | + * |
|
| 947 | + * @access protected |
|
| 948 | + * @return int|void |
|
| 949 | + * @throws EE_Error |
|
| 950 | + * @throws InvalidArgumentException |
|
| 951 | + * @throws InvalidDataTypeException |
|
| 952 | + * @throws InvalidInterfaceException |
|
| 953 | + */ |
|
| 954 | + protected function _toggle_checkin_status() |
|
| 955 | + { |
|
| 956 | + // first let's get the query args out of the way for the redirect |
|
| 957 | + $query_args = array( |
|
| 958 | + 'action' => 'event_registrations', |
|
| 959 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 960 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 961 | + ); |
|
| 962 | + $new_status = false; |
|
| 963 | + // bulk action check in toggle |
|
| 964 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 965 | + // cycle thru checkboxes |
|
| 966 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 967 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 968 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 969 | + } |
|
| 970 | + } elseif (isset($this->_req_data['_regid'])) { |
|
| 971 | + // coming from ajax request |
|
| 972 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 973 | + $query_args['DTT_ID'] = $DTT_ID; |
|
| 974 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 975 | + } else { |
|
| 976 | + EE_Error::add_error( |
|
| 977 | + esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 978 | + __FILE__, |
|
| 979 | + __FUNCTION__, |
|
| 980 | + __LINE__ |
|
| 981 | + ); |
|
| 982 | + } |
|
| 983 | + if (defined('DOING_AJAX')) { |
|
| 984 | + return $new_status; |
|
| 985 | + } |
|
| 986 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 987 | + } |
|
| 988 | 988 | |
| 989 | 989 | |
| 990 | - /** |
|
| 991 | - * This is toggles a single Check-in for the given registration and datetime. |
|
| 992 | - * |
|
| 993 | - * @param int $REG_ID The registration we're toggling |
|
| 994 | - * @param int $DTT_ID The datetime we're toggling |
|
| 995 | - * @return int The new status toggled to. |
|
| 996 | - * @throws EE_Error |
|
| 997 | - * @throws InvalidArgumentException |
|
| 998 | - * @throws InvalidDataTypeException |
|
| 999 | - * @throws InvalidInterfaceException |
|
| 1000 | - */ |
|
| 1001 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 1002 | - { |
|
| 1003 | - /** @var EE_Registration $REG */ |
|
| 1004 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1005 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 1006 | - if ($new_status !== false) { |
|
| 1007 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 1008 | - } else { |
|
| 1009 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 1010 | - $new_status = false; |
|
| 1011 | - } |
|
| 1012 | - return $new_status; |
|
| 1013 | - } |
|
| 990 | + /** |
|
| 991 | + * This is toggles a single Check-in for the given registration and datetime. |
|
| 992 | + * |
|
| 993 | + * @param int $REG_ID The registration we're toggling |
|
| 994 | + * @param int $DTT_ID The datetime we're toggling |
|
| 995 | + * @return int The new status toggled to. |
|
| 996 | + * @throws EE_Error |
|
| 997 | + * @throws InvalidArgumentException |
|
| 998 | + * @throws InvalidDataTypeException |
|
| 999 | + * @throws InvalidInterfaceException |
|
| 1000 | + */ |
|
| 1001 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 1002 | + { |
|
| 1003 | + /** @var EE_Registration $REG */ |
|
| 1004 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 1005 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 1006 | + if ($new_status !== false) { |
|
| 1007 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 1008 | + } else { |
|
| 1009 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 1010 | + $new_status = false; |
|
| 1011 | + } |
|
| 1012 | + return $new_status; |
|
| 1013 | + } |
|
| 1014 | 1014 | |
| 1015 | 1015 | |
| 1016 | - /** |
|
| 1017 | - * Takes care of deleting multiple EE_Checkin table rows |
|
| 1018 | - * |
|
| 1019 | - * @access protected |
|
| 1020 | - * @return void |
|
| 1021 | - * @throws EE_Error |
|
| 1022 | - * @throws InvalidArgumentException |
|
| 1023 | - * @throws InvalidDataTypeException |
|
| 1024 | - * @throws InvalidInterfaceException |
|
| 1025 | - */ |
|
| 1026 | - protected function _delete_checkin_rows() |
|
| 1027 | - { |
|
| 1028 | - $query_args = array( |
|
| 1029 | - 'action' => 'registration_checkins', |
|
| 1030 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 1031 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
| 1032 | - ); |
|
| 1033 | - $errors = 0; |
|
| 1034 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1035 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1036 | - if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 1037 | - $errors++; |
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1040 | - } else { |
|
| 1041 | - EE_Error::add_error( |
|
| 1042 | - esc_html__( |
|
| 1043 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 1044 | - 'event_espresso' |
|
| 1045 | - ), |
|
| 1046 | - __FILE__, |
|
| 1047 | - __FUNCTION__, |
|
| 1048 | - __LINE__ |
|
| 1049 | - ); |
|
| 1050 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1051 | - } |
|
| 1052 | - if ($errors > 0) { |
|
| 1053 | - EE_Error::add_error( |
|
| 1054 | - sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 1055 | - __FILE__, |
|
| 1056 | - __FUNCTION__, |
|
| 1057 | - __LINE__ |
|
| 1058 | - ); |
|
| 1059 | - } else { |
|
| 1060 | - EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
| 1061 | - } |
|
| 1062 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1063 | - } |
|
| 1016 | + /** |
|
| 1017 | + * Takes care of deleting multiple EE_Checkin table rows |
|
| 1018 | + * |
|
| 1019 | + * @access protected |
|
| 1020 | + * @return void |
|
| 1021 | + * @throws EE_Error |
|
| 1022 | + * @throws InvalidArgumentException |
|
| 1023 | + * @throws InvalidDataTypeException |
|
| 1024 | + * @throws InvalidInterfaceException |
|
| 1025 | + */ |
|
| 1026 | + protected function _delete_checkin_rows() |
|
| 1027 | + { |
|
| 1028 | + $query_args = array( |
|
| 1029 | + 'action' => 'registration_checkins', |
|
| 1030 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 1031 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
| 1032 | + ); |
|
| 1033 | + $errors = 0; |
|
| 1034 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1035 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1036 | + if (! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 1037 | + $errors++; |
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | + } else { |
|
| 1041 | + EE_Error::add_error( |
|
| 1042 | + esc_html__( |
|
| 1043 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 1044 | + 'event_espresso' |
|
| 1045 | + ), |
|
| 1046 | + __FILE__, |
|
| 1047 | + __FUNCTION__, |
|
| 1048 | + __LINE__ |
|
| 1049 | + ); |
|
| 1050 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1051 | + } |
|
| 1052 | + if ($errors > 0) { |
|
| 1053 | + EE_Error::add_error( |
|
| 1054 | + sprintf(esc_html__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 1055 | + __FILE__, |
|
| 1056 | + __FUNCTION__, |
|
| 1057 | + __LINE__ |
|
| 1058 | + ); |
|
| 1059 | + } else { |
|
| 1060 | + EE_Error::add_success(esc_html__('Records were successfully deleted', 'event_espresso')); |
|
| 1061 | + } |
|
| 1062 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1063 | + } |
|
| 1064 | 1064 | |
| 1065 | 1065 | |
| 1066 | - /** |
|
| 1067 | - * Deletes a single EE_Checkin row |
|
| 1068 | - * |
|
| 1069 | - * @return void |
|
| 1070 | - * @throws EE_Error |
|
| 1071 | - * @throws InvalidArgumentException |
|
| 1072 | - * @throws InvalidDataTypeException |
|
| 1073 | - * @throws InvalidInterfaceException |
|
| 1074 | - */ |
|
| 1075 | - protected function _delete_checkin_row() |
|
| 1076 | - { |
|
| 1077 | - $query_args = array( |
|
| 1078 | - 'action' => 'registration_checkins', |
|
| 1079 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 1080 | - '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
| 1081 | - ); |
|
| 1082 | - if (! empty($this->_req_data['CHK_ID'])) { |
|
| 1083 | - if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 1084 | - EE_Error::add_error( |
|
| 1085 | - esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 1086 | - __FILE__, |
|
| 1087 | - __FUNCTION__, |
|
| 1088 | - __LINE__ |
|
| 1089 | - ); |
|
| 1090 | - } else { |
|
| 1091 | - EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
| 1092 | - } |
|
| 1093 | - } else { |
|
| 1094 | - EE_Error::add_error( |
|
| 1095 | - esc_html__( |
|
| 1096 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
| 1097 | - 'event_espresso' |
|
| 1098 | - ), |
|
| 1099 | - __FILE__, |
|
| 1100 | - __FUNCTION__, |
|
| 1101 | - __LINE__ |
|
| 1102 | - ); |
|
| 1103 | - } |
|
| 1104 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1105 | - } |
|
| 1066 | + /** |
|
| 1067 | + * Deletes a single EE_Checkin row |
|
| 1068 | + * |
|
| 1069 | + * @return void |
|
| 1070 | + * @throws EE_Error |
|
| 1071 | + * @throws InvalidArgumentException |
|
| 1072 | + * @throws InvalidDataTypeException |
|
| 1073 | + * @throws InvalidInterfaceException |
|
| 1074 | + */ |
|
| 1075 | + protected function _delete_checkin_row() |
|
| 1076 | + { |
|
| 1077 | + $query_args = array( |
|
| 1078 | + 'action' => 'registration_checkins', |
|
| 1079 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 1080 | + '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0, |
|
| 1081 | + ); |
|
| 1082 | + if (! empty($this->_req_data['CHK_ID'])) { |
|
| 1083 | + if (! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 1084 | + EE_Error::add_error( |
|
| 1085 | + esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 1086 | + __FILE__, |
|
| 1087 | + __FUNCTION__, |
|
| 1088 | + __LINE__ |
|
| 1089 | + ); |
|
| 1090 | + } else { |
|
| 1091 | + EE_Error::add_success(esc_html__('Check-In record successfully deleted', 'event_espresso')); |
|
| 1092 | + } |
|
| 1093 | + } else { |
|
| 1094 | + EE_Error::add_error( |
|
| 1095 | + esc_html__( |
|
| 1096 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
| 1097 | + 'event_espresso' |
|
| 1098 | + ), |
|
| 1099 | + __FILE__, |
|
| 1100 | + __FUNCTION__, |
|
| 1101 | + __LINE__ |
|
| 1102 | + ); |
|
| 1103 | + } |
|
| 1104 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1105 | + } |
|
| 1106 | 1106 | |
| 1107 | 1107 | |
| 1108 | - /** |
|
| 1109 | - * generates HTML for the Event Registrations List Table |
|
| 1110 | - * |
|
| 1111 | - * @access protected |
|
| 1112 | - * @return void |
|
| 1113 | - * @throws EE_Error |
|
| 1114 | - * @throws InvalidArgumentException |
|
| 1115 | - * @throws InvalidDataTypeException |
|
| 1116 | - * @throws InvalidInterfaceException |
|
| 1117 | - */ |
|
| 1118 | - protected function _event_registrations_list_table() |
|
| 1119 | - { |
|
| 1120 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1121 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 1122 | - ? $this->get_action_link_or_button( |
|
| 1123 | - 'new_registration', |
|
| 1124 | - 'add-registrant', |
|
| 1125 | - array('event_id' => $this->_req_data['event_id']), |
|
| 1126 | - 'add-new-h2', |
|
| 1127 | - '', |
|
| 1128 | - false |
|
| 1129 | - ) |
|
| 1130 | - : ''; |
|
| 1131 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
| 1132 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
| 1133 | - $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
| 1134 | - $legend_items = array( |
|
| 1135 | - 'star-icon' => array( |
|
| 1136 | - 'class' => 'dashicons dashicons-star-filled gold-icon', |
|
| 1137 | - 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1138 | - ), |
|
| 1139 | - 'checkin' => array( |
|
| 1140 | - 'class' => $checked_in->cssClasses(), |
|
| 1141 | - 'desc' => $checked_in->legendLabel(), |
|
| 1142 | - ), |
|
| 1143 | - 'checkout' => array( |
|
| 1144 | - 'class' => $checked_out->cssClasses(), |
|
| 1145 | - 'desc' => $checked_out->legendLabel(), |
|
| 1146 | - ), |
|
| 1147 | - 'nocheckinrecord' => array( |
|
| 1148 | - 'class' => $checked_never->cssClasses(), |
|
| 1149 | - 'desc' => $checked_never->legendLabel(), |
|
| 1150 | - ), |
|
| 1151 | - 'approved_status' => array( |
|
| 1152 | - 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_approved, |
|
| 1153 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1154 | - ), |
|
| 1155 | - 'cancelled_status' => array( |
|
| 1156 | - 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_cancelled, |
|
| 1157 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1158 | - ), |
|
| 1159 | - 'declined_status' => array( |
|
| 1160 | - 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_declined, |
|
| 1161 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1162 | - ), |
|
| 1163 | - 'not_approved' => array( |
|
| 1164 | - 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_not_approved, |
|
| 1165 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1166 | - ), |
|
| 1167 | - 'pending_status' => array( |
|
| 1168 | - 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_pending_payment, |
|
| 1169 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1170 | - ), |
|
| 1171 | - 'wait_list' => array( |
|
| 1172 | - 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_wait_list, |
|
| 1173 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1174 | - ), |
|
| 1175 | - ); |
|
| 1176 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1177 | - $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1178 | - /** @var EE_Event $event */ |
|
| 1179 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1180 | - $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
| 1181 | - ? '<h2>' . sprintf( |
|
| 1182 | - esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1183 | - EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1184 | - ) . '</h2>' |
|
| 1185 | - : ''; |
|
| 1186 | - // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
| 1187 | - // the event. |
|
| 1188 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1189 | - $datetime = null; |
|
| 1190 | - if ($event instanceof EE_Event) { |
|
| 1191 | - $datetimes_on_event = $event->datetimes(); |
|
| 1192 | - if (count($datetimes_on_event) === 1) { |
|
| 1193 | - $datetime = reset($datetimes_on_event); |
|
| 1194 | - } |
|
| 1195 | - } |
|
| 1196 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1197 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1198 | - $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1199 | - $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1200 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1201 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1202 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1203 | - $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1204 | - } |
|
| 1205 | - // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
| 1206 | - // column represents |
|
| 1207 | - if (! $datetime instanceof EE_Datetime) { |
|
| 1208 | - $this->_template_args['before_list_table'] .= '<h3 class="description">' |
|
| 1209 | - . esc_html__( |
|
| 1210 | - 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1211 | - 'event_espresso' |
|
| 1212 | - ) |
|
| 1213 | - . '</h3>'; |
|
| 1214 | - } |
|
| 1215 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1216 | - } |
|
| 1108 | + /** |
|
| 1109 | + * generates HTML for the Event Registrations List Table |
|
| 1110 | + * |
|
| 1111 | + * @access protected |
|
| 1112 | + * @return void |
|
| 1113 | + * @throws EE_Error |
|
| 1114 | + * @throws InvalidArgumentException |
|
| 1115 | + * @throws InvalidDataTypeException |
|
| 1116 | + * @throws InvalidInterfaceException |
|
| 1117 | + */ |
|
| 1118 | + protected function _event_registrations_list_table() |
|
| 1119 | + { |
|
| 1120 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1121 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 1122 | + ? $this->get_action_link_or_button( |
|
| 1123 | + 'new_registration', |
|
| 1124 | + 'add-registrant', |
|
| 1125 | + array('event_id' => $this->_req_data['event_id']), |
|
| 1126 | + 'add-new-h2', |
|
| 1127 | + '', |
|
| 1128 | + false |
|
| 1129 | + ) |
|
| 1130 | + : ''; |
|
| 1131 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
| 1132 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
| 1133 | + $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
| 1134 | + $legend_items = array( |
|
| 1135 | + 'star-icon' => array( |
|
| 1136 | + 'class' => 'dashicons dashicons-star-filled gold-icon', |
|
| 1137 | + 'desc' => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1138 | + ), |
|
| 1139 | + 'checkin' => array( |
|
| 1140 | + 'class' => $checked_in->cssClasses(), |
|
| 1141 | + 'desc' => $checked_in->legendLabel(), |
|
| 1142 | + ), |
|
| 1143 | + 'checkout' => array( |
|
| 1144 | + 'class' => $checked_out->cssClasses(), |
|
| 1145 | + 'desc' => $checked_out->legendLabel(), |
|
| 1146 | + ), |
|
| 1147 | + 'nocheckinrecord' => array( |
|
| 1148 | + 'class' => $checked_never->cssClasses(), |
|
| 1149 | + 'desc' => $checked_never->legendLabel(), |
|
| 1150 | + ), |
|
| 1151 | + 'approved_status' => array( |
|
| 1152 | + 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_approved, |
|
| 1153 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1154 | + ), |
|
| 1155 | + 'cancelled_status' => array( |
|
| 1156 | + 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_cancelled, |
|
| 1157 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1158 | + ), |
|
| 1159 | + 'declined_status' => array( |
|
| 1160 | + 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_declined, |
|
| 1161 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1162 | + ), |
|
| 1163 | + 'not_approved' => array( |
|
| 1164 | + 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_not_approved, |
|
| 1165 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1166 | + ), |
|
| 1167 | + 'pending_status' => array( |
|
| 1168 | + 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_pending_payment, |
|
| 1169 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1170 | + ), |
|
| 1171 | + 'wait_list' => array( |
|
| 1172 | + 'class' => 'ee-status-legend ee-status-legend--' . EEM_Registration::status_id_wait_list, |
|
| 1173 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1174 | + ), |
|
| 1175 | + ); |
|
| 1176 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1177 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1178 | + /** @var EE_Event $event */ |
|
| 1179 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1180 | + $this->_template_args['before_list_table'] = $event instanceof EE_Event |
|
| 1181 | + ? '<h2>' . sprintf( |
|
| 1182 | + esc_html__('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1183 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1184 | + ) . '</h2>' |
|
| 1185 | + : ''; |
|
| 1186 | + // need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on |
|
| 1187 | + // the event. |
|
| 1188 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1189 | + $datetime = null; |
|
| 1190 | + if ($event instanceof EE_Event) { |
|
| 1191 | + $datetimes_on_event = $event->datetimes(); |
|
| 1192 | + if (count($datetimes_on_event) === 1) { |
|
| 1193 | + $datetime = reset($datetimes_on_event); |
|
| 1194 | + } |
|
| 1195 | + } |
|
| 1196 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1197 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1198 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1199 | + $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1200 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1201 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1202 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1203 | + $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1204 | + } |
|
| 1205 | + // if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status |
|
| 1206 | + // column represents |
|
| 1207 | + if (! $datetime instanceof EE_Datetime) { |
|
| 1208 | + $this->_template_args['before_list_table'] .= '<h3 class="description">' |
|
| 1209 | + . esc_html__( |
|
| 1210 | + 'In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1211 | + 'event_espresso' |
|
| 1212 | + ) |
|
| 1213 | + . '</h3>'; |
|
| 1214 | + } |
|
| 1215 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1216 | + } |
|
| 1217 | 1217 | |
| 1218 | - /** |
|
| 1219 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1220 | - * conditions) |
|
| 1221 | - * |
|
| 1222 | - * @return void ends the request by a redirect or download |
|
| 1223 | - */ |
|
| 1224 | - public function _registrations_checkin_report() |
|
| 1225 | - { |
|
| 1226 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1227 | - } |
|
| 1218 | + /** |
|
| 1219 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1220 | + * conditions) |
|
| 1221 | + * |
|
| 1222 | + * @return void ends the request by a redirect or download |
|
| 1223 | + */ |
|
| 1224 | + public function _registrations_checkin_report() |
|
| 1225 | + { |
|
| 1226 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1227 | + } |
|
| 1228 | 1228 | |
| 1229 | - /** |
|
| 1230 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1231 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1232 | - * |
|
| 1233 | - * @param array $request |
|
| 1234 | - * @param int $per_page |
|
| 1235 | - * @param bool $count |
|
| 1236 | - * @return array |
|
| 1237 | - * @throws EE_Error |
|
| 1238 | - */ |
|
| 1239 | - protected function _get_checkin_query_params_from_request( |
|
| 1240 | - $request, |
|
| 1241 | - $per_page = 10, |
|
| 1242 | - $count = false |
|
| 1243 | - ) { |
|
| 1244 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1245 | - // unlike the regular registrations list table, |
|
| 1246 | - $status_ids_array = apply_filters( |
|
| 1247 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1248 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1249 | - ); |
|
| 1250 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1251 | - return $query_params; |
|
| 1252 | - } |
|
| 1229 | + /** |
|
| 1230 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1231 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1232 | + * |
|
| 1233 | + * @param array $request |
|
| 1234 | + * @param int $per_page |
|
| 1235 | + * @param bool $count |
|
| 1236 | + * @return array |
|
| 1237 | + * @throws EE_Error |
|
| 1238 | + */ |
|
| 1239 | + protected function _get_checkin_query_params_from_request( |
|
| 1240 | + $request, |
|
| 1241 | + $per_page = 10, |
|
| 1242 | + $count = false |
|
| 1243 | + ) { |
|
| 1244 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1245 | + // unlike the regular registrations list table, |
|
| 1246 | + $status_ids_array = apply_filters( |
|
| 1247 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1248 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1249 | + ); |
|
| 1250 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1251 | + return $query_params; |
|
| 1252 | + } |
|
| 1253 | 1253 | |
| 1254 | 1254 | |
| 1255 | - /** |
|
| 1256 | - * Gets registrations for an event |
|
| 1257 | - * |
|
| 1258 | - * @param int $per_page |
|
| 1259 | - * @param bool $count whether to return count or data. |
|
| 1260 | - * @param bool $trash |
|
| 1261 | - * @param string $orderby |
|
| 1262 | - * @return EE_Registration[]|int |
|
| 1263 | - * @throws EE_Error |
|
| 1264 | - * @throws InvalidArgumentException |
|
| 1265 | - * @throws InvalidDataTypeException |
|
| 1266 | - * @throws InvalidInterfaceException |
|
| 1267 | - */ |
|
| 1268 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1269 | - { |
|
| 1270 | - // normalize some request params that get setup by the parent `get_registrations` method. |
|
| 1271 | - $request = $this->_req_data; |
|
| 1272 | - $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
| 1273 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1274 | - if ($trash) { |
|
| 1275 | - $request['status'] = 'trash'; |
|
| 1276 | - } |
|
| 1277 | - $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count); |
|
| 1278 | - /** |
|
| 1279 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1280 | - * |
|
| 1281 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1282 | - * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
| 1283 | - * or if you have the development copy of EE you can view this at the path: |
|
| 1284 | - * /docs/G--Model-System/model-query-params.md |
|
| 1285 | - */ |
|
| 1286 | - $query_params['group_by'] = ''; |
|
| 1255 | + /** |
|
| 1256 | + * Gets registrations for an event |
|
| 1257 | + * |
|
| 1258 | + * @param int $per_page |
|
| 1259 | + * @param bool $count whether to return count or data. |
|
| 1260 | + * @param bool $trash |
|
| 1261 | + * @param string $orderby |
|
| 1262 | + * @return EE_Registration[]|int |
|
| 1263 | + * @throws EE_Error |
|
| 1264 | + * @throws InvalidArgumentException |
|
| 1265 | + * @throws InvalidDataTypeException |
|
| 1266 | + * @throws InvalidInterfaceException |
|
| 1267 | + */ |
|
| 1268 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1269 | + { |
|
| 1270 | + // normalize some request params that get setup by the parent `get_registrations` method. |
|
| 1271 | + $request = $this->_req_data; |
|
| 1272 | + $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
| 1273 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1274 | + if ($trash) { |
|
| 1275 | + $request['status'] = 'trash'; |
|
| 1276 | + } |
|
| 1277 | + $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count); |
|
| 1278 | + /** |
|
| 1279 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1280 | + * |
|
| 1281 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1282 | + * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
| 1283 | + * or if you have the development copy of EE you can view this at the path: |
|
| 1284 | + * /docs/G--Model-System/model-query-params.md |
|
| 1285 | + */ |
|
| 1286 | + $query_params['group_by'] = ''; |
|
| 1287 | 1287 | |
| 1288 | - return $count |
|
| 1289 | - ? EEM_Registration::instance()->count($query_params) |
|
| 1290 | - /** @type EE_Registration[] */ |
|
| 1291 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 1292 | - } |
|
| 1288 | + return $count |
|
| 1289 | + ? EEM_Registration::instance()->count($query_params) |
|
| 1290 | + /** @type EE_Registration[] */ |
|
| 1291 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 1292 | + } |
|
| 1293 | 1293 | } |