@@ -11,28 +11,28 @@ |
||
11 | 11 | */ |
12 | 12 | class PaymentsInfoCSV |
13 | 13 | { |
14 | - /** |
|
15 | - * Extracts payment information using the payment records |
|
16 | - * |
|
17 | - * @param array $payments_info |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public static function extractPaymentInfo(array $payments_info) |
|
21 | - { |
|
22 | - $payment_methods = []; |
|
23 | - $gateway_txn_ids_etc = []; |
|
24 | - $payment_times = []; |
|
25 | - foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
26 | - $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
27 | - ? $payment_method_and_gateway_txn_id['name'] |
|
28 | - : esc_html__('Unknown', 'event_espresso'); |
|
29 | - $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
30 | - ? $payment_method_and_gateway_txn_id['gateway_txn_id'] |
|
31 | - : ''; |
|
32 | - $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
33 | - ? $payment_method_and_gateway_txn_id['payment_time'] |
|
34 | - : ''; |
|
35 | - } |
|
36 | - return [$payment_methods, $gateway_txn_ids_etc, $payment_times]; |
|
37 | - } |
|
14 | + /** |
|
15 | + * Extracts payment information using the payment records |
|
16 | + * |
|
17 | + * @param array $payments_info |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public static function extractPaymentInfo(array $payments_info) |
|
21 | + { |
|
22 | + $payment_methods = []; |
|
23 | + $gateway_txn_ids_etc = []; |
|
24 | + $payment_times = []; |
|
25 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
26 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
27 | + ? $payment_method_and_gateway_txn_id['name'] |
|
28 | + : esc_html__('Unknown', 'event_espresso'); |
|
29 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
30 | + ? $payment_method_and_gateway_txn_id['gateway_txn_id'] |
|
31 | + : ''; |
|
32 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
33 | + ? $payment_method_and_gateway_txn_id['payment_time'] |
|
34 | + : ''; |
|
35 | + } |
|
36 | + return [$payment_methods, $gateway_txn_ids_etc, $payment_times]; |
|
37 | + } |
|
38 | 38 | } |
@@ -16,57 +16,57 @@ |
||
16 | 16 | */ |
17 | 17 | class CheckinsCSV |
18 | 18 | { |
19 | - /** |
|
20 | - * Returns datetime label |
|
21 | - * |
|
22 | - * @param EE_Datetime $datetime |
|
23 | - * @return string |
|
24 | - * @throws EE_Error |
|
25 | - * @throws ReflectionException |
|
26 | - */ |
|
27 | - public static function getDatetineLabel(EE_Datetime $datetime) |
|
28 | - { |
|
29 | - if (trim($datetime->get('DTT_name'))) { |
|
30 | - /* translators: 1: datetime name, 2: datetime ID */ |
|
31 | - return sprintf( |
|
32 | - esc_html__('Check-ins for %1$s - ID: %2$s', 'event_espresso'), |
|
33 | - esc_html($datetime->get('DTT_name')), |
|
34 | - esc_html($datetime->get('DTT_ID')) |
|
35 | - ); |
|
36 | - } |
|
19 | + /** |
|
20 | + * Returns datetime label |
|
21 | + * |
|
22 | + * @param EE_Datetime $datetime |
|
23 | + * @return string |
|
24 | + * @throws EE_Error |
|
25 | + * @throws ReflectionException |
|
26 | + */ |
|
27 | + public static function getDatetineLabel(EE_Datetime $datetime) |
|
28 | + { |
|
29 | + if (trim($datetime->get('DTT_name'))) { |
|
30 | + /* translators: 1: datetime name, 2: datetime ID */ |
|
31 | + return sprintf( |
|
32 | + esc_html__('Check-ins for %1$s - ID: %2$s', 'event_espresso'), |
|
33 | + esc_html($datetime->get('DTT_name')), |
|
34 | + esc_html($datetime->get('DTT_ID')) |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | - /* translators: %s: datetime ID */ |
|
39 | - return sprintf( |
|
40 | - esc_html__('ID: %1$s', 'event_espresso'), |
|
41 | - esc_html($datetime->get('DTT_ID')) |
|
42 | - ); |
|
43 | - } |
|
38 | + /* translators: %s: datetime ID */ |
|
39 | + return sprintf( |
|
40 | + esc_html__('ID: %1$s', 'event_espresso'), |
|
41 | + esc_html($datetime->get('DTT_ID')) |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Returns checkin value using checkin status and datetime |
|
48 | - * |
|
49 | - * @param EE_Checkin $checkin |
|
50 | - * @return string|null |
|
51 | - * @throws EE_Error |
|
52 | - * @throws ReflectionException |
|
53 | - */ |
|
54 | - public static function getCheckinValue(?EE_Checkin $checkin) |
|
55 | - { |
|
56 | - if ($checkin instanceof EE_Checkin && $checkin->get('CHK_in') === true) { |
|
57 | - /* translators: 1: check-in timestamp */ |
|
58 | - return sprintf( |
|
59 | - esc_html__('IN: %1$s', 'event_espresso'), |
|
60 | - $checkin->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
61 | - ); |
|
62 | - } elseif ($checkin instanceof EE_Checkin && $checkin->get('CHK_in') === false) { |
|
63 | - /* translators: 1: check-in timestamp */ |
|
64 | - return sprintf( |
|
65 | - esc_html__('OUT: %1$s', 'event_espresso'), |
|
66 | - $checkin->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
67 | - ); |
|
68 | - } |
|
46 | + /** |
|
47 | + * Returns checkin value using checkin status and datetime |
|
48 | + * |
|
49 | + * @param EE_Checkin $checkin |
|
50 | + * @return string|null |
|
51 | + * @throws EE_Error |
|
52 | + * @throws ReflectionException |
|
53 | + */ |
|
54 | + public static function getCheckinValue(?EE_Checkin $checkin) |
|
55 | + { |
|
56 | + if ($checkin instanceof EE_Checkin && $checkin->get('CHK_in') === true) { |
|
57 | + /* translators: 1: check-in timestamp */ |
|
58 | + return sprintf( |
|
59 | + esc_html__('IN: %1$s', 'event_espresso'), |
|
60 | + $checkin->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
61 | + ); |
|
62 | + } elseif ($checkin instanceof EE_Checkin && $checkin->get('CHK_in') === false) { |
|
63 | + /* translators: 1: check-in timestamp */ |
|
64 | + return sprintf( |
|
65 | + esc_html__('OUT: %1$s', 'event_espresso'), |
|
66 | + $checkin->get_datetime('CHK_timestamp', 'Y-m-d', 'g:i a') |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | |
70 | - return ''; |
|
71 | - } |
|
70 | + return ''; |
|
71 | + } |
|
72 | 72 | } |
@@ -17,61 +17,61 @@ |
||
17 | 17 | */ |
18 | 18 | class AnswersCSV |
19 | 19 | { |
20 | - /** |
|
21 | - * Add question / answer columns to the CSV row |
|
22 | - * |
|
23 | - * @param array $reg_row |
|
24 | - * @param array $data |
|
25 | - * @param array $question_labels |
|
26 | - * @return mixed |
|
27 | - * @throws EE_Error |
|
28 | - */ |
|
29 | - public static function addAnswerColumns(array $reg_row, $data, $question_labels) |
|
30 | - { |
|
31 | - // make sure each registration has the same questions in the same order |
|
32 | - foreach ($question_labels as $question_label) { |
|
33 | - if (! isset($data[ $question_label ])) { |
|
34 | - $data[ $question_label ] = null; |
|
35 | - } |
|
36 | - } |
|
37 | - $answers = EEM_Answer::instance()->get_all_wpdb_results([ |
|
38 | - ['REG_ID' => $reg_row['Registration.REG_ID']], |
|
39 | - 'force_join' => ['Question'], |
|
40 | - ]); |
|
41 | - // now fill out the questions THEY answered |
|
42 | - foreach ($answers as $answer_row) { |
|
43 | - if ($answer_row['Question.QST_system']) { |
|
44 | - // it's an answer to a system question. That was already displayed as part of the attendee |
|
45 | - // fields, so don't write it out again thanks. |
|
46 | - continue; |
|
47 | - } |
|
48 | - if ($answer_row['Question.QST_ID']) { |
|
49 | - $question_label = EEH_Export::prepare_value_from_db_for_display( |
|
50 | - EEM_Question::instance(), |
|
51 | - 'QST_admin_label', |
|
52 | - $answer_row['Question.QST_admin_label'] |
|
53 | - ); |
|
54 | - } else { |
|
55 | - $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
56 | - } |
|
57 | - if ( |
|
58 | - isset($answer_row['Question.QST_type']) |
|
59 | - && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
|
60 | - ) { |
|
61 | - $data[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
62 | - $answer_row['Answer.ANS_value'] |
|
63 | - ); |
|
64 | - } else { |
|
65 | - // this isn't for html, so don't show html entities |
|
66 | - $data[ $question_label ] = html_entity_decode( |
|
67 | - EEH_Export::prepare_value_from_db_for_display( |
|
68 | - EEM_Answer::instance(), |
|
69 | - 'ANS_value', |
|
70 | - $answer_row['Answer.ANS_value'] |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
75 | - return $data; |
|
76 | - } |
|
20 | + /** |
|
21 | + * Add question / answer columns to the CSV row |
|
22 | + * |
|
23 | + * @param array $reg_row |
|
24 | + * @param array $data |
|
25 | + * @param array $question_labels |
|
26 | + * @return mixed |
|
27 | + * @throws EE_Error |
|
28 | + */ |
|
29 | + public static function addAnswerColumns(array $reg_row, $data, $question_labels) |
|
30 | + { |
|
31 | + // make sure each registration has the same questions in the same order |
|
32 | + foreach ($question_labels as $question_label) { |
|
33 | + if (! isset($data[ $question_label ])) { |
|
34 | + $data[ $question_label ] = null; |
|
35 | + } |
|
36 | + } |
|
37 | + $answers = EEM_Answer::instance()->get_all_wpdb_results([ |
|
38 | + ['REG_ID' => $reg_row['Registration.REG_ID']], |
|
39 | + 'force_join' => ['Question'], |
|
40 | + ]); |
|
41 | + // now fill out the questions THEY answered |
|
42 | + foreach ($answers as $answer_row) { |
|
43 | + if ($answer_row['Question.QST_system']) { |
|
44 | + // it's an answer to a system question. That was already displayed as part of the attendee |
|
45 | + // fields, so don't write it out again thanks. |
|
46 | + continue; |
|
47 | + } |
|
48 | + if ($answer_row['Question.QST_ID']) { |
|
49 | + $question_label = EEH_Export::prepare_value_from_db_for_display( |
|
50 | + EEM_Question::instance(), |
|
51 | + 'QST_admin_label', |
|
52 | + $answer_row['Question.QST_admin_label'] |
|
53 | + ); |
|
54 | + } else { |
|
55 | + $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
56 | + } |
|
57 | + if ( |
|
58 | + isset($answer_row['Question.QST_type']) |
|
59 | + && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state |
|
60 | + ) { |
|
61 | + $data[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( |
|
62 | + $answer_row['Answer.ANS_value'] |
|
63 | + ); |
|
64 | + } else { |
|
65 | + // this isn't for html, so don't show html entities |
|
66 | + $data[ $question_label ] = html_entity_decode( |
|
67 | + EEH_Export::prepare_value_from_db_for_display( |
|
68 | + EEM_Answer::instance(), |
|
69 | + 'ANS_value', |
|
70 | + $answer_row['Answer.ANS_value'] |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | + return $data; |
|
76 | + } |
|
77 | 77 | } |