@@ -40,659 +40,659 @@ |
||
40 | 40 | */ |
41 | 41 | class RegistrationsReport extends JobHandlerFile |
42 | 42 | { |
43 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
44 | - // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
45 | - /** |
|
46 | - * Performs any necessary setup for starting the job. This is also a good |
|
47 | - * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
48 | - * when continue_job will be called |
|
49 | - * |
|
50 | - * @param JobParameters $job_parameters |
|
51 | - * @return JobStepResponse |
|
52 | - * @throws BatchRequestException |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - public function create_job(JobParameters $job_parameters) |
|
57 | - { |
|
58 | - $event_id = (int) $job_parameters->request_datum('EVT_ID', '0'); |
|
59 | - $DTT_ID = (int) $job_parameters->request_datum('DTT_ID', '0'); |
|
60 | - if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
61 | - throw new BatchRequestException(esc_html__('You do not have permission to view registrations', 'event_espresso')); |
|
62 | - } |
|
63 | - $filepath = $this->create_file_from_job_with_name( |
|
64 | - $job_parameters->job_id(), |
|
65 | - $this->get_filename($event_id) |
|
66 | - ); |
|
67 | - $job_parameters->add_extra_data('filepath', $filepath); |
|
68 | - $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
69 | - array( |
|
70 | - 'OR' => array( |
|
71 | - // don't include registrations from failed or abandoned transactions... |
|
72 | - 'Transaction.STS_ID' => array( |
|
73 | - 'NOT IN', |
|
74 | - array( |
|
75 | - EEM_Transaction::failed_status_code, |
|
76 | - EEM_Transaction::abandoned_status_code, |
|
77 | - ), |
|
78 | - ), |
|
79 | - // unless the registration is approved, in which case include it regardless of transaction status |
|
80 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
81 | - ), |
|
82 | - 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
83 | - ), |
|
84 | - 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
85 | - 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
86 | - 'caps' => EEM_Base::caps_read_admin, |
|
87 | - ), $event_id); |
|
88 | - if ($event_id) { |
|
89 | - $query_params[0]['EVT_ID'] = $event_id; |
|
90 | - } else { |
|
91 | - $query_params['force_join'][] = 'Event'; |
|
92 | - } |
|
93 | - if (! isset($query_params['force_join'])) { |
|
94 | - $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
|
95 | - } |
|
96 | - $job_parameters->add_extra_data('query_params', $query_params); |
|
97 | - $question_labels = $this->_get_question_labels($query_params); |
|
98 | - $job_parameters->add_extra_data('question_labels', $question_labels); |
|
99 | - $job_parameters->set_job_size( |
|
100 | - EEM_Registration::instance()->count( |
|
101 | - array_diff_key( |
|
102 | - $query_params, |
|
103 | - array_flip( |
|
104 | - array('limit') |
|
105 | - ) |
|
106 | - ) |
|
107 | - ) |
|
108 | - ); |
|
109 | - // we should also set the header columns |
|
110 | - $csv_data_for_row = $this->get_csv_data_for( |
|
111 | - $event_id, |
|
112 | - 0, |
|
113 | - 1, |
|
114 | - $job_parameters->extra_datum('question_labels'), |
|
115 | - $job_parameters->extra_datum('query_params'), |
|
116 | - $DTT_ID |
|
117 | - ); |
|
118 | - EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
119 | - // if we actually processed a row there, record it |
|
120 | - if ($job_parameters->job_size()) { |
|
121 | - $job_parameters->mark_processed(1); |
|
122 | - } |
|
123 | - return new JobStepResponse( |
|
124 | - $job_parameters, |
|
125 | - esc_html__('Registrations report started successfully...', 'event_espresso') |
|
126 | - ); |
|
127 | - } |
|
43 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
44 | + // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
45 | + /** |
|
46 | + * Performs any necessary setup for starting the job. This is also a good |
|
47 | + * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
48 | + * when continue_job will be called |
|
49 | + * |
|
50 | + * @param JobParameters $job_parameters |
|
51 | + * @return JobStepResponse |
|
52 | + * @throws BatchRequestException |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + public function create_job(JobParameters $job_parameters) |
|
57 | + { |
|
58 | + $event_id = (int) $job_parameters->request_datum('EVT_ID', '0'); |
|
59 | + $DTT_ID = (int) $job_parameters->request_datum('DTT_ID', '0'); |
|
60 | + if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
61 | + throw new BatchRequestException(esc_html__('You do not have permission to view registrations', 'event_espresso')); |
|
62 | + } |
|
63 | + $filepath = $this->create_file_from_job_with_name( |
|
64 | + $job_parameters->job_id(), |
|
65 | + $this->get_filename($event_id) |
|
66 | + ); |
|
67 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
68 | + $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
69 | + array( |
|
70 | + 'OR' => array( |
|
71 | + // don't include registrations from failed or abandoned transactions... |
|
72 | + 'Transaction.STS_ID' => array( |
|
73 | + 'NOT IN', |
|
74 | + array( |
|
75 | + EEM_Transaction::failed_status_code, |
|
76 | + EEM_Transaction::abandoned_status_code, |
|
77 | + ), |
|
78 | + ), |
|
79 | + // unless the registration is approved, in which case include it regardless of transaction status |
|
80 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
81 | + ), |
|
82 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
83 | + ), |
|
84 | + 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
85 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
86 | + 'caps' => EEM_Base::caps_read_admin, |
|
87 | + ), $event_id); |
|
88 | + if ($event_id) { |
|
89 | + $query_params[0]['EVT_ID'] = $event_id; |
|
90 | + } else { |
|
91 | + $query_params['force_join'][] = 'Event'; |
|
92 | + } |
|
93 | + if (! isset($query_params['force_join'])) { |
|
94 | + $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
|
95 | + } |
|
96 | + $job_parameters->add_extra_data('query_params', $query_params); |
|
97 | + $question_labels = $this->_get_question_labels($query_params); |
|
98 | + $job_parameters->add_extra_data('question_labels', $question_labels); |
|
99 | + $job_parameters->set_job_size( |
|
100 | + EEM_Registration::instance()->count( |
|
101 | + array_diff_key( |
|
102 | + $query_params, |
|
103 | + array_flip( |
|
104 | + array('limit') |
|
105 | + ) |
|
106 | + ) |
|
107 | + ) |
|
108 | + ); |
|
109 | + // we should also set the header columns |
|
110 | + $csv_data_for_row = $this->get_csv_data_for( |
|
111 | + $event_id, |
|
112 | + 0, |
|
113 | + 1, |
|
114 | + $job_parameters->extra_datum('question_labels'), |
|
115 | + $job_parameters->extra_datum('query_params'), |
|
116 | + $DTT_ID |
|
117 | + ); |
|
118 | + EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
119 | + // if we actually processed a row there, record it |
|
120 | + if ($job_parameters->job_size()) { |
|
121 | + $job_parameters->mark_processed(1); |
|
122 | + } |
|
123 | + return new JobStepResponse( |
|
124 | + $job_parameters, |
|
125 | + esc_html__('Registrations report started successfully...', 'event_espresso') |
|
126 | + ); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * Gets the filename |
|
132 | - * |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - protected function get_filename() |
|
136 | - { |
|
137 | - return apply_filters( |
|
138 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename', |
|
139 | - sprintf( |
|
140 | - "event-espresso-registrations-%s.csv", |
|
141 | - str_replace(array(':', ' '), '-', current_time('mysql')) |
|
142 | - ) |
|
143 | - ); |
|
144 | - } |
|
130 | + /** |
|
131 | + * Gets the filename |
|
132 | + * |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + protected function get_filename() |
|
136 | + { |
|
137 | + return apply_filters( |
|
138 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename', |
|
139 | + sprintf( |
|
140 | + "event-espresso-registrations-%s.csv", |
|
141 | + str_replace(array(':', ' '), '-', current_time('mysql')) |
|
142 | + ) |
|
143 | + ); |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | - /** |
|
148 | - * Gets the questions which are to be used for this report, so they |
|
149 | - * can be remembered for later |
|
150 | - * |
|
151 | - * @param array $registration_query_params |
|
152 | - * @return array question admin labels to be used for this report |
|
153 | - */ |
|
154 | - protected function _get_question_labels($registration_query_params) |
|
155 | - { |
|
156 | - $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null; |
|
157 | - $question_query_params = array(); |
|
158 | - if ($where !== null) { |
|
159 | - $question_query_params = array( |
|
160 | - $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
|
161 | - ); |
|
162 | - } |
|
163 | - // Make sure it's not a system question |
|
164 | - $question_query_params[0]['OR*not-system-questions'] = [ |
|
165 | - 'QST_system' => '', |
|
166 | - 'QST_system*null' => ['IS_NULL'] |
|
167 | - ]; |
|
168 | - if ( |
|
169 | - apply_filters( |
|
170 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', |
|
171 | - false, |
|
172 | - $registration_query_params |
|
173 | - ) |
|
174 | - ) { |
|
175 | - $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL'); |
|
176 | - } |
|
177 | - $question_query_params['group_by'] = array('QST_ID'); |
|
178 | - return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label')); |
|
179 | - } |
|
147 | + /** |
|
148 | + * Gets the questions which are to be used for this report, so they |
|
149 | + * can be remembered for later |
|
150 | + * |
|
151 | + * @param array $registration_query_params |
|
152 | + * @return array question admin labels to be used for this report |
|
153 | + */ |
|
154 | + protected function _get_question_labels($registration_query_params) |
|
155 | + { |
|
156 | + $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null; |
|
157 | + $question_query_params = array(); |
|
158 | + if ($where !== null) { |
|
159 | + $question_query_params = array( |
|
160 | + $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
|
161 | + ); |
|
162 | + } |
|
163 | + // Make sure it's not a system question |
|
164 | + $question_query_params[0]['OR*not-system-questions'] = [ |
|
165 | + 'QST_system' => '', |
|
166 | + 'QST_system*null' => ['IS_NULL'] |
|
167 | + ]; |
|
168 | + if ( |
|
169 | + apply_filters( |
|
170 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', |
|
171 | + false, |
|
172 | + $registration_query_params |
|
173 | + ) |
|
174 | + ) { |
|
175 | + $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL'); |
|
176 | + } |
|
177 | + $question_query_params['group_by'] = array('QST_ID'); |
|
178 | + return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label')); |
|
179 | + } |
|
180 | 180 | |
181 | 181 | |
182 | - /** |
|
183 | - * Takes where params meant for registrations and changes them to work for questions |
|
184 | - * |
|
185 | - * @param array $reg_where_params |
|
186 | - * @return array |
|
187 | - */ |
|
188 | - protected function _change_registration_where_params_to_question_where_params($reg_where_params) |
|
189 | - { |
|
190 | - $question_where_params = array(); |
|
191 | - foreach ($reg_where_params as $key => $val) { |
|
192 | - if (EEM_Registration::instance()->is_logic_query_param_key($key)) { |
|
193 | - $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val); |
|
194 | - } else { |
|
195 | - // it's a normal where condition |
|
196 | - $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val; |
|
197 | - } |
|
198 | - } |
|
199 | - return $question_where_params; |
|
200 | - } |
|
182 | + /** |
|
183 | + * Takes where params meant for registrations and changes them to work for questions |
|
184 | + * |
|
185 | + * @param array $reg_where_params |
|
186 | + * @return array |
|
187 | + */ |
|
188 | + protected function _change_registration_where_params_to_question_where_params($reg_where_params) |
|
189 | + { |
|
190 | + $question_where_params = array(); |
|
191 | + foreach ($reg_where_params as $key => $val) { |
|
192 | + if (EEM_Registration::instance()->is_logic_query_param_key($key)) { |
|
193 | + $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val); |
|
194 | + } else { |
|
195 | + // it's a normal where condition |
|
196 | + $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val; |
|
197 | + } |
|
198 | + } |
|
199 | + return $question_where_params; |
|
200 | + } |
|
201 | 201 | |
202 | 202 | |
203 | - /** |
|
204 | - * Performs another step of the job |
|
205 | - * |
|
206 | - * @param JobParameters $job_parameters |
|
207 | - * @param int $batch_size |
|
208 | - * @return JobStepResponse |
|
209 | - * @throws EE_Error |
|
210 | - * @throws ReflectionException |
|
211 | - */ |
|
212 | - public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
213 | - { |
|
214 | - if ($job_parameters->units_processed() < $job_parameters->job_size()) { |
|
215 | - $csv_data = $this->get_csv_data_for( |
|
216 | - (int) $job_parameters->request_datum('EVT_ID', '0'), |
|
217 | - $job_parameters->units_processed(), |
|
218 | - $batch_size, |
|
219 | - $job_parameters->extra_datum('question_labels'), |
|
220 | - $job_parameters->extra_datum('query_params'), |
|
221 | - (int) $job_parameters->request_datum('DTT_ID', '0') |
|
222 | - ); |
|
223 | - EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
224 | - $units_processed = count($csv_data); |
|
225 | - } else { |
|
226 | - $csv_data = array(); |
|
227 | - $units_processed = 0; |
|
228 | - } |
|
229 | - $job_parameters->mark_processed($units_processed); |
|
230 | - $extra_response_data = array( |
|
231 | - 'file_url' => '', |
|
232 | - ); |
|
233 | - if ($units_processed < $batch_size) { |
|
234 | - $job_parameters->set_status(JobParameters::status_complete); |
|
235 | - $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
236 | - } |
|
203 | + /** |
|
204 | + * Performs another step of the job |
|
205 | + * |
|
206 | + * @param JobParameters $job_parameters |
|
207 | + * @param int $batch_size |
|
208 | + * @return JobStepResponse |
|
209 | + * @throws EE_Error |
|
210 | + * @throws ReflectionException |
|
211 | + */ |
|
212 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
213 | + { |
|
214 | + if ($job_parameters->units_processed() < $job_parameters->job_size()) { |
|
215 | + $csv_data = $this->get_csv_data_for( |
|
216 | + (int) $job_parameters->request_datum('EVT_ID', '0'), |
|
217 | + $job_parameters->units_processed(), |
|
218 | + $batch_size, |
|
219 | + $job_parameters->extra_datum('question_labels'), |
|
220 | + $job_parameters->extra_datum('query_params'), |
|
221 | + (int) $job_parameters->request_datum('DTT_ID', '0') |
|
222 | + ); |
|
223 | + EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
224 | + $units_processed = count($csv_data); |
|
225 | + } else { |
|
226 | + $csv_data = array(); |
|
227 | + $units_processed = 0; |
|
228 | + } |
|
229 | + $job_parameters->mark_processed($units_processed); |
|
230 | + $extra_response_data = array( |
|
231 | + 'file_url' => '', |
|
232 | + ); |
|
233 | + if ($units_processed < $batch_size) { |
|
234 | + $job_parameters->set_status(JobParameters::status_complete); |
|
235 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
236 | + } |
|
237 | 237 | |
238 | - return new JobStepResponse( |
|
239 | - $job_parameters, |
|
240 | - sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)), |
|
241 | - $extra_response_data |
|
242 | - ); |
|
243 | - } |
|
238 | + return new JobStepResponse( |
|
239 | + $job_parameters, |
|
240 | + sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)), |
|
241 | + $extra_response_data |
|
242 | + ); |
|
243 | + } |
|
244 | 244 | |
245 | 245 | |
246 | - /** |
|
247 | - * Gets the csv data for a batch of registrations |
|
248 | - * |
|
249 | - * @param int|null $event_id |
|
250 | - * @param int $offset |
|
251 | - * @param int $limit |
|
252 | - * @param array $question_labels the IDs for all the questions which were answered by someone in this selection |
|
253 | - * @param array $query_params for using where querying the model |
|
254 | - * @param int $DTT_ID |
|
255 | - * @return array top-level keys are numeric, next-level keys are column headers |
|
256 | - * @throws EE_Error |
|
257 | - * @throws ReflectionException |
|
258 | - */ |
|
259 | - public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params, $DTT_ID = 0) |
|
260 | - { |
|
261 | - $reg_fields_to_include = [ |
|
262 | - 'TXN_ID', |
|
263 | - 'ATT_ID', |
|
264 | - 'REG_date', |
|
265 | - 'REG_code', |
|
266 | - 'REG_count', |
|
267 | - 'REG_final_price', |
|
268 | - ]; |
|
269 | - $att_fields_to_include = [ |
|
270 | - 'ATT_fname', |
|
271 | - 'ATT_lname', |
|
272 | - 'ATT_email', |
|
273 | - 'ATT_address', |
|
274 | - 'ATT_address2', |
|
275 | - 'ATT_city', |
|
276 | - 'STA_ID', |
|
277 | - 'CNT_ISO', |
|
278 | - 'ATT_zip', |
|
279 | - 'ATT_phone', |
|
280 | - ]; |
|
281 | - $registrations_csv_ready_array = []; |
|
282 | - $reg_model = EE_Registry::instance()->load_model('Registration'); |
|
283 | - $query_params['limit'] = [$offset, $limit]; |
|
284 | - $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
285 | - foreach ($registration_rows as $reg_row) { |
|
286 | - if (!is_array($reg_row)) { |
|
287 | - continue; |
|
288 | - } |
|
289 | - $reg_csv_array = []; |
|
290 | - // registration Id |
|
291 | - $reg_id_field = $reg_model->field_settings_for('REG_ID'); |
|
292 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display( |
|
293 | - $reg_model, |
|
294 | - 'REG_ID', |
|
295 | - $reg_row[ $reg_id_field->get_qualified_column() ] |
|
296 | - ); |
|
297 | - if (! $event_id) { |
|
298 | - // get the event's name and Id |
|
299 | - $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf( |
|
300 | - /* translators: 1: event name, 2: event ID */ |
|
301 | - esc_html__('%1$s (%2$s)', 'event_espresso'), |
|
302 | - EEH_Export::prepare_value_from_db_for_display( |
|
303 | - EEM_Event::instance(), |
|
304 | - 'EVT_name', |
|
305 | - $reg_row['Event_CPT.post_title'] |
|
306 | - ), |
|
307 | - $reg_row['Event_CPT.ID'] |
|
308 | - ); |
|
309 | - } |
|
310 | - // add attendee columns |
|
311 | - foreach ($att_fields_to_include as $att_field_name) { |
|
312 | - $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
313 | - if ($reg_row['Attendee_CPT.ID']) { |
|
314 | - if ($att_field_name == 'STA_ID') { |
|
315 | - $value = EEM_State::instance()->get_var( |
|
316 | - [ |
|
317 | - ['STA_ID' => $reg_row['Attendee_Meta.STA_ID']] |
|
318 | - ], |
|
319 | - 'STA_name' |
|
320 | - ); |
|
321 | - } elseif ($att_field_name == 'CNT_ISO') { |
|
322 | - $value = EEM_Country::instance()->get_var( |
|
323 | - [ |
|
324 | - ['CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO']] |
|
325 | - ], |
|
326 | - 'CNT_name' |
|
327 | - ); |
|
328 | - } else { |
|
329 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
330 | - EEM_Attendee::instance(), |
|
331 | - $att_field_name, |
|
332 | - $reg_row[ $field_obj->get_qualified_column() ] |
|
333 | - ); |
|
334 | - } |
|
335 | - } else { |
|
336 | - $value = ''; |
|
337 | - } |
|
338 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
339 | - } |
|
340 | - $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
341 | - /*@var $reg_row EE_Registration */ |
|
342 | - foreach ($reg_fields_to_include as $field_name) { |
|
343 | - $field = $reg_model->field_settings_for($field_name); |
|
344 | - if ($field_name == 'REG_final_price') { |
|
345 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
346 | - $reg_model, |
|
347 | - $field_name, |
|
348 | - $reg_row['Registration.REG_final_price'], |
|
349 | - 'localized_float' |
|
350 | - ); |
|
351 | - } elseif ($field_name == 'REG_count') { |
|
352 | - $value = sprintf( |
|
353 | - /* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */ |
|
354 | - esc_html__('%1$s of %2$s', 'event_espresso'), |
|
355 | - EEH_Export::prepare_value_from_db_for_display( |
|
356 | - $reg_model, |
|
357 | - 'REG_count', |
|
358 | - $reg_row['Registration.REG_count'] |
|
359 | - ), |
|
360 | - EEH_Export::prepare_value_from_db_for_display( |
|
361 | - $reg_model, |
|
362 | - 'REG_group_size', |
|
363 | - $reg_row['Registration.REG_group_size'] |
|
364 | - ) |
|
365 | - ); |
|
366 | - } elseif ($field_name == 'REG_date') { |
|
367 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
368 | - $reg_model, |
|
369 | - $field_name, |
|
370 | - $reg_row['Registration.REG_date'], |
|
371 | - 'no_html' |
|
372 | - ); |
|
373 | - } else { |
|
374 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
375 | - $reg_model, |
|
376 | - $field_name, |
|
377 | - $reg_row[ $field->get_qualified_column() ] |
|
378 | - ); |
|
379 | - } |
|
380 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value; |
|
381 | - if ($field_name == 'REG_final_price') { |
|
382 | - // add a column named Currency after the final price |
|
383 | - $reg_csv_array[ (string) esc_html__("Currency", "event_espresso") ] = EE_Config::instance()->currency->code; |
|
384 | - } |
|
385 | - } |
|
386 | - // get pretty status |
|
387 | - $stati = EEM_Status::instance()->localized_status( |
|
388 | - [ |
|
389 | - $reg_row['Registration.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
390 | - $reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
391 | - ], |
|
392 | - false, |
|
393 | - 'sentence' |
|
394 | - ); |
|
395 | - $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ]; |
|
396 | - // get pretty transaction status |
|
397 | - $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ]; |
|
398 | - $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg |
|
399 | - ? EEH_Export::prepare_value_from_db_for_display( |
|
400 | - EEM_Transaction::instance(), |
|
401 | - 'TXN_total', |
|
402 | - $reg_row['TransactionTable.TXN_total'], |
|
403 | - 'localized_float' |
|
404 | - ) : '0.00'; |
|
405 | - $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg |
|
406 | - ? EEH_Export::prepare_value_from_db_for_display( |
|
407 | - EEM_Transaction::instance(), |
|
408 | - 'TXN_paid', |
|
409 | - $reg_row['TransactionTable.TXN_paid'], |
|
410 | - 'localized_float' |
|
411 | - ) : '0.00'; |
|
412 | - $payment_methods = []; |
|
413 | - $gateway_txn_ids_etc = []; |
|
414 | - $payment_times = []; |
|
415 | - if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
416 | - $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
|
417 | - [ |
|
418 | - [ |
|
419 | - 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
420 | - 'STS_ID' => EEM_Payment::status_id_approved, |
|
421 | - ], |
|
422 | - 'force_join' => ['Payment_Method'], |
|
423 | - ], |
|
424 | - ARRAY_A, |
|
425 | - 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' |
|
426 | - ); |
|
427 | - foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
428 | - $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
429 | - ? $payment_method_and_gateway_txn_id['name'] : esc_html__('Unknown', 'event_espresso'); |
|
430 | - $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
431 | - ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
432 | - $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
433 | - ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
434 | - } |
|
435 | - } |
|
436 | - $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times); |
|
437 | - $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods); |
|
438 | - $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode( |
|
439 | - ',', |
|
440 | - $gateway_txn_ids_etc |
|
441 | - ); |
|
442 | - // get ticket of registration and its price |
|
443 | - $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
|
444 | - if ($reg_row['Ticket.TKT_ID']) { |
|
445 | - $ticket_name = EEH_Export::prepare_value_from_db_for_display( |
|
446 | - $ticket_model, |
|
447 | - 'TKT_name', |
|
448 | - $reg_row['Ticket.TKT_name'] |
|
449 | - ); |
|
450 | - $datetimes_strings = []; |
|
451 | - foreach ( |
|
452 | - EEM_Datetime::instance()->get_all_wpdb_results( |
|
453 | - [ |
|
454 | - ['Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']], |
|
455 | - 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
456 | - 'default_where_conditions' => 'none', |
|
457 | - ] |
|
458 | - ) as $datetime |
|
459 | - ) { |
|
460 | - $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display( |
|
461 | - EEM_Datetime::instance(), |
|
462 | - 'DTT_EVT_start', |
|
463 | - $datetime['Datetime.DTT_EVT_start'] |
|
464 | - ); |
|
465 | - } |
|
466 | - } else { |
|
467 | - $ticket_name = esc_html__('Unknown', 'event_espresso'); |
|
468 | - $datetimes_strings = [esc_html__('Unknown', 'event_espresso')]; |
|
469 | - } |
|
470 | - $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name; |
|
471 | - $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings); |
|
472 | - // make sure each registration has the same questions in the same order |
|
473 | - foreach ($question_labels as $question_label) { |
|
474 | - if (! isset($reg_csv_array[ $question_label ])) { |
|
475 | - $reg_csv_array[ $question_label ] = null; |
|
476 | - } |
|
477 | - } |
|
478 | - $answers = EEM_Answer::instance()->get_all_wpdb_results([ |
|
479 | - ['REG_ID' => $reg_row['Registration.REG_ID']], |
|
480 | - 'force_join' => ['Question'], |
|
481 | - ]); |
|
482 | - // now fill out the questions THEY answered |
|
483 | - foreach ($answers as $answer_row) { |
|
484 | - if ($answer_row['Question.QST_system']) { |
|
485 | - // it's an answer to a system question. That was already displayed as part of the attendee |
|
486 | - // fields, so don't write it out again thanks. |
|
487 | - continue; |
|
488 | - } |
|
489 | - if ($answer_row['Question.QST_ID']) { |
|
490 | - $question_label = EEH_Export::prepare_value_from_db_for_display( |
|
491 | - EEM_Question::instance(), |
|
492 | - 'QST_admin_label', |
|
493 | - $answer_row['Question.QST_admin_label'] |
|
494 | - ); |
|
495 | - } else { |
|
496 | - $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
497 | - } |
|
498 | - if ( |
|
499 | - isset($answer_row['Question.QST_type']) |
|
500 | - && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
|
501 | - ) { |
|
502 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
503 | - $answer_row['Answer.ANS_value'] |
|
504 | - ); |
|
505 | - } else { |
|
506 | - // this isn't for html, so don't show html entities |
|
507 | - $reg_csv_array[ $question_label ] = html_entity_decode( |
|
508 | - EEH_Export::prepare_value_from_db_for_display( |
|
509 | - EEM_Answer::instance(), |
|
510 | - 'ANS_value', |
|
511 | - $answer_row['Answer.ANS_value'] |
|
512 | - ) |
|
513 | - ); |
|
514 | - } |
|
515 | - } |
|
516 | - // Include check-in data |
|
517 | - if ($event_id && $DTT_ID) { |
|
518 | - // get whether or not the user has checked in |
|
519 | - $reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related( |
|
520 | - $reg_row['Registration.REG_ID'], |
|
521 | - 'Checkin', |
|
522 | - [ |
|
523 | - [ |
|
524 | - 'DTT_ID' => $DTT_ID |
|
525 | - ] |
|
526 | - ] |
|
527 | - ); |
|
528 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
529 | - $checkin_rows = EEM_Checkin::instance()->get_all_wpdb_results( |
|
530 | - [ |
|
531 | - [ |
|
532 | - 'REG_ID' => $reg_row['Registration.REG_ID'], |
|
533 | - 'DTT_ID' => $datetime->get('DTT_ID'), |
|
534 | - ], |
|
535 | - ] |
|
536 | - ); |
|
537 | - if (trim($datetime->get('DTT_name'))) { |
|
538 | - /* translators: 1: datetime name, 2: datetime ID */ |
|
539 | - $datetime_name = sprintf( |
|
540 | - esc_html__('Check-ins for %1$s - ID: %2$s', 'event_espresso'), |
|
541 | - esc_html($datetime->get('DTT_name')), |
|
542 | - esc_html($datetime->get('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->get('DTT_ID')) |
|
549 | - ); |
|
550 | - } |
|
551 | - $checkins = []; |
|
552 | - foreach ($checkin_rows as $checkin_row) { |
|
553 | - if ((int) $checkin_row['Checkin.CHK_in'] === 1) { |
|
554 | - /* translators: 1: check-in timestamp */ |
|
555 | - $checkin_value = sprintf( |
|
556 | - esc_html__('IN: %1$s', 'event_espresso'), |
|
557 | - date('Y-m-d g:i a', strtotime($checkin_row['Checkin.CHK_timestamp'])) |
|
558 | - ); |
|
559 | - $checkins[] = $checkin_value; |
|
560 | - } elseif ((int) $checkin_row['Checkin.CHK_in'] === 0) { |
|
561 | - /* translators: 1: check-in timestamp */ |
|
562 | - $checkin_value = sprintf( |
|
563 | - esc_html__('OUT: %1$s', 'event_espresso'), |
|
564 | - date('Y-m-d g:i a', strtotime($checkin_row['Checkin.CHK_timestamp'])) |
|
565 | - ); |
|
566 | - $checkins[] = $checkin_value; |
|
567 | - } |
|
568 | - } |
|
569 | - $reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins); |
|
570 | - } elseif ($event_id) { |
|
571 | - // get whether or not the user has checked in |
|
572 | - $reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related( |
|
573 | - $reg_row['Registration.REG_ID'], |
|
574 | - 'Checkin' |
|
575 | - ); |
|
576 | - $datetimes = EEM_Datetime::instance()->get_all_wpdb_results( |
|
577 | - [ |
|
578 | - [ |
|
579 | - 'Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID'], |
|
580 | - ], |
|
581 | - 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
582 | - 'default_where_conditions' => 'none', |
|
583 | - ] |
|
584 | - ); |
|
585 | - foreach ($datetimes as $datetime) { |
|
586 | - $checkin_row = EEM_Checkin::instance()->get_one( |
|
587 | - [ |
|
588 | - [ |
|
589 | - 'REG_ID' => $reg_row['Registration.REG_ID'], |
|
590 | - 'DTT_ID' => $datetime['Datetime.DTT_ID'], |
|
591 | - ], |
|
592 | - 'limit' => 1, |
|
593 | - 'order_by' => [ |
|
594 | - 'CHK_ID' => 'DESC' |
|
595 | - ] |
|
596 | - ] |
|
597 | - ); |
|
598 | - if (trim($datetime['Datetime.DTT_name'])) { |
|
599 | - /* translators: 1: datetime name, 2: datetime ID */ |
|
600 | - $datetime_name = sprintf( |
|
601 | - esc_html__('Check-ins for %1$s - ID: %2$s', 'event_espresso'), |
|
602 | - esc_html($datetime['Datetime.DTT_name']), |
|
603 | - esc_html($datetime['Datetime.DTT_ID']) |
|
604 | - ); |
|
605 | - } else { |
|
606 | - /* translators: %s: datetime ID */ |
|
607 | - $datetime_name = sprintf( |
|
608 | - esc_html__('ID: %1$s', 'event_espresso'), |
|
609 | - esc_html($datetime['Datetime.DTT_ID']) |
|
610 | - ); |
|
611 | - } |
|
612 | - $checkin_value = ''; |
|
613 | - if ($checkin_row instanceof EE_Checkin && $checkin_row->get('CHK_in') === true) { |
|
614 | - /* translators: 1: check-in timestamp */ |
|
615 | - $checkin_value = sprintf( |
|
616 | - esc_html__('IN: %1$s', 'event_espresso'), |
|
617 | - $checkin_row->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
618 | - ); |
|
619 | - } elseif ($checkin_row instanceof EE_Checkin && $checkin_row->get('CHK_in') === false) { |
|
620 | - /* translators: 1: check-in timestamp */ |
|
621 | - $checkin_value = sprintf( |
|
622 | - esc_html__('OUT: %1$s', 'event_espresso'), |
|
623 | - $checkin_row->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
624 | - ); |
|
625 | - } |
|
626 | - $reg_csv_array[ (string) $datetime_name ] = $checkin_value; |
|
627 | - } |
|
628 | - } |
|
629 | - /** |
|
630 | - * Filter to change the contents of each row of the registrations report CSV file. |
|
631 | - * This can be used to add or remote columns from the CSV file, or change their values. |
|
632 | - * Note when using: all rows in the CSV should have the same columns. |
|
633 | - * @param array $reg_csv_array keys are the column names, values are their cell values |
|
634 | - * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results() |
|
635 | - */ |
|
636 | - $registrations_csv_ready_array[] = apply_filters( |
|
637 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
638 | - $reg_csv_array, |
|
639 | - $reg_row |
|
640 | - ); |
|
641 | - } |
|
642 | - // if we couldn't export anything, we want to at least show the column headers |
|
643 | - if (empty($registrations_csv_ready_array)) { |
|
644 | - $reg_csv_array = []; |
|
645 | - $model_and_fields_to_include = [ |
|
646 | - 'Registration' => $reg_fields_to_include, |
|
647 | - 'Attendee' => $att_fields_to_include, |
|
648 | - ]; |
|
649 | - foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
650 | - $model = EE_Registry::instance()->load_model($model_name); |
|
651 | - foreach ($field_list as $field_name) { |
|
652 | - $field = $model->field_settings_for($field_name); |
|
653 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null; |
|
654 | - } |
|
655 | - } |
|
656 | - $registrations_csv_ready_array[] = $reg_csv_array; |
|
657 | - } |
|
658 | - return $registrations_csv_ready_array; |
|
659 | - } |
|
246 | + /** |
|
247 | + * Gets the csv data for a batch of registrations |
|
248 | + * |
|
249 | + * @param int|null $event_id |
|
250 | + * @param int $offset |
|
251 | + * @param int $limit |
|
252 | + * @param array $question_labels the IDs for all the questions which were answered by someone in this selection |
|
253 | + * @param array $query_params for using where querying the model |
|
254 | + * @param int $DTT_ID |
|
255 | + * @return array top-level keys are numeric, next-level keys are column headers |
|
256 | + * @throws EE_Error |
|
257 | + * @throws ReflectionException |
|
258 | + */ |
|
259 | + public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params, $DTT_ID = 0) |
|
260 | + { |
|
261 | + $reg_fields_to_include = [ |
|
262 | + 'TXN_ID', |
|
263 | + 'ATT_ID', |
|
264 | + 'REG_date', |
|
265 | + 'REG_code', |
|
266 | + 'REG_count', |
|
267 | + 'REG_final_price', |
|
268 | + ]; |
|
269 | + $att_fields_to_include = [ |
|
270 | + 'ATT_fname', |
|
271 | + 'ATT_lname', |
|
272 | + 'ATT_email', |
|
273 | + 'ATT_address', |
|
274 | + 'ATT_address2', |
|
275 | + 'ATT_city', |
|
276 | + 'STA_ID', |
|
277 | + 'CNT_ISO', |
|
278 | + 'ATT_zip', |
|
279 | + 'ATT_phone', |
|
280 | + ]; |
|
281 | + $registrations_csv_ready_array = []; |
|
282 | + $reg_model = EE_Registry::instance()->load_model('Registration'); |
|
283 | + $query_params['limit'] = [$offset, $limit]; |
|
284 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
285 | + foreach ($registration_rows as $reg_row) { |
|
286 | + if (!is_array($reg_row)) { |
|
287 | + continue; |
|
288 | + } |
|
289 | + $reg_csv_array = []; |
|
290 | + // registration Id |
|
291 | + $reg_id_field = $reg_model->field_settings_for('REG_ID'); |
|
292 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display( |
|
293 | + $reg_model, |
|
294 | + 'REG_ID', |
|
295 | + $reg_row[ $reg_id_field->get_qualified_column() ] |
|
296 | + ); |
|
297 | + if (! $event_id) { |
|
298 | + // get the event's name and Id |
|
299 | + $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf( |
|
300 | + /* translators: 1: event name, 2: event ID */ |
|
301 | + esc_html__('%1$s (%2$s)', 'event_espresso'), |
|
302 | + EEH_Export::prepare_value_from_db_for_display( |
|
303 | + EEM_Event::instance(), |
|
304 | + 'EVT_name', |
|
305 | + $reg_row['Event_CPT.post_title'] |
|
306 | + ), |
|
307 | + $reg_row['Event_CPT.ID'] |
|
308 | + ); |
|
309 | + } |
|
310 | + // add attendee columns |
|
311 | + foreach ($att_fields_to_include as $att_field_name) { |
|
312 | + $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
313 | + if ($reg_row['Attendee_CPT.ID']) { |
|
314 | + if ($att_field_name == 'STA_ID') { |
|
315 | + $value = EEM_State::instance()->get_var( |
|
316 | + [ |
|
317 | + ['STA_ID' => $reg_row['Attendee_Meta.STA_ID']] |
|
318 | + ], |
|
319 | + 'STA_name' |
|
320 | + ); |
|
321 | + } elseif ($att_field_name == 'CNT_ISO') { |
|
322 | + $value = EEM_Country::instance()->get_var( |
|
323 | + [ |
|
324 | + ['CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO']] |
|
325 | + ], |
|
326 | + 'CNT_name' |
|
327 | + ); |
|
328 | + } else { |
|
329 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
330 | + EEM_Attendee::instance(), |
|
331 | + $att_field_name, |
|
332 | + $reg_row[ $field_obj->get_qualified_column() ] |
|
333 | + ); |
|
334 | + } |
|
335 | + } else { |
|
336 | + $value = ''; |
|
337 | + } |
|
338 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
339 | + } |
|
340 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
341 | + /*@var $reg_row EE_Registration */ |
|
342 | + foreach ($reg_fields_to_include as $field_name) { |
|
343 | + $field = $reg_model->field_settings_for($field_name); |
|
344 | + if ($field_name == 'REG_final_price') { |
|
345 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
346 | + $reg_model, |
|
347 | + $field_name, |
|
348 | + $reg_row['Registration.REG_final_price'], |
|
349 | + 'localized_float' |
|
350 | + ); |
|
351 | + } elseif ($field_name == 'REG_count') { |
|
352 | + $value = sprintf( |
|
353 | + /* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */ |
|
354 | + esc_html__('%1$s of %2$s', 'event_espresso'), |
|
355 | + EEH_Export::prepare_value_from_db_for_display( |
|
356 | + $reg_model, |
|
357 | + 'REG_count', |
|
358 | + $reg_row['Registration.REG_count'] |
|
359 | + ), |
|
360 | + EEH_Export::prepare_value_from_db_for_display( |
|
361 | + $reg_model, |
|
362 | + 'REG_group_size', |
|
363 | + $reg_row['Registration.REG_group_size'] |
|
364 | + ) |
|
365 | + ); |
|
366 | + } elseif ($field_name == 'REG_date') { |
|
367 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
368 | + $reg_model, |
|
369 | + $field_name, |
|
370 | + $reg_row['Registration.REG_date'], |
|
371 | + 'no_html' |
|
372 | + ); |
|
373 | + } else { |
|
374 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
375 | + $reg_model, |
|
376 | + $field_name, |
|
377 | + $reg_row[ $field->get_qualified_column() ] |
|
378 | + ); |
|
379 | + } |
|
380 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value; |
|
381 | + if ($field_name == 'REG_final_price') { |
|
382 | + // add a column named Currency after the final price |
|
383 | + $reg_csv_array[ (string) esc_html__("Currency", "event_espresso") ] = EE_Config::instance()->currency->code; |
|
384 | + } |
|
385 | + } |
|
386 | + // get pretty status |
|
387 | + $stati = EEM_Status::instance()->localized_status( |
|
388 | + [ |
|
389 | + $reg_row['Registration.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
390 | + $reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
391 | + ], |
|
392 | + false, |
|
393 | + 'sentence' |
|
394 | + ); |
|
395 | + $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ]; |
|
396 | + // get pretty transaction status |
|
397 | + $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ]; |
|
398 | + $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg |
|
399 | + ? EEH_Export::prepare_value_from_db_for_display( |
|
400 | + EEM_Transaction::instance(), |
|
401 | + 'TXN_total', |
|
402 | + $reg_row['TransactionTable.TXN_total'], |
|
403 | + 'localized_float' |
|
404 | + ) : '0.00'; |
|
405 | + $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg |
|
406 | + ? EEH_Export::prepare_value_from_db_for_display( |
|
407 | + EEM_Transaction::instance(), |
|
408 | + 'TXN_paid', |
|
409 | + $reg_row['TransactionTable.TXN_paid'], |
|
410 | + 'localized_float' |
|
411 | + ) : '0.00'; |
|
412 | + $payment_methods = []; |
|
413 | + $gateway_txn_ids_etc = []; |
|
414 | + $payment_times = []; |
|
415 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
416 | + $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
|
417 | + [ |
|
418 | + [ |
|
419 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
420 | + 'STS_ID' => EEM_Payment::status_id_approved, |
|
421 | + ], |
|
422 | + 'force_join' => ['Payment_Method'], |
|
423 | + ], |
|
424 | + ARRAY_A, |
|
425 | + 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' |
|
426 | + ); |
|
427 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
428 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
429 | + ? $payment_method_and_gateway_txn_id['name'] : esc_html__('Unknown', 'event_espresso'); |
|
430 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
431 | + ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
432 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
433 | + ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
434 | + } |
|
435 | + } |
|
436 | + $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times); |
|
437 | + $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods); |
|
438 | + $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode( |
|
439 | + ',', |
|
440 | + $gateway_txn_ids_etc |
|
441 | + ); |
|
442 | + // get ticket of registration and its price |
|
443 | + $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
|
444 | + if ($reg_row['Ticket.TKT_ID']) { |
|
445 | + $ticket_name = EEH_Export::prepare_value_from_db_for_display( |
|
446 | + $ticket_model, |
|
447 | + 'TKT_name', |
|
448 | + $reg_row['Ticket.TKT_name'] |
|
449 | + ); |
|
450 | + $datetimes_strings = []; |
|
451 | + foreach ( |
|
452 | + EEM_Datetime::instance()->get_all_wpdb_results( |
|
453 | + [ |
|
454 | + ['Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']], |
|
455 | + 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
456 | + 'default_where_conditions' => 'none', |
|
457 | + ] |
|
458 | + ) as $datetime |
|
459 | + ) { |
|
460 | + $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display( |
|
461 | + EEM_Datetime::instance(), |
|
462 | + 'DTT_EVT_start', |
|
463 | + $datetime['Datetime.DTT_EVT_start'] |
|
464 | + ); |
|
465 | + } |
|
466 | + } else { |
|
467 | + $ticket_name = esc_html__('Unknown', 'event_espresso'); |
|
468 | + $datetimes_strings = [esc_html__('Unknown', 'event_espresso')]; |
|
469 | + } |
|
470 | + $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name; |
|
471 | + $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings); |
|
472 | + // make sure each registration has the same questions in the same order |
|
473 | + foreach ($question_labels as $question_label) { |
|
474 | + if (! isset($reg_csv_array[ $question_label ])) { |
|
475 | + $reg_csv_array[ $question_label ] = null; |
|
476 | + } |
|
477 | + } |
|
478 | + $answers = EEM_Answer::instance()->get_all_wpdb_results([ |
|
479 | + ['REG_ID' => $reg_row['Registration.REG_ID']], |
|
480 | + 'force_join' => ['Question'], |
|
481 | + ]); |
|
482 | + // now fill out the questions THEY answered |
|
483 | + foreach ($answers as $answer_row) { |
|
484 | + if ($answer_row['Question.QST_system']) { |
|
485 | + // it's an answer to a system question. That was already displayed as part of the attendee |
|
486 | + // fields, so don't write it out again thanks. |
|
487 | + continue; |
|
488 | + } |
|
489 | + if ($answer_row['Question.QST_ID']) { |
|
490 | + $question_label = EEH_Export::prepare_value_from_db_for_display( |
|
491 | + EEM_Question::instance(), |
|
492 | + 'QST_admin_label', |
|
493 | + $answer_row['Question.QST_admin_label'] |
|
494 | + ); |
|
495 | + } else { |
|
496 | + $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
497 | + } |
|
498 | + if ( |
|
499 | + isset($answer_row['Question.QST_type']) |
|
500 | + && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
|
501 | + ) { |
|
502 | + $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
503 | + $answer_row['Answer.ANS_value'] |
|
504 | + ); |
|
505 | + } else { |
|
506 | + // this isn't for html, so don't show html entities |
|
507 | + $reg_csv_array[ $question_label ] = html_entity_decode( |
|
508 | + EEH_Export::prepare_value_from_db_for_display( |
|
509 | + EEM_Answer::instance(), |
|
510 | + 'ANS_value', |
|
511 | + $answer_row['Answer.ANS_value'] |
|
512 | + ) |
|
513 | + ); |
|
514 | + } |
|
515 | + } |
|
516 | + // Include check-in data |
|
517 | + if ($event_id && $DTT_ID) { |
|
518 | + // get whether or not the user has checked in |
|
519 | + $reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related( |
|
520 | + $reg_row['Registration.REG_ID'], |
|
521 | + 'Checkin', |
|
522 | + [ |
|
523 | + [ |
|
524 | + 'DTT_ID' => $DTT_ID |
|
525 | + ] |
|
526 | + ] |
|
527 | + ); |
|
528 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
529 | + $checkin_rows = EEM_Checkin::instance()->get_all_wpdb_results( |
|
530 | + [ |
|
531 | + [ |
|
532 | + 'REG_ID' => $reg_row['Registration.REG_ID'], |
|
533 | + 'DTT_ID' => $datetime->get('DTT_ID'), |
|
534 | + ], |
|
535 | + ] |
|
536 | + ); |
|
537 | + if (trim($datetime->get('DTT_name'))) { |
|
538 | + /* translators: 1: datetime name, 2: datetime ID */ |
|
539 | + $datetime_name = sprintf( |
|
540 | + esc_html__('Check-ins for %1$s - ID: %2$s', 'event_espresso'), |
|
541 | + esc_html($datetime->get('DTT_name')), |
|
542 | + esc_html($datetime->get('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->get('DTT_ID')) |
|
549 | + ); |
|
550 | + } |
|
551 | + $checkins = []; |
|
552 | + foreach ($checkin_rows as $checkin_row) { |
|
553 | + if ((int) $checkin_row['Checkin.CHK_in'] === 1) { |
|
554 | + /* translators: 1: check-in timestamp */ |
|
555 | + $checkin_value = sprintf( |
|
556 | + esc_html__('IN: %1$s', 'event_espresso'), |
|
557 | + date('Y-m-d g:i a', strtotime($checkin_row['Checkin.CHK_timestamp'])) |
|
558 | + ); |
|
559 | + $checkins[] = $checkin_value; |
|
560 | + } elseif ((int) $checkin_row['Checkin.CHK_in'] === 0) { |
|
561 | + /* translators: 1: check-in timestamp */ |
|
562 | + $checkin_value = sprintf( |
|
563 | + esc_html__('OUT: %1$s', 'event_espresso'), |
|
564 | + date('Y-m-d g:i a', strtotime($checkin_row['Checkin.CHK_timestamp'])) |
|
565 | + ); |
|
566 | + $checkins[] = $checkin_value; |
|
567 | + } |
|
568 | + } |
|
569 | + $reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins); |
|
570 | + } elseif ($event_id) { |
|
571 | + // get whether or not the user has checked in |
|
572 | + $reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related( |
|
573 | + $reg_row['Registration.REG_ID'], |
|
574 | + 'Checkin' |
|
575 | + ); |
|
576 | + $datetimes = EEM_Datetime::instance()->get_all_wpdb_results( |
|
577 | + [ |
|
578 | + [ |
|
579 | + 'Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID'], |
|
580 | + ], |
|
581 | + 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
582 | + 'default_where_conditions' => 'none', |
|
583 | + ] |
|
584 | + ); |
|
585 | + foreach ($datetimes as $datetime) { |
|
586 | + $checkin_row = EEM_Checkin::instance()->get_one( |
|
587 | + [ |
|
588 | + [ |
|
589 | + 'REG_ID' => $reg_row['Registration.REG_ID'], |
|
590 | + 'DTT_ID' => $datetime['Datetime.DTT_ID'], |
|
591 | + ], |
|
592 | + 'limit' => 1, |
|
593 | + 'order_by' => [ |
|
594 | + 'CHK_ID' => 'DESC' |
|
595 | + ] |
|
596 | + ] |
|
597 | + ); |
|
598 | + if (trim($datetime['Datetime.DTT_name'])) { |
|
599 | + /* translators: 1: datetime name, 2: datetime ID */ |
|
600 | + $datetime_name = sprintf( |
|
601 | + esc_html__('Check-ins for %1$s - ID: %2$s', 'event_espresso'), |
|
602 | + esc_html($datetime['Datetime.DTT_name']), |
|
603 | + esc_html($datetime['Datetime.DTT_ID']) |
|
604 | + ); |
|
605 | + } else { |
|
606 | + /* translators: %s: datetime ID */ |
|
607 | + $datetime_name = sprintf( |
|
608 | + esc_html__('ID: %1$s', 'event_espresso'), |
|
609 | + esc_html($datetime['Datetime.DTT_ID']) |
|
610 | + ); |
|
611 | + } |
|
612 | + $checkin_value = ''; |
|
613 | + if ($checkin_row instanceof EE_Checkin && $checkin_row->get('CHK_in') === true) { |
|
614 | + /* translators: 1: check-in timestamp */ |
|
615 | + $checkin_value = sprintf( |
|
616 | + esc_html__('IN: %1$s', 'event_espresso'), |
|
617 | + $checkin_row->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
618 | + ); |
|
619 | + } elseif ($checkin_row instanceof EE_Checkin && $checkin_row->get('CHK_in') === false) { |
|
620 | + /* translators: 1: check-in timestamp */ |
|
621 | + $checkin_value = sprintf( |
|
622 | + esc_html__('OUT: %1$s', 'event_espresso'), |
|
623 | + $checkin_row->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
624 | + ); |
|
625 | + } |
|
626 | + $reg_csv_array[ (string) $datetime_name ] = $checkin_value; |
|
627 | + } |
|
628 | + } |
|
629 | + /** |
|
630 | + * Filter to change the contents of each row of the registrations report CSV file. |
|
631 | + * This can be used to add or remote columns from the CSV file, or change their values. |
|
632 | + * Note when using: all rows in the CSV should have the same columns. |
|
633 | + * @param array $reg_csv_array keys are the column names, values are their cell values |
|
634 | + * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results() |
|
635 | + */ |
|
636 | + $registrations_csv_ready_array[] = apply_filters( |
|
637 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
638 | + $reg_csv_array, |
|
639 | + $reg_row |
|
640 | + ); |
|
641 | + } |
|
642 | + // if we couldn't export anything, we want to at least show the column headers |
|
643 | + if (empty($registrations_csv_ready_array)) { |
|
644 | + $reg_csv_array = []; |
|
645 | + $model_and_fields_to_include = [ |
|
646 | + 'Registration' => $reg_fields_to_include, |
|
647 | + 'Attendee' => $att_fields_to_include, |
|
648 | + ]; |
|
649 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
650 | + $model = EE_Registry::instance()->load_model($model_name); |
|
651 | + foreach ($field_list as $field_name) { |
|
652 | + $field = $model->field_settings_for($field_name); |
|
653 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null; |
|
654 | + } |
|
655 | + } |
|
656 | + $registrations_csv_ready_array[] = $reg_csv_array; |
|
657 | + } |
|
658 | + return $registrations_csv_ready_array; |
|
659 | + } |
|
660 | 660 | |
661 | 661 | |
662 | - /** |
|
663 | - * Counts total unit to process |
|
664 | - * |
|
665 | - * @deprecated since 4.9.19 |
|
666 | - * @param int|array $event_id |
|
667 | - * @return int |
|
668 | - */ |
|
669 | - public function count_units_to_process($event_id) |
|
670 | - { |
|
671 | - // use the legacy filter |
|
672 | - if ($event_id) { |
|
673 | - $query_params[0]['EVT_ID'] = $event_id; |
|
674 | - } else { |
|
675 | - $query_params['force_join'][] = 'Event'; |
|
676 | - } |
|
677 | - return EEM_Registration::instance()->count($query_params); |
|
678 | - } |
|
662 | + /** |
|
663 | + * Counts total unit to process |
|
664 | + * |
|
665 | + * @deprecated since 4.9.19 |
|
666 | + * @param int|array $event_id |
|
667 | + * @return int |
|
668 | + */ |
|
669 | + public function count_units_to_process($event_id) |
|
670 | + { |
|
671 | + // use the legacy filter |
|
672 | + if ($event_id) { |
|
673 | + $query_params[0]['EVT_ID'] = $event_id; |
|
674 | + } else { |
|
675 | + $query_params['force_join'][] = 'Event'; |
|
676 | + } |
|
677 | + return EEM_Registration::instance()->count($query_params); |
|
678 | + } |
|
679 | 679 | |
680 | 680 | |
681 | - /** |
|
682 | - * Performs any clean-up logic when we know the job is completed. |
|
683 | - * In this case, we delete the temporary file |
|
684 | - * |
|
685 | - * @param JobParameters $job_parameters |
|
686 | - * @return boolean |
|
687 | - * @throws EE_Error |
|
688 | - */ |
|
689 | - public function cleanup_job(JobParameters $job_parameters) |
|
690 | - { |
|
691 | - $this->_file_helper->delete( |
|
692 | - EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
693 | - true, |
|
694 | - 'd' |
|
695 | - ); |
|
696 | - return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso')); |
|
697 | - } |
|
681 | + /** |
|
682 | + * Performs any clean-up logic when we know the job is completed. |
|
683 | + * In this case, we delete the temporary file |
|
684 | + * |
|
685 | + * @param JobParameters $job_parameters |
|
686 | + * @return boolean |
|
687 | + * @throws EE_Error |
|
688 | + */ |
|
689 | + public function cleanup_job(JobParameters $job_parameters) |
|
690 | + { |
|
691 | + $this->_file_helper->delete( |
|
692 | + EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
693 | + true, |
|
694 | + 'd' |
|
695 | + ); |
|
696 | + return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso')); |
|
697 | + } |
|
698 | 698 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $event_id = (int) $job_parameters->request_datum('EVT_ID', '0'); |
59 | 59 | $DTT_ID = (int) $job_parameters->request_datum('DTT_ID', '0'); |
60 | - if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
60 | + if ( ! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
61 | 61 | throw new BatchRequestException(esc_html__('You do not have permission to view registrations', 'event_espresso')); |
62 | 62 | } |
63 | 63 | $filepath = $this->create_file_from_job_with_name( |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } else { |
91 | 91 | $query_params['force_join'][] = 'Event'; |
92 | 92 | } |
93 | - if (! isset($query_params['force_join'])) { |
|
93 | + if ( ! isset($query_params['force_join'])) { |
|
94 | 94 | $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
95 | 95 | } |
96 | 96 | $job_parameters->add_extra_data('query_params', $query_params); |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | $question_where_params = array(); |
191 | 191 | foreach ($reg_where_params as $key => $val) { |
192 | 192 | if (EEM_Registration::instance()->is_logic_query_param_key($key)) { |
193 | - $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val); |
|
193 | + $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val); |
|
194 | 194 | } else { |
195 | 195 | // it's a normal where condition |
196 | - $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val; |
|
196 | + $question_where_params['Question_Group.Event.Registration.'.$key] = $val; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | return $question_where_params; |
@@ -283,20 +283,20 @@ discard block |
||
283 | 283 | $query_params['limit'] = [$offset, $limit]; |
284 | 284 | $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
285 | 285 | foreach ($registration_rows as $reg_row) { |
286 | - if (!is_array($reg_row)) { |
|
286 | + if ( ! is_array($reg_row)) { |
|
287 | 287 | continue; |
288 | 288 | } |
289 | 289 | $reg_csv_array = []; |
290 | 290 | // registration Id |
291 | 291 | $reg_id_field = $reg_model->field_settings_for('REG_ID'); |
292 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display( |
|
292 | + $reg_csv_array[EEH_Export::get_column_name_for_field($reg_id_field)] = EEH_Export::prepare_value_from_db_for_display( |
|
293 | 293 | $reg_model, |
294 | 294 | 'REG_ID', |
295 | - $reg_row[ $reg_id_field->get_qualified_column() ] |
|
295 | + $reg_row[$reg_id_field->get_qualified_column()] |
|
296 | 296 | ); |
297 | - if (! $event_id) { |
|
297 | + if ( ! $event_id) { |
|
298 | 298 | // get the event's name and Id |
299 | - $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf( |
|
299 | + $reg_csv_array[(string) esc_html__('Event', 'event_espresso')] = sprintf( |
|
300 | 300 | /* translators: 1: event name, 2: event ID */ |
301 | 301 | esc_html__('%1$s (%2$s)', 'event_espresso'), |
302 | 302 | EEH_Export::prepare_value_from_db_for_display( |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | $value = EEH_Export::prepare_value_from_db_for_display( |
330 | 330 | EEM_Attendee::instance(), |
331 | 331 | $att_field_name, |
332 | - $reg_row[ $field_obj->get_qualified_column() ] |
|
332 | + $reg_row[$field_obj->get_qualified_column()] |
|
333 | 333 | ); |
334 | 334 | } |
335 | 335 | } else { |
336 | 336 | $value = ''; |
337 | 337 | } |
338 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
338 | + $reg_csv_array[EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
339 | 339 | } |
340 | 340 | $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
341 | 341 | /*@var $reg_row EE_Registration */ |
@@ -374,13 +374,13 @@ discard block |
||
374 | 374 | $value = EEH_Export::prepare_value_from_db_for_display( |
375 | 375 | $reg_model, |
376 | 376 | $field_name, |
377 | - $reg_row[ $field->get_qualified_column() ] |
|
377 | + $reg_row[$field->get_qualified_column()] |
|
378 | 378 | ); |
379 | 379 | } |
380 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value; |
|
380 | + $reg_csv_array[EEH_Export::get_column_name_for_field($field)] = $value; |
|
381 | 381 | if ($field_name == 'REG_final_price') { |
382 | 382 | // add a column named Currency after the final price |
383 | - $reg_csv_array[ (string) esc_html__("Currency", "event_espresso") ] = EE_Config::instance()->currency->code; |
|
383 | + $reg_csv_array[(string) esc_html__("Currency", "event_espresso")] = EE_Config::instance()->currency->code; |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | // get pretty status |
@@ -392,17 +392,17 @@ discard block |
||
392 | 392 | false, |
393 | 393 | 'sentence' |
394 | 394 | ); |
395 | - $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ]; |
|
395 | + $reg_csv_array[(string) esc_html__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
396 | 396 | // get pretty transaction status |
397 | - $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ]; |
|
398 | - $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg |
|
397 | + $reg_csv_array[(string) esc_html__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
398 | + $reg_csv_array[(string) esc_html__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg |
|
399 | 399 | ? EEH_Export::prepare_value_from_db_for_display( |
400 | 400 | EEM_Transaction::instance(), |
401 | 401 | 'TXN_total', |
402 | 402 | $reg_row['TransactionTable.TXN_total'], |
403 | 403 | 'localized_float' |
404 | 404 | ) : '0.00'; |
405 | - $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg |
|
405 | + $reg_csv_array[(string) esc_html__('Amount Paid', 'event_espresso')] = $is_primary_reg |
|
406 | 406 | ? EEH_Export::prepare_value_from_db_for_display( |
407 | 407 | EEM_Transaction::instance(), |
408 | 408 | 'TXN_paid', |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
434 | 434 | } |
435 | 435 | } |
436 | - $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times); |
|
437 | - $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods); |
|
438 | - $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode( |
|
436 | + $reg_csv_array[(string) esc_html__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
437 | + $reg_csv_array[(string) esc_html__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
438 | + $reg_csv_array[(string) esc_html__('Gateway Transaction ID(s)', 'event_espresso')] = implode( |
|
439 | 439 | ',', |
440 | 440 | $gateway_txn_ids_etc |
441 | 441 | ); |
@@ -467,12 +467,12 @@ discard block |
||
467 | 467 | $ticket_name = esc_html__('Unknown', 'event_espresso'); |
468 | 468 | $datetimes_strings = [esc_html__('Unknown', 'event_espresso')]; |
469 | 469 | } |
470 | - $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name; |
|
471 | - $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings); |
|
470 | + $reg_csv_array[(string) $ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
|
471 | + $reg_csv_array[(string) esc_html__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
|
472 | 472 | // make sure each registration has the same questions in the same order |
473 | 473 | foreach ($question_labels as $question_label) { |
474 | - if (! isset($reg_csv_array[ $question_label ])) { |
|
475 | - $reg_csv_array[ $question_label ] = null; |
|
474 | + if ( ! isset($reg_csv_array[$question_label])) { |
|
475 | + $reg_csv_array[$question_label] = null; |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | $answers = EEM_Answer::instance()->get_all_wpdb_results([ |
@@ -499,12 +499,12 @@ discard block |
||
499 | 499 | isset($answer_row['Question.QST_type']) |
500 | 500 | && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
501 | 501 | ) { |
502 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
502 | + $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID( |
|
503 | 503 | $answer_row['Answer.ANS_value'] |
504 | 504 | ); |
505 | 505 | } else { |
506 | 506 | // this isn't for html, so don't show html entities |
507 | - $reg_csv_array[ $question_label ] = html_entity_decode( |
|
507 | + $reg_csv_array[$question_label] = html_entity_decode( |
|
508 | 508 | EEH_Export::prepare_value_from_db_for_display( |
509 | 509 | EEM_Answer::instance(), |
510 | 510 | 'ANS_value', |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | // Include check-in data |
517 | 517 | if ($event_id && $DTT_ID) { |
518 | 518 | // get whether or not the user has checked in |
519 | - $reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related( |
|
519 | + $reg_csv_array[(string) esc_html__('Datetime Check-ins #', 'event_espresso')] = $reg_model->count_related( |
|
520 | 520 | $reg_row['Registration.REG_ID'], |
521 | 521 | 'Checkin', |
522 | 522 | [ |
@@ -566,10 +566,10 @@ discard block |
||
566 | 566 | $checkins[] = $checkin_value; |
567 | 567 | } |
568 | 568 | } |
569 | - $reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins); |
|
569 | + $reg_csv_array[(string) $datetime_name] = implode(' --- ', $checkins); |
|
570 | 570 | } elseif ($event_id) { |
571 | 571 | // get whether or not the user has checked in |
572 | - $reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related( |
|
572 | + $reg_csv_array[(string) esc_html__('Event Check-ins #', 'event_espresso')] = $reg_model->count_related( |
|
573 | 573 | $reg_row['Registration.REG_ID'], |
574 | 574 | 'Checkin' |
575 | 575 | ); |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | $checkin_row->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
624 | 624 | ); |
625 | 625 | } |
626 | - $reg_csv_array[ (string) $datetime_name ] = $checkin_value; |
|
626 | + $reg_csv_array[(string) $datetime_name] = $checkin_value; |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | /** |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | $model = EE_Registry::instance()->load_model($model_name); |
651 | 651 | foreach ($field_list as $field_name) { |
652 | 652 | $field = $model->field_settings_for($field_name); |
653 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null; |
|
653 | + $reg_csv_array[EEH_Export::get_column_name_for_field($field)] = null; |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | $registrations_csv_ready_array[] = $reg_csv_array; |
@@ -13,553 +13,553 @@ |
||
13 | 13 | class EE_Event_Registrations_List_Table extends EE_Admin_List_Table |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
18 | - * |
|
19 | - * @var EE_Datetime[] |
|
20 | - */ |
|
21 | - protected $_dtts_for_event = array(); |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * The event if one is specified in the request |
|
26 | - * |
|
27 | - * @var EE_Event |
|
28 | - */ |
|
29 | - protected $_evt = null; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * The DTT_ID if the current view has a specified datetime. |
|
34 | - * |
|
35 | - * @var int $_cur_dtt_id |
|
36 | - */ |
|
37 | - protected $_cur_dtt_id = 0; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * EE_Event_Registrations_List_Table constructor. |
|
42 | - * |
|
43 | - * @param Registrations_Admin_Page $admin_page |
|
44 | - */ |
|
45 | - public function __construct($admin_page) |
|
46 | - { |
|
47 | - parent::__construct($admin_page); |
|
48 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - protected function _setup_data() |
|
53 | - { |
|
54 | - $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
55 | - : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
56 | - $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
|
57 | - $this->_per_page, |
|
58 | - true |
|
59 | - ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - protected function _set_properties() |
|
64 | - { |
|
65 | - $return_url = $this->getReturnUrl(); |
|
66 | - |
|
67 | - $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
68 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
69 | - $this->_wp_list_args = array( |
|
70 | - 'singular' => esc_html__('registrant', 'event_espresso'), |
|
71 | - 'plural' => esc_html__('registrants', 'event_espresso'), |
|
72 | - 'ajax' => true, |
|
73 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
74 | - ); |
|
75 | - $columns = array(); |
|
76 | - // $columns['_Reg_Status'] = ''; |
|
77 | - $this->_columns = array( |
|
78 | - '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
79 | - 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
80 | - 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
81 | - 'Event' => esc_html__('Event', 'event_espresso'), |
|
82 | - 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
83 | - '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
84 | - 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
85 | - 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
86 | - ); |
|
87 | - // Add/remove columns when an event has been selected |
|
88 | - if (! empty($evt_id)) { |
|
89 | - // Render a checkbox column |
|
90 | - $columns['cb'] = '<input type="checkbox" />'; |
|
91 | - $this->_has_checkbox_column = true; |
|
92 | - // Remove the 'Event' column |
|
93 | - unset($this->_columns['Event']); |
|
94 | - } |
|
95 | - $this->_columns = array_merge($columns, $this->_columns); |
|
96 | - $this->_primary_column = '_REG_att_checked_in'; |
|
97 | - if ( |
|
98 | - ! empty($evt_id) |
|
99 | - && EE_Registry::instance()->CAP->current_user_can( |
|
100 | - 'ee_read_registrations', |
|
101 | - 'espresso_registrations_registrations_reports', |
|
102 | - $evt_id |
|
103 | - ) |
|
104 | - ) { |
|
105 | - $route_details = [ |
|
106 | - 'route' => 'registrations_report', |
|
107 | - 'extra_request' => [ |
|
108 | - 'EVT_ID' => $evt_id, |
|
109 | - 'return_url' => $return_url, |
|
110 | - ] |
|
111 | - ]; |
|
112 | - if ($DTT_ID) { |
|
113 | - $route_details['extra_request']['DTT_ID'] = $DTT_ID; |
|
114 | - $this->_bottom_buttons['report_datetime'] = $route_details; |
|
115 | - } else { |
|
116 | - $this->_bottom_buttons['report'] = $route_details; |
|
117 | - } |
|
118 | - } |
|
119 | - $this->_sortable_columns = array( |
|
120 | - /** |
|
121 | - * Allows users to change the default sort if they wish. |
|
122 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
123 | - * |
|
124 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
125 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
126 | - * for a specific list table you can use the provided reference to this object instance. |
|
127 | - */ |
|
128 | - 'ATT_name' => array( |
|
129 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
130 | - true, |
|
131 | - $this, |
|
132 | - ) |
|
133 | - ? array('ATT_lname' => true) |
|
134 | - : array('ATT_fname' => true), |
|
135 | - 'Event' => array('Event.EVT_name' => false), |
|
136 | - ); |
|
137 | - $this->_hidden_columns = array(); |
|
138 | - $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
139 | - $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @param EE_Registration $item |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - protected function _get_row_class($item) |
|
148 | - { |
|
149 | - $class = parent::_get_row_class($item); |
|
150 | - // add status class |
|
151 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
152 | - if ($this->_has_checkbox_column) { |
|
153 | - $class .= ' has-checkbox-column'; |
|
154 | - } |
|
155 | - return $class; |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @return array |
|
161 | - * @throws EE_Error |
|
162 | - * @throws ReflectionException |
|
163 | - */ |
|
164 | - protected function _get_table_filters() |
|
165 | - { |
|
166 | - $filters = $where = array(); |
|
167 | - $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
168 | - if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
169 | - // this means we don't have an event so let's setup a filter dropdown for all the events to select |
|
170 | - // note possible capability restrictions |
|
171 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
172 | - $where['status**'] = array('!=', 'private'); |
|
173 | - } |
|
174 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
175 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
176 | - } |
|
177 | - $events = EEM_Event::instance()->get_all( |
|
178 | - array( |
|
179 | - $where, |
|
180 | - 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
181 | - ) |
|
182 | - ); |
|
183 | - $evts[] = array( |
|
184 | - 'id' => 0, |
|
185 | - 'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'), |
|
186 | - ); |
|
187 | - $checked = 'checked'; |
|
188 | - /** @var EE_Event $evt */ |
|
189 | - foreach ($events as $evt) { |
|
190 | - // any registrations for this event? |
|
191 | - if (! $evt->get_count_of_all_registrations()) { |
|
192 | - continue; |
|
193 | - } |
|
194 | - $evts[] = array( |
|
195 | - 'id' => $evt->ID(), |
|
196 | - 'text' => apply_filters( |
|
197 | - 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
198 | - $evt->get('EVT_name'), |
|
199 | - $evt |
|
200 | - ), |
|
201 | - 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
|
202 | - ); |
|
203 | - if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
204 | - $checked = ''; |
|
205 | - } |
|
206 | - } |
|
207 | - $event_filter = '<div class="ee-event-filter">'; |
|
208 | - $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
209 | - $event_filter .= '<span class="ee-event-filter-toggle">'; |
|
210 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
211 | - $event_filter .= esc_html__('Hide Expired Events', 'event_espresso'); |
|
212 | - $event_filter .= '</span>'; |
|
213 | - $event_filter .= '</div>'; |
|
214 | - $filters[] = $event_filter; |
|
215 | - } |
|
216 | - if (! empty($this->_dtts_for_event)) { |
|
217 | - // DTT datetimes filter |
|
218 | - $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
219 | - if (count($this->_dtts_for_event) > 1) { |
|
220 | - $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
221 | - foreach ($this->_dtts_for_event as $dtt) { |
|
222 | - $datetime_string = $dtt->name(); |
|
223 | - $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
224 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
225 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
226 | - } |
|
227 | - $input = new EE_Select_Input( |
|
228 | - $dtts, |
|
229 | - array( |
|
230 | - 'html_name' => 'DTT_ID', |
|
231 | - 'html_id' => 'DTT_ID', |
|
232 | - 'default' => $this->_cur_dtt_id, |
|
233 | - ) |
|
234 | - ); |
|
235 | - $filters[] = $input->get_html_for_input(); |
|
236 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
237 | - } |
|
238 | - } |
|
239 | - return $filters; |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - protected function _add_view_counts() |
|
244 | - { |
|
245 | - $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * @return int |
|
251 | - * @throws EE_Error |
|
252 | - */ |
|
253 | - protected function _get_total_event_attendees() |
|
254 | - { |
|
255 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
256 | - $DTT_ID = $this->_cur_dtt_id; |
|
257 | - $query_params = array(); |
|
258 | - if ($EVT_ID) { |
|
259 | - $query_params[0]['EVT_ID'] = $EVT_ID; |
|
260 | - } |
|
261 | - // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
262 | - if ($DTT_ID) { |
|
263 | - $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
264 | - } |
|
265 | - $status_ids_array = apply_filters( |
|
266 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
267 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
268 | - ); |
|
269 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
270 | - return EEM_Registration::instance()->count($query_params); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * @param EE_Registration $item |
|
276 | - * @return string |
|
277 | - */ |
|
278 | - public function column__Reg_Status(EE_Registration $item) |
|
279 | - { |
|
280 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * @param EE_Registration $item |
|
286 | - * @return string |
|
287 | - * @throws EE_Error |
|
288 | - */ |
|
289 | - public function column_cb($item) |
|
290 | - { |
|
291 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * column_REG_att_checked_in |
|
297 | - * |
|
298 | - * @param EE_Registration $item |
|
299 | - * @return string |
|
300 | - * @throws EE_Error |
|
301 | - * @throws InvalidArgumentException |
|
302 | - * @throws InvalidDataTypeException |
|
303 | - * @throws InvalidInterfaceException |
|
304 | - */ |
|
305 | - public function column__REG_att_checked_in(EE_Registration $item) |
|
306 | - { |
|
307 | - $attendee = $item->attendee(); |
|
308 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
309 | - |
|
310 | - if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
311 | - $latest_related_datetime = $item->get_latest_related_datetime(); |
|
312 | - if ($latest_related_datetime instanceof EE_Datetime) { |
|
313 | - $this->_cur_dtt_id = $latest_related_datetime->ID(); |
|
314 | - } |
|
315 | - } |
|
316 | - $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
317 | - $item, |
|
318 | - $this->_cur_dtt_id |
|
319 | - ); |
|
320 | - $nonce = wp_create_nonce('checkin_nonce'); |
|
321 | - $toggle_active = ! empty($this->_cur_dtt_id) |
|
322 | - && EE_Registry::instance()->CAP->current_user_can( |
|
323 | - 'ee_edit_checkin', |
|
324 | - 'espresso_registrations_toggle_checkin_status', |
|
325 | - $item->ID() |
|
326 | - ) |
|
327 | - ? ' clickable trigger-checkin' |
|
328 | - : ''; |
|
329 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
330 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
331 | - . ' data-_regid="' . $item->ID() . '"' |
|
332 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
333 | - . ' data-nonce="' . $nonce . '">' |
|
334 | - . '</span>' |
|
335 | - . $mobile_view_content; |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - /** |
|
340 | - * @param EE_Registration $item |
|
341 | - * @return mixed|string|void |
|
342 | - * @throws EE_Error |
|
343 | - */ |
|
344 | - public function column_ATT_name(EE_Registration $item) |
|
345 | - { |
|
346 | - $attendee = $item->attendee(); |
|
347 | - if (! $attendee instanceof EE_Attendee) { |
|
348 | - return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
349 | - } |
|
350 | - // edit attendee link |
|
351 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
352 | - array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
353 | - REG_ADMIN_URL |
|
354 | - ); |
|
355 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
356 | - 'ee_edit_contacts', |
|
357 | - 'espresso_registrations_edit_attendee' |
|
358 | - ) |
|
359 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
360 | - . $item->attendee()->full_name() |
|
361 | - . '</a>' |
|
362 | - : $item->attendee()->full_name(); |
|
363 | - $name_link .= $item->count() === 1 |
|
364 | - ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
|
365 | - : ''; |
|
366 | - // add group details |
|
367 | - $name_link .= ' ' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
368 | - // add regcode |
|
369 | - $link = 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 .= '<br>'; |
|
374 | - $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
375 | - 'ee_read_registration', |
|
376 | - 'view_registration', |
|
377 | - $item->ID() |
|
378 | - ) |
|
379 | - ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
380 | - . $item->reg_code() |
|
381 | - . '</a>' |
|
382 | - : $item->reg_code(); |
|
383 | - // status |
|
384 | - $name_link .= '<br><span class="ee-status-text-small">'; |
|
385 | - $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
386 | - $name_link .= '</span>'; |
|
387 | - $actions = array(); |
|
388 | - $DTT_ID = $this->_cur_dtt_id; |
|
389 | - $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
390 | - ? $item->get_latest_related_datetime() |
|
391 | - : null; |
|
392 | - $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
|
393 | - ? $latest_related_datetime->ID() |
|
394 | - : $DTT_ID; |
|
395 | - if ( |
|
396 | - ! empty($DTT_ID) |
|
397 | - && EE_Registry::instance()->CAP->current_user_can( |
|
398 | - 'ee_read_checkins', |
|
399 | - 'espresso_registrations_registration_checkins' |
|
400 | - ) |
|
401 | - ) { |
|
402 | - $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
403 | - array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
404 | - REG_ADMIN_URL |
|
405 | - ); |
|
406 | - // get the timestamps for this registration's checkins, related to the selected datetime |
|
407 | - $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
408 | - if (! empty($timestamps)) { |
|
409 | - // get the last timestamp |
|
410 | - $last_timestamp = end($timestamps); |
|
411 | - // checked in or checked out? |
|
412 | - $checkin_status = $last_timestamp->get('CHK_in') |
|
413 | - ? esc_html__('Checked In', 'event_espresso') |
|
414 | - : esc_html__('Checked Out', 'event_espresso'); |
|
415 | - // get timestamp string |
|
416 | - $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
417 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' |
|
418 | - . esc_attr__( |
|
419 | - 'View this registrant\'s check-ins/checkouts for the datetime', |
|
420 | - 'event_espresso' |
|
421 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
422 | - } |
|
423 | - } |
|
424 | - return (! empty($DTT_ID) && ! empty($timestamps)) |
|
425 | - ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
426 | - : $name_link; |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * @param EE_Registration $item |
|
432 | - * @return string |
|
433 | - */ |
|
434 | - public function column_ATT_email(EE_Registration $item) |
|
435 | - { |
|
436 | - $attendee = $item->attendee(); |
|
437 | - return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * @param EE_Registration $item |
|
443 | - * @return bool|string |
|
444 | - * @throws EE_Error |
|
445 | - */ |
|
446 | - public function column_Event(EE_Registration $item) |
|
447 | - { |
|
448 | - try { |
|
449 | - $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
|
450 | - $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
451 | - array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
452 | - REG_ADMIN_URL |
|
453 | - ); |
|
454 | - $event_label = EE_Registry::instance()->CAP->current_user_can( |
|
455 | - 'ee_read_checkins', |
|
456 | - 'espresso_registrations_registration_checkins' |
|
457 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' |
|
458 | - . esc_attr__( |
|
459 | - 'View Checkins for this Event', |
|
460 | - 'event_espresso' |
|
461 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
462 | - } catch (EntityNotFoundException $e) { |
|
463 | - $event_label = esc_html__('Unknown', 'event_espresso'); |
|
464 | - } |
|
465 | - return $event_label; |
|
466 | - } |
|
467 | - |
|
468 | - |
|
469 | - /** |
|
470 | - * @param EE_Registration $item |
|
471 | - * @return mixed|string|void |
|
472 | - */ |
|
473 | - public function column_PRC_name(EE_Registration $item) |
|
474 | - { |
|
475 | - return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso"); |
|
476 | - } |
|
477 | - |
|
478 | - |
|
479 | - /** |
|
480 | - * column_REG_final_price |
|
481 | - * |
|
482 | - * @param EE_Registration $item |
|
483 | - * @return string |
|
484 | - */ |
|
485 | - public function column__REG_final_price(EE_Registration $item) |
|
486 | - { |
|
487 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
488 | - } |
|
489 | - |
|
490 | - |
|
491 | - /** |
|
492 | - * column_TXN_paid |
|
493 | - * |
|
494 | - * @param EE_Registration $item |
|
495 | - * @return string |
|
496 | - * @throws EE_Error |
|
497 | - */ |
|
498 | - public function column_TXN_paid(EE_Registration $item) |
|
499 | - { |
|
500 | - if ($item->count() === 1) { |
|
501 | - if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
502 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
503 | - } else { |
|
504 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
505 | - array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
506 | - TXN_ADMIN_URL |
|
507 | - ); |
|
508 | - return EE_Registry::instance()->CAP->current_user_can( |
|
509 | - 'ee_read_transaction', |
|
510 | - 'espresso_transactions_view_transaction' |
|
511 | - ) ? ' |
|
16 | + /** |
|
17 | + * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
18 | + * |
|
19 | + * @var EE_Datetime[] |
|
20 | + */ |
|
21 | + protected $_dtts_for_event = array(); |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * The event if one is specified in the request |
|
26 | + * |
|
27 | + * @var EE_Event |
|
28 | + */ |
|
29 | + protected $_evt = null; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * The DTT_ID if the current view has a specified datetime. |
|
34 | + * |
|
35 | + * @var int $_cur_dtt_id |
|
36 | + */ |
|
37 | + protected $_cur_dtt_id = 0; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * EE_Event_Registrations_List_Table constructor. |
|
42 | + * |
|
43 | + * @param Registrations_Admin_Page $admin_page |
|
44 | + */ |
|
45 | + public function __construct($admin_page) |
|
46 | + { |
|
47 | + parent::__construct($admin_page); |
|
48 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + protected function _setup_data() |
|
53 | + { |
|
54 | + $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
55 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
56 | + $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
|
57 | + $this->_per_page, |
|
58 | + true |
|
59 | + ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + protected function _set_properties() |
|
64 | + { |
|
65 | + $return_url = $this->getReturnUrl(); |
|
66 | + |
|
67 | + $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
68 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
69 | + $this->_wp_list_args = array( |
|
70 | + 'singular' => esc_html__('registrant', 'event_espresso'), |
|
71 | + 'plural' => esc_html__('registrants', 'event_espresso'), |
|
72 | + 'ajax' => true, |
|
73 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
74 | + ); |
|
75 | + $columns = array(); |
|
76 | + // $columns['_Reg_Status'] = ''; |
|
77 | + $this->_columns = array( |
|
78 | + '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
79 | + 'ATT_name' => esc_html__('Registrant', 'event_espresso'), |
|
80 | + 'ATT_email' => esc_html__('Email Address', 'event_espresso'), |
|
81 | + 'Event' => esc_html__('Event', 'event_espresso'), |
|
82 | + 'PRC_name' => esc_html__('TKT Option', 'event_espresso'), |
|
83 | + '_REG_final_price' => esc_html__('Price', 'event_espresso'), |
|
84 | + 'TXN_paid' => esc_html__('Paid', 'event_espresso'), |
|
85 | + 'TXN_total' => esc_html__('Total', 'event_espresso'), |
|
86 | + ); |
|
87 | + // Add/remove columns when an event has been selected |
|
88 | + if (! empty($evt_id)) { |
|
89 | + // Render a checkbox column |
|
90 | + $columns['cb'] = '<input type="checkbox" />'; |
|
91 | + $this->_has_checkbox_column = true; |
|
92 | + // Remove the 'Event' column |
|
93 | + unset($this->_columns['Event']); |
|
94 | + } |
|
95 | + $this->_columns = array_merge($columns, $this->_columns); |
|
96 | + $this->_primary_column = '_REG_att_checked_in'; |
|
97 | + if ( |
|
98 | + ! empty($evt_id) |
|
99 | + && EE_Registry::instance()->CAP->current_user_can( |
|
100 | + 'ee_read_registrations', |
|
101 | + 'espresso_registrations_registrations_reports', |
|
102 | + $evt_id |
|
103 | + ) |
|
104 | + ) { |
|
105 | + $route_details = [ |
|
106 | + 'route' => 'registrations_report', |
|
107 | + 'extra_request' => [ |
|
108 | + 'EVT_ID' => $evt_id, |
|
109 | + 'return_url' => $return_url, |
|
110 | + ] |
|
111 | + ]; |
|
112 | + if ($DTT_ID) { |
|
113 | + $route_details['extra_request']['DTT_ID'] = $DTT_ID; |
|
114 | + $this->_bottom_buttons['report_datetime'] = $route_details; |
|
115 | + } else { |
|
116 | + $this->_bottom_buttons['report'] = $route_details; |
|
117 | + } |
|
118 | + } |
|
119 | + $this->_sortable_columns = array( |
|
120 | + /** |
|
121 | + * Allows users to change the default sort if they wish. |
|
122 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
123 | + * |
|
124 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
125 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
126 | + * for a specific list table you can use the provided reference to this object instance. |
|
127 | + */ |
|
128 | + 'ATT_name' => array( |
|
129 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
130 | + true, |
|
131 | + $this, |
|
132 | + ) |
|
133 | + ? array('ATT_lname' => true) |
|
134 | + : array('ATT_fname' => true), |
|
135 | + 'Event' => array('Event.EVT_name' => false), |
|
136 | + ); |
|
137 | + $this->_hidden_columns = array(); |
|
138 | + $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
139 | + $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @param EE_Registration $item |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + protected function _get_row_class($item) |
|
148 | + { |
|
149 | + $class = parent::_get_row_class($item); |
|
150 | + // add status class |
|
151 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
152 | + if ($this->_has_checkbox_column) { |
|
153 | + $class .= ' has-checkbox-column'; |
|
154 | + } |
|
155 | + return $class; |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @return array |
|
161 | + * @throws EE_Error |
|
162 | + * @throws ReflectionException |
|
163 | + */ |
|
164 | + protected function _get_table_filters() |
|
165 | + { |
|
166 | + $filters = $where = array(); |
|
167 | + $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
168 | + if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
169 | + // this means we don't have an event so let's setup a filter dropdown for all the events to select |
|
170 | + // note possible capability restrictions |
|
171 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
172 | + $where['status**'] = array('!=', 'private'); |
|
173 | + } |
|
174 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
175 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
176 | + } |
|
177 | + $events = EEM_Event::instance()->get_all( |
|
178 | + array( |
|
179 | + $where, |
|
180 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
181 | + ) |
|
182 | + ); |
|
183 | + $evts[] = array( |
|
184 | + 'id' => 0, |
|
185 | + 'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'), |
|
186 | + ); |
|
187 | + $checked = 'checked'; |
|
188 | + /** @var EE_Event $evt */ |
|
189 | + foreach ($events as $evt) { |
|
190 | + // any registrations for this event? |
|
191 | + if (! $evt->get_count_of_all_registrations()) { |
|
192 | + continue; |
|
193 | + } |
|
194 | + $evts[] = array( |
|
195 | + 'id' => $evt->ID(), |
|
196 | + 'text' => apply_filters( |
|
197 | + 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
198 | + $evt->get('EVT_name'), |
|
199 | + $evt |
|
200 | + ), |
|
201 | + 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
|
202 | + ); |
|
203 | + if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
204 | + $checked = ''; |
|
205 | + } |
|
206 | + } |
|
207 | + $event_filter = '<div class="ee-event-filter">'; |
|
208 | + $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
209 | + $event_filter .= '<span class="ee-event-filter-toggle">'; |
|
210 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
211 | + $event_filter .= esc_html__('Hide Expired Events', 'event_espresso'); |
|
212 | + $event_filter .= '</span>'; |
|
213 | + $event_filter .= '</div>'; |
|
214 | + $filters[] = $event_filter; |
|
215 | + } |
|
216 | + if (! empty($this->_dtts_for_event)) { |
|
217 | + // DTT datetimes filter |
|
218 | + $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
219 | + if (count($this->_dtts_for_event) > 1) { |
|
220 | + $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
221 | + foreach ($this->_dtts_for_event as $dtt) { |
|
222 | + $datetime_string = $dtt->name(); |
|
223 | + $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
224 | + $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
225 | + $dtts[ $dtt->ID() ] = $datetime_string; |
|
226 | + } |
|
227 | + $input = new EE_Select_Input( |
|
228 | + $dtts, |
|
229 | + array( |
|
230 | + 'html_name' => 'DTT_ID', |
|
231 | + 'html_id' => 'DTT_ID', |
|
232 | + 'default' => $this->_cur_dtt_id, |
|
233 | + ) |
|
234 | + ); |
|
235 | + $filters[] = $input->get_html_for_input(); |
|
236 | + $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
237 | + } |
|
238 | + } |
|
239 | + return $filters; |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + protected function _add_view_counts() |
|
244 | + { |
|
245 | + $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * @return int |
|
251 | + * @throws EE_Error |
|
252 | + */ |
|
253 | + protected function _get_total_event_attendees() |
|
254 | + { |
|
255 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
256 | + $DTT_ID = $this->_cur_dtt_id; |
|
257 | + $query_params = array(); |
|
258 | + if ($EVT_ID) { |
|
259 | + $query_params[0]['EVT_ID'] = $EVT_ID; |
|
260 | + } |
|
261 | + // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
262 | + if ($DTT_ID) { |
|
263 | + $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
264 | + } |
|
265 | + $status_ids_array = apply_filters( |
|
266 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
267 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
268 | + ); |
|
269 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
270 | + return EEM_Registration::instance()->count($query_params); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * @param EE_Registration $item |
|
276 | + * @return string |
|
277 | + */ |
|
278 | + public function column__Reg_Status(EE_Registration $item) |
|
279 | + { |
|
280 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * @param EE_Registration $item |
|
286 | + * @return string |
|
287 | + * @throws EE_Error |
|
288 | + */ |
|
289 | + public function column_cb($item) |
|
290 | + { |
|
291 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * column_REG_att_checked_in |
|
297 | + * |
|
298 | + * @param EE_Registration $item |
|
299 | + * @return string |
|
300 | + * @throws EE_Error |
|
301 | + * @throws InvalidArgumentException |
|
302 | + * @throws InvalidDataTypeException |
|
303 | + * @throws InvalidInterfaceException |
|
304 | + */ |
|
305 | + public function column__REG_att_checked_in(EE_Registration $item) |
|
306 | + { |
|
307 | + $attendee = $item->attendee(); |
|
308 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
309 | + |
|
310 | + if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
311 | + $latest_related_datetime = $item->get_latest_related_datetime(); |
|
312 | + if ($latest_related_datetime instanceof EE_Datetime) { |
|
313 | + $this->_cur_dtt_id = $latest_related_datetime->ID(); |
|
314 | + } |
|
315 | + } |
|
316 | + $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
317 | + $item, |
|
318 | + $this->_cur_dtt_id |
|
319 | + ); |
|
320 | + $nonce = wp_create_nonce('checkin_nonce'); |
|
321 | + $toggle_active = ! empty($this->_cur_dtt_id) |
|
322 | + && EE_Registry::instance()->CAP->current_user_can( |
|
323 | + 'ee_edit_checkin', |
|
324 | + 'espresso_registrations_toggle_checkin_status', |
|
325 | + $item->ID() |
|
326 | + ) |
|
327 | + ? ' clickable trigger-checkin' |
|
328 | + : ''; |
|
329 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
330 | + return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
331 | + . ' data-_regid="' . $item->ID() . '"' |
|
332 | + . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
333 | + . ' data-nonce="' . $nonce . '">' |
|
334 | + . '</span>' |
|
335 | + . $mobile_view_content; |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + /** |
|
340 | + * @param EE_Registration $item |
|
341 | + * @return mixed|string|void |
|
342 | + * @throws EE_Error |
|
343 | + */ |
|
344 | + public function column_ATT_name(EE_Registration $item) |
|
345 | + { |
|
346 | + $attendee = $item->attendee(); |
|
347 | + if (! $attendee instanceof EE_Attendee) { |
|
348 | + return esc_html__('No contact record for this registration.', 'event_espresso'); |
|
349 | + } |
|
350 | + // edit attendee link |
|
351 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
352 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
353 | + REG_ADMIN_URL |
|
354 | + ); |
|
355 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
356 | + 'ee_edit_contacts', |
|
357 | + 'espresso_registrations_edit_attendee' |
|
358 | + ) |
|
359 | + ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
360 | + . $item->attendee()->full_name() |
|
361 | + . '</a>' |
|
362 | + : $item->attendee()->full_name(); |
|
363 | + $name_link .= $item->count() === 1 |
|
364 | + ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
|
365 | + : ''; |
|
366 | + // add group details |
|
367 | + $name_link .= ' ' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
368 | + // add regcode |
|
369 | + $link = 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 .= '<br>'; |
|
374 | + $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
375 | + 'ee_read_registration', |
|
376 | + 'view_registration', |
|
377 | + $item->ID() |
|
378 | + ) |
|
379 | + ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
380 | + . $item->reg_code() |
|
381 | + . '</a>' |
|
382 | + : $item->reg_code(); |
|
383 | + // status |
|
384 | + $name_link .= '<br><span class="ee-status-text-small">'; |
|
385 | + $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
386 | + $name_link .= '</span>'; |
|
387 | + $actions = array(); |
|
388 | + $DTT_ID = $this->_cur_dtt_id; |
|
389 | + $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
390 | + ? $item->get_latest_related_datetime() |
|
391 | + : null; |
|
392 | + $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
|
393 | + ? $latest_related_datetime->ID() |
|
394 | + : $DTT_ID; |
|
395 | + if ( |
|
396 | + ! empty($DTT_ID) |
|
397 | + && EE_Registry::instance()->CAP->current_user_can( |
|
398 | + 'ee_read_checkins', |
|
399 | + 'espresso_registrations_registration_checkins' |
|
400 | + ) |
|
401 | + ) { |
|
402 | + $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
403 | + array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
404 | + REG_ADMIN_URL |
|
405 | + ); |
|
406 | + // get the timestamps for this registration's checkins, related to the selected datetime |
|
407 | + $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
408 | + if (! empty($timestamps)) { |
|
409 | + // get the last timestamp |
|
410 | + $last_timestamp = end($timestamps); |
|
411 | + // checked in or checked out? |
|
412 | + $checkin_status = $last_timestamp->get('CHK_in') |
|
413 | + ? esc_html__('Checked In', 'event_espresso') |
|
414 | + : esc_html__('Checked Out', 'event_espresso'); |
|
415 | + // get timestamp string |
|
416 | + $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
417 | + $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' |
|
418 | + . esc_attr__( |
|
419 | + 'View this registrant\'s check-ins/checkouts for the datetime', |
|
420 | + 'event_espresso' |
|
421 | + ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
422 | + } |
|
423 | + } |
|
424 | + return (! empty($DTT_ID) && ! empty($timestamps)) |
|
425 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
426 | + : $name_link; |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * @param EE_Registration $item |
|
432 | + * @return string |
|
433 | + */ |
|
434 | + public function column_ATT_email(EE_Registration $item) |
|
435 | + { |
|
436 | + $attendee = $item->attendee(); |
|
437 | + return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * @param EE_Registration $item |
|
443 | + * @return bool|string |
|
444 | + * @throws EE_Error |
|
445 | + */ |
|
446 | + public function column_Event(EE_Registration $item) |
|
447 | + { |
|
448 | + try { |
|
449 | + $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
|
450 | + $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
451 | + array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
452 | + REG_ADMIN_URL |
|
453 | + ); |
|
454 | + $event_label = EE_Registry::instance()->CAP->current_user_can( |
|
455 | + 'ee_read_checkins', |
|
456 | + 'espresso_registrations_registration_checkins' |
|
457 | + ) ? '<a href="' . $chkin_lnk_url . '" title="' |
|
458 | + . esc_attr__( |
|
459 | + 'View Checkins for this Event', |
|
460 | + 'event_espresso' |
|
461 | + ) . '">' . $event->name() . '</a>' : $event->name(); |
|
462 | + } catch (EntityNotFoundException $e) { |
|
463 | + $event_label = esc_html__('Unknown', 'event_espresso'); |
|
464 | + } |
|
465 | + return $event_label; |
|
466 | + } |
|
467 | + |
|
468 | + |
|
469 | + /** |
|
470 | + * @param EE_Registration $item |
|
471 | + * @return mixed|string|void |
|
472 | + */ |
|
473 | + public function column_PRC_name(EE_Registration $item) |
|
474 | + { |
|
475 | + return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso"); |
|
476 | + } |
|
477 | + |
|
478 | + |
|
479 | + /** |
|
480 | + * column_REG_final_price |
|
481 | + * |
|
482 | + * @param EE_Registration $item |
|
483 | + * @return string |
|
484 | + */ |
|
485 | + public function column__REG_final_price(EE_Registration $item) |
|
486 | + { |
|
487 | + return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
488 | + } |
|
489 | + |
|
490 | + |
|
491 | + /** |
|
492 | + * column_TXN_paid |
|
493 | + * |
|
494 | + * @param EE_Registration $item |
|
495 | + * @return string |
|
496 | + * @throws EE_Error |
|
497 | + */ |
|
498 | + public function column_TXN_paid(EE_Registration $item) |
|
499 | + { |
|
500 | + if ($item->count() === 1) { |
|
501 | + if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
502 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
503 | + } else { |
|
504 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
505 | + array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
506 | + TXN_ADMIN_URL |
|
507 | + ); |
|
508 | + return EE_Registry::instance()->CAP->current_user_can( |
|
509 | + 'ee_read_transaction', |
|
510 | + 'espresso_transactions_view_transaction' |
|
511 | + ) ? ' |
|
512 | 512 | <span class="reg-pad-rght"> |
513 | 513 | <a class="status-' |
514 | - . $item->transaction()->status_ID() |
|
515 | - . '" href="' |
|
516 | - . $view_txn_lnk_url |
|
517 | - . '" title="' |
|
518 | - . esc_attr__('View Transaction', 'event_espresso') |
|
519 | - . '"> |
|
514 | + . $item->transaction()->status_ID() |
|
515 | + . '" href="' |
|
516 | + . $view_txn_lnk_url |
|
517 | + . '" title="' |
|
518 | + . esc_attr__('View Transaction', 'event_espresso') |
|
519 | + . '"> |
|
520 | 520 | ' |
521 | - . $item->transaction()->pretty_paid() |
|
522 | - . ' |
|
521 | + . $item->transaction()->pretty_paid() |
|
522 | + . ' |
|
523 | 523 | </a> |
524 | 524 | <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
525 | - } |
|
526 | - } else { |
|
527 | - return '<span class="reg-pad-rght"></span>'; |
|
528 | - } |
|
529 | - } |
|
530 | - |
|
531 | - |
|
532 | - /** |
|
533 | - * column_TXN_total |
|
534 | - * |
|
535 | - * @param EE_Registration $item |
|
536 | - * @return string |
|
537 | - * @throws EE_Error |
|
538 | - */ |
|
539 | - public function column_TXN_total(EE_Registration $item) |
|
540 | - { |
|
541 | - $txn = $item->transaction(); |
|
542 | - $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
543 | - if ($item->get('REG_count') === 1) { |
|
544 | - $line_total_obj = $txn->total_line_item(); |
|
545 | - $txn_total = $line_total_obj instanceof EE_Line_Item |
|
546 | - ? $line_total_obj->get_pretty('LIN_total') |
|
547 | - : esc_html__( |
|
548 | - 'View Transaction', |
|
549 | - 'event_espresso' |
|
550 | - ); |
|
551 | - return EE_Registry::instance()->CAP->current_user_can( |
|
552 | - 'ee_read_transaction', |
|
553 | - 'espresso_transactions_view_transaction' |
|
554 | - ) ? '<a href="' |
|
555 | - . $view_txn_url |
|
556 | - . '" title="' |
|
557 | - . esc_attr__('View Transaction', 'event_espresso') |
|
558 | - . '"><span class="reg-pad-rght">' |
|
559 | - . $txn_total |
|
560 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
561 | - } else { |
|
562 | - return '<span class="reg-pad-rght"></span>'; |
|
563 | - } |
|
564 | - } |
|
525 | + } |
|
526 | + } else { |
|
527 | + return '<span class="reg-pad-rght"></span>'; |
|
528 | + } |
|
529 | + } |
|
530 | + |
|
531 | + |
|
532 | + /** |
|
533 | + * column_TXN_total |
|
534 | + * |
|
535 | + * @param EE_Registration $item |
|
536 | + * @return string |
|
537 | + * @throws EE_Error |
|
538 | + */ |
|
539 | + public function column_TXN_total(EE_Registration $item) |
|
540 | + { |
|
541 | + $txn = $item->transaction(); |
|
542 | + $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
543 | + if ($item->get('REG_count') === 1) { |
|
544 | + $line_total_obj = $txn->total_line_item(); |
|
545 | + $txn_total = $line_total_obj instanceof EE_Line_Item |
|
546 | + ? $line_total_obj->get_pretty('LIN_total') |
|
547 | + : esc_html__( |
|
548 | + 'View Transaction', |
|
549 | + 'event_espresso' |
|
550 | + ); |
|
551 | + return EE_Registry::instance()->CAP->current_user_can( |
|
552 | + 'ee_read_transaction', |
|
553 | + 'espresso_transactions_view_transaction' |
|
554 | + ) ? '<a href="' |
|
555 | + . $view_txn_url |
|
556 | + . '" title="' |
|
557 | + . esc_attr__('View Transaction', 'event_espresso') |
|
558 | + . '"><span class="reg-pad-rght">' |
|
559 | + . $txn_total |
|
560 | + . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
561 | + } else { |
|
562 | + return '<span class="reg-pad-rght"></span>'; |
|
563 | + } |
|
564 | + } |
|
565 | 565 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | 'TXN_total' => esc_html__('Total', 'event_espresso'), |
86 | 86 | ); |
87 | 87 | // Add/remove columns when an event has been selected |
88 | - if (! empty($evt_id)) { |
|
88 | + if ( ! empty($evt_id)) { |
|
89 | 89 | // Render a checkbox column |
90 | 90 | $columns['cb'] = '<input type="checkbox" />'; |
91 | 91 | $this->_has_checkbox_column = true; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | { |
149 | 149 | $class = parent::_get_row_class($item); |
150 | 150 | // add status class |
151 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
151 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
152 | 152 | if ($this->_has_checkbox_column) { |
153 | 153 | $class .= ' has-checkbox-column'; |
154 | 154 | } |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
169 | 169 | // this means we don't have an event so let's setup a filter dropdown for all the events to select |
170 | 170 | // note possible capability restrictions |
171 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
171 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
172 | 172 | $where['status**'] = array('!=', 'private'); |
173 | 173 | } |
174 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
174 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
175 | 175 | $where['EVT_wp_user'] = get_current_user_id(); |
176 | 176 | } |
177 | 177 | $events = EEM_Event::instance()->get_all( |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | /** @var EE_Event $evt */ |
189 | 189 | foreach ($events as $evt) { |
190 | 190 | // any registrations for this event? |
191 | - if (! $evt->get_count_of_all_registrations()) { |
|
191 | + if ( ! $evt->get_count_of_all_registrations()) { |
|
192 | 192 | continue; |
193 | 193 | } |
194 | 194 | $evts[] = array( |
@@ -207,22 +207,22 @@ discard block |
||
207 | 207 | $event_filter = '<div class="ee-event-filter">'; |
208 | 208 | $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
209 | 209 | $event_filter .= '<span class="ee-event-filter-toggle">'; |
210 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
210 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> '; |
|
211 | 211 | $event_filter .= esc_html__('Hide Expired Events', 'event_espresso'); |
212 | 212 | $event_filter .= '</span>'; |
213 | 213 | $event_filter .= '</div>'; |
214 | 214 | $filters[] = $event_filter; |
215 | 215 | } |
216 | - if (! empty($this->_dtts_for_event)) { |
|
216 | + if ( ! empty($this->_dtts_for_event)) { |
|
217 | 217 | // DTT datetimes filter |
218 | 218 | $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
219 | 219 | if (count($this->_dtts_for_event) > 1) { |
220 | 220 | $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso'); |
221 | 221 | foreach ($this->_dtts_for_event as $dtt) { |
222 | 222 | $datetime_string = $dtt->name(); |
223 | - $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
224 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
225 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
223 | + $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : ''; |
|
224 | + $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string; |
|
225 | + $dtts[$dtt->ID()] = $datetime_string; |
|
226 | 226 | } |
227 | 227 | $input = new EE_Select_Input( |
228 | 228 | $dtts, |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | $filters[] = $input->get_html_for_input(); |
236 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
236 | + $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">'; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | return $filters; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function column__Reg_Status(EE_Registration $item) |
279 | 279 | { |
280 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
280 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>'; |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | ) |
327 | 327 | ? ' clickable trigger-checkin' |
328 | 328 | : ''; |
329 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
330 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
331 | - . ' data-_regid="' . $item->ID() . '"' |
|
332 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
333 | - . ' data-nonce="' . $nonce . '">' |
|
329 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
330 | + return '<span class="'.$checkin_status_dashicon->cssClasses().$toggle_active.'"' |
|
331 | + . ' data-_regid="'.$item->ID().'"' |
|
332 | + . ' data-dttid="'.$this->_cur_dtt_id.'"' |
|
333 | + . ' data-nonce="'.$nonce.'">' |
|
334 | 334 | . '</span>' |
335 | 335 | . $mobile_view_content; |
336 | 336 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | public function column_ATT_name(EE_Registration $item) |
345 | 345 | { |
346 | 346 | $attendee = $item->attendee(); |
347 | - if (! $attendee instanceof EE_Attendee) { |
|
347 | + if ( ! $attendee instanceof EE_Attendee) { |
|
348 | 348 | return esc_html__('No contact record for this registration.', 'event_espresso'); |
349 | 349 | } |
350 | 350 | // edit attendee link |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | 'ee_edit_contacts', |
357 | 357 | 'espresso_registrations_edit_attendee' |
358 | 358 | ) |
359 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
359 | + ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
360 | 360 | . $item->attendee()->full_name() |
361 | 361 | . '</a>' |
362 | 362 | : $item->attendee()->full_name(); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
365 | 365 | : ''; |
366 | 366 | // add group details |
367 | - $name_link .= ' ' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
367 | + $name_link .= ' '.sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
368 | 368 | // add regcode |
369 | 369 | $link = EE_Admin_Page::add_query_args_and_nonce( |
370 | 370 | array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | 'view_registration', |
377 | 377 | $item->ID() |
378 | 378 | ) |
379 | - ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
379 | + ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
380 | 380 | . $item->reg_code() |
381 | 381 | . '</a>' |
382 | 382 | : $item->reg_code(); |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | ); |
406 | 406 | // get the timestamps for this registration's checkins, related to the selected datetime |
407 | 407 | $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
408 | - if (! empty($timestamps)) { |
|
408 | + if ( ! empty($timestamps)) { |
|
409 | 409 | // get the last timestamp |
410 | 410 | $last_timestamp = end($timestamps); |
411 | 411 | // checked in or checked out? |
@@ -414,14 +414,14 @@ discard block |
||
414 | 414 | : esc_html__('Checked Out', 'event_espresso'); |
415 | 415 | // get timestamp string |
416 | 416 | $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
417 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' |
|
417 | + $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="' |
|
418 | 418 | . esc_attr__( |
419 | 419 | 'View this registrant\'s check-ins/checkouts for the datetime', |
420 | 420 | 'event_espresso' |
421 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
421 | + ).'">'.$checkin_status.': '.$timestamp_string.'</a>'; |
|
422 | 422 | } |
423 | 423 | } |
424 | - return (! empty($DTT_ID) && ! empty($timestamps)) |
|
424 | + return ( ! empty($DTT_ID) && ! empty($timestamps)) |
|
425 | 425 | ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
426 | 426 | : $name_link; |
427 | 427 | } |
@@ -454,11 +454,11 @@ discard block |
||
454 | 454 | $event_label = EE_Registry::instance()->CAP->current_user_can( |
455 | 455 | 'ee_read_checkins', |
456 | 456 | 'espresso_registrations_registration_checkins' |
457 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' |
|
457 | + ) ? '<a href="'.$chkin_lnk_url.'" title="' |
|
458 | 458 | . esc_attr__( |
459 | 459 | 'View Checkins for this Event', |
460 | 460 | 'event_espresso' |
461 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
461 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
462 | 462 | } catch (EntityNotFoundException $e) { |
463 | 463 | $event_label = esc_html__('Unknown', 'event_espresso'); |
464 | 464 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | */ |
485 | 485 | public function column__REG_final_price(EE_Registration $item) |
486 | 486 | { |
487 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
487 | + return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>'; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | . $item->transaction()->pretty_paid() |
522 | 522 | . ' |
523 | 523 | </a> |
524 | - <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
524 | + <span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
525 | 525 | } |
526 | 526 | } else { |
527 | 527 | return '<span class="reg-pad-rght"></span>'; |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | . esc_attr__('View Transaction', 'event_espresso') |
558 | 558 | . '"><span class="reg-pad-rght">' |
559 | 559 | . $txn_total |
560 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
560 | + . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>'; |
|
561 | 561 | } else { |
562 | 562 | return '<span class="reg-pad-rght"></span>'; |
563 | 563 | } |