@@ -15,1065 +15,1065 @@ |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @var Registrations_Admin_Page |
|
| 20 | - */ |
|
| 21 | - protected $_admin_page; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 26 | - private $_status; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * An array of transaction details for the related transaction to the registration being processed. |
|
| 30 | - * This is set via the _set_related_details method. |
|
| 31 | - * |
|
| 32 | - * @var array |
|
| 33 | - */ |
|
| 34 | - protected $_transaction_details = []; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * An array of event details for the related event to the registration being processed. |
|
| 38 | - * This is set via the _set_related_details method. |
|
| 39 | - * |
|
| 40 | - * @var array |
|
| 41 | - */ |
|
| 42 | - protected $_event_details = []; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @param Registrations_Admin_Page $admin_page |
|
| 47 | - */ |
|
| 48 | - public function __construct(Registrations_Admin_Page $admin_page) |
|
| 49 | - { |
|
| 50 | - $req_data = $admin_page->get_request_data(); |
|
| 51 | - if (! empty($req_data['event_id'])) { |
|
| 52 | - $extra_query_args = []; |
|
| 53 | - foreach ($admin_page->get_views() as $view_details) { |
|
| 54 | - $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']]; |
|
| 55 | - } |
|
| 56 | - $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
| 57 | - } |
|
| 58 | - parent::__construct($admin_page); |
|
| 59 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @return void |
|
| 65 | - * @throws EE_Error |
|
| 66 | - */ |
|
| 67 | - protected function _setup_data() |
|
| 68 | - { |
|
| 69 | - $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
| 70 | - $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @return void |
|
| 76 | - */ |
|
| 77 | - protected function _set_properties() |
|
| 78 | - { |
|
| 79 | - $return_url = $this->getReturnUrl(); |
|
| 80 | - $this->_wp_list_args = [ |
|
| 81 | - 'singular' => esc_html__('registration', 'event_espresso'), |
|
| 82 | - 'plural' => esc_html__('registrations', 'event_espresso'), |
|
| 83 | - 'ajax' => true, |
|
| 84 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 85 | - ]; |
|
| 86 | - $ID_column_name = esc_html__('ID', 'event_espresso'); |
|
| 87 | - $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
| 88 | - $ID_column_name .= esc_html__('Registrant Name', 'event_espresso'); |
|
| 89 | - $ID_column_name .= '</span> '; |
|
| 90 | - $req_data = $this->_admin_page->get_request_data(); |
|
| 91 | - if (isset($req_data['event_id'])) { |
|
| 92 | - $this->_columns = [ |
|
| 93 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 94 | - '_REG_ID' => $ID_column_name, |
|
| 95 | - 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
|
| 96 | - 'ATT_email' => esc_html__('Email', 'event_espresso'), |
|
| 97 | - '_REG_date' => esc_html__('Reg Date', 'event_espresso'), |
|
| 98 | - 'PRC_amount' => esc_html__('TKT Price', 'event_espresso'), |
|
| 99 | - '_REG_final_price' => esc_html__('Final Price', 'event_espresso'), |
|
| 100 | - 'TXN_total' => esc_html__('Total Txn', 'event_espresso'), |
|
| 101 | - 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 102 | - 'actions' => esc_html__('Actions', 'event_espresso'), |
|
| 103 | - ]; |
|
| 104 | - $this->_bottom_buttons = [ |
|
| 105 | - 'report' => [ |
|
| 106 | - 'route' => 'registrations_report', |
|
| 107 | - 'extra_request' => [ |
|
| 108 | - 'EVT_ID' => isset($this->_req_data['event_id']) |
|
| 109 | - ? $this->_req_data['event_id'] |
|
| 110 | - : null, |
|
| 111 | - 'return_url' => $return_url, |
|
| 112 | - 'incude_checkins' => true, |
|
| 113 | - ], |
|
| 114 | - ], |
|
| 115 | - ]; |
|
| 116 | - } else { |
|
| 117 | - $this->_columns = [ |
|
| 118 | - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 119 | - '_REG_ID' => $ID_column_name, |
|
| 120 | - 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
|
| 121 | - '_REG_date' => esc_html__('TXN Date', 'event_espresso'), |
|
| 122 | - 'event_name' => esc_html__('Event', 'event_espresso'), |
|
| 123 | - 'DTT_EVT_start' => esc_html__('Event Date', 'event_espresso'), |
|
| 124 | - '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
| 125 | - '_REG_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 126 | - 'actions' => esc_html__('Actions', 'event_espresso'), |
|
| 127 | - ]; |
|
| 128 | - $this->_bottom_buttons = [ |
|
| 129 | - 'report_all' => [ |
|
| 130 | - 'route' => 'registrations_report', |
|
| 131 | - 'extra_request' => [ |
|
| 132 | - 'return_url' => $return_url, |
|
| 133 | - ], |
|
| 134 | - ], |
|
| 135 | - ]; |
|
| 136 | - } |
|
| 137 | - $this->_bottom_buttons['report_filtered'] = [ |
|
| 138 | - 'route' => 'registrations_report', |
|
| 139 | - 'extra_request' => [ |
|
| 140 | - 'use_filters' => true, |
|
| 141 | - 'incude_checkins' => isset($req_data['event_id']) ? true : false, |
|
| 142 | - 'return_url' => $return_url, |
|
| 143 | - ], |
|
| 144 | - ]; |
|
| 145 | - $filters = array_diff_key( |
|
| 146 | - $this->_req_data, |
|
| 147 | - array_flip( |
|
| 148 | - [ |
|
| 149 | - 'page', |
|
| 150 | - 'action', |
|
| 151 | - 'default_nonce', |
|
| 152 | - ] |
|
| 153 | - ) |
|
| 154 | - ); |
|
| 155 | - if (! empty($filters)) { |
|
| 156 | - $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters; |
|
| 157 | - } |
|
| 158 | - $this->_primary_column = '_REG_ID'; |
|
| 159 | - $this->_sortable_columns = [ |
|
| 160 | - '_REG_date' => ['_REG_date' => true], // true means its already sorted |
|
| 161 | - /** |
|
| 162 | - * Allows users to change the default sort if they wish. |
|
| 163 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last |
|
| 164 | - * name. |
|
| 165 | - */ |
|
| 166 | - 'ATT_fname' => [ |
|
| 167 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 168 | - true, |
|
| 169 | - $this, |
|
| 170 | - ] |
|
| 171 | - ? ['ATT_lname' => false] |
|
| 172 | - : ['ATT_fname' => false], |
|
| 173 | - 'event_name' => ['event_name' => false], |
|
| 174 | - 'DTT_EVT_start' => ['DTT_EVT_start' => false], |
|
| 175 | - '_REG_ID' => ['_REG_ID' => false], |
|
| 176 | - ]; |
|
| 177 | - $this->_hidden_columns = []; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * This simply sets up the row class for the table rows. |
|
| 183 | - * Allows for easier overriding of child methods for setting up sorting. |
|
| 184 | - * |
|
| 185 | - * @param EE_Registration $item the current item |
|
| 186 | - * @return string |
|
| 187 | - */ |
|
| 188 | - protected function _get_row_class($item) |
|
| 189 | - { |
|
| 190 | - $class = parent::_get_row_class($item); |
|
| 191 | - // add status class |
|
| 192 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 193 | - if ($this->_has_checkbox_column) { |
|
| 194 | - $class .= ' has-checkbox-column'; |
|
| 195 | - } |
|
| 196 | - return $class; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Set the $_transaction_details property if not set yet. |
|
| 202 | - * |
|
| 203 | - * @param EE_Registration $registration |
|
| 204 | - * @throws EE_Error |
|
| 205 | - * @throws InvalidArgumentException |
|
| 206 | - * @throws ReflectionException |
|
| 207 | - * @throws InvalidDataTypeException |
|
| 208 | - * @throws InvalidInterfaceException |
|
| 209 | - */ |
|
| 210 | - protected function _set_related_details(EE_Registration $registration) |
|
| 211 | - { |
|
| 212 | - $transaction = $registration->get_first_related('Transaction'); |
|
| 213 | - $status = $transaction instanceof EE_Transaction |
|
| 214 | - ? $transaction->status_ID() |
|
| 215 | - : EEM_Transaction::failed_status_code; |
|
| 216 | - $this->_transaction_details = [ |
|
| 217 | - 'transaction' => $transaction, |
|
| 218 | - 'status' => $status, |
|
| 219 | - 'id' => $transaction instanceof EE_Transaction |
|
| 220 | - ? $transaction->ID() |
|
| 221 | - : 0, |
|
| 222 | - 'title_attr' => sprintf( |
|
| 223 | - esc_html__('View Transaction Details (%s)', 'event_espresso'), |
|
| 224 | - EEH_Template::pretty_status($status, false, 'sentence') |
|
| 225 | - ), |
|
| 226 | - ]; |
|
| 227 | - try { |
|
| 228 | - $event = $registration->event(); |
|
| 229 | - } catch (EntityNotFoundException $e) { |
|
| 230 | - $event = null; |
|
| 231 | - } |
|
| 232 | - $status = $event instanceof EE_Event |
|
| 233 | - ? $event->get_active_status() |
|
| 234 | - : EE_Datetime::inactive; |
|
| 235 | - $this->_event_details = [ |
|
| 236 | - 'event' => $event, |
|
| 237 | - 'status' => $status, |
|
| 238 | - 'id' => $event instanceof EE_Event |
|
| 239 | - ? $event->ID() |
|
| 240 | - : 0, |
|
| 241 | - 'title_attr' => sprintf( |
|
| 242 | - esc_html__('Edit Event (%s)', 'event_espresso'), |
|
| 243 | - EEH_Template::pretty_status($status, false, 'sentence') |
|
| 244 | - ), |
|
| 245 | - ]; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * _get_table_filters |
|
| 251 | - * |
|
| 252 | - * @return array |
|
| 253 | - */ |
|
| 254 | - protected function _get_table_filters() |
|
| 255 | - { |
|
| 256 | - $filters = []; |
|
| 257 | - // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as |
|
| 258 | - // methods. |
|
| 259 | - $cur_date = isset($this->_req_data['month_range']) |
|
| 260 | - ? $this->_req_data['month_range'] |
|
| 261 | - : ''; |
|
| 262 | - $cur_category = isset($this->_req_data['EVT_CAT']) |
|
| 263 | - ? $this->_req_data['EVT_CAT'] |
|
| 264 | - : -1; |
|
| 265 | - $reg_status = isset($this->_req_data['_reg_status']) |
|
| 266 | - ? $this->_req_data['_reg_status'] |
|
| 267 | - : ''; |
|
| 268 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
| 269 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
| 270 | - $status = []; |
|
| 271 | - $status[] = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')]; |
|
| 272 | - foreach ($this->_status as $key => $value) { |
|
| 273 | - $status[] = ['id' => $key, 'text' => $value]; |
|
| 274 | - } |
|
| 275 | - if ($this->_view !== 'incomplete') { |
|
| 276 | - $filters[] = EEH_Form_Fields::select_input( |
|
| 277 | - '_reg_status', |
|
| 278 | - $status, |
|
| 279 | - isset($this->_req_data['_reg_status']) |
|
| 280 | - ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
| 281 | - : '' |
|
| 282 | - ); |
|
| 283 | - } |
|
| 284 | - if (isset($this->_req_data['event_id'])) { |
|
| 285 | - $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
| 286 | - } |
|
| 287 | - return $filters; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * @return void |
|
| 293 | - * @throws EE_Error |
|
| 294 | - * @throws InvalidArgumentException |
|
| 295 | - * @throws InvalidDataTypeException |
|
| 296 | - * @throws InvalidInterfaceException |
|
| 297 | - */ |
|
| 298 | - protected function _add_view_counts() |
|
| 299 | - { |
|
| 300 | - $this->_views['all']['count'] = $this->_total_registrations(); |
|
| 301 | - $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
| 302 | - $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
| 303 | - if ( |
|
| 304 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 305 | - 'ee_delete_registrations', |
|
| 306 | - 'espresso_registrations_trash_registrations' |
|
| 307 | - ) |
|
| 308 | - ) { |
|
| 309 | - $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
| 310 | - $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * @param string $view |
|
| 317 | - * @return int |
|
| 318 | - * @throws EE_Error |
|
| 319 | - * @throws InvalidArgumentException |
|
| 320 | - * @throws InvalidDataTypeException |
|
| 321 | - * @throws InvalidInterfaceException |
|
| 322 | - */ |
|
| 323 | - protected function _total_registrations($view = '') |
|
| 324 | - { |
|
| 325 | - $_where = []; |
|
| 326 | - $EVT_ID = isset($this->_req_data['event_id']) |
|
| 327 | - ? absint($this->_req_data['event_id']) |
|
| 328 | - : false; |
|
| 329 | - if ($EVT_ID) { |
|
| 330 | - $_where['EVT_ID'] = $EVT_ID; |
|
| 331 | - } |
|
| 332 | - switch ($view) { |
|
| 333 | - case 'trash': |
|
| 334 | - return EEM_Registration::instance()->count_deleted([$_where]); |
|
| 335 | - case 'incomplete': |
|
| 336 | - $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 337 | - break; |
|
| 338 | - default: |
|
| 339 | - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 340 | - } |
|
| 341 | - return EEM_Registration::instance()->count([$_where]); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * @return int |
|
| 347 | - * @throws EE_Error |
|
| 348 | - * @throws InvalidArgumentException |
|
| 349 | - * @throws InvalidDataTypeException |
|
| 350 | - * @throws InvalidInterfaceException |
|
| 351 | - */ |
|
| 352 | - protected function _total_registrations_this_month() |
|
| 353 | - { |
|
| 354 | - $EVT_ID = isset($this->_req_data['event_id']) |
|
| 355 | - ? absint($this->_req_data['event_id']) |
|
| 356 | - : false; |
|
| 357 | - $_where = $EVT_ID |
|
| 358 | - ? ['EVT_ID' => $EVT_ID] |
|
| 359 | - : []; |
|
| 360 | - $this_year_r = date('Y', current_time('timestamp')); |
|
| 361 | - $time_start = ' 00:00:00'; |
|
| 362 | - $time_end = ' 23:59:59'; |
|
| 363 | - $this_month_r = date('m', current_time('timestamp')); |
|
| 364 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 365 | - // setup date query. |
|
| 366 | - $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 367 | - 'REG_date', |
|
| 368 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 369 | - 'Y-m-d H:i:s' |
|
| 370 | - ); |
|
| 371 | - $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 372 | - 'REG_date', |
|
| 373 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 374 | - 'Y-m-d H:i:s' |
|
| 375 | - ); |
|
| 376 | - $_where['REG_date'] = [ |
|
| 377 | - 'BETWEEN', |
|
| 378 | - [ |
|
| 379 | - $beginning_string, |
|
| 380 | - $end_string, |
|
| 381 | - ], |
|
| 382 | - ]; |
|
| 383 | - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 384 | - return EEM_Registration::instance()->count([$_where]); |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * @return int |
|
| 390 | - * @throws EE_Error |
|
| 391 | - * @throws InvalidArgumentException |
|
| 392 | - * @throws InvalidDataTypeException |
|
| 393 | - * @throws InvalidInterfaceException |
|
| 394 | - */ |
|
| 395 | - protected function _total_registrations_today() |
|
| 396 | - { |
|
| 397 | - $EVT_ID = isset($this->_req_data['event_id']) |
|
| 398 | - ? absint($this->_req_data['event_id']) |
|
| 399 | - : false; |
|
| 400 | - $_where = $EVT_ID |
|
| 401 | - ? ['EVT_ID' => $EVT_ID] |
|
| 402 | - : []; |
|
| 403 | - $current_date = date('Y-m-d', current_time('timestamp')); |
|
| 404 | - $time_start = ' 00:00:00'; |
|
| 405 | - $time_end = ' 23:59:59'; |
|
| 406 | - $_where['REG_date'] = [ |
|
| 407 | - 'BETWEEN', |
|
| 408 | - [ |
|
| 409 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 410 | - 'REG_date', |
|
| 411 | - $current_date . $time_start, |
|
| 412 | - 'Y-m-d H:i:s' |
|
| 413 | - ), |
|
| 414 | - EEM_Registration::instance()->convert_datetime_for_query( |
|
| 415 | - 'REG_date', |
|
| 416 | - $current_date . $time_end, |
|
| 417 | - 'Y-m-d H:i:s' |
|
| 418 | - ), |
|
| 419 | - ], |
|
| 420 | - ]; |
|
| 421 | - $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 422 | - return EEM_Registration::instance()->count([$_where]); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - |
|
| 426 | - /** |
|
| 427 | - * @param EE_Registration $item |
|
| 428 | - * @return string |
|
| 429 | - * @throws EE_Error |
|
| 430 | - * @throws InvalidArgumentException |
|
| 431 | - * @throws InvalidDataTypeException |
|
| 432 | - * @throws InvalidInterfaceException |
|
| 433 | - * @throws ReflectionException |
|
| 434 | - */ |
|
| 435 | - public function column_cb($item) |
|
| 436 | - { |
|
| 437 | - /** checkbox/lock **/ |
|
| 438 | - $transaction = $item->get_first_related('Transaction'); |
|
| 439 | - $payment_count = $transaction instanceof EE_Transaction |
|
| 440 | - ? $transaction->count_related('Payment') |
|
| 441 | - : 0; |
|
| 442 | - return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can( |
|
| 443 | - 'ee_edit_registration', |
|
| 444 | - 'registration_list_table_checkbox_input', |
|
| 445 | - $item->ID() |
|
| 446 | - ) |
|
| 447 | - ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()) |
|
| 448 | - . '<span class="ee-lock-icon"></span>' |
|
| 449 | - : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()); |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * @param EE_Registration $item |
|
| 455 | - * @return string |
|
| 456 | - * @throws EE_Error |
|
| 457 | - * @throws InvalidArgumentException |
|
| 458 | - * @throws InvalidDataTypeException |
|
| 459 | - * @throws InvalidInterfaceException |
|
| 460 | - * @throws ReflectionException |
|
| 461 | - */ |
|
| 462 | - public function column__REG_ID(EE_Registration $item) |
|
| 463 | - { |
|
| 464 | - $attendee = $item->attendee(); |
|
| 465 | - $content = $item->ID(); |
|
| 466 | - $content .= '<div class="show-on-mobile-view-only">'; |
|
| 467 | - $content .= '<br>'; |
|
| 468 | - $content .= $attendee instanceof EE_Attendee |
|
| 469 | - ? $attendee->full_name() |
|
| 470 | - : ''; |
|
| 471 | - $content .= ' '; |
|
| 472 | - $content .= sprintf( |
|
| 473 | - esc_html__('(%1$s / %2$s)', 'event_espresso'), |
|
| 474 | - $item->count(), |
|
| 475 | - $item->group_size() |
|
| 476 | - ); |
|
| 477 | - $content .= '<br>'; |
|
| 478 | - $content .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 479 | - $content .= '</div>'; |
|
| 480 | - return $content; |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * @param EE_Registration $item |
|
| 486 | - * @return string |
|
| 487 | - * @throws EE_Error |
|
| 488 | - * @throws InvalidArgumentException |
|
| 489 | - * @throws InvalidDataTypeException |
|
| 490 | - * @throws InvalidInterfaceException |
|
| 491 | - * @throws ReflectionException |
|
| 492 | - */ |
|
| 493 | - public function column__REG_date(EE_Registration $item) |
|
| 494 | - { |
|
| 495 | - $this->_set_related_details($item); |
|
| 496 | - // Build row actions |
|
| 497 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 498 | - [ |
|
| 499 | - 'action' => 'view_transaction', |
|
| 500 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
| 501 | - ], |
|
| 502 | - TXN_ADMIN_URL |
|
| 503 | - ); |
|
| 504 | - $view_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 505 | - 'ee_read_transaction', |
|
| 506 | - 'espresso_transactions_view_transaction' |
|
| 507 | - ) |
|
| 508 | - ? '<a class="ee-status-color-' |
|
| 509 | - . $this->_transaction_details['status'] |
|
| 510 | - . '" href="' |
|
| 511 | - . $view_lnk_url |
|
| 512 | - . '" title="' |
|
| 513 | - . esc_attr($this->_transaction_details['title_attr']) |
|
| 514 | - . '">' |
|
| 515 | - . $item->get_i18n_datetime('REG_date') |
|
| 516 | - . '</a>' |
|
| 517 | - : $item->get_i18n_datetime('REG_date'); |
|
| 518 | - $view_link .= '<br><span class="ee-status-text-small">' |
|
| 519 | - . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
| 520 | - . '</span>'; |
|
| 521 | - return $view_link; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - |
|
| 525 | - /** |
|
| 526 | - * @param EE_Registration $item |
|
| 527 | - * @return string |
|
| 528 | - * @throws EE_Error |
|
| 529 | - * @throws InvalidArgumentException |
|
| 530 | - * @throws InvalidDataTypeException |
|
| 531 | - * @throws InvalidInterfaceException |
|
| 532 | - * @throws ReflectionException |
|
| 533 | - */ |
|
| 534 | - public function column_event_name(EE_Registration $item) |
|
| 535 | - { |
|
| 536 | - $this->_set_related_details($item); |
|
| 537 | - // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
| 538 | - $EVT_ID = $item->event_ID(); |
|
| 539 | - $event_name = $item->event_name(); |
|
| 540 | - $event_name = |
|
| 541 | - $event_name |
|
| 542 | - ?: esc_html__("No Associated Event", 'event_espresso'); |
|
| 543 | - $event_name = wp_trim_words($event_name, 30, '...'); |
|
| 544 | - if ($EVT_ID) { |
|
| 545 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 546 | - ['action' => 'edit', 'post' => $EVT_ID], |
|
| 547 | - EVENTS_ADMIN_URL |
|
| 548 | - ); |
|
| 549 | - $edit_event = |
|
| 550 | - EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
| 551 | - ? '<a class="ee-status-color-' |
|
| 552 | - . $this->_event_details['status'] |
|
| 553 | - . '" href="' |
|
| 554 | - . $edit_event_url |
|
| 555 | - . '" title="' |
|
| 556 | - . esc_attr($this->_event_details['title_attr']) |
|
| 557 | - . '">' |
|
| 558 | - . $event_name |
|
| 559 | - . '</a>' |
|
| 560 | - : $event_name; |
|
| 561 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL); |
|
| 562 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
| 563 | - $actions['event_filter'] .= sprintf( |
|
| 564 | - esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
|
| 565 | - $event_name |
|
| 566 | - ); |
|
| 567 | - $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>'; |
|
| 568 | - } else { |
|
| 569 | - $edit_event = $event_name; |
|
| 570 | - $actions['event_filter'] = ''; |
|
| 571 | - } |
|
| 572 | - return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * @param EE_Registration $item |
|
| 578 | - * @return string |
|
| 579 | - * @throws EE_Error |
|
| 580 | - * @throws InvalidArgumentException |
|
| 581 | - * @throws InvalidDataTypeException |
|
| 582 | - * @throws InvalidInterfaceException |
|
| 583 | - * @throws ReflectionException |
|
| 584 | - */ |
|
| 585 | - public function column_DTT_EVT_start(EE_Registration $item) |
|
| 586 | - { |
|
| 587 | - $datetime_strings = []; |
|
| 588 | - $ticket = $item->ticket(); |
|
| 589 | - if ($ticket instanceof EE_Ticket) { |
|
| 590 | - $remove_defaults = ['default_where_conditions' => 'none']; |
|
| 591 | - $datetimes = $ticket->datetimes($remove_defaults); |
|
| 592 | - foreach ($datetimes as $datetime) { |
|
| 593 | - $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 594 | - } |
|
| 595 | - return $this->generateDisplayForDatetimes($datetime_strings); |
|
| 596 | - } |
|
| 597 | - return esc_html__('There is no ticket on this registration', 'event_espresso'); |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - |
|
| 601 | - /** |
|
| 602 | - * Receives an array of datetime strings to display and converts them to the html container for the column. |
|
| 603 | - * |
|
| 604 | - * @param array $datetime_strings |
|
| 605 | - * @return string |
|
| 606 | - */ |
|
| 607 | - public function generateDisplayForDateTimes(array $datetime_strings) |
|
| 608 | - { |
|
| 609 | - $content = '<div class="ee-registration-event-datetimes-container">'; |
|
| 610 | - $expand_toggle = count($datetime_strings) > 1 |
|
| 611 | - ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso') |
|
| 612 | - . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>' |
|
| 613 | - : ''; |
|
| 614 | - // get first item for initial visibility |
|
| 615 | - $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>'; |
|
| 616 | - $content .= $expand_toggle; |
|
| 617 | - if ($datetime_strings) { |
|
| 618 | - $content .= '<div style="clear:both"></div>'; |
|
| 619 | - $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">'; |
|
| 620 | - $content .= implode("<br />", $datetime_strings); |
|
| 621 | - $content .= '</div>'; |
|
| 622 | - } |
|
| 623 | - $content .= '</div>'; |
|
| 624 | - return $content; |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - |
|
| 628 | - /** |
|
| 629 | - * @param EE_Registration $item |
|
| 630 | - * @return string |
|
| 631 | - * @throws EE_Error |
|
| 632 | - * @throws InvalidArgumentException |
|
| 633 | - * @throws InvalidDataTypeException |
|
| 634 | - * @throws InvalidInterfaceException |
|
| 635 | - * @throws ReflectionException |
|
| 636 | - */ |
|
| 637 | - public function column_ATT_fname(EE_Registration $item) |
|
| 638 | - { |
|
| 639 | - $attendee = $item->attendee(); |
|
| 640 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 641 | - [ |
|
| 642 | - 'action' => 'view_registration', |
|
| 643 | - '_REG_ID' => $item->ID(), |
|
| 644 | - ], |
|
| 645 | - REG_ADMIN_URL |
|
| 646 | - ); |
|
| 647 | - $attendee_name = $attendee instanceof EE_Attendee |
|
| 648 | - ? $attendee->full_name() |
|
| 649 | - : ''; |
|
| 650 | - $link = EE_Registry::instance()->CAP->current_user_can( |
|
| 651 | - 'ee_read_registration', |
|
| 652 | - 'espresso_registrations_view_registration', |
|
| 653 | - $item->ID() |
|
| 654 | - ) |
|
| 655 | - ? '<a href="' |
|
| 656 | - . $edit_lnk_url |
|
| 657 | - . '" title="' |
|
| 658 | - . esc_attr__('View Registration Details', 'event_espresso') |
|
| 659 | - . '">' |
|
| 660 | - . $attendee_name |
|
| 661 | - . '</a>' |
|
| 662 | - : $attendee_name; |
|
| 663 | - $link .= $item->count() === 1 |
|
| 664 | - ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' |
|
| 665 | - : ''; |
|
| 666 | - $t = $item->get_first_related('Transaction'); |
|
| 667 | - $payment_count = $t instanceof EE_Transaction |
|
| 668 | - ? $t->count_related('Payment') |
|
| 669 | - : 0; |
|
| 670 | - // append group count to name |
|
| 671 | - $link .= ' ' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 672 | - // append reg_code |
|
| 673 | - $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 674 | - // reg status text for accessibility |
|
| 675 | - $link .= '<br><span class="ee-status-text-small">' |
|
| 676 | - . EEH_Template::pretty_status($item->status_ID(), false, 'sentence') |
|
| 677 | - . '</span>'; |
|
| 678 | - $action = ['_REG_ID' => $item->ID()]; |
|
| 679 | - if (isset($this->_req_data['event_id'])) { |
|
| 680 | - $action['event_id'] = $item->event_ID(); |
|
| 681 | - } |
|
| 682 | - // trash/restore/delete actions |
|
| 683 | - $actions = []; |
|
| 684 | - if ( |
|
| 685 | - $this->_view !== 'trash' |
|
| 686 | - && $payment_count === 0 |
|
| 687 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 688 | - 'ee_delete_registration', |
|
| 689 | - 'espresso_registrations_trash_registrations', |
|
| 690 | - $item->ID() |
|
| 691 | - ) |
|
| 692 | - ) { |
|
| 693 | - $action['action'] = 'trash_registrations'; |
|
| 694 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 695 | - $action, |
|
| 696 | - REG_ADMIN_URL |
|
| 697 | - ); |
|
| 698 | - $actions['trash'] = '<a href="' |
|
| 699 | - . $trash_lnk_url |
|
| 700 | - . '" title="' |
|
| 701 | - . esc_attr__('Trash Registration', 'event_espresso') |
|
| 702 | - . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
| 703 | - } elseif ($this->_view === 'trash') { |
|
| 704 | - // restore registration link |
|
| 705 | - if ( |
|
| 706 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 707 | - 'ee_delete_registration', |
|
| 708 | - 'espresso_registrations_restore_registrations', |
|
| 709 | - $item->ID() |
|
| 710 | - ) |
|
| 711 | - ) { |
|
| 712 | - $action['action'] = 'restore_registrations'; |
|
| 713 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 714 | - $action, |
|
| 715 | - REG_ADMIN_URL |
|
| 716 | - ); |
|
| 717 | - $actions['restore'] = '<a href="' |
|
| 718 | - . $restore_lnk_url |
|
| 719 | - . '" title="' |
|
| 720 | - . esc_attr__('Restore Registration', 'event_espresso') . '">' |
|
| 721 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
| 722 | - } |
|
| 723 | - if ( |
|
| 724 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 725 | - 'ee_delete_registration', |
|
| 726 | - 'espresso_registrations_ee_delete_registrations', |
|
| 727 | - $item->ID() |
|
| 728 | - ) |
|
| 729 | - ) { |
|
| 730 | - $action['action'] = 'delete_registrations'; |
|
| 731 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 732 | - $action, |
|
| 733 | - REG_ADMIN_URL |
|
| 734 | - ); |
|
| 735 | - $actions['delete'] = '<a href="' |
|
| 736 | - . $delete_lnk_url |
|
| 737 | - . '" title="' |
|
| 738 | - . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
| 739 | - . '">' |
|
| 740 | - . esc_html__('Delete', 'event_espresso') |
|
| 741 | - . '</a>'; |
|
| 742 | - } |
|
| 743 | - } |
|
| 744 | - return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - |
|
| 748 | - /** |
|
| 749 | - * @param EE_Registration $item |
|
| 750 | - * @return string |
|
| 751 | - * @throws EE_Error |
|
| 752 | - * @throws InvalidArgumentException |
|
| 753 | - * @throws InvalidDataTypeException |
|
| 754 | - * @throws InvalidInterfaceException |
|
| 755 | - * @throws ReflectionException |
|
| 756 | - */ |
|
| 757 | - public function column_ATT_email(EE_Registration $item) |
|
| 758 | - { |
|
| 759 | - $attendee = $item->get_first_related('Attendee'); |
|
| 760 | - return ! $attendee instanceof EE_Attendee |
|
| 761 | - ? esc_html__('No attached contact record.', 'event_espresso') |
|
| 762 | - : $attendee->email(); |
|
| 763 | - } |
|
| 764 | - |
|
| 765 | - |
|
| 766 | - /** |
|
| 767 | - * @param EE_Registration $item |
|
| 768 | - * @return string |
|
| 769 | - */ |
|
| 770 | - public function column__REG_count(EE_Registration $item) |
|
| 771 | - { |
|
| 772 | - return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - |
|
| 776 | - /** |
|
| 777 | - * @param EE_Registration $item |
|
| 778 | - * @return string |
|
| 779 | - * @throws EE_Error |
|
| 780 | - * @throws ReflectionException |
|
| 781 | - */ |
|
| 782 | - public function column_PRC_amount(EE_Registration $item) |
|
| 783 | - { |
|
| 784 | - $ticket = $item->ticket(); |
|
| 785 | - $req_data = $this->_admin_page->get_request_data(); |
|
| 786 | - $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket |
|
| 787 | - ? '<span class="TKT_name">' . $ticket->name() . '</span><br />' |
|
| 788 | - : ''; |
|
| 789 | - if ($item->final_price() > 0) { |
|
| 790 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 791 | - } else { |
|
| 792 | - // free event |
|
| 793 | - $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
| 794 | - . esc_html__('free', 'event_espresso') |
|
| 795 | - . '</span>'; |
|
| 796 | - } |
|
| 797 | - return $content; |
|
| 798 | - } |
|
| 799 | - |
|
| 800 | - |
|
| 801 | - /** |
|
| 802 | - * @param EE_Registration $item |
|
| 803 | - * @return string |
|
| 804 | - * @throws EE_Error |
|
| 805 | - * @throws ReflectionException |
|
| 806 | - */ |
|
| 807 | - public function column__REG_final_price(EE_Registration $item) |
|
| 808 | - { |
|
| 809 | - $ticket = $item->ticket(); |
|
| 810 | - $req_data = $this->_admin_page->get_request_data(); |
|
| 811 | - $content = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket |
|
| 812 | - ? '' |
|
| 813 | - : '<span class="TKT_name">' . $ticket->name() . '</span><br />'; |
|
| 814 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 815 | - return $content; |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - |
|
| 819 | - /** |
|
| 820 | - * @param EE_Registration $item |
|
| 821 | - * @return string |
|
| 822 | - * @throws EE_Error |
|
| 823 | - */ |
|
| 824 | - public function column__REG_paid(EE_Registration $item) |
|
| 825 | - { |
|
| 826 | - $payment_method = $item->payment_method(); |
|
| 827 | - $payment_method_name = $payment_method instanceof EE_Payment_Method |
|
| 828 | - ? $payment_method->admin_name() |
|
| 829 | - : esc_html__('Unknown', 'event_espresso'); |
|
| 830 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
| 831 | - if ($item->paid() > 0) { |
|
| 832 | - $content .= '<br><span class="ee-status-text-small">' |
|
| 833 | - . sprintf( |
|
| 834 | - esc_html__('...via %s', 'event_espresso'), |
|
| 835 | - $payment_method_name |
|
| 836 | - ) |
|
| 837 | - . '</span>'; |
|
| 838 | - } |
|
| 839 | - return $content; |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - |
|
| 843 | - /** |
|
| 844 | - * @param EE_Registration $item |
|
| 845 | - * @return string |
|
| 846 | - * @throws EE_Error |
|
| 847 | - * @throws EntityNotFoundException |
|
| 848 | - * @throws InvalidArgumentException |
|
| 849 | - * @throws InvalidDataTypeException |
|
| 850 | - * @throws InvalidInterfaceException |
|
| 851 | - * @throws ReflectionException |
|
| 852 | - */ |
|
| 853 | - public function column_TXN_total(EE_Registration $item) |
|
| 854 | - { |
|
| 855 | - if ($item->transaction()) { |
|
| 856 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 857 | - [ |
|
| 858 | - 'action' => 'view_transaction', |
|
| 859 | - 'TXN_ID' => $item->transaction_ID(), |
|
| 860 | - ], |
|
| 861 | - TXN_ADMIN_URL |
|
| 862 | - ); |
|
| 863 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 864 | - 'ee_read_transaction', |
|
| 865 | - 'espresso_transactions_view_transaction', |
|
| 866 | - $item->transaction_ID() |
|
| 867 | - ) |
|
| 868 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
| 869 | - . $item->transaction()->status_ID() |
|
| 870 | - . '" href="' |
|
| 871 | - . $view_txn_lnk_url |
|
| 872 | - . '" title="' |
|
| 873 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 874 | - . '">' |
|
| 875 | - . $item->transaction()->pretty_total() |
|
| 876 | - . '</a></span>' |
|
| 877 | - : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
| 878 | - } else { |
|
| 879 | - return esc_html__("None", "event_espresso"); |
|
| 880 | - } |
|
| 881 | - } |
|
| 882 | - |
|
| 883 | - |
|
| 884 | - /** |
|
| 885 | - * @param EE_Registration $item |
|
| 886 | - * @return string |
|
| 887 | - * @throws EE_Error |
|
| 888 | - * @throws EntityNotFoundException |
|
| 889 | - * @throws InvalidArgumentException |
|
| 890 | - * @throws InvalidDataTypeException |
|
| 891 | - * @throws InvalidInterfaceException |
|
| 892 | - * @throws ReflectionException |
|
| 893 | - */ |
|
| 894 | - public function column_TXN_paid(EE_Registration $item) |
|
| 895 | - { |
|
| 896 | - if ($item->count() === 1) { |
|
| 897 | - $transaction = $item->transaction() |
|
| 898 | - ? $item->transaction() |
|
| 899 | - : EE_Transaction::new_instance(); |
|
| 900 | - if ($transaction->paid() >= $transaction->total()) { |
|
| 901 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 902 | - } else { |
|
| 903 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 904 | - [ |
|
| 905 | - 'action' => 'view_transaction', |
|
| 906 | - 'TXN_ID' => $item->transaction_ID(), |
|
| 907 | - ], |
|
| 908 | - TXN_ADMIN_URL |
|
| 909 | - ); |
|
| 910 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 911 | - 'ee_read_transaction', |
|
| 912 | - 'espresso_transactions_view_transaction', |
|
| 913 | - $item->transaction_ID() |
|
| 914 | - ) |
|
| 915 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
| 916 | - . $transaction->status_ID() |
|
| 917 | - . '" href="' |
|
| 918 | - . $view_txn_lnk_url |
|
| 919 | - . '" title="' |
|
| 920 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 921 | - . '">' |
|
| 922 | - . $item->transaction()->pretty_paid() |
|
| 923 | - . '</a><span>' |
|
| 924 | - : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 925 | - } |
|
| 926 | - } |
|
| 927 | - return ' '; |
|
| 928 | - } |
|
| 929 | - |
|
| 930 | - |
|
| 931 | - /** |
|
| 932 | - * column_actions |
|
| 933 | - * |
|
| 934 | - * @param EE_Registration $item |
|
| 935 | - * @return string |
|
| 936 | - * @throws EE_Error |
|
| 937 | - * @throws InvalidArgumentException |
|
| 938 | - * @throws InvalidDataTypeException |
|
| 939 | - * @throws InvalidInterfaceException |
|
| 940 | - * @throws ReflectionException |
|
| 941 | - */ |
|
| 942 | - public function column_actions(EE_Registration $item) |
|
| 943 | - { |
|
| 944 | - $actions = []; |
|
| 945 | - $attendee = $item->attendee(); |
|
| 946 | - $this->_set_related_details($item); |
|
| 947 | - |
|
| 948 | - // Build row actions |
|
| 949 | - if ( |
|
| 950 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 951 | - 'ee_read_registration', |
|
| 952 | - 'espresso_registrations_view_registration', |
|
| 953 | - $item->ID() |
|
| 954 | - ) |
|
| 955 | - ) { |
|
| 956 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 957 | - [ |
|
| 958 | - 'action' => 'view_registration', |
|
| 959 | - '_REG_ID' => $item->ID(), |
|
| 960 | - ], |
|
| 961 | - REG_ADMIN_URL |
|
| 962 | - ); |
|
| 963 | - $actions['view_lnk'] = ' |
|
| 18 | + /** |
|
| 19 | + * @var Registrations_Admin_Page |
|
| 20 | + */ |
|
| 21 | + protected $_admin_page; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | + private $_status; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * An array of transaction details for the related transaction to the registration being processed. |
|
| 30 | + * This is set via the _set_related_details method. |
|
| 31 | + * |
|
| 32 | + * @var array |
|
| 33 | + */ |
|
| 34 | + protected $_transaction_details = []; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * An array of event details for the related event to the registration being processed. |
|
| 38 | + * This is set via the _set_related_details method. |
|
| 39 | + * |
|
| 40 | + * @var array |
|
| 41 | + */ |
|
| 42 | + protected $_event_details = []; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @param Registrations_Admin_Page $admin_page |
|
| 47 | + */ |
|
| 48 | + public function __construct(Registrations_Admin_Page $admin_page) |
|
| 49 | + { |
|
| 50 | + $req_data = $admin_page->get_request_data(); |
|
| 51 | + if (! empty($req_data['event_id'])) { |
|
| 52 | + $extra_query_args = []; |
|
| 53 | + foreach ($admin_page->get_views() as $view_details) { |
|
| 54 | + $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']]; |
|
| 55 | + } |
|
| 56 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
| 57 | + } |
|
| 58 | + parent::__construct($admin_page); |
|
| 59 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @return void |
|
| 65 | + * @throws EE_Error |
|
| 66 | + */ |
|
| 67 | + protected function _setup_data() |
|
| 68 | + { |
|
| 69 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
| 70 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @return void |
|
| 76 | + */ |
|
| 77 | + protected function _set_properties() |
|
| 78 | + { |
|
| 79 | + $return_url = $this->getReturnUrl(); |
|
| 80 | + $this->_wp_list_args = [ |
|
| 81 | + 'singular' => esc_html__('registration', 'event_espresso'), |
|
| 82 | + 'plural' => esc_html__('registrations', 'event_espresso'), |
|
| 83 | + 'ajax' => true, |
|
| 84 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 85 | + ]; |
|
| 86 | + $ID_column_name = esc_html__('ID', 'event_espresso'); |
|
| 87 | + $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
| 88 | + $ID_column_name .= esc_html__('Registrant Name', 'event_espresso'); |
|
| 89 | + $ID_column_name .= '</span> '; |
|
| 90 | + $req_data = $this->_admin_page->get_request_data(); |
|
| 91 | + if (isset($req_data['event_id'])) { |
|
| 92 | + $this->_columns = [ |
|
| 93 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 94 | + '_REG_ID' => $ID_column_name, |
|
| 95 | + 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
|
| 96 | + 'ATT_email' => esc_html__('Email', 'event_espresso'), |
|
| 97 | + '_REG_date' => esc_html__('Reg Date', 'event_espresso'), |
|
| 98 | + 'PRC_amount' => esc_html__('TKT Price', 'event_espresso'), |
|
| 99 | + '_REG_final_price' => esc_html__('Final Price', 'event_espresso'), |
|
| 100 | + 'TXN_total' => esc_html__('Total Txn', 'event_espresso'), |
|
| 101 | + 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 102 | + 'actions' => esc_html__('Actions', 'event_espresso'), |
|
| 103 | + ]; |
|
| 104 | + $this->_bottom_buttons = [ |
|
| 105 | + 'report' => [ |
|
| 106 | + 'route' => 'registrations_report', |
|
| 107 | + 'extra_request' => [ |
|
| 108 | + 'EVT_ID' => isset($this->_req_data['event_id']) |
|
| 109 | + ? $this->_req_data['event_id'] |
|
| 110 | + : null, |
|
| 111 | + 'return_url' => $return_url, |
|
| 112 | + 'incude_checkins' => true, |
|
| 113 | + ], |
|
| 114 | + ], |
|
| 115 | + ]; |
|
| 116 | + } else { |
|
| 117 | + $this->_columns = [ |
|
| 118 | + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text |
|
| 119 | + '_REG_ID' => $ID_column_name, |
|
| 120 | + 'ATT_fname' => esc_html__('Name', 'event_espresso'), |
|
| 121 | + '_REG_date' => esc_html__('TXN Date', 'event_espresso'), |
|
| 122 | + 'event_name' => esc_html__('Event', 'event_espresso'), |
|
| 123 | + 'DTT_EVT_start' => esc_html__('Event Date', 'event_espresso'), |
|
| 124 | + '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
| 125 | + '_REG_paid' => esc_html__('Paid', 'event_espresso'), |
|
| 126 | + 'actions' => esc_html__('Actions', 'event_espresso'), |
|
| 127 | + ]; |
|
| 128 | + $this->_bottom_buttons = [ |
|
| 129 | + 'report_all' => [ |
|
| 130 | + 'route' => 'registrations_report', |
|
| 131 | + 'extra_request' => [ |
|
| 132 | + 'return_url' => $return_url, |
|
| 133 | + ], |
|
| 134 | + ], |
|
| 135 | + ]; |
|
| 136 | + } |
|
| 137 | + $this->_bottom_buttons['report_filtered'] = [ |
|
| 138 | + 'route' => 'registrations_report', |
|
| 139 | + 'extra_request' => [ |
|
| 140 | + 'use_filters' => true, |
|
| 141 | + 'incude_checkins' => isset($req_data['event_id']) ? true : false, |
|
| 142 | + 'return_url' => $return_url, |
|
| 143 | + ], |
|
| 144 | + ]; |
|
| 145 | + $filters = array_diff_key( |
|
| 146 | + $this->_req_data, |
|
| 147 | + array_flip( |
|
| 148 | + [ |
|
| 149 | + 'page', |
|
| 150 | + 'action', |
|
| 151 | + 'default_nonce', |
|
| 152 | + ] |
|
| 153 | + ) |
|
| 154 | + ); |
|
| 155 | + if (! empty($filters)) { |
|
| 156 | + $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters; |
|
| 157 | + } |
|
| 158 | + $this->_primary_column = '_REG_ID'; |
|
| 159 | + $this->_sortable_columns = [ |
|
| 160 | + '_REG_date' => ['_REG_date' => true], // true means its already sorted |
|
| 161 | + /** |
|
| 162 | + * Allows users to change the default sort if they wish. |
|
| 163 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last |
|
| 164 | + * name. |
|
| 165 | + */ |
|
| 166 | + 'ATT_fname' => [ |
|
| 167 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 168 | + true, |
|
| 169 | + $this, |
|
| 170 | + ] |
|
| 171 | + ? ['ATT_lname' => false] |
|
| 172 | + : ['ATT_fname' => false], |
|
| 173 | + 'event_name' => ['event_name' => false], |
|
| 174 | + 'DTT_EVT_start' => ['DTT_EVT_start' => false], |
|
| 175 | + '_REG_ID' => ['_REG_ID' => false], |
|
| 176 | + ]; |
|
| 177 | + $this->_hidden_columns = []; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * This simply sets up the row class for the table rows. |
|
| 183 | + * Allows for easier overriding of child methods for setting up sorting. |
|
| 184 | + * |
|
| 185 | + * @param EE_Registration $item the current item |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 188 | + protected function _get_row_class($item) |
|
| 189 | + { |
|
| 190 | + $class = parent::_get_row_class($item); |
|
| 191 | + // add status class |
|
| 192 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 193 | + if ($this->_has_checkbox_column) { |
|
| 194 | + $class .= ' has-checkbox-column'; |
|
| 195 | + } |
|
| 196 | + return $class; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Set the $_transaction_details property if not set yet. |
|
| 202 | + * |
|
| 203 | + * @param EE_Registration $registration |
|
| 204 | + * @throws EE_Error |
|
| 205 | + * @throws InvalidArgumentException |
|
| 206 | + * @throws ReflectionException |
|
| 207 | + * @throws InvalidDataTypeException |
|
| 208 | + * @throws InvalidInterfaceException |
|
| 209 | + */ |
|
| 210 | + protected function _set_related_details(EE_Registration $registration) |
|
| 211 | + { |
|
| 212 | + $transaction = $registration->get_first_related('Transaction'); |
|
| 213 | + $status = $transaction instanceof EE_Transaction |
|
| 214 | + ? $transaction->status_ID() |
|
| 215 | + : EEM_Transaction::failed_status_code; |
|
| 216 | + $this->_transaction_details = [ |
|
| 217 | + 'transaction' => $transaction, |
|
| 218 | + 'status' => $status, |
|
| 219 | + 'id' => $transaction instanceof EE_Transaction |
|
| 220 | + ? $transaction->ID() |
|
| 221 | + : 0, |
|
| 222 | + 'title_attr' => sprintf( |
|
| 223 | + esc_html__('View Transaction Details (%s)', 'event_espresso'), |
|
| 224 | + EEH_Template::pretty_status($status, false, 'sentence') |
|
| 225 | + ), |
|
| 226 | + ]; |
|
| 227 | + try { |
|
| 228 | + $event = $registration->event(); |
|
| 229 | + } catch (EntityNotFoundException $e) { |
|
| 230 | + $event = null; |
|
| 231 | + } |
|
| 232 | + $status = $event instanceof EE_Event |
|
| 233 | + ? $event->get_active_status() |
|
| 234 | + : EE_Datetime::inactive; |
|
| 235 | + $this->_event_details = [ |
|
| 236 | + 'event' => $event, |
|
| 237 | + 'status' => $status, |
|
| 238 | + 'id' => $event instanceof EE_Event |
|
| 239 | + ? $event->ID() |
|
| 240 | + : 0, |
|
| 241 | + 'title_attr' => sprintf( |
|
| 242 | + esc_html__('Edit Event (%s)', 'event_espresso'), |
|
| 243 | + EEH_Template::pretty_status($status, false, 'sentence') |
|
| 244 | + ), |
|
| 245 | + ]; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * _get_table_filters |
|
| 251 | + * |
|
| 252 | + * @return array |
|
| 253 | + */ |
|
| 254 | + protected function _get_table_filters() |
|
| 255 | + { |
|
| 256 | + $filters = []; |
|
| 257 | + // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as |
|
| 258 | + // methods. |
|
| 259 | + $cur_date = isset($this->_req_data['month_range']) |
|
| 260 | + ? $this->_req_data['month_range'] |
|
| 261 | + : ''; |
|
| 262 | + $cur_category = isset($this->_req_data['EVT_CAT']) |
|
| 263 | + ? $this->_req_data['EVT_CAT'] |
|
| 264 | + : -1; |
|
| 265 | + $reg_status = isset($this->_req_data['_reg_status']) |
|
| 266 | + ? $this->_req_data['_reg_status'] |
|
| 267 | + : ''; |
|
| 268 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
| 269 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
| 270 | + $status = []; |
|
| 271 | + $status[] = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')]; |
|
| 272 | + foreach ($this->_status as $key => $value) { |
|
| 273 | + $status[] = ['id' => $key, 'text' => $value]; |
|
| 274 | + } |
|
| 275 | + if ($this->_view !== 'incomplete') { |
|
| 276 | + $filters[] = EEH_Form_Fields::select_input( |
|
| 277 | + '_reg_status', |
|
| 278 | + $status, |
|
| 279 | + isset($this->_req_data['_reg_status']) |
|
| 280 | + ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
| 281 | + : '' |
|
| 282 | + ); |
|
| 283 | + } |
|
| 284 | + if (isset($this->_req_data['event_id'])) { |
|
| 285 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
| 286 | + } |
|
| 287 | + return $filters; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * @return void |
|
| 293 | + * @throws EE_Error |
|
| 294 | + * @throws InvalidArgumentException |
|
| 295 | + * @throws InvalidDataTypeException |
|
| 296 | + * @throws InvalidInterfaceException |
|
| 297 | + */ |
|
| 298 | + protected function _add_view_counts() |
|
| 299 | + { |
|
| 300 | + $this->_views['all']['count'] = $this->_total_registrations(); |
|
| 301 | + $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
| 302 | + $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
| 303 | + if ( |
|
| 304 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 305 | + 'ee_delete_registrations', |
|
| 306 | + 'espresso_registrations_trash_registrations' |
|
| 307 | + ) |
|
| 308 | + ) { |
|
| 309 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
| 310 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * @param string $view |
|
| 317 | + * @return int |
|
| 318 | + * @throws EE_Error |
|
| 319 | + * @throws InvalidArgumentException |
|
| 320 | + * @throws InvalidDataTypeException |
|
| 321 | + * @throws InvalidInterfaceException |
|
| 322 | + */ |
|
| 323 | + protected function _total_registrations($view = '') |
|
| 324 | + { |
|
| 325 | + $_where = []; |
|
| 326 | + $EVT_ID = isset($this->_req_data['event_id']) |
|
| 327 | + ? absint($this->_req_data['event_id']) |
|
| 328 | + : false; |
|
| 329 | + if ($EVT_ID) { |
|
| 330 | + $_where['EVT_ID'] = $EVT_ID; |
|
| 331 | + } |
|
| 332 | + switch ($view) { |
|
| 333 | + case 'trash': |
|
| 334 | + return EEM_Registration::instance()->count_deleted([$_where]); |
|
| 335 | + case 'incomplete': |
|
| 336 | + $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 337 | + break; |
|
| 338 | + default: |
|
| 339 | + $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 340 | + } |
|
| 341 | + return EEM_Registration::instance()->count([$_where]); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * @return int |
|
| 347 | + * @throws EE_Error |
|
| 348 | + * @throws InvalidArgumentException |
|
| 349 | + * @throws InvalidDataTypeException |
|
| 350 | + * @throws InvalidInterfaceException |
|
| 351 | + */ |
|
| 352 | + protected function _total_registrations_this_month() |
|
| 353 | + { |
|
| 354 | + $EVT_ID = isset($this->_req_data['event_id']) |
|
| 355 | + ? absint($this->_req_data['event_id']) |
|
| 356 | + : false; |
|
| 357 | + $_where = $EVT_ID |
|
| 358 | + ? ['EVT_ID' => $EVT_ID] |
|
| 359 | + : []; |
|
| 360 | + $this_year_r = date('Y', current_time('timestamp')); |
|
| 361 | + $time_start = ' 00:00:00'; |
|
| 362 | + $time_end = ' 23:59:59'; |
|
| 363 | + $this_month_r = date('m', current_time('timestamp')); |
|
| 364 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 365 | + // setup date query. |
|
| 366 | + $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 367 | + 'REG_date', |
|
| 368 | + $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 369 | + 'Y-m-d H:i:s' |
|
| 370 | + ); |
|
| 371 | + $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
|
| 372 | + 'REG_date', |
|
| 373 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 374 | + 'Y-m-d H:i:s' |
|
| 375 | + ); |
|
| 376 | + $_where['REG_date'] = [ |
|
| 377 | + 'BETWEEN', |
|
| 378 | + [ |
|
| 379 | + $beginning_string, |
|
| 380 | + $end_string, |
|
| 381 | + ], |
|
| 382 | + ]; |
|
| 383 | + $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 384 | + return EEM_Registration::instance()->count([$_where]); |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * @return int |
|
| 390 | + * @throws EE_Error |
|
| 391 | + * @throws InvalidArgumentException |
|
| 392 | + * @throws InvalidDataTypeException |
|
| 393 | + * @throws InvalidInterfaceException |
|
| 394 | + */ |
|
| 395 | + protected function _total_registrations_today() |
|
| 396 | + { |
|
| 397 | + $EVT_ID = isset($this->_req_data['event_id']) |
|
| 398 | + ? absint($this->_req_data['event_id']) |
|
| 399 | + : false; |
|
| 400 | + $_where = $EVT_ID |
|
| 401 | + ? ['EVT_ID' => $EVT_ID] |
|
| 402 | + : []; |
|
| 403 | + $current_date = date('Y-m-d', current_time('timestamp')); |
|
| 404 | + $time_start = ' 00:00:00'; |
|
| 405 | + $time_end = ' 23:59:59'; |
|
| 406 | + $_where['REG_date'] = [ |
|
| 407 | + 'BETWEEN', |
|
| 408 | + [ |
|
| 409 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 410 | + 'REG_date', |
|
| 411 | + $current_date . $time_start, |
|
| 412 | + 'Y-m-d H:i:s' |
|
| 413 | + ), |
|
| 414 | + EEM_Registration::instance()->convert_datetime_for_query( |
|
| 415 | + 'REG_date', |
|
| 416 | + $current_date . $time_end, |
|
| 417 | + 'Y-m-d H:i:s' |
|
| 418 | + ), |
|
| 419 | + ], |
|
| 420 | + ]; |
|
| 421 | + $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete]; |
|
| 422 | + return EEM_Registration::instance()->count([$_where]); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + |
|
| 426 | + /** |
|
| 427 | + * @param EE_Registration $item |
|
| 428 | + * @return string |
|
| 429 | + * @throws EE_Error |
|
| 430 | + * @throws InvalidArgumentException |
|
| 431 | + * @throws InvalidDataTypeException |
|
| 432 | + * @throws InvalidInterfaceException |
|
| 433 | + * @throws ReflectionException |
|
| 434 | + */ |
|
| 435 | + public function column_cb($item) |
|
| 436 | + { |
|
| 437 | + /** checkbox/lock **/ |
|
| 438 | + $transaction = $item->get_first_related('Transaction'); |
|
| 439 | + $payment_count = $transaction instanceof EE_Transaction |
|
| 440 | + ? $transaction->count_related('Payment') |
|
| 441 | + : 0; |
|
| 442 | + return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can( |
|
| 443 | + 'ee_edit_registration', |
|
| 444 | + 'registration_list_table_checkbox_input', |
|
| 445 | + $item->ID() |
|
| 446 | + ) |
|
| 447 | + ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()) |
|
| 448 | + . '<span class="ee-lock-icon"></span>' |
|
| 449 | + : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID()); |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * @param EE_Registration $item |
|
| 455 | + * @return string |
|
| 456 | + * @throws EE_Error |
|
| 457 | + * @throws InvalidArgumentException |
|
| 458 | + * @throws InvalidDataTypeException |
|
| 459 | + * @throws InvalidInterfaceException |
|
| 460 | + * @throws ReflectionException |
|
| 461 | + */ |
|
| 462 | + public function column__REG_ID(EE_Registration $item) |
|
| 463 | + { |
|
| 464 | + $attendee = $item->attendee(); |
|
| 465 | + $content = $item->ID(); |
|
| 466 | + $content .= '<div class="show-on-mobile-view-only">'; |
|
| 467 | + $content .= '<br>'; |
|
| 468 | + $content .= $attendee instanceof EE_Attendee |
|
| 469 | + ? $attendee->full_name() |
|
| 470 | + : ''; |
|
| 471 | + $content .= ' '; |
|
| 472 | + $content .= sprintf( |
|
| 473 | + esc_html__('(%1$s / %2$s)', 'event_espresso'), |
|
| 474 | + $item->count(), |
|
| 475 | + $item->group_size() |
|
| 476 | + ); |
|
| 477 | + $content .= '<br>'; |
|
| 478 | + $content .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 479 | + $content .= '</div>'; |
|
| 480 | + return $content; |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * @param EE_Registration $item |
|
| 486 | + * @return string |
|
| 487 | + * @throws EE_Error |
|
| 488 | + * @throws InvalidArgumentException |
|
| 489 | + * @throws InvalidDataTypeException |
|
| 490 | + * @throws InvalidInterfaceException |
|
| 491 | + * @throws ReflectionException |
|
| 492 | + */ |
|
| 493 | + public function column__REG_date(EE_Registration $item) |
|
| 494 | + { |
|
| 495 | + $this->_set_related_details($item); |
|
| 496 | + // Build row actions |
|
| 497 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 498 | + [ |
|
| 499 | + 'action' => 'view_transaction', |
|
| 500 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
| 501 | + ], |
|
| 502 | + TXN_ADMIN_URL |
|
| 503 | + ); |
|
| 504 | + $view_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 505 | + 'ee_read_transaction', |
|
| 506 | + 'espresso_transactions_view_transaction' |
|
| 507 | + ) |
|
| 508 | + ? '<a class="ee-status-color-' |
|
| 509 | + . $this->_transaction_details['status'] |
|
| 510 | + . '" href="' |
|
| 511 | + . $view_lnk_url |
|
| 512 | + . '" title="' |
|
| 513 | + . esc_attr($this->_transaction_details['title_attr']) |
|
| 514 | + . '">' |
|
| 515 | + . $item->get_i18n_datetime('REG_date') |
|
| 516 | + . '</a>' |
|
| 517 | + : $item->get_i18n_datetime('REG_date'); |
|
| 518 | + $view_link .= '<br><span class="ee-status-text-small">' |
|
| 519 | + . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
| 520 | + . '</span>'; |
|
| 521 | + return $view_link; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + |
|
| 525 | + /** |
|
| 526 | + * @param EE_Registration $item |
|
| 527 | + * @return string |
|
| 528 | + * @throws EE_Error |
|
| 529 | + * @throws InvalidArgumentException |
|
| 530 | + * @throws InvalidDataTypeException |
|
| 531 | + * @throws InvalidInterfaceException |
|
| 532 | + * @throws ReflectionException |
|
| 533 | + */ |
|
| 534 | + public function column_event_name(EE_Registration $item) |
|
| 535 | + { |
|
| 536 | + $this->_set_related_details($item); |
|
| 537 | + // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
| 538 | + $EVT_ID = $item->event_ID(); |
|
| 539 | + $event_name = $item->event_name(); |
|
| 540 | + $event_name = |
|
| 541 | + $event_name |
|
| 542 | + ?: esc_html__("No Associated Event", 'event_espresso'); |
|
| 543 | + $event_name = wp_trim_words($event_name, 30, '...'); |
|
| 544 | + if ($EVT_ID) { |
|
| 545 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 546 | + ['action' => 'edit', 'post' => $EVT_ID], |
|
| 547 | + EVENTS_ADMIN_URL |
|
| 548 | + ); |
|
| 549 | + $edit_event = |
|
| 550 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
| 551 | + ? '<a class="ee-status-color-' |
|
| 552 | + . $this->_event_details['status'] |
|
| 553 | + . '" href="' |
|
| 554 | + . $edit_event_url |
|
| 555 | + . '" title="' |
|
| 556 | + . esc_attr($this->_event_details['title_attr']) |
|
| 557 | + . '">' |
|
| 558 | + . $event_name |
|
| 559 | + . '</a>' |
|
| 560 | + : $event_name; |
|
| 561 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL); |
|
| 562 | + $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
| 563 | + $actions['event_filter'] .= sprintf( |
|
| 564 | + esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), |
|
| 565 | + $event_name |
|
| 566 | + ); |
|
| 567 | + $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>'; |
|
| 568 | + } else { |
|
| 569 | + $edit_event = $event_name; |
|
| 570 | + $actions['event_filter'] = ''; |
|
| 571 | + } |
|
| 572 | + return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * @param EE_Registration $item |
|
| 578 | + * @return string |
|
| 579 | + * @throws EE_Error |
|
| 580 | + * @throws InvalidArgumentException |
|
| 581 | + * @throws InvalidDataTypeException |
|
| 582 | + * @throws InvalidInterfaceException |
|
| 583 | + * @throws ReflectionException |
|
| 584 | + */ |
|
| 585 | + public function column_DTT_EVT_start(EE_Registration $item) |
|
| 586 | + { |
|
| 587 | + $datetime_strings = []; |
|
| 588 | + $ticket = $item->ticket(); |
|
| 589 | + if ($ticket instanceof EE_Ticket) { |
|
| 590 | + $remove_defaults = ['default_where_conditions' => 'none']; |
|
| 591 | + $datetimes = $ticket->datetimes($remove_defaults); |
|
| 592 | + foreach ($datetimes as $datetime) { |
|
| 593 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 594 | + } |
|
| 595 | + return $this->generateDisplayForDatetimes($datetime_strings); |
|
| 596 | + } |
|
| 597 | + return esc_html__('There is no ticket on this registration', 'event_espresso'); |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + |
|
| 601 | + /** |
|
| 602 | + * Receives an array of datetime strings to display and converts them to the html container for the column. |
|
| 603 | + * |
|
| 604 | + * @param array $datetime_strings |
|
| 605 | + * @return string |
|
| 606 | + */ |
|
| 607 | + public function generateDisplayForDateTimes(array $datetime_strings) |
|
| 608 | + { |
|
| 609 | + $content = '<div class="ee-registration-event-datetimes-container">'; |
|
| 610 | + $expand_toggle = count($datetime_strings) > 1 |
|
| 611 | + ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso') |
|
| 612 | + . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>' |
|
| 613 | + : ''; |
|
| 614 | + // get first item for initial visibility |
|
| 615 | + $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>'; |
|
| 616 | + $content .= $expand_toggle; |
|
| 617 | + if ($datetime_strings) { |
|
| 618 | + $content .= '<div style="clear:both"></div>'; |
|
| 619 | + $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">'; |
|
| 620 | + $content .= implode("<br />", $datetime_strings); |
|
| 621 | + $content .= '</div>'; |
|
| 622 | + } |
|
| 623 | + $content .= '</div>'; |
|
| 624 | + return $content; |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + |
|
| 628 | + /** |
|
| 629 | + * @param EE_Registration $item |
|
| 630 | + * @return string |
|
| 631 | + * @throws EE_Error |
|
| 632 | + * @throws InvalidArgumentException |
|
| 633 | + * @throws InvalidDataTypeException |
|
| 634 | + * @throws InvalidInterfaceException |
|
| 635 | + * @throws ReflectionException |
|
| 636 | + */ |
|
| 637 | + public function column_ATT_fname(EE_Registration $item) |
|
| 638 | + { |
|
| 639 | + $attendee = $item->attendee(); |
|
| 640 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 641 | + [ |
|
| 642 | + 'action' => 'view_registration', |
|
| 643 | + '_REG_ID' => $item->ID(), |
|
| 644 | + ], |
|
| 645 | + REG_ADMIN_URL |
|
| 646 | + ); |
|
| 647 | + $attendee_name = $attendee instanceof EE_Attendee |
|
| 648 | + ? $attendee->full_name() |
|
| 649 | + : ''; |
|
| 650 | + $link = EE_Registry::instance()->CAP->current_user_can( |
|
| 651 | + 'ee_read_registration', |
|
| 652 | + 'espresso_registrations_view_registration', |
|
| 653 | + $item->ID() |
|
| 654 | + ) |
|
| 655 | + ? '<a href="' |
|
| 656 | + . $edit_lnk_url |
|
| 657 | + . '" title="' |
|
| 658 | + . esc_attr__('View Registration Details', 'event_espresso') |
|
| 659 | + . '">' |
|
| 660 | + . $attendee_name |
|
| 661 | + . '</a>' |
|
| 662 | + : $attendee_name; |
|
| 663 | + $link .= $item->count() === 1 |
|
| 664 | + ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' |
|
| 665 | + : ''; |
|
| 666 | + $t = $item->get_first_related('Transaction'); |
|
| 667 | + $payment_count = $t instanceof EE_Transaction |
|
| 668 | + ? $t->count_related('Payment') |
|
| 669 | + : 0; |
|
| 670 | + // append group count to name |
|
| 671 | + $link .= ' ' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 672 | + // append reg_code |
|
| 673 | + $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 674 | + // reg status text for accessibility |
|
| 675 | + $link .= '<br><span class="ee-status-text-small">' |
|
| 676 | + . EEH_Template::pretty_status($item->status_ID(), false, 'sentence') |
|
| 677 | + . '</span>'; |
|
| 678 | + $action = ['_REG_ID' => $item->ID()]; |
|
| 679 | + if (isset($this->_req_data['event_id'])) { |
|
| 680 | + $action['event_id'] = $item->event_ID(); |
|
| 681 | + } |
|
| 682 | + // trash/restore/delete actions |
|
| 683 | + $actions = []; |
|
| 684 | + if ( |
|
| 685 | + $this->_view !== 'trash' |
|
| 686 | + && $payment_count === 0 |
|
| 687 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 688 | + 'ee_delete_registration', |
|
| 689 | + 'espresso_registrations_trash_registrations', |
|
| 690 | + $item->ID() |
|
| 691 | + ) |
|
| 692 | + ) { |
|
| 693 | + $action['action'] = 'trash_registrations'; |
|
| 694 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 695 | + $action, |
|
| 696 | + REG_ADMIN_URL |
|
| 697 | + ); |
|
| 698 | + $actions['trash'] = '<a href="' |
|
| 699 | + . $trash_lnk_url |
|
| 700 | + . '" title="' |
|
| 701 | + . esc_attr__('Trash Registration', 'event_espresso') |
|
| 702 | + . '">' . esc_html__('Trash', 'event_espresso') . '</a>'; |
|
| 703 | + } elseif ($this->_view === 'trash') { |
|
| 704 | + // restore registration link |
|
| 705 | + if ( |
|
| 706 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 707 | + 'ee_delete_registration', |
|
| 708 | + 'espresso_registrations_restore_registrations', |
|
| 709 | + $item->ID() |
|
| 710 | + ) |
|
| 711 | + ) { |
|
| 712 | + $action['action'] = 'restore_registrations'; |
|
| 713 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 714 | + $action, |
|
| 715 | + REG_ADMIN_URL |
|
| 716 | + ); |
|
| 717 | + $actions['restore'] = '<a href="' |
|
| 718 | + . $restore_lnk_url |
|
| 719 | + . '" title="' |
|
| 720 | + . esc_attr__('Restore Registration', 'event_espresso') . '">' |
|
| 721 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
| 722 | + } |
|
| 723 | + if ( |
|
| 724 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 725 | + 'ee_delete_registration', |
|
| 726 | + 'espresso_registrations_ee_delete_registrations', |
|
| 727 | + $item->ID() |
|
| 728 | + ) |
|
| 729 | + ) { |
|
| 730 | + $action['action'] = 'delete_registrations'; |
|
| 731 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 732 | + $action, |
|
| 733 | + REG_ADMIN_URL |
|
| 734 | + ); |
|
| 735 | + $actions['delete'] = '<a href="' |
|
| 736 | + . $delete_lnk_url |
|
| 737 | + . '" title="' |
|
| 738 | + . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
| 739 | + . '">' |
|
| 740 | + . esc_html__('Delete', 'event_espresso') |
|
| 741 | + . '</a>'; |
|
| 742 | + } |
|
| 743 | + } |
|
| 744 | + return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + |
|
| 748 | + /** |
|
| 749 | + * @param EE_Registration $item |
|
| 750 | + * @return string |
|
| 751 | + * @throws EE_Error |
|
| 752 | + * @throws InvalidArgumentException |
|
| 753 | + * @throws InvalidDataTypeException |
|
| 754 | + * @throws InvalidInterfaceException |
|
| 755 | + * @throws ReflectionException |
|
| 756 | + */ |
|
| 757 | + public function column_ATT_email(EE_Registration $item) |
|
| 758 | + { |
|
| 759 | + $attendee = $item->get_first_related('Attendee'); |
|
| 760 | + return ! $attendee instanceof EE_Attendee |
|
| 761 | + ? esc_html__('No attached contact record.', 'event_espresso') |
|
| 762 | + : $attendee->email(); |
|
| 763 | + } |
|
| 764 | + |
|
| 765 | + |
|
| 766 | + /** |
|
| 767 | + * @param EE_Registration $item |
|
| 768 | + * @return string |
|
| 769 | + */ |
|
| 770 | + public function column__REG_count(EE_Registration $item) |
|
| 771 | + { |
|
| 772 | + return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + |
|
| 776 | + /** |
|
| 777 | + * @param EE_Registration $item |
|
| 778 | + * @return string |
|
| 779 | + * @throws EE_Error |
|
| 780 | + * @throws ReflectionException |
|
| 781 | + */ |
|
| 782 | + public function column_PRC_amount(EE_Registration $item) |
|
| 783 | + { |
|
| 784 | + $ticket = $item->ticket(); |
|
| 785 | + $req_data = $this->_admin_page->get_request_data(); |
|
| 786 | + $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket |
|
| 787 | + ? '<span class="TKT_name">' . $ticket->name() . '</span><br />' |
|
| 788 | + : ''; |
|
| 789 | + if ($item->final_price() > 0) { |
|
| 790 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 791 | + } else { |
|
| 792 | + // free event |
|
| 793 | + $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
| 794 | + . esc_html__('free', 'event_espresso') |
|
| 795 | + . '</span>'; |
|
| 796 | + } |
|
| 797 | + return $content; |
|
| 798 | + } |
|
| 799 | + |
|
| 800 | + |
|
| 801 | + /** |
|
| 802 | + * @param EE_Registration $item |
|
| 803 | + * @return string |
|
| 804 | + * @throws EE_Error |
|
| 805 | + * @throws ReflectionException |
|
| 806 | + */ |
|
| 807 | + public function column__REG_final_price(EE_Registration $item) |
|
| 808 | + { |
|
| 809 | + $ticket = $item->ticket(); |
|
| 810 | + $req_data = $this->_admin_page->get_request_data(); |
|
| 811 | + $content = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket |
|
| 812 | + ? '' |
|
| 813 | + : '<span class="TKT_name">' . $ticket->name() . '</span><br />'; |
|
| 814 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 815 | + return $content; |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + |
|
| 819 | + /** |
|
| 820 | + * @param EE_Registration $item |
|
| 821 | + * @return string |
|
| 822 | + * @throws EE_Error |
|
| 823 | + */ |
|
| 824 | + public function column__REG_paid(EE_Registration $item) |
|
| 825 | + { |
|
| 826 | + $payment_method = $item->payment_method(); |
|
| 827 | + $payment_method_name = $payment_method instanceof EE_Payment_Method |
|
| 828 | + ? $payment_method->admin_name() |
|
| 829 | + : esc_html__('Unknown', 'event_espresso'); |
|
| 830 | + $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
| 831 | + if ($item->paid() > 0) { |
|
| 832 | + $content .= '<br><span class="ee-status-text-small">' |
|
| 833 | + . sprintf( |
|
| 834 | + esc_html__('...via %s', 'event_espresso'), |
|
| 835 | + $payment_method_name |
|
| 836 | + ) |
|
| 837 | + . '</span>'; |
|
| 838 | + } |
|
| 839 | + return $content; |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + |
|
| 843 | + /** |
|
| 844 | + * @param EE_Registration $item |
|
| 845 | + * @return string |
|
| 846 | + * @throws EE_Error |
|
| 847 | + * @throws EntityNotFoundException |
|
| 848 | + * @throws InvalidArgumentException |
|
| 849 | + * @throws InvalidDataTypeException |
|
| 850 | + * @throws InvalidInterfaceException |
|
| 851 | + * @throws ReflectionException |
|
| 852 | + */ |
|
| 853 | + public function column_TXN_total(EE_Registration $item) |
|
| 854 | + { |
|
| 855 | + if ($item->transaction()) { |
|
| 856 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 857 | + [ |
|
| 858 | + 'action' => 'view_transaction', |
|
| 859 | + 'TXN_ID' => $item->transaction_ID(), |
|
| 860 | + ], |
|
| 861 | + TXN_ADMIN_URL |
|
| 862 | + ); |
|
| 863 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 864 | + 'ee_read_transaction', |
|
| 865 | + 'espresso_transactions_view_transaction', |
|
| 866 | + $item->transaction_ID() |
|
| 867 | + ) |
|
| 868 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
| 869 | + . $item->transaction()->status_ID() |
|
| 870 | + . '" href="' |
|
| 871 | + . $view_txn_lnk_url |
|
| 872 | + . '" title="' |
|
| 873 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 874 | + . '">' |
|
| 875 | + . $item->transaction()->pretty_total() |
|
| 876 | + . '</a></span>' |
|
| 877 | + : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
| 878 | + } else { |
|
| 879 | + return esc_html__("None", "event_espresso"); |
|
| 880 | + } |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + |
|
| 884 | + /** |
|
| 885 | + * @param EE_Registration $item |
|
| 886 | + * @return string |
|
| 887 | + * @throws EE_Error |
|
| 888 | + * @throws EntityNotFoundException |
|
| 889 | + * @throws InvalidArgumentException |
|
| 890 | + * @throws InvalidDataTypeException |
|
| 891 | + * @throws InvalidInterfaceException |
|
| 892 | + * @throws ReflectionException |
|
| 893 | + */ |
|
| 894 | + public function column_TXN_paid(EE_Registration $item) |
|
| 895 | + { |
|
| 896 | + if ($item->count() === 1) { |
|
| 897 | + $transaction = $item->transaction() |
|
| 898 | + ? $item->transaction() |
|
| 899 | + : EE_Transaction::new_instance(); |
|
| 900 | + if ($transaction->paid() >= $transaction->total()) { |
|
| 901 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 902 | + } else { |
|
| 903 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 904 | + [ |
|
| 905 | + 'action' => 'view_transaction', |
|
| 906 | + 'TXN_ID' => $item->transaction_ID(), |
|
| 907 | + ], |
|
| 908 | + TXN_ADMIN_URL |
|
| 909 | + ); |
|
| 910 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 911 | + 'ee_read_transaction', |
|
| 912 | + 'espresso_transactions_view_transaction', |
|
| 913 | + $item->transaction_ID() |
|
| 914 | + ) |
|
| 915 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
| 916 | + . $transaction->status_ID() |
|
| 917 | + . '" href="' |
|
| 918 | + . $view_txn_lnk_url |
|
| 919 | + . '" title="' |
|
| 920 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 921 | + . '">' |
|
| 922 | + . $item->transaction()->pretty_paid() |
|
| 923 | + . '</a><span>' |
|
| 924 | + : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 925 | + } |
|
| 926 | + } |
|
| 927 | + return ' '; |
|
| 928 | + } |
|
| 929 | + |
|
| 930 | + |
|
| 931 | + /** |
|
| 932 | + * column_actions |
|
| 933 | + * |
|
| 934 | + * @param EE_Registration $item |
|
| 935 | + * @return string |
|
| 936 | + * @throws EE_Error |
|
| 937 | + * @throws InvalidArgumentException |
|
| 938 | + * @throws InvalidDataTypeException |
|
| 939 | + * @throws InvalidInterfaceException |
|
| 940 | + * @throws ReflectionException |
|
| 941 | + */ |
|
| 942 | + public function column_actions(EE_Registration $item) |
|
| 943 | + { |
|
| 944 | + $actions = []; |
|
| 945 | + $attendee = $item->attendee(); |
|
| 946 | + $this->_set_related_details($item); |
|
| 947 | + |
|
| 948 | + // Build row actions |
|
| 949 | + if ( |
|
| 950 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 951 | + 'ee_read_registration', |
|
| 952 | + 'espresso_registrations_view_registration', |
|
| 953 | + $item->ID() |
|
| 954 | + ) |
|
| 955 | + ) { |
|
| 956 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 957 | + [ |
|
| 958 | + 'action' => 'view_registration', |
|
| 959 | + '_REG_ID' => $item->ID(), |
|
| 960 | + ], |
|
| 961 | + REG_ADMIN_URL |
|
| 962 | + ); |
|
| 963 | + $actions['view_lnk'] = ' |
|
| 964 | 964 | <li> |
| 965 | 965 | <a href="' . $view_lnk_url . '" title="' |
| 966 | - . esc_attr__('View Registration Details', 'event_espresso') |
|
| 967 | - . '" class="tiny-text"> |
|
| 966 | + . esc_attr__('View Registration Details', 'event_espresso') |
|
| 967 | + . '" class="tiny-text"> |
|
| 968 | 968 | <div class="dashicons dashicons-clipboard"></div> |
| 969 | 969 | </a> |
| 970 | 970 | </li>'; |
| 971 | - } |
|
| 972 | - |
|
| 973 | - if ( |
|
| 974 | - $attendee instanceof EE_Attendee |
|
| 975 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 976 | - 'ee_edit_contacts', |
|
| 977 | - 'espresso_registrations_edit_attendee' |
|
| 978 | - ) |
|
| 979 | - ) { |
|
| 980 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 981 | - [ |
|
| 982 | - 'action' => 'edit_attendee', |
|
| 983 | - 'post' => $item->attendee_ID(), |
|
| 984 | - ], |
|
| 985 | - REG_ADMIN_URL |
|
| 986 | - ); |
|
| 987 | - $actions['edit_lnk'] = ' |
|
| 971 | + } |
|
| 972 | + |
|
| 973 | + if ( |
|
| 974 | + $attendee instanceof EE_Attendee |
|
| 975 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 976 | + 'ee_edit_contacts', |
|
| 977 | + 'espresso_registrations_edit_attendee' |
|
| 978 | + ) |
|
| 979 | + ) { |
|
| 980 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 981 | + [ |
|
| 982 | + 'action' => 'edit_attendee', |
|
| 983 | + 'post' => $item->attendee_ID(), |
|
| 984 | + ], |
|
| 985 | + REG_ADMIN_URL |
|
| 986 | + ); |
|
| 987 | + $actions['edit_lnk'] = ' |
|
| 988 | 988 | <li> |
| 989 | 989 | <a href="' . $edit_lnk_url . '" title="' |
| 990 | - . esc_attr__('Edit Contact Details', 'event_espresso') |
|
| 991 | - . '" class="tiny-text"> |
|
| 990 | + . esc_attr__('Edit Contact Details', 'event_espresso') |
|
| 991 | + . '" class="tiny-text"> |
|
| 992 | 992 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
| 993 | 993 | </a> |
| 994 | 994 | </li>'; |
| 995 | - } |
|
| 996 | - |
|
| 997 | - if ( |
|
| 998 | - $attendee instanceof EE_Attendee |
|
| 999 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 1000 | - 'ee_send_message', |
|
| 1001 | - 'espresso_registrations_resend_registration', |
|
| 1002 | - $item->ID() |
|
| 1003 | - ) |
|
| 1004 | - ) { |
|
| 1005 | - $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1006 | - [ |
|
| 1007 | - 'action' => 'resend_registration', |
|
| 1008 | - '_REG_ID' => $item->ID(), |
|
| 1009 | - ], |
|
| 1010 | - REG_ADMIN_URL, |
|
| 1011 | - true |
|
| 1012 | - ); |
|
| 1013 | - $actions['resend_reg_lnk'] = ' |
|
| 995 | + } |
|
| 996 | + |
|
| 997 | + if ( |
|
| 998 | + $attendee instanceof EE_Attendee |
|
| 999 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 1000 | + 'ee_send_message', |
|
| 1001 | + 'espresso_registrations_resend_registration', |
|
| 1002 | + $item->ID() |
|
| 1003 | + ) |
|
| 1004 | + ) { |
|
| 1005 | + $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1006 | + [ |
|
| 1007 | + 'action' => 'resend_registration', |
|
| 1008 | + '_REG_ID' => $item->ID(), |
|
| 1009 | + ], |
|
| 1010 | + REG_ADMIN_URL, |
|
| 1011 | + true |
|
| 1012 | + ); |
|
| 1013 | + $actions['resend_reg_lnk'] = ' |
|
| 1014 | 1014 | <li> |
| 1015 | 1015 | <a href="' . $resend_reg_lnk_url . '" title="' |
| 1016 | - . esc_attr__('Resend Registration Details', 'event_espresso') |
|
| 1017 | - . '" class="tiny-text"> |
|
| 1016 | + . esc_attr__('Resend Registration Details', 'event_espresso') |
|
| 1017 | + . '" class="tiny-text"> |
|
| 1018 | 1018 | <div class="dashicons dashicons-email-alt"></div> |
| 1019 | 1019 | </a> |
| 1020 | 1020 | </li>'; |
| 1021 | - } |
|
| 1022 | - |
|
| 1023 | - if ( |
|
| 1024 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 1025 | - 'ee_read_transaction', |
|
| 1026 | - 'espresso_transactions_view_transaction', |
|
| 1027 | - $this->_transaction_details['id'] |
|
| 1028 | - ) |
|
| 1029 | - ) { |
|
| 1030 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1031 | - [ |
|
| 1032 | - 'action' => 'view_transaction', |
|
| 1033 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
| 1034 | - ], |
|
| 1035 | - TXN_ADMIN_URL |
|
| 1036 | - ); |
|
| 1037 | - $actions['view_txn_lnk'] = ' |
|
| 1021 | + } |
|
| 1022 | + |
|
| 1023 | + if ( |
|
| 1024 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 1025 | + 'ee_read_transaction', |
|
| 1026 | + 'espresso_transactions_view_transaction', |
|
| 1027 | + $this->_transaction_details['id'] |
|
| 1028 | + ) |
|
| 1029 | + ) { |
|
| 1030 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 1031 | + [ |
|
| 1032 | + 'action' => 'view_transaction', |
|
| 1033 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
| 1034 | + ], |
|
| 1035 | + TXN_ADMIN_URL |
|
| 1036 | + ); |
|
| 1037 | + $actions['view_txn_lnk'] = ' |
|
| 1038 | 1038 | <li> |
| 1039 | 1039 | <a class="ee-status-color-' . $this->_transaction_details['status'] |
| 1040 | - . ' tiny-text" href="' . $view_txn_lnk_url |
|
| 1041 | - . '" title="' . $this->_transaction_details['title_attr'] . '"> |
|
| 1040 | + . ' tiny-text" href="' . $view_txn_lnk_url |
|
| 1041 | + . '" title="' . $this->_transaction_details['title_attr'] . '"> |
|
| 1042 | 1042 | <div class="dashicons dashicons-cart"></div> |
| 1043 | 1043 | </a> |
| 1044 | 1044 | </li>'; |
| 1045 | - } |
|
| 1046 | - |
|
| 1047 | - // only show invoice link if message type is active. |
|
| 1048 | - if ( |
|
| 1049 | - $attendee instanceof EE_Attendee |
|
| 1050 | - && $item->is_primary_registrant() |
|
| 1051 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
| 1052 | - ) { |
|
| 1053 | - $actions['dl_invoice_lnk'] = ' |
|
| 1045 | + } |
|
| 1046 | + |
|
| 1047 | + // only show invoice link if message type is active. |
|
| 1048 | + if ( |
|
| 1049 | + $attendee instanceof EE_Attendee |
|
| 1050 | + && $item->is_primary_registrant() |
|
| 1051 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
| 1052 | + ) { |
|
| 1053 | + $actions['dl_invoice_lnk'] = ' |
|
| 1054 | 1054 | <li> |
| 1055 | 1055 | <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') |
| 1056 | - . '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text"> |
|
| 1056 | + . '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text"> |
|
| 1057 | 1057 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
| 1058 | 1058 | </a> |
| 1059 | 1059 | </li>'; |
| 1060 | - } |
|
| 1060 | + } |
|
| 1061 | 1061 | |
| 1062 | - // message list table link (filtered by REG_ID |
|
| 1063 | - if ( |
|
| 1064 | - EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages') |
|
| 1065 | - ) { |
|
| 1066 | - $actions['filtered_messages_link'] = ' |
|
| 1062 | + // message list table link (filtered by REG_ID |
|
| 1063 | + if ( |
|
| 1064 | + EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages') |
|
| 1065 | + ) { |
|
| 1066 | + $actions['filtered_messages_link'] = ' |
|
| 1067 | 1067 | <li> |
| 1068 | 1068 | ' . EEH_MSG_Template::get_message_action_link( |
| 1069 | - 'see_notifications_for', |
|
| 1070 | - null, |
|
| 1071 | - ['_REG_ID' => $item->ID()] |
|
| 1072 | - ) . ' |
|
| 1069 | + 'see_notifications_for', |
|
| 1070 | + null, |
|
| 1071 | + ['_REG_ID' => $item->ID()] |
|
| 1072 | + ) . ' |
|
| 1073 | 1073 | </li>'; |
| 1074 | - } |
|
| 1074 | + } |
|
| 1075 | 1075 | |
| 1076 | - $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
| 1077 | - return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
| 1078 | - } |
|
| 1076 | + $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
| 1077 | + return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
| 1078 | + } |
|
| 1079 | 1079 | } |
@@ -12,572 +12,572 @@ |
||
| 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 | - // $columns['_Reg_Status'] = ''; |
|
| 75 | - $this->_columns = array( |
|
| 76 | - '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
| 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 | - 'incude_checkins' => true, |
|
| 111 | - ), |
|
| 112 | - ), |
|
| 113 | - ); |
|
| 114 | - } |
|
| 115 | - $this->_bottom_buttons['report_filtered'] = array( |
|
| 116 | - 'route' => 'registrations_checkin_report', |
|
| 117 | - 'extra_request' => array( |
|
| 118 | - 'use_filters' => true, |
|
| 119 | - 'incude_checkins' => $evt_id ? true : false, |
|
| 120 | - 'filters' => array_merge( |
|
| 121 | - array( |
|
| 122 | - 'EVT_ID' => $evt_id, |
|
| 123 | - ), |
|
| 124 | - array_diff_key( |
|
| 125 | - $this->_req_data, |
|
| 126 | - array_flip( |
|
| 127 | - array( |
|
| 128 | - 'page', |
|
| 129 | - 'action', |
|
| 130 | - 'default_nonce', |
|
| 131 | - ) |
|
| 132 | - ) |
|
| 133 | - ) |
|
| 134 | - ), |
|
| 135 | - 'return_url' => $return_url, |
|
| 136 | - ), |
|
| 137 | - ); |
|
| 138 | - $this->_sortable_columns = array( |
|
| 139 | - /** |
|
| 140 | - * Allows users to change the default sort if they wish. |
|
| 141 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 142 | - * |
|
| 143 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 144 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 145 | - * for a specific list table you can use the provided reference to this object instance. |
|
| 146 | - */ |
|
| 147 | - 'ATT_name' => array( |
|
| 148 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 149 | - true, |
|
| 150 | - $this, |
|
| 151 | - ) |
|
| 152 | - ? array('ATT_lname' => true) |
|
| 153 | - : array('ATT_fname' => true), |
|
| 154 | - 'Event' => array('Event.EVT_name' => false), |
|
| 155 | - ); |
|
| 156 | - $this->_hidden_columns = array(); |
|
| 157 | - $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
| 158 | - $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param \EE_Registration $item |
|
| 164 | - * @return string |
|
| 165 | - */ |
|
| 166 | - protected function _get_row_class($item) |
|
| 167 | - { |
|
| 168 | - $class = parent::_get_row_class($item); |
|
| 169 | - // add status class |
|
| 170 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 171 | - if ($this->_has_checkbox_column) { |
|
| 172 | - $class .= ' has-checkbox-column'; |
|
| 173 | - } |
|
| 174 | - return $class; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * @return array |
|
| 180 | - * @throws \EE_Error |
|
| 181 | - */ |
|
| 182 | - protected function _get_table_filters() |
|
| 183 | - { |
|
| 184 | - $filters = $where = array(); |
|
| 185 | - $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
| 186 | - if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
| 187 | - // this means we don't have an event so let's setup a filter dropdown for all the events to select |
|
| 188 | - // note possible capability restrictions |
|
| 189 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 190 | - $where['status**'] = array('!=', 'private'); |
|
| 191 | - } |
|
| 192 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 193 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
| 194 | - } |
|
| 195 | - $events = EEM_Event::instance()->get_all( |
|
| 196 | - array( |
|
| 197 | - $where, |
|
| 198 | - 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
| 199 | - ) |
|
| 200 | - ); |
|
| 201 | - $evts[] = array( |
|
| 202 | - 'id' => 0, |
|
| 203 | - 'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'), |
|
| 204 | - ); |
|
| 205 | - $checked = 'checked'; |
|
| 206 | - /** @var EE_Event $evt */ |
|
| 207 | - foreach ($events as $evt) { |
|
| 208 | - // any registrations for this event? |
|
| 209 | - if (! $evt->get_count_of_all_registrations()) { |
|
| 210 | - continue; |
|
| 211 | - } |
|
| 212 | - $evts[] = array( |
|
| 213 | - 'id' => $evt->ID(), |
|
| 214 | - 'text' => apply_filters( |
|
| 215 | - 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
| 216 | - $evt->get('EVT_name'), |
|
| 217 | - $evt |
|
| 218 | - ), |
|
| 219 | - 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
|
| 220 | - ); |
|
| 221 | - if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
| 222 | - $checked = ''; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - $event_filter = '<div class="ee-event-filter">'; |
|
| 226 | - $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
| 227 | - $event_filter .= '<span class="ee-event-filter-toggle">'; |
|
| 228 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
| 229 | - $event_filter .= esc_html__('Hide Expired Events', 'event_espresso'); |
|
| 230 | - $event_filter .= '</span>'; |
|
| 231 | - $event_filter .= '</div>'; |
|
| 232 | - $filters[] = $event_filter; |
|
| 233 | - } |
|
| 234 | - if (! empty($this->_dtts_for_event)) { |
|
| 235 | - // DTT datetimes filter |
|
| 236 | - $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
| 237 | - if (count($this->_dtts_for_event) > 1) { |
|
| 238 | - $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
| 239 | - foreach ($this->_dtts_for_event as $dtt) { |
|
| 240 | - $datetime_string = $dtt->name(); |
|
| 241 | - $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
| 242 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
| 243 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
| 244 | - } |
|
| 245 | - $input = new EE_Select_Input( |
|
| 246 | - $dtts, |
|
| 247 | - array( |
|
| 248 | - 'html_name' => 'DTT_ID', |
|
| 249 | - 'html_id' => 'DTT_ID', |
|
| 250 | - 'default' => $this->_cur_dtt_id, |
|
| 251 | - ) |
|
| 252 | - ); |
|
| 253 | - $filters[] = $input->get_html_for_input(); |
|
| 254 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - return $filters; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - |
|
| 261 | - protected function _add_view_counts() |
|
| 262 | - { |
|
| 263 | - $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * @return int |
|
| 269 | - * @throws \EE_Error |
|
| 270 | - */ |
|
| 271 | - protected function _get_total_event_attendees() |
|
| 272 | - { |
|
| 273 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 274 | - $DTT_ID = $this->_cur_dtt_id; |
|
| 275 | - $query_params = array(); |
|
| 276 | - if ($EVT_ID) { |
|
| 277 | - $query_params[0]['EVT_ID'] = $EVT_ID; |
|
| 278 | - } |
|
| 279 | - // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
| 280 | - if ($DTT_ID) { |
|
| 281 | - $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
| 282 | - } |
|
| 283 | - $status_ids_array = apply_filters( |
|
| 284 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 285 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 286 | - ); |
|
| 287 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 288 | - return EEM_Registration::instance()->count($query_params); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * @param \EE_Registration $item |
|
| 294 | - * @return string |
|
| 295 | - */ |
|
| 296 | - public function column__Reg_Status(EE_Registration $item) |
|
| 297 | - { |
|
| 298 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * @param \EE_Registration $item |
|
| 304 | - * @return string |
|
| 305 | - * @throws \EE_Error |
|
| 306 | - */ |
|
| 307 | - public function column_cb($item) |
|
| 308 | - { |
|
| 309 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * column_REG_att_checked_in |
|
| 315 | - * |
|
| 316 | - * @param EE_Registration $item |
|
| 317 | - * @return string |
|
| 318 | - * @throws EE_Error |
|
| 319 | - * @throws InvalidArgumentException |
|
| 320 | - * @throws InvalidDataTypeException |
|
| 321 | - * @throws InvalidInterfaceException |
|
| 322 | - */ |
|
| 323 | - public function column__REG_att_checked_in(EE_Registration $item) |
|
| 324 | - { |
|
| 325 | - $attendee = $item->attendee(); |
|
| 326 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 327 | - |
|
| 328 | - if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
| 329 | - $latest_related_datetime = $item->get_latest_related_datetime(); |
|
| 330 | - if ($latest_related_datetime instanceof EE_Datetime) { |
|
| 331 | - $this->_cur_dtt_id = $latest_related_datetime->ID(); |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
| 335 | - $item, |
|
| 336 | - $this->_cur_dtt_id |
|
| 337 | - ); |
|
| 338 | - $nonce = wp_create_nonce('checkin_nonce'); |
|
| 339 | - $toggle_active = ! empty($this->_cur_dtt_id) |
|
| 340 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 341 | - 'ee_edit_checkin', |
|
| 342 | - 'espresso_registrations_toggle_checkin_status', |
|
| 343 | - $item->ID() |
|
| 344 | - ) |
|
| 345 | - ? ' clickable trigger-checkin' |
|
| 346 | - : ''; |
|
| 347 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 348 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
| 349 | - . ' data-_regid="' . $item->ID() . '"' |
|
| 350 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 351 | - . ' data-nonce="' . $nonce . '">' |
|
| 352 | - . '</span>' |
|
| 353 | - . $mobile_view_content; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * @param \EE_Registration $item |
|
| 359 | - * @return mixed|string|void |
|
| 360 | - * @throws \EE_Error |
|
| 361 | - */ |
|
| 362 | - public function column_ATT_name(EE_Registration $item) |
|
| 363 | - { |
|
| 364 | - $attendee = $item->attendee(); |
|
| 365 | - if (! $attendee instanceof EE_Attendee) { |
|
| 366 | - return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
| 367 | - } |
|
| 368 | - // edit attendee link |
|
| 369 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 370 | - array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 371 | - REG_ADMIN_URL |
|
| 372 | - ); |
|
| 373 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 374 | - 'ee_edit_contacts', |
|
| 375 | - 'espresso_registrations_edit_attendee' |
|
| 376 | - ) |
|
| 377 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 378 | - . $item->attendee()->full_name() |
|
| 379 | - . '</a>' |
|
| 380 | - : $item->attendee()->full_name(); |
|
| 381 | - $name_link .= $item->count() === 1 |
|
| 382 | - ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
|
| 383 | - : ''; |
|
| 384 | - // add group details |
|
| 385 | - $name_link .= ' ' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 386 | - // add regcode |
|
| 387 | - $link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 388 | - array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 389 | - REG_ADMIN_URL |
|
| 390 | - ); |
|
| 391 | - $name_link .= '<br>'; |
|
| 392 | - $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
| 393 | - 'ee_read_registration', |
|
| 394 | - 'view_registration', |
|
| 395 | - $item->ID() |
|
| 396 | - ) |
|
| 397 | - ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 398 | - . $item->reg_code() |
|
| 399 | - . '</a>' |
|
| 400 | - : $item->reg_code(); |
|
| 401 | - // status |
|
| 402 | - $name_link .= '<br><span class="ee-status-text-small">'; |
|
| 403 | - $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
| 404 | - $name_link .= '</span>'; |
|
| 405 | - $actions = array(); |
|
| 406 | - $DTT_ID = $this->_cur_dtt_id; |
|
| 407 | - $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
| 408 | - ? $item->get_latest_related_datetime() |
|
| 409 | - : null; |
|
| 410 | - $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
|
| 411 | - ? $latest_related_datetime->ID() |
|
| 412 | - : $DTT_ID; |
|
| 413 | - if ( |
|
| 414 | - ! empty($DTT_ID) |
|
| 415 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 416 | - 'ee_read_checkins', |
|
| 417 | - 'espresso_registrations_registration_checkins' |
|
| 418 | - ) |
|
| 419 | - ) { |
|
| 420 | - $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 421 | - array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
| 422 | - REG_ADMIN_URL |
|
| 423 | - ); |
|
| 424 | - // get the timestamps for this registration's checkins, related to the selected datetime |
|
| 425 | - $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
| 426 | - if (! empty($timestamps)) { |
|
| 427 | - // get the last timestamp |
|
| 428 | - $last_timestamp = end($timestamps); |
|
| 429 | - // checked in or checked out? |
|
| 430 | - $checkin_status = $last_timestamp->get('CHK_in') |
|
| 431 | - ? esc_html__('Checked In', 'event_espresso') |
|
| 432 | - : esc_html__('Checked Out', 'event_espresso'); |
|
| 433 | - // get timestamp string |
|
| 434 | - $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
| 435 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' |
|
| 436 | - . esc_attr__( |
|
| 437 | - 'View this registrant\'s check-ins/checkouts for the datetime', |
|
| 438 | - 'event_espresso' |
|
| 439 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
| 440 | - } |
|
| 441 | - } |
|
| 442 | - return (! empty($DTT_ID) && ! empty($timestamps)) |
|
| 443 | - ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
| 444 | - : $name_link; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * @param \EE_Registration $item |
|
| 450 | - * @return string |
|
| 451 | - */ |
|
| 452 | - public function column_ATT_email(EE_Registration $item) |
|
| 453 | - { |
|
| 454 | - $attendee = $item->attendee(); |
|
| 455 | - return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - |
|
| 459 | - /** |
|
| 460 | - * @param \EE_Registration $item |
|
| 461 | - * @return bool|string |
|
| 462 | - * @throws \EE_Error |
|
| 463 | - */ |
|
| 464 | - public function column_Event(EE_Registration $item) |
|
| 465 | - { |
|
| 466 | - try { |
|
| 467 | - $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
|
| 468 | - $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 469 | - array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
| 470 | - REG_ADMIN_URL |
|
| 471 | - ); |
|
| 472 | - $event_label = EE_Registry::instance()->CAP->current_user_can( |
|
| 473 | - 'ee_read_checkins', |
|
| 474 | - 'espresso_registrations_registration_checkins' |
|
| 475 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' |
|
| 476 | - . esc_attr__( |
|
| 477 | - 'View Checkins for this Event', |
|
| 478 | - 'event_espresso' |
|
| 479 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 480 | - } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 481 | - $event_label = esc_html__('Unknown', 'event_espresso'); |
|
| 482 | - } |
|
| 483 | - return $event_label; |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * @param \EE_Registration $item |
|
| 489 | - * @return mixed|string|void |
|
| 490 | - */ |
|
| 491 | - public function column_PRC_name(EE_Registration $item) |
|
| 492 | - { |
|
| 493 | - return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso"); |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * column_REG_final_price |
|
| 499 | - * |
|
| 500 | - * @param \EE_Registration $item |
|
| 501 | - * @return string |
|
| 502 | - */ |
|
| 503 | - public function column__REG_final_price(EE_Registration $item) |
|
| 504 | - { |
|
| 505 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - |
|
| 509 | - /** |
|
| 510 | - * column_TXN_paid |
|
| 511 | - * |
|
| 512 | - * @param \EE_Registration $item |
|
| 513 | - * @return string |
|
| 514 | - * @throws \EE_Error |
|
| 515 | - */ |
|
| 516 | - public function column_TXN_paid(EE_Registration $item) |
|
| 517 | - { |
|
| 518 | - if ($item->count() === 1) { |
|
| 519 | - if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
| 520 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 521 | - } else { |
|
| 522 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 523 | - array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
| 524 | - TXN_ADMIN_URL |
|
| 525 | - ); |
|
| 526 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 527 | - 'ee_read_transaction', |
|
| 528 | - 'espresso_transactions_view_transaction' |
|
| 529 | - ) ? ' |
|
| 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 | + // $columns['_Reg_Status'] = ''; |
|
| 75 | + $this->_columns = array( |
|
| 76 | + '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
| 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 | + 'incude_checkins' => true, |
|
| 111 | + ), |
|
| 112 | + ), |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | + $this->_bottom_buttons['report_filtered'] = array( |
|
| 116 | + 'route' => 'registrations_checkin_report', |
|
| 117 | + 'extra_request' => array( |
|
| 118 | + 'use_filters' => true, |
|
| 119 | + 'incude_checkins' => $evt_id ? true : false, |
|
| 120 | + 'filters' => array_merge( |
|
| 121 | + array( |
|
| 122 | + 'EVT_ID' => $evt_id, |
|
| 123 | + ), |
|
| 124 | + array_diff_key( |
|
| 125 | + $this->_req_data, |
|
| 126 | + array_flip( |
|
| 127 | + array( |
|
| 128 | + 'page', |
|
| 129 | + 'action', |
|
| 130 | + 'default_nonce', |
|
| 131 | + ) |
|
| 132 | + ) |
|
| 133 | + ) |
|
| 134 | + ), |
|
| 135 | + 'return_url' => $return_url, |
|
| 136 | + ), |
|
| 137 | + ); |
|
| 138 | + $this->_sortable_columns = array( |
|
| 139 | + /** |
|
| 140 | + * Allows users to change the default sort if they wish. |
|
| 141 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 142 | + * |
|
| 143 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 144 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 145 | + * for a specific list table you can use the provided reference to this object instance. |
|
| 146 | + */ |
|
| 147 | + 'ATT_name' => array( |
|
| 148 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 149 | + true, |
|
| 150 | + $this, |
|
| 151 | + ) |
|
| 152 | + ? array('ATT_lname' => true) |
|
| 153 | + : array('ATT_fname' => true), |
|
| 154 | + 'Event' => array('Event.EVT_name' => false), |
|
| 155 | + ); |
|
| 156 | + $this->_hidden_columns = array(); |
|
| 157 | + $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
| 158 | + $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @param \EE_Registration $item |
|
| 164 | + * @return string |
|
| 165 | + */ |
|
| 166 | + protected function _get_row_class($item) |
|
| 167 | + { |
|
| 168 | + $class = parent::_get_row_class($item); |
|
| 169 | + // add status class |
|
| 170 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 171 | + if ($this->_has_checkbox_column) { |
|
| 172 | + $class .= ' has-checkbox-column'; |
|
| 173 | + } |
|
| 174 | + return $class; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * @return array |
|
| 180 | + * @throws \EE_Error |
|
| 181 | + */ |
|
| 182 | + protected function _get_table_filters() |
|
| 183 | + { |
|
| 184 | + $filters = $where = array(); |
|
| 185 | + $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
| 186 | + if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
| 187 | + // this means we don't have an event so let's setup a filter dropdown for all the events to select |
|
| 188 | + // note possible capability restrictions |
|
| 189 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 190 | + $where['status**'] = array('!=', 'private'); |
|
| 191 | + } |
|
| 192 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 193 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
| 194 | + } |
|
| 195 | + $events = EEM_Event::instance()->get_all( |
|
| 196 | + array( |
|
| 197 | + $where, |
|
| 198 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
| 199 | + ) |
|
| 200 | + ); |
|
| 201 | + $evts[] = array( |
|
| 202 | + 'id' => 0, |
|
| 203 | + 'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'), |
|
| 204 | + ); |
|
| 205 | + $checked = 'checked'; |
|
| 206 | + /** @var EE_Event $evt */ |
|
| 207 | + foreach ($events as $evt) { |
|
| 208 | + // any registrations for this event? |
|
| 209 | + if (! $evt->get_count_of_all_registrations()) { |
|
| 210 | + continue; |
|
| 211 | + } |
|
| 212 | + $evts[] = array( |
|
| 213 | + 'id' => $evt->ID(), |
|
| 214 | + 'text' => apply_filters( |
|
| 215 | + 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
| 216 | + $evt->get('EVT_name'), |
|
| 217 | + $evt |
|
| 218 | + ), |
|
| 219 | + 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
|
| 220 | + ); |
|
| 221 | + if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
| 222 | + $checked = ''; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + $event_filter = '<div class="ee-event-filter">'; |
|
| 226 | + $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
| 227 | + $event_filter .= '<span class="ee-event-filter-toggle">'; |
|
| 228 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
| 229 | + $event_filter .= esc_html__('Hide Expired Events', 'event_espresso'); |
|
| 230 | + $event_filter .= '</span>'; |
|
| 231 | + $event_filter .= '</div>'; |
|
| 232 | + $filters[] = $event_filter; |
|
| 233 | + } |
|
| 234 | + if (! empty($this->_dtts_for_event)) { |
|
| 235 | + // DTT datetimes filter |
|
| 236 | + $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
| 237 | + if (count($this->_dtts_for_event) > 1) { |
|
| 238 | + $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
| 239 | + foreach ($this->_dtts_for_event as $dtt) { |
|
| 240 | + $datetime_string = $dtt->name(); |
|
| 241 | + $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
| 242 | + $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
| 243 | + $dtts[ $dtt->ID() ] = $datetime_string; |
|
| 244 | + } |
|
| 245 | + $input = new EE_Select_Input( |
|
| 246 | + $dtts, |
|
| 247 | + array( |
|
| 248 | + 'html_name' => 'DTT_ID', |
|
| 249 | + 'html_id' => 'DTT_ID', |
|
| 250 | + 'default' => $this->_cur_dtt_id, |
|
| 251 | + ) |
|
| 252 | + ); |
|
| 253 | + $filters[] = $input->get_html_for_input(); |
|
| 254 | + $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + return $filters; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + |
|
| 261 | + protected function _add_view_counts() |
|
| 262 | + { |
|
| 263 | + $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * @return int |
|
| 269 | + * @throws \EE_Error |
|
| 270 | + */ |
|
| 271 | + protected function _get_total_event_attendees() |
|
| 272 | + { |
|
| 273 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 274 | + $DTT_ID = $this->_cur_dtt_id; |
|
| 275 | + $query_params = array(); |
|
| 276 | + if ($EVT_ID) { |
|
| 277 | + $query_params[0]['EVT_ID'] = $EVT_ID; |
|
| 278 | + } |
|
| 279 | + // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
| 280 | + if ($DTT_ID) { |
|
| 281 | + $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
| 282 | + } |
|
| 283 | + $status_ids_array = apply_filters( |
|
| 284 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 285 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 286 | + ); |
|
| 287 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 288 | + return EEM_Registration::instance()->count($query_params); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * @param \EE_Registration $item |
|
| 294 | + * @return string |
|
| 295 | + */ |
|
| 296 | + public function column__Reg_Status(EE_Registration $item) |
|
| 297 | + { |
|
| 298 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * @param \EE_Registration $item |
|
| 304 | + * @return string |
|
| 305 | + * @throws \EE_Error |
|
| 306 | + */ |
|
| 307 | + public function column_cb($item) |
|
| 308 | + { |
|
| 309 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * column_REG_att_checked_in |
|
| 315 | + * |
|
| 316 | + * @param EE_Registration $item |
|
| 317 | + * @return string |
|
| 318 | + * @throws EE_Error |
|
| 319 | + * @throws InvalidArgumentException |
|
| 320 | + * @throws InvalidDataTypeException |
|
| 321 | + * @throws InvalidInterfaceException |
|
| 322 | + */ |
|
| 323 | + public function column__REG_att_checked_in(EE_Registration $item) |
|
| 324 | + { |
|
| 325 | + $attendee = $item->attendee(); |
|
| 326 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 327 | + |
|
| 328 | + if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
| 329 | + $latest_related_datetime = $item->get_latest_related_datetime(); |
|
| 330 | + if ($latest_related_datetime instanceof EE_Datetime) { |
|
| 331 | + $this->_cur_dtt_id = $latest_related_datetime->ID(); |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
| 335 | + $item, |
|
| 336 | + $this->_cur_dtt_id |
|
| 337 | + ); |
|
| 338 | + $nonce = wp_create_nonce('checkin_nonce'); |
|
| 339 | + $toggle_active = ! empty($this->_cur_dtt_id) |
|
| 340 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 341 | + 'ee_edit_checkin', |
|
| 342 | + 'espresso_registrations_toggle_checkin_status', |
|
| 343 | + $item->ID() |
|
| 344 | + ) |
|
| 345 | + ? ' clickable trigger-checkin' |
|
| 346 | + : ''; |
|
| 347 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 348 | + return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
| 349 | + . ' data-_regid="' . $item->ID() . '"' |
|
| 350 | + . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 351 | + . ' data-nonce="' . $nonce . '">' |
|
| 352 | + . '</span>' |
|
| 353 | + . $mobile_view_content; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + /** |
|
| 358 | + * @param \EE_Registration $item |
|
| 359 | + * @return mixed|string|void |
|
| 360 | + * @throws \EE_Error |
|
| 361 | + */ |
|
| 362 | + public function column_ATT_name(EE_Registration $item) |
|
| 363 | + { |
|
| 364 | + $attendee = $item->attendee(); |
|
| 365 | + if (! $attendee instanceof EE_Attendee) { |
|
| 366 | + return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
| 367 | + } |
|
| 368 | + // edit attendee link |
|
| 369 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 370 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 371 | + REG_ADMIN_URL |
|
| 372 | + ); |
|
| 373 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
| 374 | + 'ee_edit_contacts', |
|
| 375 | + 'espresso_registrations_edit_attendee' |
|
| 376 | + ) |
|
| 377 | + ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 378 | + . $item->attendee()->full_name() |
|
| 379 | + . '</a>' |
|
| 380 | + : $item->attendee()->full_name(); |
|
| 381 | + $name_link .= $item->count() === 1 |
|
| 382 | + ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
|
| 383 | + : ''; |
|
| 384 | + // add group details |
|
| 385 | + $name_link .= ' ' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 386 | + // add regcode |
|
| 387 | + $link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 388 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 389 | + REG_ADMIN_URL |
|
| 390 | + ); |
|
| 391 | + $name_link .= '<br>'; |
|
| 392 | + $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
| 393 | + 'ee_read_registration', |
|
| 394 | + 'view_registration', |
|
| 395 | + $item->ID() |
|
| 396 | + ) |
|
| 397 | + ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
| 398 | + . $item->reg_code() |
|
| 399 | + . '</a>' |
|
| 400 | + : $item->reg_code(); |
|
| 401 | + // status |
|
| 402 | + $name_link .= '<br><span class="ee-status-text-small">'; |
|
| 403 | + $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
| 404 | + $name_link .= '</span>'; |
|
| 405 | + $actions = array(); |
|
| 406 | + $DTT_ID = $this->_cur_dtt_id; |
|
| 407 | + $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
| 408 | + ? $item->get_latest_related_datetime() |
|
| 409 | + : null; |
|
| 410 | + $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
|
| 411 | + ? $latest_related_datetime->ID() |
|
| 412 | + : $DTT_ID; |
|
| 413 | + if ( |
|
| 414 | + ! empty($DTT_ID) |
|
| 415 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 416 | + 'ee_read_checkins', |
|
| 417 | + 'espresso_registrations_registration_checkins' |
|
| 418 | + ) |
|
| 419 | + ) { |
|
| 420 | + $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 421 | + array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
| 422 | + REG_ADMIN_URL |
|
| 423 | + ); |
|
| 424 | + // get the timestamps for this registration's checkins, related to the selected datetime |
|
| 425 | + $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
| 426 | + if (! empty($timestamps)) { |
|
| 427 | + // get the last timestamp |
|
| 428 | + $last_timestamp = end($timestamps); |
|
| 429 | + // checked in or checked out? |
|
| 430 | + $checkin_status = $last_timestamp->get('CHK_in') |
|
| 431 | + ? esc_html__('Checked In', 'event_espresso') |
|
| 432 | + : esc_html__('Checked Out', 'event_espresso'); |
|
| 433 | + // get timestamp string |
|
| 434 | + $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
| 435 | + $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' |
|
| 436 | + . esc_attr__( |
|
| 437 | + 'View this registrant\'s check-ins/checkouts for the datetime', |
|
| 438 | + 'event_espresso' |
|
| 439 | + ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
| 440 | + } |
|
| 441 | + } |
|
| 442 | + return (! empty($DTT_ID) && ! empty($timestamps)) |
|
| 443 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
| 444 | + : $name_link; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * @param \EE_Registration $item |
|
| 450 | + * @return string |
|
| 451 | + */ |
|
| 452 | + public function column_ATT_email(EE_Registration $item) |
|
| 453 | + { |
|
| 454 | + $attendee = $item->attendee(); |
|
| 455 | + return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + |
|
| 459 | + /** |
|
| 460 | + * @param \EE_Registration $item |
|
| 461 | + * @return bool|string |
|
| 462 | + * @throws \EE_Error |
|
| 463 | + */ |
|
| 464 | + public function column_Event(EE_Registration $item) |
|
| 465 | + { |
|
| 466 | + try { |
|
| 467 | + $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
|
| 468 | + $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 469 | + array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
| 470 | + REG_ADMIN_URL |
|
| 471 | + ); |
|
| 472 | + $event_label = EE_Registry::instance()->CAP->current_user_can( |
|
| 473 | + 'ee_read_checkins', |
|
| 474 | + 'espresso_registrations_registration_checkins' |
|
| 475 | + ) ? '<a href="' . $chkin_lnk_url . '" title="' |
|
| 476 | + . esc_attr__( |
|
| 477 | + 'View Checkins for this Event', |
|
| 478 | + 'event_espresso' |
|
| 479 | + ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 480 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 481 | + $event_label = esc_html__('Unknown', 'event_espresso'); |
|
| 482 | + } |
|
| 483 | + return $event_label; |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * @param \EE_Registration $item |
|
| 489 | + * @return mixed|string|void |
|
| 490 | + */ |
|
| 491 | + public function column_PRC_name(EE_Registration $item) |
|
| 492 | + { |
|
| 493 | + return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso"); |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * column_REG_final_price |
|
| 499 | + * |
|
| 500 | + * @param \EE_Registration $item |
|
| 501 | + * @return string |
|
| 502 | + */ |
|
| 503 | + public function column__REG_final_price(EE_Registration $item) |
|
| 504 | + { |
|
| 505 | + return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
| 506 | + } |
|
| 507 | + |
|
| 508 | + |
|
| 509 | + /** |
|
| 510 | + * column_TXN_paid |
|
| 511 | + * |
|
| 512 | + * @param \EE_Registration $item |
|
| 513 | + * @return string |
|
| 514 | + * @throws \EE_Error |
|
| 515 | + */ |
|
| 516 | + public function column_TXN_paid(EE_Registration $item) |
|
| 517 | + { |
|
| 518 | + if ($item->count() === 1) { |
|
| 519 | + if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
| 520 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 521 | + } else { |
|
| 522 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
| 523 | + array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
| 524 | + TXN_ADMIN_URL |
|
| 525 | + ); |
|
| 526 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 527 | + 'ee_read_transaction', |
|
| 528 | + 'espresso_transactions_view_transaction' |
|
| 529 | + ) ? ' |
|
| 530 | 530 | <span class="reg-pad-rght"> |
| 531 | 531 | <a class="status-' |
| 532 | - . $item->transaction()->status_ID() |
|
| 533 | - . '" href="' |
|
| 534 | - . $view_txn_lnk_url |
|
| 535 | - . '" title="' |
|
| 536 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 537 | - . '"> |
|
| 532 | + . $item->transaction()->status_ID() |
|
| 533 | + . '" href="' |
|
| 534 | + . $view_txn_lnk_url |
|
| 535 | + . '" title="' |
|
| 536 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 537 | + . '"> |
|
| 538 | 538 | ' |
| 539 | - . $item->transaction()->pretty_paid() |
|
| 540 | - . ' |
|
| 539 | + . $item->transaction()->pretty_paid() |
|
| 540 | + . ' |
|
| 541 | 541 | </a> |
| 542 | 542 | <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
| 543 | - } |
|
| 544 | - } else { |
|
| 545 | - return '<span class="reg-pad-rght"></span>'; |
|
| 546 | - } |
|
| 547 | - } |
|
| 548 | - |
|
| 549 | - |
|
| 550 | - /** |
|
| 551 | - * column_TXN_total |
|
| 552 | - * |
|
| 553 | - * @param \EE_Registration $item |
|
| 554 | - * @return string |
|
| 555 | - * @throws \EE_Error |
|
| 556 | - */ |
|
| 557 | - public function column_TXN_total(EE_Registration $item) |
|
| 558 | - { |
|
| 559 | - $txn = $item->transaction(); |
|
| 560 | - $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
| 561 | - if ($item->get('REG_count') === 1) { |
|
| 562 | - $line_total_obj = $txn->total_line_item(); |
|
| 563 | - $txn_total = $line_total_obj instanceof EE_Line_Item |
|
| 564 | - ? $line_total_obj->get_pretty('LIN_total') |
|
| 565 | - : esc_html__( |
|
| 566 | - 'View Transaction', |
|
| 567 | - 'event_espresso' |
|
| 568 | - ); |
|
| 569 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 570 | - 'ee_read_transaction', |
|
| 571 | - 'espresso_transactions_view_transaction' |
|
| 572 | - ) ? '<a href="' |
|
| 573 | - . $view_txn_url |
|
| 574 | - . '" title="' |
|
| 575 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 576 | - . '"><span class="reg-pad-rght">' |
|
| 577 | - . $txn_total |
|
| 578 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 579 | - } else { |
|
| 580 | - return '<span class="reg-pad-rght"></span>'; |
|
| 581 | - } |
|
| 582 | - } |
|
| 543 | + } |
|
| 544 | + } else { |
|
| 545 | + return '<span class="reg-pad-rght"></span>'; |
|
| 546 | + } |
|
| 547 | + } |
|
| 548 | + |
|
| 549 | + |
|
| 550 | + /** |
|
| 551 | + * column_TXN_total |
|
| 552 | + * |
|
| 553 | + * @param \EE_Registration $item |
|
| 554 | + * @return string |
|
| 555 | + * @throws \EE_Error |
|
| 556 | + */ |
|
| 557 | + public function column_TXN_total(EE_Registration $item) |
|
| 558 | + { |
|
| 559 | + $txn = $item->transaction(); |
|
| 560 | + $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
| 561 | + if ($item->get('REG_count') === 1) { |
|
| 562 | + $line_total_obj = $txn->total_line_item(); |
|
| 563 | + $txn_total = $line_total_obj instanceof EE_Line_Item |
|
| 564 | + ? $line_total_obj->get_pretty('LIN_total') |
|
| 565 | + : esc_html__( |
|
| 566 | + 'View Transaction', |
|
| 567 | + 'event_espresso' |
|
| 568 | + ); |
|
| 569 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 570 | + 'ee_read_transaction', |
|
| 571 | + 'espresso_transactions_view_transaction' |
|
| 572 | + ) ? '<a href="' |
|
| 573 | + . $view_txn_url |
|
| 574 | + . '" title="' |
|
| 575 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 576 | + . '"><span class="reg-pad-rght">' |
|
| 577 | + . $txn_total |
|
| 578 | + . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 579 | + } else { |
|
| 580 | + return '<span class="reg-pad-rght"></span>'; |
|
| 581 | + } |
|
| 582 | + } |
|
| 583 | 583 | } |
@@ -33,606 +33,606 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class RegistrationsReport extends JobHandlerFile |
| 35 | 35 | { |
| 36 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 37 | - // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
| 38 | - /** |
|
| 39 | - * Performs any necessary setup for starting the job. This is also a good |
|
| 40 | - * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
| 41 | - * when continue_job will be called |
|
| 42 | - * |
|
| 43 | - * @param JobParameters $job_parameters |
|
| 44 | - * @throws BatchRequestException |
|
| 45 | - * @return JobStepResponse |
|
| 46 | - */ |
|
| 47 | - public function create_job(JobParameters $job_parameters) |
|
| 48 | - { |
|
| 49 | - $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
| 50 | - if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
| 51 | - throw new BatchRequestException(esc_html__('You do not have permission to view registrations', 'event_espresso')); |
|
| 52 | - } |
|
| 53 | - $filepath = $this->create_file_from_job_with_name( |
|
| 54 | - $job_parameters->job_id(), |
|
| 55 | - $this->get_filename($event_id) |
|
| 56 | - ); |
|
| 57 | - $job_parameters->add_extra_data('filepath', $filepath); |
|
| 58 | - if ($job_parameters->request_datum('use_filters', false)) { |
|
| 59 | - $query_params = maybe_unserialize($job_parameters->request_datum('filters', array())); |
|
| 60 | - } else { |
|
| 61 | - $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
| 62 | - array( |
|
| 63 | - 'OR' => array( |
|
| 64 | - // don't include registrations from failed or abandoned transactions... |
|
| 65 | - 'Transaction.STS_ID' => array( |
|
| 66 | - 'NOT IN', |
|
| 67 | - array( |
|
| 68 | - EEM_Transaction::failed_status_code, |
|
| 69 | - EEM_Transaction::abandoned_status_code, |
|
| 70 | - ), |
|
| 71 | - ), |
|
| 72 | - // unless the registration is approved, in which case include it regardless of transaction status |
|
| 73 | - 'STS_ID' => \EEM_Registration::status_id_approved, |
|
| 74 | - ), |
|
| 75 | - 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
| 76 | - ), |
|
| 77 | - 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
| 78 | - 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
| 79 | - 'caps' => \EEM_Base::caps_read_admin, |
|
| 80 | - ), $event_id); |
|
| 81 | - if ($event_id) { |
|
| 82 | - $query_params[0]['EVT_ID'] = $event_id; |
|
| 83 | - } else { |
|
| 84 | - $query_params['force_join'][] = 'Event'; |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - if (! isset($query_params['force_join'])) { |
|
| 88 | - $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
|
| 89 | - } |
|
| 90 | - $job_parameters->add_extra_data('query_params', $query_params); |
|
| 91 | - $question_labels = $this->_get_question_labels($query_params); |
|
| 92 | - $job_parameters->add_extra_data('question_labels', $question_labels); |
|
| 93 | - $job_parameters->set_job_size( |
|
| 94 | - \EEM_Registration::instance()->count( |
|
| 95 | - array_diff_key( |
|
| 96 | - $query_params, |
|
| 97 | - array_flip( |
|
| 98 | - array('limit') |
|
| 99 | - ) |
|
| 100 | - ) |
|
| 101 | - ) |
|
| 102 | - ); |
|
| 103 | - // Include check-in, check-out data |
|
| 104 | - $incude_checkins = (bool) $job_parameters->request_datum('incude_checkins', 0); |
|
| 105 | - // we should also set the header columns |
|
| 106 | - $csv_data_for_row = $this->get_csv_data_for( |
|
| 107 | - $event_id, |
|
| 108 | - 0, |
|
| 109 | - 1, |
|
| 110 | - $job_parameters->extra_datum('question_labels'), |
|
| 111 | - $job_parameters->extra_datum('query_params'), |
|
| 112 | - $incude_checkins |
|
| 113 | - ); |
|
| 114 | - EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
| 115 | - // if we actually processed a row there, record it |
|
| 116 | - if ($job_parameters->job_size()) { |
|
| 117 | - $job_parameters->mark_processed(1); |
|
| 118 | - } |
|
| 119 | - return new JobStepResponse( |
|
| 120 | - $job_parameters, |
|
| 121 | - esc_html__('Registrations report started successfully...', 'event_espresso') |
|
| 122 | - ); |
|
| 123 | - } |
|
| 36 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 37 | + // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
| 38 | + /** |
|
| 39 | + * Performs any necessary setup for starting the job. This is also a good |
|
| 40 | + * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
| 41 | + * when continue_job will be called |
|
| 42 | + * |
|
| 43 | + * @param JobParameters $job_parameters |
|
| 44 | + * @throws BatchRequestException |
|
| 45 | + * @return JobStepResponse |
|
| 46 | + */ |
|
| 47 | + public function create_job(JobParameters $job_parameters) |
|
| 48 | + { |
|
| 49 | + $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
| 50 | + if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
| 51 | + throw new BatchRequestException(esc_html__('You do not have permission to view registrations', 'event_espresso')); |
|
| 52 | + } |
|
| 53 | + $filepath = $this->create_file_from_job_with_name( |
|
| 54 | + $job_parameters->job_id(), |
|
| 55 | + $this->get_filename($event_id) |
|
| 56 | + ); |
|
| 57 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
| 58 | + if ($job_parameters->request_datum('use_filters', false)) { |
|
| 59 | + $query_params = maybe_unserialize($job_parameters->request_datum('filters', array())); |
|
| 60 | + } else { |
|
| 61 | + $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
| 62 | + array( |
|
| 63 | + 'OR' => array( |
|
| 64 | + // don't include registrations from failed or abandoned transactions... |
|
| 65 | + 'Transaction.STS_ID' => array( |
|
| 66 | + 'NOT IN', |
|
| 67 | + array( |
|
| 68 | + EEM_Transaction::failed_status_code, |
|
| 69 | + EEM_Transaction::abandoned_status_code, |
|
| 70 | + ), |
|
| 71 | + ), |
|
| 72 | + // unless the registration is approved, in which case include it regardless of transaction status |
|
| 73 | + 'STS_ID' => \EEM_Registration::status_id_approved, |
|
| 74 | + ), |
|
| 75 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
| 76 | + ), |
|
| 77 | + 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
| 78 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
| 79 | + 'caps' => \EEM_Base::caps_read_admin, |
|
| 80 | + ), $event_id); |
|
| 81 | + if ($event_id) { |
|
| 82 | + $query_params[0]['EVT_ID'] = $event_id; |
|
| 83 | + } else { |
|
| 84 | + $query_params['force_join'][] = 'Event'; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + if (! isset($query_params['force_join'])) { |
|
| 88 | + $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
|
| 89 | + } |
|
| 90 | + $job_parameters->add_extra_data('query_params', $query_params); |
|
| 91 | + $question_labels = $this->_get_question_labels($query_params); |
|
| 92 | + $job_parameters->add_extra_data('question_labels', $question_labels); |
|
| 93 | + $job_parameters->set_job_size( |
|
| 94 | + \EEM_Registration::instance()->count( |
|
| 95 | + array_diff_key( |
|
| 96 | + $query_params, |
|
| 97 | + array_flip( |
|
| 98 | + array('limit') |
|
| 99 | + ) |
|
| 100 | + ) |
|
| 101 | + ) |
|
| 102 | + ); |
|
| 103 | + // Include check-in, check-out data |
|
| 104 | + $incude_checkins = (bool) $job_parameters->request_datum('incude_checkins', 0); |
|
| 105 | + // we should also set the header columns |
|
| 106 | + $csv_data_for_row = $this->get_csv_data_for( |
|
| 107 | + $event_id, |
|
| 108 | + 0, |
|
| 109 | + 1, |
|
| 110 | + $job_parameters->extra_datum('question_labels'), |
|
| 111 | + $job_parameters->extra_datum('query_params'), |
|
| 112 | + $incude_checkins |
|
| 113 | + ); |
|
| 114 | + EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
| 115 | + // if we actually processed a row there, record it |
|
| 116 | + if ($job_parameters->job_size()) { |
|
| 117 | + $job_parameters->mark_processed(1); |
|
| 118 | + } |
|
| 119 | + return new JobStepResponse( |
|
| 120 | + $job_parameters, |
|
| 121 | + esc_html__('Registrations report started successfully...', 'event_espresso') |
|
| 122 | + ); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Gets the filename |
|
| 128 | - * |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - protected function get_filename() |
|
| 132 | - { |
|
| 133 | - return apply_filters( |
|
| 134 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename', |
|
| 135 | - sprintf( |
|
| 136 | - "event-espresso-registrations-%s.csv", |
|
| 137 | - str_replace(array(':', ' '), '-', current_time('mysql')) |
|
| 138 | - ) |
|
| 139 | - ); |
|
| 140 | - } |
|
| 126 | + /** |
|
| 127 | + * Gets the filename |
|
| 128 | + * |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + protected function get_filename() |
|
| 132 | + { |
|
| 133 | + return apply_filters( |
|
| 134 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename', |
|
| 135 | + sprintf( |
|
| 136 | + "event-espresso-registrations-%s.csv", |
|
| 137 | + str_replace(array(':', ' '), '-', current_time('mysql')) |
|
| 138 | + ) |
|
| 139 | + ); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Gets the questions which are to be used for this report, so they |
|
| 145 | - * can be remembered for later |
|
| 146 | - * |
|
| 147 | - * @param array $registration_query_params |
|
| 148 | - * @return array question admin labels to be used for this report |
|
| 149 | - */ |
|
| 150 | - protected function _get_question_labels($registration_query_params) |
|
| 151 | - { |
|
| 152 | - $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null; |
|
| 153 | - $question_query_params = array(); |
|
| 154 | - if ($where !== null) { |
|
| 155 | - $question_query_params = array( |
|
| 156 | - $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
|
| 157 | - ); |
|
| 158 | - } |
|
| 159 | - // Make sure it's not a system question |
|
| 160 | - $question_query_params[0]['OR*not-system-questions'] = [ |
|
| 161 | - 'QST_system' => '', |
|
| 162 | - 'QST_system*null' => ['IS_NULL'] |
|
| 163 | - ]; |
|
| 164 | - if ( |
|
| 165 | - apply_filters( |
|
| 166 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', |
|
| 167 | - false, |
|
| 168 | - $registration_query_params |
|
| 169 | - ) |
|
| 170 | - ) { |
|
| 171 | - $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL'); |
|
| 172 | - } |
|
| 173 | - $question_query_params['group_by'] = array('QST_ID'); |
|
| 174 | - return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label')); |
|
| 175 | - } |
|
| 143 | + /** |
|
| 144 | + * Gets the questions which are to be used for this report, so they |
|
| 145 | + * can be remembered for later |
|
| 146 | + * |
|
| 147 | + * @param array $registration_query_params |
|
| 148 | + * @return array question admin labels to be used for this report |
|
| 149 | + */ |
|
| 150 | + protected function _get_question_labels($registration_query_params) |
|
| 151 | + { |
|
| 152 | + $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null; |
|
| 153 | + $question_query_params = array(); |
|
| 154 | + if ($where !== null) { |
|
| 155 | + $question_query_params = array( |
|
| 156 | + $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
|
| 157 | + ); |
|
| 158 | + } |
|
| 159 | + // Make sure it's not a system question |
|
| 160 | + $question_query_params[0]['OR*not-system-questions'] = [ |
|
| 161 | + 'QST_system' => '', |
|
| 162 | + 'QST_system*null' => ['IS_NULL'] |
|
| 163 | + ]; |
|
| 164 | + if ( |
|
| 165 | + apply_filters( |
|
| 166 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', |
|
| 167 | + false, |
|
| 168 | + $registration_query_params |
|
| 169 | + ) |
|
| 170 | + ) { |
|
| 171 | + $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL'); |
|
| 172 | + } |
|
| 173 | + $question_query_params['group_by'] = array('QST_ID'); |
|
| 174 | + return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label')); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Takes where params meant for registrations and changes them to work for questions |
|
| 180 | - * |
|
| 181 | - * @param array $reg_where_params |
|
| 182 | - * @return array |
|
| 183 | - */ |
|
| 184 | - protected function _change_registration_where_params_to_question_where_params($reg_where_params) |
|
| 185 | - { |
|
| 186 | - $question_where_params = array(); |
|
| 187 | - foreach ($reg_where_params as $key => $val) { |
|
| 188 | - if (\EEM_Registration::instance()->is_logic_query_param_key($key)) { |
|
| 189 | - $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val); |
|
| 190 | - } else { |
|
| 191 | - // it's a normal where condition |
|
| 192 | - $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val; |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - return $question_where_params; |
|
| 196 | - } |
|
| 178 | + /** |
|
| 179 | + * Takes where params meant for registrations and changes them to work for questions |
|
| 180 | + * |
|
| 181 | + * @param array $reg_where_params |
|
| 182 | + * @return array |
|
| 183 | + */ |
|
| 184 | + protected function _change_registration_where_params_to_question_where_params($reg_where_params) |
|
| 185 | + { |
|
| 186 | + $question_where_params = array(); |
|
| 187 | + foreach ($reg_where_params as $key => $val) { |
|
| 188 | + if (\EEM_Registration::instance()->is_logic_query_param_key($key)) { |
|
| 189 | + $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val); |
|
| 190 | + } else { |
|
| 191 | + // it's a normal where condition |
|
| 192 | + $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val; |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + return $question_where_params; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * Performs another step of the job |
|
| 201 | - * |
|
| 202 | - * @param JobParameters $job_parameters |
|
| 203 | - * @param int $batch_size |
|
| 204 | - * @return JobStepResponse |
|
| 205 | - * @throws \EE_Error |
|
| 206 | - */ |
|
| 207 | - public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
| 208 | - { |
|
| 209 | - if ($job_parameters->units_processed() < $job_parameters->job_size()) { |
|
| 210 | - // Include check-in, check-out data |
|
| 211 | - $incude_checkins = (bool) $job_parameters->request_datum('incude_checkins', 0); |
|
| 212 | - $csv_data = $this->get_csv_data_for( |
|
| 213 | - $job_parameters->request_datum('EVT_ID', '0'), |
|
| 214 | - $job_parameters->units_processed(), |
|
| 215 | - $batch_size, |
|
| 216 | - $job_parameters->extra_datum('question_labels'), |
|
| 217 | - $job_parameters->extra_datum('query_params'), |
|
| 218 | - $incude_checkins |
|
| 219 | - ); |
|
| 220 | - EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
| 221 | - $units_processed = count($csv_data); |
|
| 222 | - } else { |
|
| 223 | - $csv_data = array(); |
|
| 224 | - $units_processed = 0; |
|
| 225 | - } |
|
| 226 | - $job_parameters->mark_processed($units_processed); |
|
| 227 | - $extra_response_data = array( |
|
| 228 | - 'file_url' => '', |
|
| 229 | - ); |
|
| 230 | - if ($units_processed < $batch_size) { |
|
| 231 | - $job_parameters->set_status(JobParameters::status_complete); |
|
| 232 | - $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
| 233 | - } |
|
| 199 | + /** |
|
| 200 | + * Performs another step of the job |
|
| 201 | + * |
|
| 202 | + * @param JobParameters $job_parameters |
|
| 203 | + * @param int $batch_size |
|
| 204 | + * @return JobStepResponse |
|
| 205 | + * @throws \EE_Error |
|
| 206 | + */ |
|
| 207 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
| 208 | + { |
|
| 209 | + if ($job_parameters->units_processed() < $job_parameters->job_size()) { |
|
| 210 | + // Include check-in, check-out data |
|
| 211 | + $incude_checkins = (bool) $job_parameters->request_datum('incude_checkins', 0); |
|
| 212 | + $csv_data = $this->get_csv_data_for( |
|
| 213 | + $job_parameters->request_datum('EVT_ID', '0'), |
|
| 214 | + $job_parameters->units_processed(), |
|
| 215 | + $batch_size, |
|
| 216 | + $job_parameters->extra_datum('question_labels'), |
|
| 217 | + $job_parameters->extra_datum('query_params'), |
|
| 218 | + $incude_checkins |
|
| 219 | + ); |
|
| 220 | + EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
| 221 | + $units_processed = count($csv_data); |
|
| 222 | + } else { |
|
| 223 | + $csv_data = array(); |
|
| 224 | + $units_processed = 0; |
|
| 225 | + } |
|
| 226 | + $job_parameters->mark_processed($units_processed); |
|
| 227 | + $extra_response_data = array( |
|
| 228 | + 'file_url' => '', |
|
| 229 | + ); |
|
| 230 | + if ($units_processed < $batch_size) { |
|
| 231 | + $job_parameters->set_status(JobParameters::status_complete); |
|
| 232 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - return new JobStepResponse( |
|
| 236 | - $job_parameters, |
|
| 237 | - sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)), |
|
| 238 | - $extra_response_data |
|
| 239 | - ); |
|
| 240 | - } |
|
| 235 | + return new JobStepResponse( |
|
| 236 | + $job_parameters, |
|
| 237 | + sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)), |
|
| 238 | + $extra_response_data |
|
| 239 | + ); |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Gets the csv data for a batch of registrations |
|
| 245 | - * |
|
| 246 | - * @param int|null $event_id |
|
| 247 | - * @param int $offset |
|
| 248 | - * @param int $limit |
|
| 249 | - * @param array $question_labels the IDs for all the questions which were answered by someone in this selection |
|
| 250 | - * @param array $query_params for using where querying the model |
|
| 251 | - * @param bool $incude_checkins |
|
| 252 | - * @return array top-level keys are numeric, next-level keys are column headers |
|
| 253 | - * @throws \EE_Error |
|
| 254 | - * @throws \ReflectionException |
|
| 255 | - */ |
|
| 256 | - public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params, $incude_checkins = false) |
|
| 257 | - { |
|
| 258 | - $reg_fields_to_include = [ |
|
| 259 | - 'TXN_ID', |
|
| 260 | - 'ATT_ID', |
|
| 261 | - 'REG_ID', |
|
| 262 | - 'REG_date', |
|
| 263 | - 'REG_code', |
|
| 264 | - 'REG_count', |
|
| 265 | - 'REG_final_price', |
|
| 266 | - ]; |
|
| 267 | - $att_fields_to_include = [ |
|
| 268 | - 'ATT_fname', |
|
| 269 | - 'ATT_lname', |
|
| 270 | - 'ATT_email', |
|
| 271 | - 'ATT_address', |
|
| 272 | - 'ATT_address2', |
|
| 273 | - 'ATT_city', |
|
| 274 | - 'STA_ID', |
|
| 275 | - 'CNT_ISO', |
|
| 276 | - 'ATT_zip', |
|
| 277 | - 'ATT_phone', |
|
| 278 | - ]; |
|
| 279 | - $registrations_csv_ready_array = []; |
|
| 280 | - $reg_model = EE_Registry::instance()->load_model('Registration'); |
|
| 281 | - $query_params['limit'] = [$offset, $limit]; |
|
| 282 | - $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
| 283 | - foreach ($registration_rows as $reg_row) { |
|
| 284 | - if (!is_array($reg_row)) { |
|
| 285 | - continue; |
|
| 286 | - } |
|
| 287 | - $reg_csv_array = []; |
|
| 288 | - if (! $event_id) { |
|
| 289 | - // get the event's name and Id |
|
| 290 | - $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf( |
|
| 291 | - /* translators: 1: event name, 2: event ID */ |
|
| 292 | - esc_html__('%1$s (%2$s)', 'event_espresso'), |
|
| 293 | - EEH_Export::prepare_value_from_db_for_display( |
|
| 294 | - EEM_Event::instance(), |
|
| 295 | - 'EVT_name', |
|
| 296 | - $reg_row['Event_CPT.post_title'] |
|
| 297 | - ), |
|
| 298 | - $reg_row['Event_CPT.ID'] |
|
| 299 | - ); |
|
| 300 | - } |
|
| 301 | - $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
| 302 | - /*@var $reg_row EE_Registration */ |
|
| 303 | - foreach ($reg_fields_to_include as $field_name) { |
|
| 304 | - $field = $reg_model->field_settings_for($field_name); |
|
| 305 | - if ($field_name == 'REG_final_price') { |
|
| 306 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
| 307 | - $reg_model, |
|
| 308 | - $field_name, |
|
| 309 | - $reg_row['Registration.REG_final_price'], |
|
| 310 | - 'localized_float' |
|
| 311 | - ); |
|
| 312 | - } elseif ($field_name == 'REG_count') { |
|
| 313 | - $value = sprintf( |
|
| 314 | - /* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */ |
|
| 315 | - esc_html__('%1$s of %2$s', 'event_espresso'), |
|
| 316 | - EEH_Export::prepare_value_from_db_for_display( |
|
| 317 | - $reg_model, |
|
| 318 | - 'REG_count', |
|
| 319 | - $reg_row['Registration.REG_count'] |
|
| 320 | - ), |
|
| 321 | - EEH_Export::prepare_value_from_db_for_display( |
|
| 322 | - $reg_model, |
|
| 323 | - 'REG_group_size', |
|
| 324 | - $reg_row['Registration.REG_group_size'] |
|
| 325 | - ) |
|
| 326 | - ); |
|
| 327 | - } elseif ($field_name == 'REG_date') { |
|
| 328 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
| 329 | - $reg_model, |
|
| 330 | - $field_name, |
|
| 331 | - $reg_row['Registration.REG_date'], |
|
| 332 | - 'no_html' |
|
| 333 | - ); |
|
| 334 | - } else { |
|
| 335 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
| 336 | - $reg_model, |
|
| 337 | - $field_name, |
|
| 338 | - $reg_row[ $field->get_qualified_column() ] |
|
| 339 | - ); |
|
| 340 | - } |
|
| 341 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value; |
|
| 342 | - if ($field_name == 'REG_final_price') { |
|
| 343 | - // add a column named Currency after the final price |
|
| 344 | - $reg_csv_array[ (string) esc_html__("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code; |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - // get pretty status |
|
| 348 | - $stati = EEM_Status::instance()->localized_status( |
|
| 349 | - [ |
|
| 350 | - $reg_row['Registration.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
| 351 | - $reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
| 352 | - ], |
|
| 353 | - false, |
|
| 354 | - 'sentence' |
|
| 355 | - ); |
|
| 356 | - $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ]; |
|
| 357 | - // get pretty transaction status |
|
| 358 | - $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ]; |
|
| 359 | - $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg |
|
| 360 | - ? EEH_Export::prepare_value_from_db_for_display( |
|
| 361 | - EEM_Transaction::instance(), |
|
| 362 | - 'TXN_total', |
|
| 363 | - $reg_row['TransactionTable.TXN_total'], |
|
| 364 | - 'localized_float' |
|
| 365 | - ) : '0.00'; |
|
| 366 | - $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg |
|
| 367 | - ? EEH_Export::prepare_value_from_db_for_display( |
|
| 368 | - EEM_Transaction::instance(), |
|
| 369 | - 'TXN_paid', |
|
| 370 | - $reg_row['TransactionTable.TXN_paid'], |
|
| 371 | - 'localized_float' |
|
| 372 | - ) : '0.00'; |
|
| 373 | - $payment_methods = []; |
|
| 374 | - $gateway_txn_ids_etc = []; |
|
| 375 | - $payment_times = []; |
|
| 376 | - if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
| 377 | - $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
|
| 378 | - [ |
|
| 379 | - [ |
|
| 380 | - 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
| 381 | - 'STS_ID' => EEM_Payment::status_id_approved, |
|
| 382 | - ], |
|
| 383 | - 'force_join' => ['Payment_Method'], |
|
| 384 | - ], |
|
| 385 | - ARRAY_A, |
|
| 386 | - 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' |
|
| 387 | - ); |
|
| 388 | - foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
| 389 | - $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
| 390 | - ? $payment_method_and_gateway_txn_id['name'] : esc_html__('Unknown', 'event_espresso'); |
|
| 391 | - $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
| 392 | - ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
| 393 | - $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
| 394 | - ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times); |
|
| 398 | - $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods); |
|
| 399 | - $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode( |
|
| 400 | - ',', |
|
| 401 | - $gateway_txn_ids_etc |
|
| 402 | - ); |
|
| 403 | - // get whether or not the user has checked in |
|
| 404 | - $reg_csv_array[ (string) esc_html__('Check-Ins', 'event_espresso') ] = $reg_model->count_related( |
|
| 405 | - $reg_row['Registration.REG_ID'], |
|
| 406 | - 'Checkin' |
|
| 407 | - ); |
|
| 408 | - // get ticket of registration and its price |
|
| 409 | - $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
|
| 410 | - if ($reg_row['Ticket.TKT_ID']) { |
|
| 411 | - $ticket_name = EEH_Export::prepare_value_from_db_for_display( |
|
| 412 | - $ticket_model, |
|
| 413 | - 'TKT_name', |
|
| 414 | - $reg_row['Ticket.TKT_name'] |
|
| 415 | - ); |
|
| 416 | - $datetimes_strings = []; |
|
| 417 | - foreach ( |
|
| 418 | - EEM_Datetime::instance()->get_all_wpdb_results( |
|
| 419 | - [ |
|
| 420 | - ['Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']], |
|
| 421 | - 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
| 422 | - 'default_where_conditions' => 'none', |
|
| 423 | - ] |
|
| 424 | - ) as $datetime |
|
| 425 | - ) { |
|
| 426 | - $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display( |
|
| 427 | - EEM_Datetime::instance(), |
|
| 428 | - 'DTT_EVT_start', |
|
| 429 | - $datetime['Datetime.DTT_EVT_start'] |
|
| 430 | - ); |
|
| 431 | - } |
|
| 432 | - } else { |
|
| 433 | - $ticket_name = esc_html__('Unknown', 'event_espresso'); |
|
| 434 | - $datetimes_strings = [esc_html__('Unknown', 'event_espresso')]; |
|
| 435 | - } |
|
| 436 | - $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name; |
|
| 437 | - $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings); |
|
| 438 | - // get datetime(s) of registration |
|
| 439 | - // add attendee columns |
|
| 440 | - foreach ($att_fields_to_include as $att_field_name) { |
|
| 441 | - $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
| 442 | - if ($reg_row['Attendee_CPT.ID']) { |
|
| 443 | - if ($att_field_name == 'STA_ID') { |
|
| 444 | - $value = EEM_State::instance()->get_var( |
|
| 445 | - [ |
|
| 446 | - ['STA_ID' => $reg_row['Attendee_Meta.STA_ID']] |
|
| 447 | - ], |
|
| 448 | - 'STA_name' |
|
| 449 | - ); |
|
| 450 | - } elseif ($att_field_name == 'CNT_ISO') { |
|
| 451 | - $value = EEM_Country::instance()->get_var( |
|
| 452 | - [ |
|
| 453 | - ['CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO']] |
|
| 454 | - ], |
|
| 455 | - 'CNT_name' |
|
| 456 | - ); |
|
| 457 | - } else { |
|
| 458 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
| 459 | - EEM_Attendee::instance(), |
|
| 460 | - $att_field_name, |
|
| 461 | - $reg_row[ $field_obj->get_qualified_column() ] |
|
| 462 | - ); |
|
| 463 | - } |
|
| 464 | - } else { |
|
| 465 | - $value = ''; |
|
| 466 | - } |
|
| 467 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
| 468 | - } |
|
| 469 | - // make sure each registration has the same questions in the same order |
|
| 470 | - foreach ($question_labels as $question_label) { |
|
| 471 | - if (! isset($reg_csv_array[ $question_label ])) { |
|
| 472 | - $reg_csv_array[ $question_label ] = null; |
|
| 473 | - } |
|
| 474 | - } |
|
| 475 | - $answers = EEM_Answer::instance()->get_all_wpdb_results([ |
|
| 476 | - ['REG_ID' => $reg_row['Registration.REG_ID']], |
|
| 477 | - 'force_join' => ['Question'], |
|
| 478 | - ]); |
|
| 479 | - // now fill out the questions THEY answered |
|
| 480 | - foreach ($answers as $answer_row) { |
|
| 481 | - if ($answer_row['Question.QST_system']) { |
|
| 482 | - // it's an answer to a system question. That was already displayed as part of the attendee |
|
| 483 | - // fields, so don't write it out again thanks. |
|
| 484 | - continue; |
|
| 485 | - } |
|
| 486 | - if ($answer_row['Question.QST_ID']) { |
|
| 487 | - $question_label = EEH_Export::prepare_value_from_db_for_display( |
|
| 488 | - EEM_Question::instance(), |
|
| 489 | - 'QST_admin_label', |
|
| 490 | - $answer_row['Question.QST_admin_label'] |
|
| 491 | - ); |
|
| 492 | - } else { |
|
| 493 | - $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
| 494 | - } |
|
| 495 | - if ( |
|
| 496 | - isset($answer_row['Question.QST_type']) |
|
| 497 | - && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
|
| 498 | - ) { |
|
| 499 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
| 500 | - $answer_row['Answer.ANS_value'] |
|
| 501 | - ); |
|
| 502 | - } else { |
|
| 503 | - // this isn't for html, so don't show html entities |
|
| 504 | - $reg_csv_array[ $question_label ] = html_entity_decode( |
|
| 505 | - EEH_Export::prepare_value_from_db_for_display( |
|
| 506 | - EEM_Answer::instance(), |
|
| 507 | - 'ANS_value', |
|
| 508 | - $answer_row['Answer.ANS_value'] |
|
| 509 | - ) |
|
| 510 | - ); |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - // Include check-in data |
|
| 514 | - if ($incude_checkins) { |
|
| 515 | - $datetimes = EEM_Datetime::instance()->get_all_wpdb_results( |
|
| 516 | - [ |
|
| 517 | - [ |
|
| 518 | - 'Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID'] |
|
| 519 | - ], |
|
| 520 | - 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
| 521 | - 'default_where_conditions' => 'none', |
|
| 522 | - ] |
|
| 523 | - ); |
|
| 524 | - foreach ($datetimes as $datetime) { |
|
| 525 | - $checkin_row = EEM_Checkin::instance()->get_one( |
|
| 526 | - [ |
|
| 527 | - [ |
|
| 528 | - 'REG_ID' => $reg_row['Registration.REG_ID'], |
|
| 529 | - 'DTT_ID' => $datetime['Datetime.DTT_ID'], |
|
| 530 | - ], |
|
| 531 | - 'limit' => 1, |
|
| 532 | - 'order_by' => [ |
|
| 533 | - 'CHK_ID' => 'DESC' |
|
| 534 | - ] |
|
| 535 | - ] |
|
| 536 | - ); |
|
| 537 | - if (trim($datetime['Datetime.DTT_name'])) { |
|
| 538 | - /* translators: 1: datetime name, 2: datetime ID */ |
|
| 539 | - $datetime_name = sprintf( |
|
| 540 | - esc_html__('%1$s - ID: %2$s', 'event_espresso'), |
|
| 541 | - esc_html($datetime['Datetime.DTT_name']), |
|
| 542 | - esc_html($datetime['Datetime.DTT_ID']) |
|
| 543 | - ); |
|
| 544 | - } else { |
|
| 545 | - /* translators: %s: datetime ID */ |
|
| 546 | - $datetime_name = sprintf( |
|
| 547 | - esc_html__('ID: %1$s', 'event_espresso'), |
|
| 548 | - esc_html($datetime['Datetime.DTT_ID']) |
|
| 549 | - ); |
|
| 550 | - } |
|
| 551 | - $checkin_value = ''; |
|
| 552 | - if ($checkin_row instanceof EE_Checkin && $checkin_row->get('CHK_in') === true) { |
|
| 553 | - /* translators: 1: check-in status, 2: check-in timestamp */ |
|
| 554 | - $checkin_value = sprintf( |
|
| 555 | - esc_html__('%1$s - %2$s', 'event_espresso'), |
|
| 556 | - esc_html__('IN', 'event_espresso'), |
|
| 557 | - date('Y-m-d H:i:s', $checkin_row->get_raw('CHK_timestamp')) |
|
| 558 | - ); |
|
| 559 | - } elseif ($checkin_row instanceof EE_Checkin && $checkin_row->get('CHK_in') === false) { |
|
| 560 | - /* translators: 1: check-in status, 2: check-in timestamp */ |
|
| 561 | - $checkin_value = sprintf( |
|
| 562 | - esc_html__('%1$s - %2$s', 'event_espresso'), |
|
| 563 | - esc_html__('OUT', 'event_espresso'), |
|
| 564 | - date('Y-m-d H:i:s', $checkin_row->get_raw('CHK_timestamp')) |
|
| 565 | - ); |
|
| 566 | - } |
|
| 567 | - $reg_csv_array[ (string) $datetime_name ] = $checkin_value; |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - /** |
|
| 571 | - * Filter to change the contents of each row of the registrations report CSV file. |
|
| 572 | - * This can be used to add or remote columns from the CSV file, or change their values. |
|
| 573 | - * Note when using: all rows in the CSV should have the same columns. |
|
| 574 | - * @param array $reg_csv_array keys are the column names, values are their cell values |
|
| 575 | - * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results() |
|
| 576 | - */ |
|
| 577 | - $registrations_csv_ready_array[] = apply_filters( |
|
| 578 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
| 579 | - $reg_csv_array, |
|
| 580 | - $reg_row |
|
| 581 | - ); |
|
| 582 | - } |
|
| 583 | - // if we couldn't export anything, we want to at least show the column headers |
|
| 584 | - if (empty($registrations_csv_ready_array)) { |
|
| 585 | - $reg_csv_array = []; |
|
| 586 | - $model_and_fields_to_include = [ |
|
| 587 | - 'Registration' => $reg_fields_to_include, |
|
| 588 | - 'Attendee' => $att_fields_to_include, |
|
| 589 | - ]; |
|
| 590 | - foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
| 591 | - $model = EE_Registry::instance()->load_model($model_name); |
|
| 592 | - foreach ($field_list as $field_name) { |
|
| 593 | - $field = $model->field_settings_for($field_name); |
|
| 594 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null; |
|
| 595 | - } |
|
| 596 | - } |
|
| 597 | - $registrations_csv_ready_array[] = $reg_csv_array; |
|
| 598 | - } |
|
| 599 | - return $registrations_csv_ready_array; |
|
| 600 | - } |
|
| 243 | + /** |
|
| 244 | + * Gets the csv data for a batch of registrations |
|
| 245 | + * |
|
| 246 | + * @param int|null $event_id |
|
| 247 | + * @param int $offset |
|
| 248 | + * @param int $limit |
|
| 249 | + * @param array $question_labels the IDs for all the questions which were answered by someone in this selection |
|
| 250 | + * @param array $query_params for using where querying the model |
|
| 251 | + * @param bool $incude_checkins |
|
| 252 | + * @return array top-level keys are numeric, next-level keys are column headers |
|
| 253 | + * @throws \EE_Error |
|
| 254 | + * @throws \ReflectionException |
|
| 255 | + */ |
|
| 256 | + public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params, $incude_checkins = false) |
|
| 257 | + { |
|
| 258 | + $reg_fields_to_include = [ |
|
| 259 | + 'TXN_ID', |
|
| 260 | + 'ATT_ID', |
|
| 261 | + 'REG_ID', |
|
| 262 | + 'REG_date', |
|
| 263 | + 'REG_code', |
|
| 264 | + 'REG_count', |
|
| 265 | + 'REG_final_price', |
|
| 266 | + ]; |
|
| 267 | + $att_fields_to_include = [ |
|
| 268 | + 'ATT_fname', |
|
| 269 | + 'ATT_lname', |
|
| 270 | + 'ATT_email', |
|
| 271 | + 'ATT_address', |
|
| 272 | + 'ATT_address2', |
|
| 273 | + 'ATT_city', |
|
| 274 | + 'STA_ID', |
|
| 275 | + 'CNT_ISO', |
|
| 276 | + 'ATT_zip', |
|
| 277 | + 'ATT_phone', |
|
| 278 | + ]; |
|
| 279 | + $registrations_csv_ready_array = []; |
|
| 280 | + $reg_model = EE_Registry::instance()->load_model('Registration'); |
|
| 281 | + $query_params['limit'] = [$offset, $limit]; |
|
| 282 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
| 283 | + foreach ($registration_rows as $reg_row) { |
|
| 284 | + if (!is_array($reg_row)) { |
|
| 285 | + continue; |
|
| 286 | + } |
|
| 287 | + $reg_csv_array = []; |
|
| 288 | + if (! $event_id) { |
|
| 289 | + // get the event's name and Id |
|
| 290 | + $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf( |
|
| 291 | + /* translators: 1: event name, 2: event ID */ |
|
| 292 | + esc_html__('%1$s (%2$s)', 'event_espresso'), |
|
| 293 | + EEH_Export::prepare_value_from_db_for_display( |
|
| 294 | + EEM_Event::instance(), |
|
| 295 | + 'EVT_name', |
|
| 296 | + $reg_row['Event_CPT.post_title'] |
|
| 297 | + ), |
|
| 298 | + $reg_row['Event_CPT.ID'] |
|
| 299 | + ); |
|
| 300 | + } |
|
| 301 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
| 302 | + /*@var $reg_row EE_Registration */ |
|
| 303 | + foreach ($reg_fields_to_include as $field_name) { |
|
| 304 | + $field = $reg_model->field_settings_for($field_name); |
|
| 305 | + if ($field_name == 'REG_final_price') { |
|
| 306 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
| 307 | + $reg_model, |
|
| 308 | + $field_name, |
|
| 309 | + $reg_row['Registration.REG_final_price'], |
|
| 310 | + 'localized_float' |
|
| 311 | + ); |
|
| 312 | + } elseif ($field_name == 'REG_count') { |
|
| 313 | + $value = sprintf( |
|
| 314 | + /* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */ |
|
| 315 | + esc_html__('%1$s of %2$s', 'event_espresso'), |
|
| 316 | + EEH_Export::prepare_value_from_db_for_display( |
|
| 317 | + $reg_model, |
|
| 318 | + 'REG_count', |
|
| 319 | + $reg_row['Registration.REG_count'] |
|
| 320 | + ), |
|
| 321 | + EEH_Export::prepare_value_from_db_for_display( |
|
| 322 | + $reg_model, |
|
| 323 | + 'REG_group_size', |
|
| 324 | + $reg_row['Registration.REG_group_size'] |
|
| 325 | + ) |
|
| 326 | + ); |
|
| 327 | + } elseif ($field_name == 'REG_date') { |
|
| 328 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
| 329 | + $reg_model, |
|
| 330 | + $field_name, |
|
| 331 | + $reg_row['Registration.REG_date'], |
|
| 332 | + 'no_html' |
|
| 333 | + ); |
|
| 334 | + } else { |
|
| 335 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
| 336 | + $reg_model, |
|
| 337 | + $field_name, |
|
| 338 | + $reg_row[ $field->get_qualified_column() ] |
|
| 339 | + ); |
|
| 340 | + } |
|
| 341 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value; |
|
| 342 | + if ($field_name == 'REG_final_price') { |
|
| 343 | + // add a column named Currency after the final price |
|
| 344 | + $reg_csv_array[ (string) esc_html__("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code; |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + // get pretty status |
|
| 348 | + $stati = EEM_Status::instance()->localized_status( |
|
| 349 | + [ |
|
| 350 | + $reg_row['Registration.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
| 351 | + $reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
| 352 | + ], |
|
| 353 | + false, |
|
| 354 | + 'sentence' |
|
| 355 | + ); |
|
| 356 | + $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ]; |
|
| 357 | + // get pretty transaction status |
|
| 358 | + $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ]; |
|
| 359 | + $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg |
|
| 360 | + ? EEH_Export::prepare_value_from_db_for_display( |
|
| 361 | + EEM_Transaction::instance(), |
|
| 362 | + 'TXN_total', |
|
| 363 | + $reg_row['TransactionTable.TXN_total'], |
|
| 364 | + 'localized_float' |
|
| 365 | + ) : '0.00'; |
|
| 366 | + $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg |
|
| 367 | + ? EEH_Export::prepare_value_from_db_for_display( |
|
| 368 | + EEM_Transaction::instance(), |
|
| 369 | + 'TXN_paid', |
|
| 370 | + $reg_row['TransactionTable.TXN_paid'], |
|
| 371 | + 'localized_float' |
|
| 372 | + ) : '0.00'; |
|
| 373 | + $payment_methods = []; |
|
| 374 | + $gateway_txn_ids_etc = []; |
|
| 375 | + $payment_times = []; |
|
| 376 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
| 377 | + $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
|
| 378 | + [ |
|
| 379 | + [ |
|
| 380 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
| 381 | + 'STS_ID' => EEM_Payment::status_id_approved, |
|
| 382 | + ], |
|
| 383 | + 'force_join' => ['Payment_Method'], |
|
| 384 | + ], |
|
| 385 | + ARRAY_A, |
|
| 386 | + 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' |
|
| 387 | + ); |
|
| 388 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
| 389 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
| 390 | + ? $payment_method_and_gateway_txn_id['name'] : esc_html__('Unknown', 'event_espresso'); |
|
| 391 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
| 392 | + ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
| 393 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
| 394 | + ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times); |
|
| 398 | + $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods); |
|
| 399 | + $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode( |
|
| 400 | + ',', |
|
| 401 | + $gateway_txn_ids_etc |
|
| 402 | + ); |
|
| 403 | + // get whether or not the user has checked in |
|
| 404 | + $reg_csv_array[ (string) esc_html__('Check-Ins', 'event_espresso') ] = $reg_model->count_related( |
|
| 405 | + $reg_row['Registration.REG_ID'], |
|
| 406 | + 'Checkin' |
|
| 407 | + ); |
|
| 408 | + // get ticket of registration and its price |
|
| 409 | + $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
|
| 410 | + if ($reg_row['Ticket.TKT_ID']) { |
|
| 411 | + $ticket_name = EEH_Export::prepare_value_from_db_for_display( |
|
| 412 | + $ticket_model, |
|
| 413 | + 'TKT_name', |
|
| 414 | + $reg_row['Ticket.TKT_name'] |
|
| 415 | + ); |
|
| 416 | + $datetimes_strings = []; |
|
| 417 | + foreach ( |
|
| 418 | + EEM_Datetime::instance()->get_all_wpdb_results( |
|
| 419 | + [ |
|
| 420 | + ['Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']], |
|
| 421 | + 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
| 422 | + 'default_where_conditions' => 'none', |
|
| 423 | + ] |
|
| 424 | + ) as $datetime |
|
| 425 | + ) { |
|
| 426 | + $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display( |
|
| 427 | + EEM_Datetime::instance(), |
|
| 428 | + 'DTT_EVT_start', |
|
| 429 | + $datetime['Datetime.DTT_EVT_start'] |
|
| 430 | + ); |
|
| 431 | + } |
|
| 432 | + } else { |
|
| 433 | + $ticket_name = esc_html__('Unknown', 'event_espresso'); |
|
| 434 | + $datetimes_strings = [esc_html__('Unknown', 'event_espresso')]; |
|
| 435 | + } |
|
| 436 | + $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name; |
|
| 437 | + $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings); |
|
| 438 | + // get datetime(s) of registration |
|
| 439 | + // add attendee columns |
|
| 440 | + foreach ($att_fields_to_include as $att_field_name) { |
|
| 441 | + $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
| 442 | + if ($reg_row['Attendee_CPT.ID']) { |
|
| 443 | + if ($att_field_name == 'STA_ID') { |
|
| 444 | + $value = EEM_State::instance()->get_var( |
|
| 445 | + [ |
|
| 446 | + ['STA_ID' => $reg_row['Attendee_Meta.STA_ID']] |
|
| 447 | + ], |
|
| 448 | + 'STA_name' |
|
| 449 | + ); |
|
| 450 | + } elseif ($att_field_name == 'CNT_ISO') { |
|
| 451 | + $value = EEM_Country::instance()->get_var( |
|
| 452 | + [ |
|
| 453 | + ['CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO']] |
|
| 454 | + ], |
|
| 455 | + 'CNT_name' |
|
| 456 | + ); |
|
| 457 | + } else { |
|
| 458 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
| 459 | + EEM_Attendee::instance(), |
|
| 460 | + $att_field_name, |
|
| 461 | + $reg_row[ $field_obj->get_qualified_column() ] |
|
| 462 | + ); |
|
| 463 | + } |
|
| 464 | + } else { |
|
| 465 | + $value = ''; |
|
| 466 | + } |
|
| 467 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
| 468 | + } |
|
| 469 | + // make sure each registration has the same questions in the same order |
|
| 470 | + foreach ($question_labels as $question_label) { |
|
| 471 | + if (! isset($reg_csv_array[ $question_label ])) { |
|
| 472 | + $reg_csv_array[ $question_label ] = null; |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | + $answers = EEM_Answer::instance()->get_all_wpdb_results([ |
|
| 476 | + ['REG_ID' => $reg_row['Registration.REG_ID']], |
|
| 477 | + 'force_join' => ['Question'], |
|
| 478 | + ]); |
|
| 479 | + // now fill out the questions THEY answered |
|
| 480 | + foreach ($answers as $answer_row) { |
|
| 481 | + if ($answer_row['Question.QST_system']) { |
|
| 482 | + // it's an answer to a system question. That was already displayed as part of the attendee |
|
| 483 | + // fields, so don't write it out again thanks. |
|
| 484 | + continue; |
|
| 485 | + } |
|
| 486 | + if ($answer_row['Question.QST_ID']) { |
|
| 487 | + $question_label = EEH_Export::prepare_value_from_db_for_display( |
|
| 488 | + EEM_Question::instance(), |
|
| 489 | + 'QST_admin_label', |
|
| 490 | + $answer_row['Question.QST_admin_label'] |
|
| 491 | + ); |
|
| 492 | + } else { |
|
| 493 | + $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
| 494 | + } |
|
| 495 | + if ( |
|
| 496 | + isset($answer_row['Question.QST_type']) |
|
| 497 | + && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
|
| 498 | + ) { |
|
| 499 | + $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
| 500 | + $answer_row['Answer.ANS_value'] |
|
| 501 | + ); |
|
| 502 | + } else { |
|
| 503 | + // this isn't for html, so don't show html entities |
|
| 504 | + $reg_csv_array[ $question_label ] = html_entity_decode( |
|
| 505 | + EEH_Export::prepare_value_from_db_for_display( |
|
| 506 | + EEM_Answer::instance(), |
|
| 507 | + 'ANS_value', |
|
| 508 | + $answer_row['Answer.ANS_value'] |
|
| 509 | + ) |
|
| 510 | + ); |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + // Include check-in data |
|
| 514 | + if ($incude_checkins) { |
|
| 515 | + $datetimes = EEM_Datetime::instance()->get_all_wpdb_results( |
|
| 516 | + [ |
|
| 517 | + [ |
|
| 518 | + 'Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID'] |
|
| 519 | + ], |
|
| 520 | + 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
| 521 | + 'default_where_conditions' => 'none', |
|
| 522 | + ] |
|
| 523 | + ); |
|
| 524 | + foreach ($datetimes as $datetime) { |
|
| 525 | + $checkin_row = EEM_Checkin::instance()->get_one( |
|
| 526 | + [ |
|
| 527 | + [ |
|
| 528 | + 'REG_ID' => $reg_row['Registration.REG_ID'], |
|
| 529 | + 'DTT_ID' => $datetime['Datetime.DTT_ID'], |
|
| 530 | + ], |
|
| 531 | + 'limit' => 1, |
|
| 532 | + 'order_by' => [ |
|
| 533 | + 'CHK_ID' => 'DESC' |
|
| 534 | + ] |
|
| 535 | + ] |
|
| 536 | + ); |
|
| 537 | + if (trim($datetime['Datetime.DTT_name'])) { |
|
| 538 | + /* translators: 1: datetime name, 2: datetime ID */ |
|
| 539 | + $datetime_name = sprintf( |
|
| 540 | + esc_html__('%1$s - ID: %2$s', 'event_espresso'), |
|
| 541 | + esc_html($datetime['Datetime.DTT_name']), |
|
| 542 | + esc_html($datetime['Datetime.DTT_ID']) |
|
| 543 | + ); |
|
| 544 | + } else { |
|
| 545 | + /* translators: %s: datetime ID */ |
|
| 546 | + $datetime_name = sprintf( |
|
| 547 | + esc_html__('ID: %1$s', 'event_espresso'), |
|
| 548 | + esc_html($datetime['Datetime.DTT_ID']) |
|
| 549 | + ); |
|
| 550 | + } |
|
| 551 | + $checkin_value = ''; |
|
| 552 | + if ($checkin_row instanceof EE_Checkin && $checkin_row->get('CHK_in') === true) { |
|
| 553 | + /* translators: 1: check-in status, 2: check-in timestamp */ |
|
| 554 | + $checkin_value = sprintf( |
|
| 555 | + esc_html__('%1$s - %2$s', 'event_espresso'), |
|
| 556 | + esc_html__('IN', 'event_espresso'), |
|
| 557 | + date('Y-m-d H:i:s', $checkin_row->get_raw('CHK_timestamp')) |
|
| 558 | + ); |
|
| 559 | + } elseif ($checkin_row instanceof EE_Checkin && $checkin_row->get('CHK_in') === false) { |
|
| 560 | + /* translators: 1: check-in status, 2: check-in timestamp */ |
|
| 561 | + $checkin_value = sprintf( |
|
| 562 | + esc_html__('%1$s - %2$s', 'event_espresso'), |
|
| 563 | + esc_html__('OUT', 'event_espresso'), |
|
| 564 | + date('Y-m-d H:i:s', $checkin_row->get_raw('CHK_timestamp')) |
|
| 565 | + ); |
|
| 566 | + } |
|
| 567 | + $reg_csv_array[ (string) $datetime_name ] = $checkin_value; |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + /** |
|
| 571 | + * Filter to change the contents of each row of the registrations report CSV file. |
|
| 572 | + * This can be used to add or remote columns from the CSV file, or change their values. |
|
| 573 | + * Note when using: all rows in the CSV should have the same columns. |
|
| 574 | + * @param array $reg_csv_array keys are the column names, values are their cell values |
|
| 575 | + * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results() |
|
| 576 | + */ |
|
| 577 | + $registrations_csv_ready_array[] = apply_filters( |
|
| 578 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
| 579 | + $reg_csv_array, |
|
| 580 | + $reg_row |
|
| 581 | + ); |
|
| 582 | + } |
|
| 583 | + // if we couldn't export anything, we want to at least show the column headers |
|
| 584 | + if (empty($registrations_csv_ready_array)) { |
|
| 585 | + $reg_csv_array = []; |
|
| 586 | + $model_and_fields_to_include = [ |
|
| 587 | + 'Registration' => $reg_fields_to_include, |
|
| 588 | + 'Attendee' => $att_fields_to_include, |
|
| 589 | + ]; |
|
| 590 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
| 591 | + $model = EE_Registry::instance()->load_model($model_name); |
|
| 592 | + foreach ($field_list as $field_name) { |
|
| 593 | + $field = $model->field_settings_for($field_name); |
|
| 594 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null; |
|
| 595 | + } |
|
| 596 | + } |
|
| 597 | + $registrations_csv_ready_array[] = $reg_csv_array; |
|
| 598 | + } |
|
| 599 | + return $registrations_csv_ready_array; |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | 602 | |
| 603 | - /** |
|
| 604 | - * Counts total unit to process |
|
| 605 | - * |
|
| 606 | - * @deprecated since 4.9.19 |
|
| 607 | - * @param int|array $event_id |
|
| 608 | - * @return int |
|
| 609 | - */ |
|
| 610 | - public function count_units_to_process($event_id) |
|
| 611 | - { |
|
| 612 | - // use the legacy filter |
|
| 613 | - if ($event_id) { |
|
| 614 | - $query_params[0]['EVT_ID'] = $event_id; |
|
| 615 | - } else { |
|
| 616 | - $query_params['force_join'][] = 'Event'; |
|
| 617 | - } |
|
| 618 | - return \EEM_Registration::instance()->count($query_params); |
|
| 619 | - } |
|
| 603 | + /** |
|
| 604 | + * Counts total unit to process |
|
| 605 | + * |
|
| 606 | + * @deprecated since 4.9.19 |
|
| 607 | + * @param int|array $event_id |
|
| 608 | + * @return int |
|
| 609 | + */ |
|
| 610 | + public function count_units_to_process($event_id) |
|
| 611 | + { |
|
| 612 | + // use the legacy filter |
|
| 613 | + if ($event_id) { |
|
| 614 | + $query_params[0]['EVT_ID'] = $event_id; |
|
| 615 | + } else { |
|
| 616 | + $query_params['force_join'][] = 'Event'; |
|
| 617 | + } |
|
| 618 | + return \EEM_Registration::instance()->count($query_params); |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | |
| 622 | - /** |
|
| 623 | - * Performs any clean-up logic when we know the job is completed. |
|
| 624 | - * In this case, we delete the temporary file |
|
| 625 | - * |
|
| 626 | - * @param JobParameters $job_parameters |
|
| 627 | - * @return boolean |
|
| 628 | - */ |
|
| 629 | - public function cleanup_job(JobParameters $job_parameters) |
|
| 630 | - { |
|
| 631 | - $this->_file_helper->delete( |
|
| 632 | - \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
| 633 | - true, |
|
| 634 | - 'd' |
|
| 635 | - ); |
|
| 636 | - return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso')); |
|
| 637 | - } |
|
| 622 | + /** |
|
| 623 | + * Performs any clean-up logic when we know the job is completed. |
|
| 624 | + * In this case, we delete the temporary file |
|
| 625 | + * |
|
| 626 | + * @param JobParameters $job_parameters |
|
| 627 | + * @return boolean |
|
| 628 | + */ |
|
| 629 | + public function cleanup_job(JobParameters $job_parameters) |
|
| 630 | + { |
|
| 631 | + $this->_file_helper->delete( |
|
| 632 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
| 633 | + true, |
|
| 634 | + 'd' |
|
| 635 | + ); |
|
| 636 | + return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso')); |
|
| 637 | + } |
|
| 638 | 638 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function create_job(JobParameters $job_parameters) |
| 48 | 48 | { |
| 49 | 49 | $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
| 50 | - if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
| 50 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
| 51 | 51 | throw new BatchRequestException(esc_html__('You do not have permission to view registrations', 'event_espresso')); |
| 52 | 52 | } |
| 53 | 53 | $filepath = $this->create_file_from_job_with_name( |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $query_params['force_join'][] = 'Event'; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - if (! isset($query_params['force_join'])) { |
|
| 87 | + if ( ! isset($query_params['force_join'])) { |
|
| 88 | 88 | $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
| 89 | 89 | } |
| 90 | 90 | $job_parameters->add_extra_data('query_params', $query_params); |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | $question_where_params = array(); |
| 187 | 187 | foreach ($reg_where_params as $key => $val) { |
| 188 | 188 | if (\EEM_Registration::instance()->is_logic_query_param_key($key)) { |
| 189 | - $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val); |
|
| 189 | + $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val); |
|
| 190 | 190 | } else { |
| 191 | 191 | // it's a normal where condition |
| 192 | - $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val; |
|
| 192 | + $question_where_params['Question_Group.Event.Registration.'.$key] = $val; |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | return $question_where_params; |
@@ -281,13 +281,13 @@ discard block |
||
| 281 | 281 | $query_params['limit'] = [$offset, $limit]; |
| 282 | 282 | $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
| 283 | 283 | foreach ($registration_rows as $reg_row) { |
| 284 | - if (!is_array($reg_row)) { |
|
| 284 | + if ( ! is_array($reg_row)) { |
|
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | $reg_csv_array = []; |
| 288 | - if (! $event_id) { |
|
| 288 | + if ( ! $event_id) { |
|
| 289 | 289 | // get the event's name and Id |
| 290 | - $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf( |
|
| 290 | + $reg_csv_array[(string) esc_html__('Event', 'event_espresso')] = sprintf( |
|
| 291 | 291 | /* translators: 1: event name, 2: event ID */ |
| 292 | 292 | esc_html__('%1$s (%2$s)', 'event_espresso'), |
| 293 | 293 | EEH_Export::prepare_value_from_db_for_display( |
@@ -335,13 +335,13 @@ discard block |
||
| 335 | 335 | $value = EEH_Export::prepare_value_from_db_for_display( |
| 336 | 336 | $reg_model, |
| 337 | 337 | $field_name, |
| 338 | - $reg_row[ $field->get_qualified_column() ] |
|
| 338 | + $reg_row[$field->get_qualified_column()] |
|
| 339 | 339 | ); |
| 340 | 340 | } |
| 341 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value; |
|
| 341 | + $reg_csv_array[EEH_Export::get_column_name_for_field($field)] = $value; |
|
| 342 | 342 | if ($field_name == 'REG_final_price') { |
| 343 | 343 | // add a column named Currency after the final price |
| 344 | - $reg_csv_array[ (string) esc_html__("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code; |
|
| 344 | + $reg_csv_array[(string) esc_html__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
|
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | // get pretty status |
@@ -353,17 +353,17 @@ discard block |
||
| 353 | 353 | false, |
| 354 | 354 | 'sentence' |
| 355 | 355 | ); |
| 356 | - $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ]; |
|
| 356 | + $reg_csv_array[(string) esc_html__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
| 357 | 357 | // get pretty transaction status |
| 358 | - $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ]; |
|
| 359 | - $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg |
|
| 358 | + $reg_csv_array[(string) esc_html__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
| 359 | + $reg_csv_array[(string) esc_html__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg |
|
| 360 | 360 | ? EEH_Export::prepare_value_from_db_for_display( |
| 361 | 361 | EEM_Transaction::instance(), |
| 362 | 362 | 'TXN_total', |
| 363 | 363 | $reg_row['TransactionTable.TXN_total'], |
| 364 | 364 | 'localized_float' |
| 365 | 365 | ) : '0.00'; |
| 366 | - $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg |
|
| 366 | + $reg_csv_array[(string) esc_html__('Amount Paid', 'event_espresso')] = $is_primary_reg |
|
| 367 | 367 | ? EEH_Export::prepare_value_from_db_for_display( |
| 368 | 368 | EEM_Transaction::instance(), |
| 369 | 369 | 'TXN_paid', |
@@ -394,14 +394,14 @@ discard block |
||
| 394 | 394 | ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | - $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times); |
|
| 398 | - $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods); |
|
| 399 | - $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode( |
|
| 397 | + $reg_csv_array[(string) esc_html__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
| 398 | + $reg_csv_array[(string) esc_html__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
| 399 | + $reg_csv_array[(string) esc_html__('Gateway Transaction ID(s)', 'event_espresso')] = implode( |
|
| 400 | 400 | ',', |
| 401 | 401 | $gateway_txn_ids_etc |
| 402 | 402 | ); |
| 403 | 403 | // get whether or not the user has checked in |
| 404 | - $reg_csv_array[ (string) esc_html__('Check-Ins', 'event_espresso') ] = $reg_model->count_related( |
|
| 404 | + $reg_csv_array[(string) esc_html__('Check-Ins', 'event_espresso')] = $reg_model->count_related( |
|
| 405 | 405 | $reg_row['Registration.REG_ID'], |
| 406 | 406 | 'Checkin' |
| 407 | 407 | ); |
@@ -433,8 +433,8 @@ discard block |
||
| 433 | 433 | $ticket_name = esc_html__('Unknown', 'event_espresso'); |
| 434 | 434 | $datetimes_strings = [esc_html__('Unknown', 'event_espresso')]; |
| 435 | 435 | } |
| 436 | - $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name; |
|
| 437 | - $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings); |
|
| 436 | + $reg_csv_array[(string) $ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
|
| 437 | + $reg_csv_array[(string) esc_html__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
|
| 438 | 438 | // get datetime(s) of registration |
| 439 | 439 | // add attendee columns |
| 440 | 440 | foreach ($att_fields_to_include as $att_field_name) { |
@@ -458,18 +458,18 @@ discard block |
||
| 458 | 458 | $value = EEH_Export::prepare_value_from_db_for_display( |
| 459 | 459 | EEM_Attendee::instance(), |
| 460 | 460 | $att_field_name, |
| 461 | - $reg_row[ $field_obj->get_qualified_column() ] |
|
| 461 | + $reg_row[$field_obj->get_qualified_column()] |
|
| 462 | 462 | ); |
| 463 | 463 | } |
| 464 | 464 | } else { |
| 465 | 465 | $value = ''; |
| 466 | 466 | } |
| 467 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
| 467 | + $reg_csv_array[EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
| 468 | 468 | } |
| 469 | 469 | // make sure each registration has the same questions in the same order |
| 470 | 470 | foreach ($question_labels as $question_label) { |
| 471 | - if (! isset($reg_csv_array[ $question_label ])) { |
|
| 472 | - $reg_csv_array[ $question_label ] = null; |
|
| 471 | + if ( ! isset($reg_csv_array[$question_label])) { |
|
| 472 | + $reg_csv_array[$question_label] = null; |
|
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | $answers = EEM_Answer::instance()->get_all_wpdb_results([ |
@@ -496,12 +496,12 @@ discard block |
||
| 496 | 496 | isset($answer_row['Question.QST_type']) |
| 497 | 497 | && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
| 498 | 498 | ) { |
| 499 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
| 499 | + $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID( |
|
| 500 | 500 | $answer_row['Answer.ANS_value'] |
| 501 | 501 | ); |
| 502 | 502 | } else { |
| 503 | 503 | // this isn't for html, so don't show html entities |
| 504 | - $reg_csv_array[ $question_label ] = html_entity_decode( |
|
| 504 | + $reg_csv_array[$question_label] = html_entity_decode( |
|
| 505 | 505 | EEH_Export::prepare_value_from_db_for_display( |
| 506 | 506 | EEM_Answer::instance(), |
| 507 | 507 | 'ANS_value', |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | date('Y-m-d H:i:s', $checkin_row->get_raw('CHK_timestamp')) |
| 565 | 565 | ); |
| 566 | 566 | } |
| 567 | - $reg_csv_array[ (string) $datetime_name ] = $checkin_value; |
|
| 567 | + $reg_csv_array[(string) $datetime_name] = $checkin_value; |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | /** |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | $model = EE_Registry::instance()->load_model($model_name); |
| 592 | 592 | foreach ($field_list as $field_name) { |
| 593 | 593 | $field = $model->field_settings_for($field_name); |
| 594 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null; |
|
| 594 | + $reg_csv_array[EEH_Export::get_column_name_for_field($field)] = null; |
|
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | $registrations_csv_ready_array[] = $reg_csv_array; |