@@ -31,541 +31,541 @@ |
||
31 | 31 | */ |
32 | 32 | class RegistrationsReport extends JobHandlerFile |
33 | 33 | { |
34 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
35 | - // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
36 | - /** |
|
37 | - * Performs any necessary setup for starting the job. This is also a good |
|
38 | - * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
39 | - * when continue_job will be called |
|
40 | - * |
|
41 | - * @param JobParameters $job_parameters |
|
42 | - * @throws BatchRequestException |
|
43 | - * @return JobStepResponse |
|
44 | - */ |
|
45 | - public function create_job(JobParameters $job_parameters) |
|
46 | - { |
|
47 | - $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
48 | - if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
49 | - throw new BatchRequestException(esc_html__('You do not have permission to view registrations', 'event_espresso')); |
|
50 | - } |
|
51 | - $filepath = $this->create_file_from_job_with_name( |
|
52 | - $job_parameters->job_id(), |
|
53 | - $this->get_filename($event_id) |
|
54 | - ); |
|
55 | - $job_parameters->add_extra_data('filepath', $filepath); |
|
56 | - if ($job_parameters->request_datum('use_filters', false)) { |
|
57 | - $query_params = maybe_unserialize($job_parameters->request_datum('filters', array())); |
|
58 | - } else { |
|
59 | - $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
60 | - array( |
|
61 | - 'OR' => array( |
|
62 | - // don't include registrations from failed or abandoned transactions... |
|
63 | - 'Transaction.STS_ID' => array( |
|
64 | - 'NOT IN', |
|
65 | - array( |
|
66 | - EEM_Transaction::failed_status_code, |
|
67 | - EEM_Transaction::abandoned_status_code, |
|
68 | - ), |
|
69 | - ), |
|
70 | - // unless the registration is approved, in which case include it regardless of transaction status |
|
71 | - 'STS_ID' => \EEM_Registration::status_id_approved, |
|
72 | - ), |
|
73 | - 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
74 | - ), |
|
75 | - 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
76 | - 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
77 | - 'caps' => \EEM_Base::caps_read_admin, |
|
78 | - ), $event_id); |
|
79 | - if ($event_id) { |
|
80 | - $query_params[0]['EVT_ID'] = $event_id; |
|
81 | - } else { |
|
82 | - $query_params['force_join'][] = 'Event'; |
|
83 | - } |
|
84 | - } |
|
85 | - if (! isset($query_params['force_join'])) { |
|
86 | - $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
|
87 | - } |
|
88 | - $job_parameters->add_extra_data('query_params', $query_params); |
|
89 | - $question_labels = $this->_get_question_labels($query_params); |
|
90 | - $job_parameters->add_extra_data('question_labels', $question_labels); |
|
91 | - $job_parameters->set_job_size( |
|
92 | - \EEM_Registration::instance()->count( |
|
93 | - array_diff_key( |
|
94 | - $query_params, |
|
95 | - array_flip( |
|
96 | - array('limit') |
|
97 | - ) |
|
98 | - ) |
|
99 | - ) |
|
100 | - ); |
|
101 | - // we should also set the header columns |
|
102 | - $csv_data_for_row = $this->get_csv_data_for( |
|
103 | - $event_id, |
|
104 | - 0, |
|
105 | - 1, |
|
106 | - $job_parameters->extra_datum('question_labels'), |
|
107 | - $job_parameters->extra_datum('query_params') |
|
108 | - ); |
|
109 | - EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
110 | - // if we actually processed a row there, record it |
|
111 | - if ($job_parameters->job_size()) { |
|
112 | - $job_parameters->mark_processed(1); |
|
113 | - } |
|
114 | - return new JobStepResponse( |
|
115 | - $job_parameters, |
|
116 | - esc_html__('Registrations report started successfully...', 'event_espresso') |
|
117 | - ); |
|
118 | - } |
|
34 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
35 | + // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
36 | + /** |
|
37 | + * Performs any necessary setup for starting the job. This is also a good |
|
38 | + * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
39 | + * when continue_job will be called |
|
40 | + * |
|
41 | + * @param JobParameters $job_parameters |
|
42 | + * @throws BatchRequestException |
|
43 | + * @return JobStepResponse |
|
44 | + */ |
|
45 | + public function create_job(JobParameters $job_parameters) |
|
46 | + { |
|
47 | + $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
48 | + if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
49 | + throw new BatchRequestException(esc_html__('You do not have permission to view registrations', 'event_espresso')); |
|
50 | + } |
|
51 | + $filepath = $this->create_file_from_job_with_name( |
|
52 | + $job_parameters->job_id(), |
|
53 | + $this->get_filename($event_id) |
|
54 | + ); |
|
55 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
56 | + if ($job_parameters->request_datum('use_filters', false)) { |
|
57 | + $query_params = maybe_unserialize($job_parameters->request_datum('filters', array())); |
|
58 | + } else { |
|
59 | + $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
60 | + array( |
|
61 | + 'OR' => array( |
|
62 | + // don't include registrations from failed or abandoned transactions... |
|
63 | + 'Transaction.STS_ID' => array( |
|
64 | + 'NOT IN', |
|
65 | + array( |
|
66 | + EEM_Transaction::failed_status_code, |
|
67 | + EEM_Transaction::abandoned_status_code, |
|
68 | + ), |
|
69 | + ), |
|
70 | + // unless the registration is approved, in which case include it regardless of transaction status |
|
71 | + 'STS_ID' => \EEM_Registration::status_id_approved, |
|
72 | + ), |
|
73 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
74 | + ), |
|
75 | + 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
76 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
77 | + 'caps' => \EEM_Base::caps_read_admin, |
|
78 | + ), $event_id); |
|
79 | + if ($event_id) { |
|
80 | + $query_params[0]['EVT_ID'] = $event_id; |
|
81 | + } else { |
|
82 | + $query_params['force_join'][] = 'Event'; |
|
83 | + } |
|
84 | + } |
|
85 | + if (! isset($query_params['force_join'])) { |
|
86 | + $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee'); |
|
87 | + } |
|
88 | + $job_parameters->add_extra_data('query_params', $query_params); |
|
89 | + $question_labels = $this->_get_question_labels($query_params); |
|
90 | + $job_parameters->add_extra_data('question_labels', $question_labels); |
|
91 | + $job_parameters->set_job_size( |
|
92 | + \EEM_Registration::instance()->count( |
|
93 | + array_diff_key( |
|
94 | + $query_params, |
|
95 | + array_flip( |
|
96 | + array('limit') |
|
97 | + ) |
|
98 | + ) |
|
99 | + ) |
|
100 | + ); |
|
101 | + // we should also set the header columns |
|
102 | + $csv_data_for_row = $this->get_csv_data_for( |
|
103 | + $event_id, |
|
104 | + 0, |
|
105 | + 1, |
|
106 | + $job_parameters->extra_datum('question_labels'), |
|
107 | + $job_parameters->extra_datum('query_params') |
|
108 | + ); |
|
109 | + EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
110 | + // if we actually processed a row there, record it |
|
111 | + if ($job_parameters->job_size()) { |
|
112 | + $job_parameters->mark_processed(1); |
|
113 | + } |
|
114 | + return new JobStepResponse( |
|
115 | + $job_parameters, |
|
116 | + esc_html__('Registrations report started successfully...', 'event_espresso') |
|
117 | + ); |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * Gets the filename |
|
123 | - * |
|
124 | - * @return string |
|
125 | - */ |
|
126 | - protected function get_filename() |
|
127 | - { |
|
128 | - return apply_filters( |
|
129 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename', |
|
130 | - sprintf( |
|
131 | - "event-espresso-registrations-%s.csv", |
|
132 | - str_replace(array(':', ' '), '-', current_time('mysql')) |
|
133 | - ) |
|
134 | - ); |
|
135 | - } |
|
121 | + /** |
|
122 | + * Gets the filename |
|
123 | + * |
|
124 | + * @return string |
|
125 | + */ |
|
126 | + protected function get_filename() |
|
127 | + { |
|
128 | + return apply_filters( |
|
129 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename', |
|
130 | + sprintf( |
|
131 | + "event-espresso-registrations-%s.csv", |
|
132 | + str_replace(array(':', ' '), '-', current_time('mysql')) |
|
133 | + ) |
|
134 | + ); |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | - /** |
|
139 | - * Gets the questions which are to be used for this report, so they |
|
140 | - * can be remembered for later |
|
141 | - * |
|
142 | - * @param array $registration_query_params |
|
143 | - * @return array question admin labels to be used for this report |
|
144 | - */ |
|
145 | - protected function _get_question_labels($registration_query_params) |
|
146 | - { |
|
147 | - $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null; |
|
148 | - $question_query_params = array(); |
|
149 | - if ($where !== null) { |
|
150 | - $question_query_params = array( |
|
151 | - $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
|
152 | - ); |
|
153 | - } |
|
154 | - // Make sure it's not a system question |
|
155 | - $question_query_params[0]['OR*not-system-questions'] = [ |
|
156 | - 'QST_system' => '', |
|
157 | - 'QST_system*null' => ['IS_NULL'] |
|
158 | - ]; |
|
159 | - if ( |
|
160 | - apply_filters( |
|
161 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', |
|
162 | - false, |
|
163 | - $registration_query_params |
|
164 | - ) |
|
165 | - ) { |
|
166 | - $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL'); |
|
167 | - } |
|
168 | - $question_query_params['group_by'] = array('QST_ID'); |
|
169 | - return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label')); |
|
170 | - } |
|
138 | + /** |
|
139 | + * Gets the questions which are to be used for this report, so they |
|
140 | + * can be remembered for later |
|
141 | + * |
|
142 | + * @param array $registration_query_params |
|
143 | + * @return array question admin labels to be used for this report |
|
144 | + */ |
|
145 | + protected function _get_question_labels($registration_query_params) |
|
146 | + { |
|
147 | + $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null; |
|
148 | + $question_query_params = array(); |
|
149 | + if ($where !== null) { |
|
150 | + $question_query_params = array( |
|
151 | + $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]), |
|
152 | + ); |
|
153 | + } |
|
154 | + // Make sure it's not a system question |
|
155 | + $question_query_params[0]['OR*not-system-questions'] = [ |
|
156 | + 'QST_system' => '', |
|
157 | + 'QST_system*null' => ['IS_NULL'] |
|
158 | + ]; |
|
159 | + if ( |
|
160 | + apply_filters( |
|
161 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions', |
|
162 | + false, |
|
163 | + $registration_query_params |
|
164 | + ) |
|
165 | + ) { |
|
166 | + $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL'); |
|
167 | + } |
|
168 | + $question_query_params['group_by'] = array('QST_ID'); |
|
169 | + return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label')); |
|
170 | + } |
|
171 | 171 | |
172 | 172 | |
173 | - /** |
|
174 | - * Takes where params meant for registrations and changes them to work for questions |
|
175 | - * |
|
176 | - * @param array $reg_where_params |
|
177 | - * @return array |
|
178 | - */ |
|
179 | - protected function _change_registration_where_params_to_question_where_params($reg_where_params) |
|
180 | - { |
|
181 | - $question_where_params = array(); |
|
182 | - foreach ($reg_where_params as $key => $val) { |
|
183 | - if (\EEM_Registration::instance()->is_logic_query_param_key($key)) { |
|
184 | - $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val); |
|
185 | - } else { |
|
186 | - // it's a normal where condition |
|
187 | - $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val; |
|
188 | - } |
|
189 | - } |
|
190 | - return $question_where_params; |
|
191 | - } |
|
173 | + /** |
|
174 | + * Takes where params meant for registrations and changes them to work for questions |
|
175 | + * |
|
176 | + * @param array $reg_where_params |
|
177 | + * @return array |
|
178 | + */ |
|
179 | + protected function _change_registration_where_params_to_question_where_params($reg_where_params) |
|
180 | + { |
|
181 | + $question_where_params = array(); |
|
182 | + foreach ($reg_where_params as $key => $val) { |
|
183 | + if (\EEM_Registration::instance()->is_logic_query_param_key($key)) { |
|
184 | + $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val); |
|
185 | + } else { |
|
186 | + // it's a normal where condition |
|
187 | + $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val; |
|
188 | + } |
|
189 | + } |
|
190 | + return $question_where_params; |
|
191 | + } |
|
192 | 192 | |
193 | 193 | |
194 | - /** |
|
195 | - * Performs another step of the job |
|
196 | - * |
|
197 | - * @param JobParameters $job_parameters |
|
198 | - * @param int $batch_size |
|
199 | - * @return JobStepResponse |
|
200 | - * @throws \EE_Error |
|
201 | - */ |
|
202 | - public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
203 | - { |
|
204 | - if ($job_parameters->units_processed() < $job_parameters->job_size()) { |
|
205 | - $csv_data = $this->get_csv_data_for( |
|
206 | - $job_parameters->request_datum('EVT_ID', '0'), |
|
207 | - $job_parameters->units_processed(), |
|
208 | - $batch_size, |
|
209 | - $job_parameters->extra_datum('question_labels'), |
|
210 | - $job_parameters->extra_datum('query_params') |
|
211 | - ); |
|
212 | - EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
213 | - $units_processed = count($csv_data); |
|
214 | - } else { |
|
215 | - $csv_data = array(); |
|
216 | - $units_processed = 0; |
|
217 | - } |
|
218 | - $job_parameters->mark_processed($units_processed); |
|
219 | - $extra_response_data = array( |
|
220 | - 'file_url' => '', |
|
221 | - ); |
|
222 | - if ($units_processed < $batch_size) { |
|
223 | - $job_parameters->set_status(JobParameters::status_complete); |
|
224 | - $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
225 | - } |
|
194 | + /** |
|
195 | + * Performs another step of the job |
|
196 | + * |
|
197 | + * @param JobParameters $job_parameters |
|
198 | + * @param int $batch_size |
|
199 | + * @return JobStepResponse |
|
200 | + * @throws \EE_Error |
|
201 | + */ |
|
202 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
203 | + { |
|
204 | + if ($job_parameters->units_processed() < $job_parameters->job_size()) { |
|
205 | + $csv_data = $this->get_csv_data_for( |
|
206 | + $job_parameters->request_datum('EVT_ID', '0'), |
|
207 | + $job_parameters->units_processed(), |
|
208 | + $batch_size, |
|
209 | + $job_parameters->extra_datum('question_labels'), |
|
210 | + $job_parameters->extra_datum('query_params') |
|
211 | + ); |
|
212 | + EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
213 | + $units_processed = count($csv_data); |
|
214 | + } else { |
|
215 | + $csv_data = array(); |
|
216 | + $units_processed = 0; |
|
217 | + } |
|
218 | + $job_parameters->mark_processed($units_processed); |
|
219 | + $extra_response_data = array( |
|
220 | + 'file_url' => '', |
|
221 | + ); |
|
222 | + if ($units_processed < $batch_size) { |
|
223 | + $job_parameters->set_status(JobParameters::status_complete); |
|
224 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
225 | + } |
|
226 | 226 | |
227 | - return new JobStepResponse( |
|
228 | - $job_parameters, |
|
229 | - sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)), |
|
230 | - $extra_response_data |
|
231 | - ); |
|
232 | - } |
|
227 | + return new JobStepResponse( |
|
228 | + $job_parameters, |
|
229 | + sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)), |
|
230 | + $extra_response_data |
|
231 | + ); |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | - /** |
|
236 | - * Gets the csv data for a batch of registrations |
|
237 | - * |
|
238 | - * @param int|null $event_id |
|
239 | - * @param int $offset |
|
240 | - * @param int $limit |
|
241 | - * @param array $question_labels the IDs for all the questions which were answered by someone in this selection |
|
242 | - * @param array $query_params for using where querying the model |
|
243 | - * @return array top-level keys are numeric, next-level keys are column headers |
|
244 | - * @throws \EE_Error |
|
245 | - */ |
|
246 | - public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params) |
|
247 | - { |
|
248 | - $reg_fields_to_include = array( |
|
249 | - 'TXN_ID', |
|
250 | - 'ATT_ID', |
|
251 | - 'REG_ID', |
|
252 | - 'REG_date', |
|
253 | - 'REG_code', |
|
254 | - 'REG_count', |
|
255 | - 'REG_final_price', |
|
256 | - ); |
|
257 | - $att_fields_to_include = array( |
|
258 | - 'ATT_fname', |
|
259 | - 'ATT_lname', |
|
260 | - 'ATT_email', |
|
261 | - 'ATT_address', |
|
262 | - 'ATT_address2', |
|
263 | - 'ATT_city', |
|
264 | - 'STA_ID', |
|
265 | - 'CNT_ISO', |
|
266 | - 'ATT_zip', |
|
267 | - 'ATT_phone', |
|
268 | - ); |
|
269 | - $registrations_csv_ready_array = array(); |
|
270 | - $reg_model = EE_Registry::instance()->load_model('Registration'); |
|
271 | - $query_params['limit'] = array($offset, $limit); |
|
272 | - $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
273 | - $registration_ids = array(); |
|
274 | - foreach ($registration_rows as $reg_row) { |
|
275 | - $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
276 | - } |
|
277 | - foreach ($registration_rows as $reg_row) { |
|
278 | - if (is_array($reg_row)) { |
|
279 | - $reg_csv_array = array(); |
|
280 | - if (! $event_id) { |
|
281 | - // get the event's name and Id |
|
282 | - $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf( |
|
283 | - /* translators: 1: event name, 2: event ID */ |
|
284 | - esc_html__('%1$s (%2$s)', 'event_espresso'), |
|
285 | - EEH_Export::prepare_value_from_db_for_display( |
|
286 | - EEM_Event::instance(), |
|
287 | - 'EVT_name', |
|
288 | - $reg_row['Event_CPT.post_title'] |
|
289 | - ), |
|
290 | - $reg_row['Event_CPT.ID'] |
|
291 | - ); |
|
292 | - } |
|
293 | - $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
294 | - /*@var $reg_row EE_Registration */ |
|
295 | - foreach ($reg_fields_to_include as $field_name) { |
|
296 | - $field = $reg_model->field_settings_for($field_name); |
|
297 | - if ($field_name == 'REG_final_price') { |
|
298 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
299 | - $reg_model, |
|
300 | - $field_name, |
|
301 | - $reg_row['Registration.REG_final_price'], |
|
302 | - 'localized_float' |
|
303 | - ); |
|
304 | - } elseif ($field_name == 'REG_count') { |
|
305 | - $value = sprintf( |
|
306 | - /* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */ |
|
307 | - esc_html__('%1$s of %2$s', 'event_espresso'), |
|
308 | - EEH_Export::prepare_value_from_db_for_display( |
|
309 | - $reg_model, |
|
310 | - 'REG_count', |
|
311 | - $reg_row['Registration.REG_count'] |
|
312 | - ), |
|
313 | - EEH_Export::prepare_value_from_db_for_display( |
|
314 | - $reg_model, |
|
315 | - 'REG_group_size', |
|
316 | - $reg_row['Registration.REG_group_size'] |
|
317 | - ) |
|
318 | - ); |
|
319 | - } elseif ($field_name == 'REG_date') { |
|
320 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
321 | - $reg_model, |
|
322 | - $field_name, |
|
323 | - $reg_row['Registration.REG_date'], |
|
324 | - 'no_html' |
|
325 | - ); |
|
326 | - } else { |
|
327 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
328 | - $reg_model, |
|
329 | - $field_name, |
|
330 | - $reg_row[ $field->get_qualified_column() ] |
|
331 | - ); |
|
332 | - } |
|
333 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value; |
|
334 | - if ($field_name == 'REG_final_price') { |
|
335 | - // add a column named Currency after the final price |
|
336 | - $reg_csv_array[ (string) esc_html__("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code; |
|
337 | - } |
|
338 | - } |
|
339 | - // get pretty status |
|
340 | - $stati = EEM_Status::instance()->localized_status( |
|
341 | - array( |
|
342 | - $reg_row['Registration.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
343 | - $reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
344 | - ), |
|
345 | - false, |
|
346 | - 'sentence' |
|
347 | - ); |
|
348 | - $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ]; |
|
349 | - // get pretty transaction status |
|
350 | - $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ]; |
|
351 | - $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg |
|
352 | - ? EEH_Export::prepare_value_from_db_for_display( |
|
353 | - EEM_Transaction::instance(), |
|
354 | - 'TXN_total', |
|
355 | - $reg_row['TransactionTable.TXN_total'], |
|
356 | - 'localized_float' |
|
357 | - ) : '0.00'; |
|
358 | - $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg |
|
359 | - ? EEH_Export::prepare_value_from_db_for_display( |
|
360 | - EEM_Transaction::instance(), |
|
361 | - 'TXN_paid', |
|
362 | - $reg_row['TransactionTable.TXN_paid'], |
|
363 | - 'localized_float' |
|
364 | - ) : '0.00'; |
|
365 | - $payment_methods = array(); |
|
366 | - $gateway_txn_ids_etc = array(); |
|
367 | - $payment_times = array(); |
|
368 | - if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
369 | - $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
|
370 | - array( |
|
371 | - array( |
|
372 | - 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
373 | - 'STS_ID' => EEM_Payment::status_id_approved, |
|
374 | - ), |
|
375 | - 'force_join' => array('Payment_Method'), |
|
376 | - ), |
|
377 | - ARRAY_A, |
|
378 | - 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' |
|
379 | - ); |
|
380 | - foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
381 | - $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
382 | - ? $payment_method_and_gateway_txn_id['name'] : esc_html__('Unknown', 'event_espresso'); |
|
383 | - $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
384 | - ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
385 | - $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
386 | - ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
387 | - } |
|
388 | - } |
|
389 | - $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times); |
|
390 | - $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods); |
|
391 | - $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode( |
|
392 | - ',', |
|
393 | - $gateway_txn_ids_etc |
|
394 | - ); |
|
395 | - // get whether or not the user has checked in |
|
396 | - $reg_csv_array[ (string) esc_html__("Check-Ins", "event_espresso") ] = $reg_model->count_related( |
|
397 | - $reg_row['Registration.REG_ID'], |
|
398 | - 'Checkin' |
|
399 | - ); |
|
400 | - // get ticket of registration and its price |
|
401 | - $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
|
402 | - if ($reg_row['Ticket.TKT_ID']) { |
|
403 | - $ticket_name = EEH_Export::prepare_value_from_db_for_display( |
|
404 | - $ticket_model, |
|
405 | - 'TKT_name', |
|
406 | - $reg_row['Ticket.TKT_name'] |
|
407 | - ); |
|
408 | - $datetimes_strings = array(); |
|
409 | - foreach ( |
|
410 | - EEM_Datetime::instance()->get_all_wpdb_results( |
|
411 | - array( |
|
412 | - array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), |
|
413 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
414 | - 'default_where_conditions' => 'none', |
|
415 | - ) |
|
416 | - ) as $datetime |
|
417 | - ) { |
|
418 | - $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display( |
|
419 | - EEM_Datetime::instance(), |
|
420 | - 'DTT_EVT_start', |
|
421 | - $datetime['Datetime.DTT_EVT_start'] |
|
422 | - ); |
|
423 | - } |
|
424 | - } else { |
|
425 | - $ticket_name = esc_html__('Unknown', 'event_espresso'); |
|
426 | - $datetimes_strings = array(esc_html__('Unknown', 'event_espresso')); |
|
427 | - } |
|
428 | - $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name; |
|
429 | - $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings); |
|
430 | - // get datetime(s) of registration |
|
431 | - // add attendee columns |
|
432 | - foreach ($att_fields_to_include as $att_field_name) { |
|
433 | - $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
434 | - if ($reg_row['Attendee_CPT.ID']) { |
|
435 | - if ($att_field_name == 'STA_ID') { |
|
436 | - $value = EEM_State::instance()->get_var( |
|
437 | - array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), |
|
438 | - 'STA_name' |
|
439 | - ); |
|
440 | - } elseif ($att_field_name == 'CNT_ISO') { |
|
441 | - $value = EEM_Country::instance()->get_var( |
|
442 | - array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), |
|
443 | - 'CNT_name' |
|
444 | - ); |
|
445 | - } else { |
|
446 | - $value = EEH_Export::prepare_value_from_db_for_display( |
|
447 | - EEM_Attendee::instance(), |
|
448 | - $att_field_name, |
|
449 | - $reg_row[ $field_obj->get_qualified_column() ] |
|
450 | - ); |
|
451 | - } |
|
452 | - } else { |
|
453 | - $value = ''; |
|
454 | - } |
|
455 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
456 | - } |
|
457 | - // make sure each registration has the same questions in the same order |
|
458 | - foreach ($question_labels as $question_label) { |
|
459 | - if (! isset($reg_csv_array[ $question_label ])) { |
|
460 | - $reg_csv_array[ $question_label ] = null; |
|
461 | - } |
|
462 | - } |
|
463 | - $answers = EEM_Answer::instance()->get_all_wpdb_results(array( |
|
464 | - array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
465 | - 'force_join' => array('Question'), |
|
466 | - )); |
|
467 | - // now fill out the questions THEY answered |
|
468 | - foreach ($answers as $answer_row) { |
|
469 | - if ($answer_row['Question.QST_system']) { |
|
470 | - // it's an answer to a system question. That was already displayed as part of the attendee |
|
471 | - // fields, so don't write it out again thanks. |
|
472 | - continue; |
|
473 | - } |
|
474 | - if ($answer_row['Question.QST_ID']) { |
|
475 | - $question_label = EEH_Export::prepare_value_from_db_for_display( |
|
476 | - EEM_Question::instance(), |
|
477 | - 'QST_admin_label', |
|
478 | - $answer_row['Question.QST_admin_label'] |
|
479 | - ); |
|
480 | - } else { |
|
481 | - $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
482 | - } |
|
483 | - if ( |
|
484 | - isset($answer_row['Question.QST_type']) |
|
485 | - && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
|
486 | - ) { |
|
487 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
488 | - $answer_row['Answer.ANS_value'] |
|
489 | - ); |
|
490 | - } else { |
|
491 | - // this isn't for html, so don't show html entities |
|
492 | - $reg_csv_array[ $question_label ] = html_entity_decode( |
|
493 | - EEH_Export::prepare_value_from_db_for_display( |
|
494 | - EEM_Answer::instance(), |
|
495 | - 'ANS_value', |
|
496 | - $answer_row['Answer.ANS_value'] |
|
497 | - ) |
|
498 | - ); |
|
499 | - } |
|
500 | - } |
|
235 | + /** |
|
236 | + * Gets the csv data for a batch of registrations |
|
237 | + * |
|
238 | + * @param int|null $event_id |
|
239 | + * @param int $offset |
|
240 | + * @param int $limit |
|
241 | + * @param array $question_labels the IDs for all the questions which were answered by someone in this selection |
|
242 | + * @param array $query_params for using where querying the model |
|
243 | + * @return array top-level keys are numeric, next-level keys are column headers |
|
244 | + * @throws \EE_Error |
|
245 | + */ |
|
246 | + public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params) |
|
247 | + { |
|
248 | + $reg_fields_to_include = array( |
|
249 | + 'TXN_ID', |
|
250 | + 'ATT_ID', |
|
251 | + 'REG_ID', |
|
252 | + 'REG_date', |
|
253 | + 'REG_code', |
|
254 | + 'REG_count', |
|
255 | + 'REG_final_price', |
|
256 | + ); |
|
257 | + $att_fields_to_include = array( |
|
258 | + 'ATT_fname', |
|
259 | + 'ATT_lname', |
|
260 | + 'ATT_email', |
|
261 | + 'ATT_address', |
|
262 | + 'ATT_address2', |
|
263 | + 'ATT_city', |
|
264 | + 'STA_ID', |
|
265 | + 'CNT_ISO', |
|
266 | + 'ATT_zip', |
|
267 | + 'ATT_phone', |
|
268 | + ); |
|
269 | + $registrations_csv_ready_array = array(); |
|
270 | + $reg_model = EE_Registry::instance()->load_model('Registration'); |
|
271 | + $query_params['limit'] = array($offset, $limit); |
|
272 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
273 | + $registration_ids = array(); |
|
274 | + foreach ($registration_rows as $reg_row) { |
|
275 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
276 | + } |
|
277 | + foreach ($registration_rows as $reg_row) { |
|
278 | + if (is_array($reg_row)) { |
|
279 | + $reg_csv_array = array(); |
|
280 | + if (! $event_id) { |
|
281 | + // get the event's name and Id |
|
282 | + $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf( |
|
283 | + /* translators: 1: event name, 2: event ID */ |
|
284 | + esc_html__('%1$s (%2$s)', 'event_espresso'), |
|
285 | + EEH_Export::prepare_value_from_db_for_display( |
|
286 | + EEM_Event::instance(), |
|
287 | + 'EVT_name', |
|
288 | + $reg_row['Event_CPT.post_title'] |
|
289 | + ), |
|
290 | + $reg_row['Event_CPT.ID'] |
|
291 | + ); |
|
292 | + } |
|
293 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
294 | + /*@var $reg_row EE_Registration */ |
|
295 | + foreach ($reg_fields_to_include as $field_name) { |
|
296 | + $field = $reg_model->field_settings_for($field_name); |
|
297 | + if ($field_name == 'REG_final_price') { |
|
298 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
299 | + $reg_model, |
|
300 | + $field_name, |
|
301 | + $reg_row['Registration.REG_final_price'], |
|
302 | + 'localized_float' |
|
303 | + ); |
|
304 | + } elseif ($field_name == 'REG_count') { |
|
305 | + $value = sprintf( |
|
306 | + /* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */ |
|
307 | + esc_html__('%1$s of %2$s', 'event_espresso'), |
|
308 | + EEH_Export::prepare_value_from_db_for_display( |
|
309 | + $reg_model, |
|
310 | + 'REG_count', |
|
311 | + $reg_row['Registration.REG_count'] |
|
312 | + ), |
|
313 | + EEH_Export::prepare_value_from_db_for_display( |
|
314 | + $reg_model, |
|
315 | + 'REG_group_size', |
|
316 | + $reg_row['Registration.REG_group_size'] |
|
317 | + ) |
|
318 | + ); |
|
319 | + } elseif ($field_name == 'REG_date') { |
|
320 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
321 | + $reg_model, |
|
322 | + $field_name, |
|
323 | + $reg_row['Registration.REG_date'], |
|
324 | + 'no_html' |
|
325 | + ); |
|
326 | + } else { |
|
327 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
328 | + $reg_model, |
|
329 | + $field_name, |
|
330 | + $reg_row[ $field->get_qualified_column() ] |
|
331 | + ); |
|
332 | + } |
|
333 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value; |
|
334 | + if ($field_name == 'REG_final_price') { |
|
335 | + // add a column named Currency after the final price |
|
336 | + $reg_csv_array[ (string) esc_html__("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code; |
|
337 | + } |
|
338 | + } |
|
339 | + // get pretty status |
|
340 | + $stati = EEM_Status::instance()->localized_status( |
|
341 | + array( |
|
342 | + $reg_row['Registration.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
343 | + $reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'), |
|
344 | + ), |
|
345 | + false, |
|
346 | + 'sentence' |
|
347 | + ); |
|
348 | + $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ]; |
|
349 | + // get pretty transaction status |
|
350 | + $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ]; |
|
351 | + $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg |
|
352 | + ? EEH_Export::prepare_value_from_db_for_display( |
|
353 | + EEM_Transaction::instance(), |
|
354 | + 'TXN_total', |
|
355 | + $reg_row['TransactionTable.TXN_total'], |
|
356 | + 'localized_float' |
|
357 | + ) : '0.00'; |
|
358 | + $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg |
|
359 | + ? EEH_Export::prepare_value_from_db_for_display( |
|
360 | + EEM_Transaction::instance(), |
|
361 | + 'TXN_paid', |
|
362 | + $reg_row['TransactionTable.TXN_paid'], |
|
363 | + 'localized_float' |
|
364 | + ) : '0.00'; |
|
365 | + $payment_methods = array(); |
|
366 | + $gateway_txn_ids_etc = array(); |
|
367 | + $payment_times = array(); |
|
368 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
369 | + $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
|
370 | + array( |
|
371 | + array( |
|
372 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
373 | + 'STS_ID' => EEM_Payment::status_id_approved, |
|
374 | + ), |
|
375 | + 'force_join' => array('Payment_Method'), |
|
376 | + ), |
|
377 | + ARRAY_A, |
|
378 | + 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' |
|
379 | + ); |
|
380 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
381 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
382 | + ? $payment_method_and_gateway_txn_id['name'] : esc_html__('Unknown', 'event_espresso'); |
|
383 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
384 | + ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
385 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
386 | + ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
387 | + } |
|
388 | + } |
|
389 | + $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times); |
|
390 | + $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods); |
|
391 | + $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode( |
|
392 | + ',', |
|
393 | + $gateway_txn_ids_etc |
|
394 | + ); |
|
395 | + // get whether or not the user has checked in |
|
396 | + $reg_csv_array[ (string) esc_html__("Check-Ins", "event_espresso") ] = $reg_model->count_related( |
|
397 | + $reg_row['Registration.REG_ID'], |
|
398 | + 'Checkin' |
|
399 | + ); |
|
400 | + // get ticket of registration and its price |
|
401 | + $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
|
402 | + if ($reg_row['Ticket.TKT_ID']) { |
|
403 | + $ticket_name = EEH_Export::prepare_value_from_db_for_display( |
|
404 | + $ticket_model, |
|
405 | + 'TKT_name', |
|
406 | + $reg_row['Ticket.TKT_name'] |
|
407 | + ); |
|
408 | + $datetimes_strings = array(); |
|
409 | + foreach ( |
|
410 | + EEM_Datetime::instance()->get_all_wpdb_results( |
|
411 | + array( |
|
412 | + array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), |
|
413 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
414 | + 'default_where_conditions' => 'none', |
|
415 | + ) |
|
416 | + ) as $datetime |
|
417 | + ) { |
|
418 | + $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display( |
|
419 | + EEM_Datetime::instance(), |
|
420 | + 'DTT_EVT_start', |
|
421 | + $datetime['Datetime.DTT_EVT_start'] |
|
422 | + ); |
|
423 | + } |
|
424 | + } else { |
|
425 | + $ticket_name = esc_html__('Unknown', 'event_espresso'); |
|
426 | + $datetimes_strings = array(esc_html__('Unknown', 'event_espresso')); |
|
427 | + } |
|
428 | + $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name; |
|
429 | + $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings); |
|
430 | + // get datetime(s) of registration |
|
431 | + // add attendee columns |
|
432 | + foreach ($att_fields_to_include as $att_field_name) { |
|
433 | + $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
434 | + if ($reg_row['Attendee_CPT.ID']) { |
|
435 | + if ($att_field_name == 'STA_ID') { |
|
436 | + $value = EEM_State::instance()->get_var( |
|
437 | + array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), |
|
438 | + 'STA_name' |
|
439 | + ); |
|
440 | + } elseif ($att_field_name == 'CNT_ISO') { |
|
441 | + $value = EEM_Country::instance()->get_var( |
|
442 | + array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), |
|
443 | + 'CNT_name' |
|
444 | + ); |
|
445 | + } else { |
|
446 | + $value = EEH_Export::prepare_value_from_db_for_display( |
|
447 | + EEM_Attendee::instance(), |
|
448 | + $att_field_name, |
|
449 | + $reg_row[ $field_obj->get_qualified_column() ] |
|
450 | + ); |
|
451 | + } |
|
452 | + } else { |
|
453 | + $value = ''; |
|
454 | + } |
|
455 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value; |
|
456 | + } |
|
457 | + // make sure each registration has the same questions in the same order |
|
458 | + foreach ($question_labels as $question_label) { |
|
459 | + if (! isset($reg_csv_array[ $question_label ])) { |
|
460 | + $reg_csv_array[ $question_label ] = null; |
|
461 | + } |
|
462 | + } |
|
463 | + $answers = EEM_Answer::instance()->get_all_wpdb_results(array( |
|
464 | + array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
465 | + 'force_join' => array('Question'), |
|
466 | + )); |
|
467 | + // now fill out the questions THEY answered |
|
468 | + foreach ($answers as $answer_row) { |
|
469 | + if ($answer_row['Question.QST_system']) { |
|
470 | + // it's an answer to a system question. That was already displayed as part of the attendee |
|
471 | + // fields, so don't write it out again thanks. |
|
472 | + continue; |
|
473 | + } |
|
474 | + if ($answer_row['Question.QST_ID']) { |
|
475 | + $question_label = EEH_Export::prepare_value_from_db_for_display( |
|
476 | + EEM_Question::instance(), |
|
477 | + 'QST_admin_label', |
|
478 | + $answer_row['Question.QST_admin_label'] |
|
479 | + ); |
|
480 | + } else { |
|
481 | + $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
482 | + } |
|
483 | + if ( |
|
484 | + isset($answer_row['Question.QST_type']) |
|
485 | + && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
|
486 | + ) { |
|
487 | + $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
488 | + $answer_row['Answer.ANS_value'] |
|
489 | + ); |
|
490 | + } else { |
|
491 | + // this isn't for html, so don't show html entities |
|
492 | + $reg_csv_array[ $question_label ] = html_entity_decode( |
|
493 | + EEH_Export::prepare_value_from_db_for_display( |
|
494 | + EEM_Answer::instance(), |
|
495 | + 'ANS_value', |
|
496 | + $answer_row['Answer.ANS_value'] |
|
497 | + ) |
|
498 | + ); |
|
499 | + } |
|
500 | + } |
|
501 | 501 | |
502 | - /** |
|
503 | - * Filter to change the contents of each row of the registrations report CSV file. |
|
504 | - * This can be used to add or remote columns from the CSV file, or change their values. |
|
505 | - * Note when using: all rows in the CSV should have the same columns. |
|
506 | - * @param array $reg_csv_array keys are the column names, values are their cell values |
|
507 | - * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results() |
|
508 | - */ |
|
509 | - $registrations_csv_ready_array[] = apply_filters( |
|
510 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
511 | - $reg_csv_array, |
|
512 | - $reg_row |
|
513 | - ); |
|
514 | - } |
|
515 | - } |
|
516 | - // if we couldn't export anything, we want to at least show the column headers |
|
517 | - if (empty($registrations_csv_ready_array)) { |
|
518 | - $reg_csv_array = array(); |
|
519 | - $model_and_fields_to_include = array( |
|
520 | - 'Registration' => $reg_fields_to_include, |
|
521 | - 'Attendee' => $att_fields_to_include, |
|
522 | - ); |
|
523 | - foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
524 | - $model = EE_Registry::instance()->load_model($model_name); |
|
525 | - foreach ($field_list as $field_name) { |
|
526 | - $field = $model->field_settings_for($field_name); |
|
527 | - $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null; |
|
528 | - } |
|
529 | - } |
|
530 | - $registrations_csv_ready_array[] = $reg_csv_array; |
|
531 | - } |
|
532 | - return $registrations_csv_ready_array; |
|
533 | - } |
|
502 | + /** |
|
503 | + * Filter to change the contents of each row of the registrations report CSV file. |
|
504 | + * This can be used to add or remote columns from the CSV file, or change their values. |
|
505 | + * Note when using: all rows in the CSV should have the same columns. |
|
506 | + * @param array $reg_csv_array keys are the column names, values are their cell values |
|
507 | + * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results() |
|
508 | + */ |
|
509 | + $registrations_csv_ready_array[] = apply_filters( |
|
510 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
511 | + $reg_csv_array, |
|
512 | + $reg_row |
|
513 | + ); |
|
514 | + } |
|
515 | + } |
|
516 | + // if we couldn't export anything, we want to at least show the column headers |
|
517 | + if (empty($registrations_csv_ready_array)) { |
|
518 | + $reg_csv_array = array(); |
|
519 | + $model_and_fields_to_include = array( |
|
520 | + 'Registration' => $reg_fields_to_include, |
|
521 | + 'Attendee' => $att_fields_to_include, |
|
522 | + ); |
|
523 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
524 | + $model = EE_Registry::instance()->load_model($model_name); |
|
525 | + foreach ($field_list as $field_name) { |
|
526 | + $field = $model->field_settings_for($field_name); |
|
527 | + $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null; |
|
528 | + } |
|
529 | + } |
|
530 | + $registrations_csv_ready_array[] = $reg_csv_array; |
|
531 | + } |
|
532 | + return $registrations_csv_ready_array; |
|
533 | + } |
|
534 | 534 | |
535 | 535 | |
536 | - /** |
|
537 | - * Counts total unit to process |
|
538 | - * |
|
539 | - * @deprecated since 4.9.19 |
|
540 | - * @param int|array $event_id |
|
541 | - * @return int |
|
542 | - */ |
|
543 | - public function count_units_to_process($event_id) |
|
544 | - { |
|
545 | - // use the legacy filter |
|
546 | - if ($event_id) { |
|
547 | - $query_params[0]['EVT_ID'] = $event_id; |
|
548 | - } else { |
|
549 | - $query_params['force_join'][] = 'Event'; |
|
550 | - } |
|
551 | - return \EEM_Registration::instance()->count($query_params); |
|
552 | - } |
|
536 | + /** |
|
537 | + * Counts total unit to process |
|
538 | + * |
|
539 | + * @deprecated since 4.9.19 |
|
540 | + * @param int|array $event_id |
|
541 | + * @return int |
|
542 | + */ |
|
543 | + public function count_units_to_process($event_id) |
|
544 | + { |
|
545 | + // use the legacy filter |
|
546 | + if ($event_id) { |
|
547 | + $query_params[0]['EVT_ID'] = $event_id; |
|
548 | + } else { |
|
549 | + $query_params['force_join'][] = 'Event'; |
|
550 | + } |
|
551 | + return \EEM_Registration::instance()->count($query_params); |
|
552 | + } |
|
553 | 553 | |
554 | 554 | |
555 | - /** |
|
556 | - * Performs any clean-up logic when we know the job is completed. |
|
557 | - * In this case, we delete the temporary file |
|
558 | - * |
|
559 | - * @param JobParameters $job_parameters |
|
560 | - * @return boolean |
|
561 | - */ |
|
562 | - public function cleanup_job(JobParameters $job_parameters) |
|
563 | - { |
|
564 | - $this->_file_helper->delete( |
|
565 | - \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
566 | - true, |
|
567 | - 'd' |
|
568 | - ); |
|
569 | - return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso')); |
|
570 | - } |
|
555 | + /** |
|
556 | + * Performs any clean-up logic when we know the job is completed. |
|
557 | + * In this case, we delete the temporary file |
|
558 | + * |
|
559 | + * @param JobParameters $job_parameters |
|
560 | + * @return boolean |
|
561 | + */ |
|
562 | + public function cleanup_job(JobParameters $job_parameters) |
|
563 | + { |
|
564 | + $this->_file_helper->delete( |
|
565 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
566 | + true, |
|
567 | + 'd' |
|
568 | + ); |
|
569 | + return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso')); |
|
570 | + } |
|
571 | 571 | } |
@@ -20,111 +20,111 @@ |
||
20 | 20 | abstract class TicketSelector |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var EE_Event |
|
25 | - */ |
|
26 | - protected $event; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var EE_Ticket[] |
|
30 | - */ |
|
31 | - protected $tickets; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var int |
|
35 | - */ |
|
36 | - protected $max_attendees; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - protected $template_args; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var int |
|
45 | - */ |
|
46 | - protected $ticket_rows = 0; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * TicketSelectorSimple constructor. |
|
51 | - * |
|
52 | - * @param EE_Event $event |
|
53 | - * @param EE_Ticket[] $tickets |
|
54 | - * @param int $max_attendees |
|
55 | - * @param array $template_args |
|
56 | - */ |
|
57 | - public function __construct(EE_Event $event, array $tickets, $max_attendees, array $template_args) |
|
58 | - { |
|
59 | - $this->event = $event; |
|
60 | - $this->tickets = $tickets; |
|
61 | - $this->max_attendees = $max_attendees; |
|
62 | - $this->template_args = $template_args; |
|
63 | - $this->addTemplateArgs(); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * sets any and all template args that are required for this Ticket Selector |
|
69 | - * |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - abstract protected function addTemplateArgs(); |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * loadTicketSelectorTemplate |
|
77 | - * |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - protected function loadTicketSelectorTemplate() |
|
81 | - { |
|
82 | - try { |
|
83 | - $this->template_args['hidden_inputs'] = $this->getHiddenInputs(); |
|
84 | - return EEH_Template::locate_template( |
|
85 | - apply_filters( |
|
86 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
|
87 | - $this->template_args['template_path'], |
|
88 | - $this->event |
|
89 | - ), |
|
90 | - $this->template_args |
|
91 | - ); |
|
92 | - } catch (Exception $e) { |
|
93 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
94 | - } |
|
95 | - return ''; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * The __toString method allows a class to decide how it will react when it is converted to a string. |
|
101 | - * |
|
102 | - * @return string |
|
103 | - * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
|
104 | - */ |
|
105 | - public function __toString() |
|
106 | - { |
|
107 | - return $this->loadTicketSelectorTemplate(); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * getHiddenInputs |
|
113 | - * |
|
114 | - * @return string |
|
115 | - * @throws EE_Error |
|
116 | - * @throws ReflectionException |
|
117 | - */ |
|
118 | - public function getHiddenInputs() |
|
119 | - { |
|
120 | - $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
121 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
122 | - $html .= ' value="' . EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
123 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
124 | - $html .= '" value="' . $this->ticket_rows . '"/>'; |
|
125 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
126 | - $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
127 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
128 | - return $html; |
|
129 | - } |
|
23 | + /** |
|
24 | + * @var EE_Event |
|
25 | + */ |
|
26 | + protected $event; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var EE_Ticket[] |
|
30 | + */ |
|
31 | + protected $tickets; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var int |
|
35 | + */ |
|
36 | + protected $max_attendees; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + protected $template_args; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var int |
|
45 | + */ |
|
46 | + protected $ticket_rows = 0; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * TicketSelectorSimple constructor. |
|
51 | + * |
|
52 | + * @param EE_Event $event |
|
53 | + * @param EE_Ticket[] $tickets |
|
54 | + * @param int $max_attendees |
|
55 | + * @param array $template_args |
|
56 | + */ |
|
57 | + public function __construct(EE_Event $event, array $tickets, $max_attendees, array $template_args) |
|
58 | + { |
|
59 | + $this->event = $event; |
|
60 | + $this->tickets = $tickets; |
|
61 | + $this->max_attendees = $max_attendees; |
|
62 | + $this->template_args = $template_args; |
|
63 | + $this->addTemplateArgs(); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * sets any and all template args that are required for this Ticket Selector |
|
69 | + * |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + abstract protected function addTemplateArgs(); |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * loadTicketSelectorTemplate |
|
77 | + * |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + protected function loadTicketSelectorTemplate() |
|
81 | + { |
|
82 | + try { |
|
83 | + $this->template_args['hidden_inputs'] = $this->getHiddenInputs(); |
|
84 | + return EEH_Template::locate_template( |
|
85 | + apply_filters( |
|
86 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
|
87 | + $this->template_args['template_path'], |
|
88 | + $this->event |
|
89 | + ), |
|
90 | + $this->template_args |
|
91 | + ); |
|
92 | + } catch (Exception $e) { |
|
93 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
94 | + } |
|
95 | + return ''; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * The __toString method allows a class to decide how it will react when it is converted to a string. |
|
101 | + * |
|
102 | + * @return string |
|
103 | + * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
|
104 | + */ |
|
105 | + public function __toString() |
|
106 | + { |
|
107 | + return $this->loadTicketSelectorTemplate(); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * getHiddenInputs |
|
113 | + * |
|
114 | + * @return string |
|
115 | + * @throws EE_Error |
|
116 | + * @throws ReflectionException |
|
117 | + */ |
|
118 | + public function getHiddenInputs() |
|
119 | + { |
|
120 | + $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
121 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
122 | + $html .= ' value="' . EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
123 | + $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
124 | + $html .= '" value="' . $this->ticket_rows . '"/>'; |
|
125 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
126 | + $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
127 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
128 | + return $html; |
|
129 | + } |
|
130 | 130 | } |
@@ -118,13 +118,13 @@ |
||
118 | 118 | public function getHiddenInputs() |
119 | 119 | { |
120 | 120 | $html = '<input type="hidden" name="noheader" value="true"/>'; |
121 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
|
122 | - $html .= ' value="' . EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
|
123 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
|
124 | - $html .= '" value="' . $this->ticket_rows . '"/>'; |
|
125 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
|
126 | - $html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
|
127 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
|
121 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-'.$this->event->ID().'"'; |
|
122 | + $html .= ' value="'.EEH_URL::current_url().$this->template_args['anchor_id'].'"/>'; |
|
123 | + $html .= '<input type="hidden" name="tkt-slctr-rows-'.$this->event->ID(); |
|
124 | + $html .= '" value="'.$this->ticket_rows.'"/>'; |
|
125 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-'.$this->event->ID(); |
|
126 | + $html .= '" value="'.$this->template_args['max_atndz'].'"/>'; |
|
127 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="'.$this->event->ID().'"/>'; |
|
128 | 128 | return $html; |
129 | 129 | } |
130 | 130 | } |
@@ -20,125 +20,125 @@ |
||
20 | 20 | class TicketSelectorStandard extends TicketSelector |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var string $date_format |
|
25 | - */ |
|
26 | - protected $date_format; |
|
23 | + /** |
|
24 | + * @var string $date_format |
|
25 | + */ |
|
26 | + protected $date_format; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var string $time_format |
|
30 | - */ |
|
31 | - protected $time_format; |
|
28 | + /** |
|
29 | + * @var string $time_format |
|
30 | + */ |
|
31 | + protected $time_format; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var EE_Ticket_Selector_Config $ticket_selector_config |
|
35 | - */ |
|
36 | - protected $ticket_selector_config; |
|
33 | + /** |
|
34 | + * @var EE_Ticket_Selector_Config $ticket_selector_config |
|
35 | + */ |
|
36 | + protected $ticket_selector_config; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var EE_Tax_Config $tax_config |
|
40 | - */ |
|
41 | - protected $tax_config; |
|
38 | + /** |
|
39 | + * @var EE_Tax_Config $tax_config |
|
40 | + */ |
|
41 | + protected $tax_config; |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * TicketSelectorSimple constructor. |
|
46 | - * |
|
47 | - * @param EE_Ticket_Selector_Config $ticket_selector_config |
|
48 | - * @param EE_Tax_Config $tax_config |
|
49 | - * @param EE_Event $event |
|
50 | - * @param EE_Ticket[] $tickets |
|
51 | - * @param int $max_attendees |
|
52 | - * @param array $template_args |
|
53 | - * @param string $date_format |
|
54 | - * @param string $time_format |
|
55 | - * @throws EE_Error |
|
56 | - */ |
|
57 | - public function __construct( |
|
58 | - EE_Ticket_Selector_Config $ticket_selector_config, |
|
59 | - EE_Tax_Config $tax_config, |
|
60 | - EE_Event $event, |
|
61 | - array $tickets, |
|
62 | - $max_attendees, |
|
63 | - array $template_args, |
|
64 | - $date_format = 'Y-m-d', |
|
65 | - $time_format = 'g:i a' |
|
66 | - ) { |
|
67 | - $this->ticket_selector_config = $ticket_selector_config; |
|
68 | - $this->tax_config = $tax_config; |
|
69 | - $this->date_format = $date_format; |
|
70 | - $this->time_format = $time_format; |
|
71 | - parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
72 | - } |
|
44 | + /** |
|
45 | + * TicketSelectorSimple constructor. |
|
46 | + * |
|
47 | + * @param EE_Ticket_Selector_Config $ticket_selector_config |
|
48 | + * @param EE_Tax_Config $tax_config |
|
49 | + * @param EE_Event $event |
|
50 | + * @param EE_Ticket[] $tickets |
|
51 | + * @param int $max_attendees |
|
52 | + * @param array $template_args |
|
53 | + * @param string $date_format |
|
54 | + * @param string $time_format |
|
55 | + * @throws EE_Error |
|
56 | + */ |
|
57 | + public function __construct( |
|
58 | + EE_Ticket_Selector_Config $ticket_selector_config, |
|
59 | + EE_Tax_Config $tax_config, |
|
60 | + EE_Event $event, |
|
61 | + array $tickets, |
|
62 | + $max_attendees, |
|
63 | + array $template_args, |
|
64 | + $date_format = 'Y-m-d', |
|
65 | + $time_format = 'g:i a' |
|
66 | + ) { |
|
67 | + $this->ticket_selector_config = $ticket_selector_config; |
|
68 | + $this->tax_config = $tax_config; |
|
69 | + $this->date_format = $date_format; |
|
70 | + $this->time_format = $time_format; |
|
71 | + parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * sets any and all template args that are required for this Ticket Selector |
|
77 | - * |
|
78 | - * @return void |
|
79 | - * @throws EE_Error |
|
80 | - */ |
|
81 | - protected function addTemplateArgs() |
|
82 | - { |
|
83 | - $this->ticket_rows = 0; |
|
84 | - $all_ticket_rows_html = ''; |
|
85 | - $required_ticket_sold_out = false; |
|
86 | - // flag to indicate that at least one taxable ticket has been encountered |
|
87 | - $taxable_tickets = false; |
|
88 | - $datetime_selector = null; |
|
89 | - $this->template_args['datetime_selector'] = ''; |
|
90 | - if ( |
|
91 | - $this->ticket_selector_config->getShowDatetimeSelector() |
|
92 | - !== EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
93 | - ) { |
|
94 | - $datetime_selector = new DatetimeSelector( |
|
95 | - $this->event, |
|
96 | - $this->tickets, |
|
97 | - $this->ticket_selector_config, |
|
98 | - $this->date_format, |
|
99 | - $this->time_format |
|
100 | - ); |
|
101 | - $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
102 | - } |
|
103 | - $total_tickets = count($this->tickets); |
|
104 | - // loop through tickets |
|
105 | - foreach ($this->tickets as $ticket) { |
|
106 | - if ($ticket instanceof EE_Ticket) { |
|
107 | - $this->ticket_rows++; |
|
108 | - $cols = 2; |
|
109 | - $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
110 | - $ticket_selector_row = new TicketSelectorRowStandard( |
|
111 | - new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
112 | - $this->tax_config, |
|
113 | - $total_tickets, |
|
114 | - $this->max_attendees, |
|
115 | - $this->ticket_rows, |
|
116 | - $cols, |
|
117 | - $required_ticket_sold_out, |
|
118 | - $this->template_args['event_status'], |
|
119 | - $datetime_selector instanceof DatetimeSelector |
|
120 | - ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
121 | - : '' |
|
122 | - ); |
|
123 | - $ticket_row_html = $ticket_selector_row->getHtml(); |
|
124 | - // check if something was actually returned |
|
125 | - if (! empty($ticket_row_html)) { |
|
126 | - // add any output to the cumulative HTML |
|
127 | - $all_ticket_rows_html .= $ticket_row_html; |
|
128 | - } else { |
|
129 | - // or decrement the ticket row count since it looks like one has been removed |
|
130 | - $this->ticket_rows--; |
|
131 | - } |
|
75 | + /** |
|
76 | + * sets any and all template args that are required for this Ticket Selector |
|
77 | + * |
|
78 | + * @return void |
|
79 | + * @throws EE_Error |
|
80 | + */ |
|
81 | + protected function addTemplateArgs() |
|
82 | + { |
|
83 | + $this->ticket_rows = 0; |
|
84 | + $all_ticket_rows_html = ''; |
|
85 | + $required_ticket_sold_out = false; |
|
86 | + // flag to indicate that at least one taxable ticket has been encountered |
|
87 | + $taxable_tickets = false; |
|
88 | + $datetime_selector = null; |
|
89 | + $this->template_args['datetime_selector'] = ''; |
|
90 | + if ( |
|
91 | + $this->ticket_selector_config->getShowDatetimeSelector() |
|
92 | + !== EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
93 | + ) { |
|
94 | + $datetime_selector = new DatetimeSelector( |
|
95 | + $this->event, |
|
96 | + $this->tickets, |
|
97 | + $this->ticket_selector_config, |
|
98 | + $this->date_format, |
|
99 | + $this->time_format |
|
100 | + ); |
|
101 | + $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
102 | + } |
|
103 | + $total_tickets = count($this->tickets); |
|
104 | + // loop through tickets |
|
105 | + foreach ($this->tickets as $ticket) { |
|
106 | + if ($ticket instanceof EE_Ticket) { |
|
107 | + $this->ticket_rows++; |
|
108 | + $cols = 2; |
|
109 | + $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
110 | + $ticket_selector_row = new TicketSelectorRowStandard( |
|
111 | + new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
112 | + $this->tax_config, |
|
113 | + $total_tickets, |
|
114 | + $this->max_attendees, |
|
115 | + $this->ticket_rows, |
|
116 | + $cols, |
|
117 | + $required_ticket_sold_out, |
|
118 | + $this->template_args['event_status'], |
|
119 | + $datetime_selector instanceof DatetimeSelector |
|
120 | + ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
121 | + : '' |
|
122 | + ); |
|
123 | + $ticket_row_html = $ticket_selector_row->getHtml(); |
|
124 | + // check if something was actually returned |
|
125 | + if (! empty($ticket_row_html)) { |
|
126 | + // add any output to the cumulative HTML |
|
127 | + $all_ticket_rows_html .= $ticket_row_html; |
|
128 | + } else { |
|
129 | + // or decrement the ticket row count since it looks like one has been removed |
|
130 | + $this->ticket_rows--; |
|
131 | + } |
|
132 | 132 | |
133 | - $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
134 | - } |
|
135 | - } |
|
136 | - $this->template_args['row'] = $this->ticket_rows; |
|
137 | - $this->template_args['ticket_row_html'] = $all_ticket_rows_html; |
|
138 | - $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
139 | - $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
140 | - $this->template_args['template_path'] = |
|
141 | - TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
142 | - remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
143 | - } |
|
133 | + $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
134 | + } |
|
135 | + } |
|
136 | + $this->template_args['row'] = $this->ticket_rows; |
|
137 | + $this->template_args['ticket_row_html'] = $all_ticket_rows_html; |
|
138 | + $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
139 | + $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
140 | + $this->template_args['template_path'] = |
|
141 | + TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
142 | + remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
143 | + } |
|
144 | 144 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->ticket_selector_config->getShowDatetimeSelector() |
92 | 92 | !== EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
93 | 93 | ) { |
94 | - $datetime_selector = new DatetimeSelector( |
|
94 | + $datetime_selector = new DatetimeSelector( |
|
95 | 95 | $this->event, |
96 | 96 | $this->tickets, |
97 | 97 | $this->ticket_selector_config, |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | ); |
123 | 123 | $ticket_row_html = $ticket_selector_row->getHtml(); |
124 | 124 | // check if something was actually returned |
125 | - if (! empty($ticket_row_html)) { |
|
125 | + if ( ! empty($ticket_row_html)) { |
|
126 | 126 | // add any output to the cumulative HTML |
127 | 127 | $all_ticket_rows_html .= $ticket_row_html; |
128 | 128 | } else { |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $this->template_args['taxable_tickets'] = $taxable_tickets; |
139 | 139 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
140 | 140 | $this->template_args['template_path'] = |
141 | - TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
141 | + TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php'; |
|
142 | 142 | remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
143 | 143 | } |
144 | 144 | } |
@@ -20,59 +20,59 @@ |
||
20 | 20 | class TicketSelectorSimple extends TicketSelector |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var EE_Ticket $ticket |
|
25 | - */ |
|
26 | - protected $ticket; |
|
23 | + /** |
|
24 | + * @var EE_Ticket $ticket |
|
25 | + */ |
|
26 | + protected $ticket; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * TicketSelectorSimple constructor. |
|
31 | - * |
|
32 | - * @param EE_Event $event |
|
33 | - * @param EE_Ticket $ticket |
|
34 | - * @param int $max_attendees |
|
35 | - * @param array $template_args |
|
36 | - * @throws EE_Error |
|
37 | - */ |
|
38 | - public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args) |
|
39 | - { |
|
40 | - $this->ticket = $ticket; |
|
41 | - parent::__construct( |
|
42 | - $event, |
|
43 | - [$this->ticket], |
|
44 | - $max_attendees, |
|
45 | - $template_args |
|
46 | - ); |
|
47 | - } |
|
29 | + /** |
|
30 | + * TicketSelectorSimple constructor. |
|
31 | + * |
|
32 | + * @param EE_Event $event |
|
33 | + * @param EE_Ticket $ticket |
|
34 | + * @param int $max_attendees |
|
35 | + * @param array $template_args |
|
36 | + * @throws EE_Error |
|
37 | + */ |
|
38 | + public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args) |
|
39 | + { |
|
40 | + $this->ticket = $ticket; |
|
41 | + parent::__construct( |
|
42 | + $event, |
|
43 | + [$this->ticket], |
|
44 | + $max_attendees, |
|
45 | + $template_args |
|
46 | + ); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * sets any and all template args that are required for this Ticket Selector |
|
52 | - * |
|
53 | - * @return void |
|
54 | - * @throws UnexpectedEntityException |
|
55 | - * @throws EE_Error |
|
56 | - */ |
|
57 | - protected function addTemplateArgs() |
|
58 | - { |
|
59 | - $this->ticket_rows = 1; |
|
60 | - unset($this->template_args['tickets']); |
|
61 | - $this->template_args['ticket'] = $this->ticket; |
|
62 | - $ticket_selector_row = new TicketSelectorRowSimple( |
|
63 | - $this->ticket, |
|
64 | - $this->max_attendees, |
|
65 | - $this->template_args['date_format'], |
|
66 | - $this->template_args['event_status'] |
|
67 | - ); |
|
68 | - $this->template_args['TKT_ID'] = $this->ticket->ID(); |
|
69 | - $ticket_selector_row->setupTicketStatusDisplay(); |
|
70 | - $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
71 | - if (empty($this->template_args['ticket_status_display'])) { |
|
72 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
73 | - } |
|
74 | - $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription(); |
|
75 | - $this->template_args['template_path'] = |
|
76 | - TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
77 | - } |
|
50 | + /** |
|
51 | + * sets any and all template args that are required for this Ticket Selector |
|
52 | + * |
|
53 | + * @return void |
|
54 | + * @throws UnexpectedEntityException |
|
55 | + * @throws EE_Error |
|
56 | + */ |
|
57 | + protected function addTemplateArgs() |
|
58 | + { |
|
59 | + $this->ticket_rows = 1; |
|
60 | + unset($this->template_args['tickets']); |
|
61 | + $this->template_args['ticket'] = $this->ticket; |
|
62 | + $ticket_selector_row = new TicketSelectorRowSimple( |
|
63 | + $this->ticket, |
|
64 | + $this->max_attendees, |
|
65 | + $this->template_args['date_format'], |
|
66 | + $this->template_args['event_status'] |
|
67 | + ); |
|
68 | + $this->template_args['TKT_ID'] = $this->ticket->ID(); |
|
69 | + $ticket_selector_row->setupTicketStatusDisplay(); |
|
70 | + $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
71 | + if (empty($this->template_args['ticket_status_display'])) { |
|
72 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
73 | + } |
|
74 | + $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription(); |
|
75 | + $this->template_args['template_path'] = |
|
76 | + TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
77 | + } |
|
78 | 78 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.22.rc.001'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.22.rc.001'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |