@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
89 | 89 | { |
90 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
90 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
91 | 91 | throw new EE_Error( |
92 | 92 | sprintf( |
93 | 93 | __( |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
123 | 123 | { |
124 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
124 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
125 | 125 | throw new EE_Error( |
126 | 126 | sprintf( |
127 | 127 | __( |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
158 | 158 | { |
159 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
159 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
160 | 160 | throw new EE_Error( |
161 | 161 | sprintf( |
162 | 162 | __( |
@@ -17,214 +17,214 @@ |
||
17 | 17 | |
18 | 18 | class Datetime extends DatetimeCalculationBase |
19 | 19 | { |
20 | - /** |
|
21 | - * @var EEM_Datetime |
|
22 | - */ |
|
23 | - protected $datetime_model; |
|
20 | + /** |
|
21 | + * @var EEM_Datetime |
|
22 | + */ |
|
23 | + protected $datetime_model; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var EEM_Registration |
|
27 | - */ |
|
28 | - protected $registration_model; |
|
29 | - public function __construct(EEM_Datetime $datetime_model, EEM_Registration $registration_model) |
|
30 | - { |
|
31 | - $this->datetime_model = $datetime_model; |
|
32 | - $this->registration_model = $registration_model; |
|
33 | - } |
|
25 | + /** |
|
26 | + * @var EEM_Registration |
|
27 | + */ |
|
28 | + protected $registration_model; |
|
29 | + public function __construct(EEM_Datetime $datetime_model, EEM_Registration $registration_model) |
|
30 | + { |
|
31 | + $this->datetime_model = $datetime_model; |
|
32 | + $this->registration_model = $registration_model; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Calculates the total spaces available on the datetime, taking into account |
|
37 | - * ticket limits too. |
|
38 | - * |
|
39 | - * @see EE_Datetime::spaces_remaining( true ) |
|
40 | - * @param array $wpdb_row |
|
41 | - * @param WP_REST_Request $request |
|
42 | - * @param DatetimeControllerBase $controller |
|
43 | - * @return int |
|
44 | - * @throws EE_Error |
|
45 | - * @throws InvalidDataTypeException |
|
46 | - * @throws InvalidInterfaceException |
|
47 | - * @throws InvalidArgumentException |
|
48 | - * @throws ReflectionException |
|
49 | - */ |
|
50 | - public function spacesRemainingConsideringTickets($wpdb_row, $request, $controller) |
|
51 | - { |
|
52 | - if (is_array($wpdb_row) && isset($wpdb_row['Datetime.DTT_ID'])) { |
|
53 | - $dtt_obj = $this->datetime_model->get_one_by_ID($wpdb_row['Datetime.DTT_ID']); |
|
54 | - } else { |
|
55 | - $dtt_obj = null; |
|
56 | - } |
|
57 | - if ($dtt_obj instanceof EE_Datetime) { |
|
58 | - return $dtt_obj->spaces_remaining(true); |
|
59 | - } |
|
60 | - throw new EE_Error( |
|
61 | - sprintf( |
|
62 | - __( |
|
63 | - // @codingStandardsIgnoreStart |
|
64 | - 'Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found', |
|
65 | - // @codingStandardsIgnoreEnd |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - $wpdb_row['Datetime.DTT_ID'], |
|
69 | - print_r($wpdb_row, true) |
|
70 | - ) |
|
71 | - ); |
|
72 | - } |
|
35 | + /** |
|
36 | + * Calculates the total spaces available on the datetime, taking into account |
|
37 | + * ticket limits too. |
|
38 | + * |
|
39 | + * @see EE_Datetime::spaces_remaining( true ) |
|
40 | + * @param array $wpdb_row |
|
41 | + * @param WP_REST_Request $request |
|
42 | + * @param DatetimeControllerBase $controller |
|
43 | + * @return int |
|
44 | + * @throws EE_Error |
|
45 | + * @throws InvalidDataTypeException |
|
46 | + * @throws InvalidInterfaceException |
|
47 | + * @throws InvalidArgumentException |
|
48 | + * @throws ReflectionException |
|
49 | + */ |
|
50 | + public function spacesRemainingConsideringTickets($wpdb_row, $request, $controller) |
|
51 | + { |
|
52 | + if (is_array($wpdb_row) && isset($wpdb_row['Datetime.DTT_ID'])) { |
|
53 | + $dtt_obj = $this->datetime_model->get_one_by_ID($wpdb_row['Datetime.DTT_ID']); |
|
54 | + } else { |
|
55 | + $dtt_obj = null; |
|
56 | + } |
|
57 | + if ($dtt_obj instanceof EE_Datetime) { |
|
58 | + return $dtt_obj->spaces_remaining(true); |
|
59 | + } |
|
60 | + throw new EE_Error( |
|
61 | + sprintf( |
|
62 | + __( |
|
63 | + // @codingStandardsIgnoreStart |
|
64 | + 'Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found', |
|
65 | + // @codingStandardsIgnoreEnd |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + $wpdb_row['Datetime.DTT_ID'], |
|
69 | + print_r($wpdb_row, true) |
|
70 | + ) |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * Counts registrations who have checked into this datetime |
|
77 | - * |
|
78 | - * @param array $wpdb_row |
|
79 | - * @param WP_REST_Request $request |
|
80 | - * @param DatetimeControllerBase $controller |
|
81 | - * @return int |
|
82 | - * @throws EE_Error |
|
83 | - * @throws InvalidArgumentException |
|
84 | - * @throws InvalidDataTypeException |
|
85 | - * @throws InvalidInterfaceException |
|
86 | - * @throws RestException |
|
87 | - */ |
|
88 | - public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
|
89 | - { |
|
90 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
91 | - throw new EE_Error( |
|
92 | - sprintf( |
|
93 | - __( |
|
94 | - // @codingStandardsIgnoreStart |
|
95 | - 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
96 | - // @codingStandardsIgnoreEnd |
|
97 | - 'event_espresso' |
|
98 | - ), |
|
99 | - print_r($wpdb_row, true) |
|
100 | - ) |
|
101 | - ); |
|
102 | - } |
|
103 | - $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count'); |
|
104 | - return $this->registration_model |
|
105 | - ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true); |
|
106 | - } |
|
75 | + /** |
|
76 | + * Counts registrations who have checked into this datetime |
|
77 | + * |
|
78 | + * @param array $wpdb_row |
|
79 | + * @param WP_REST_Request $request |
|
80 | + * @param DatetimeControllerBase $controller |
|
81 | + * @return int |
|
82 | + * @throws EE_Error |
|
83 | + * @throws InvalidArgumentException |
|
84 | + * @throws InvalidDataTypeException |
|
85 | + * @throws InvalidInterfaceException |
|
86 | + * @throws RestException |
|
87 | + */ |
|
88 | + public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
|
89 | + { |
|
90 | + if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
91 | + throw new EE_Error( |
|
92 | + sprintf( |
|
93 | + __( |
|
94 | + // @codingStandardsIgnoreStart |
|
95 | + 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
96 | + // @codingStandardsIgnoreEnd |
|
97 | + 'event_espresso' |
|
98 | + ), |
|
99 | + print_r($wpdb_row, true) |
|
100 | + ) |
|
101 | + ); |
|
102 | + } |
|
103 | + $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count'); |
|
104 | + return $this->registration_model |
|
105 | + ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | - /** |
|
110 | - * Counts registrations who have checked out of this datetime |
|
111 | - * |
|
112 | - * @param array $wpdb_row |
|
113 | - * @param WP_REST_Request $request |
|
114 | - * @param DatetimeControllerBase $controller |
|
115 | - * @return int |
|
116 | - * @throws EE_Error |
|
117 | - * @throws InvalidArgumentException |
|
118 | - * @throws InvalidDataTypeException |
|
119 | - * @throws InvalidInterfaceException |
|
120 | - * @throws RestException |
|
121 | - */ |
|
122 | - public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
|
123 | - { |
|
124 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
125 | - throw new EE_Error( |
|
126 | - sprintf( |
|
127 | - __( |
|
128 | - // @codingStandardsIgnoreStart |
|
129 | - 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
130 | - // @codingStandardsIgnoreEnd |
|
131 | - 'event_espresso' |
|
132 | - ), |
|
133 | - print_r($wpdb_row, true) |
|
134 | - ) |
|
135 | - ); |
|
136 | - } |
|
137 | - $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count'); |
|
138 | - return $this->registration_model |
|
139 | - ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false); |
|
140 | - } |
|
109 | + /** |
|
110 | + * Counts registrations who have checked out of this datetime |
|
111 | + * |
|
112 | + * @param array $wpdb_row |
|
113 | + * @param WP_REST_Request $request |
|
114 | + * @param DatetimeControllerBase $controller |
|
115 | + * @return int |
|
116 | + * @throws EE_Error |
|
117 | + * @throws InvalidArgumentException |
|
118 | + * @throws InvalidDataTypeException |
|
119 | + * @throws InvalidInterfaceException |
|
120 | + * @throws RestException |
|
121 | + */ |
|
122 | + public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
|
123 | + { |
|
124 | + if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
125 | + throw new EE_Error( |
|
126 | + sprintf( |
|
127 | + __( |
|
128 | + // @codingStandardsIgnoreStart |
|
129 | + 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
130 | + // @codingStandardsIgnoreEnd |
|
131 | + 'event_espresso' |
|
132 | + ), |
|
133 | + print_r($wpdb_row, true) |
|
134 | + ) |
|
135 | + ); |
|
136 | + } |
|
137 | + $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count'); |
|
138 | + return $this->registration_model |
|
139 | + ->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false); |
|
140 | + } |
|
141 | 141 | |
142 | 142 | |
143 | - /** |
|
144 | - * Counts the number of pending-payment registrations for this event (regardless |
|
145 | - * of how many datetimes each registrations' ticket purchase is for) |
|
146 | - * |
|
147 | - * @param array $wpdb_row |
|
148 | - * @param WP_REST_Request $request |
|
149 | - * @param DatetimeControllerBase $controller |
|
150 | - * @return int |
|
151 | - * @throws EE_Error |
|
152 | - * @throws InvalidArgumentException |
|
153 | - * @throws InvalidDataTypeException |
|
154 | - * @throws InvalidInterfaceException |
|
155 | - * @throws RestException |
|
156 | - */ |
|
157 | - public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
|
158 | - { |
|
159 | - if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
160 | - throw new EE_Error( |
|
161 | - sprintf( |
|
162 | - __( |
|
163 | - // @codingStandardsIgnoreStart |
|
164 | - 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
165 | - // @codingStandardsIgnoreEnd |
|
166 | - 'event_espresso' |
|
167 | - ), |
|
168 | - print_r($wpdb_row, true) |
|
169 | - ) |
|
170 | - ); |
|
171 | - } |
|
172 | - $this->verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment'); |
|
173 | - return $this->registration_model->count( |
|
174 | - array( |
|
175 | - array( |
|
176 | - 'Ticket.Datetime.DTT_ID' => $wpdb_row['Datetime.DTT_ID'], |
|
177 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
178 | - ), |
|
179 | - ), |
|
180 | - 'REG_ID', |
|
181 | - true |
|
182 | - ); |
|
183 | - } |
|
143 | + /** |
|
144 | + * Counts the number of pending-payment registrations for this event (regardless |
|
145 | + * of how many datetimes each registrations' ticket purchase is for) |
|
146 | + * |
|
147 | + * @param array $wpdb_row |
|
148 | + * @param WP_REST_Request $request |
|
149 | + * @param DatetimeControllerBase $controller |
|
150 | + * @return int |
|
151 | + * @throws EE_Error |
|
152 | + * @throws InvalidArgumentException |
|
153 | + * @throws InvalidDataTypeException |
|
154 | + * @throws InvalidInterfaceException |
|
155 | + * @throws RestException |
|
156 | + */ |
|
157 | + public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
|
158 | + { |
|
159 | + if (! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
160 | + throw new EE_Error( |
|
161 | + sprintf( |
|
162 | + __( |
|
163 | + // @codingStandardsIgnoreStart |
|
164 | + 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Datetime.DTT_ID"', |
|
165 | + // @codingStandardsIgnoreEnd |
|
166 | + 'event_espresso' |
|
167 | + ), |
|
168 | + print_r($wpdb_row, true) |
|
169 | + ) |
|
170 | + ); |
|
171 | + } |
|
172 | + $this->verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment'); |
|
173 | + return $this->registration_model->count( |
|
174 | + array( |
|
175 | + array( |
|
176 | + 'Ticket.Datetime.DTT_ID' => $wpdb_row['Datetime.DTT_ID'], |
|
177 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
178 | + ), |
|
179 | + ), |
|
180 | + 'REG_ID', |
|
181 | + true |
|
182 | + ); |
|
183 | + } |
|
184 | 184 | |
185 | 185 | |
186 | - /** |
|
187 | - * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
188 | - * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
189 | - * |
|
190 | - * @since 4.9.68.p |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - public function schemaForCalculations() |
|
194 | - { |
|
195 | - return array( |
|
196 | - 'spaces_remaining_considering_tickets' => array( |
|
197 | - 'description' => esc_html__( |
|
198 | - 'Calculates the total spaces available on the datetime, taking into account ticket limits too.', |
|
199 | - 'event_espresso' |
|
200 | - ), |
|
201 | - 'type' => 'number', |
|
202 | - 'protected' => true, |
|
203 | - ), |
|
204 | - 'registrations_checked_in_count' => array( |
|
205 | - 'description' => esc_html__( |
|
206 | - 'Counts registrations who have checked into this datetime.', |
|
207 | - 'event_espresso' |
|
208 | - ), |
|
209 | - 'type' => 'number', |
|
210 | - 'protected' => true, |
|
211 | - ), |
|
212 | - 'registrations_checked_out_count' => array( |
|
213 | - 'description' => esc_html__( |
|
214 | - 'Counts registrations who have checked out of this datetime.', |
|
215 | - 'event_espresso' |
|
216 | - ), |
|
217 | - 'type' => 'number', |
|
218 | - 'protected' => true, |
|
219 | - ), |
|
220 | - 'spots_taken_pending_payment' => array( |
|
221 | - 'description' => esc_html__( |
|
222 | - 'The count of pending-payment registrations for this event (regardless of how many datetimes each registration\'s ticket purchase is for', |
|
223 | - 'event_espresso' |
|
224 | - ), |
|
225 | - 'type' => 'number', |
|
226 | - 'protected' => true, |
|
227 | - ), |
|
228 | - ); |
|
229 | - } |
|
186 | + /** |
|
187 | + * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
188 | + * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
189 | + * |
|
190 | + * @since 4.9.68.p |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + public function schemaForCalculations() |
|
194 | + { |
|
195 | + return array( |
|
196 | + 'spaces_remaining_considering_tickets' => array( |
|
197 | + 'description' => esc_html__( |
|
198 | + 'Calculates the total spaces available on the datetime, taking into account ticket limits too.', |
|
199 | + 'event_espresso' |
|
200 | + ), |
|
201 | + 'type' => 'number', |
|
202 | + 'protected' => true, |
|
203 | + ), |
|
204 | + 'registrations_checked_in_count' => array( |
|
205 | + 'description' => esc_html__( |
|
206 | + 'Counts registrations who have checked into this datetime.', |
|
207 | + 'event_espresso' |
|
208 | + ), |
|
209 | + 'type' => 'number', |
|
210 | + 'protected' => true, |
|
211 | + ), |
|
212 | + 'registrations_checked_out_count' => array( |
|
213 | + 'description' => esc_html__( |
|
214 | + 'Counts registrations who have checked out of this datetime.', |
|
215 | + 'event_espresso' |
|
216 | + ), |
|
217 | + 'type' => 'number', |
|
218 | + 'protected' => true, |
|
219 | + ), |
|
220 | + 'spots_taken_pending_payment' => array( |
|
221 | + 'description' => esc_html__( |
|
222 | + 'The count of pending-payment registrations for this event (regardless of how many datetimes each registration\'s ticket purchase is for', |
|
223 | + 'event_espresso' |
|
224 | + ), |
|
225 | + 'type' => 'number', |
|
226 | + 'protected' => true, |
|
227 | + ), |
|
228 | + ); |
|
229 | + } |
|
230 | 230 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | protected function verifyCurrentUserCan($required_permission, $attempted_calculation) |
25 | 25 | { |
26 | - if (! current_user_can($required_permission)) { |
|
26 | + if ( ! current_user_can($required_permission)) { |
|
27 | 27 | throw new RestException( |
28 | 28 | 'permission_denied', |
29 | 29 | sprintf( |
@@ -75,6 +75,6 @@ discard block |
||
75 | 75 | public function schemaForCalculation($calculation_index) |
76 | 76 | { |
77 | 77 | $schema_map = $this->schemaForCalculations(); |
78 | - return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array(); |
|
78 | + return isset($schema_map[$calculation_index]) ? $schema_map[$calculation_index] : array(); |
|
79 | 79 | } |
80 | 80 | } |
@@ -16,65 +16,65 @@ |
||
16 | 16 | class Base |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param $required_permission |
|
21 | - * @param $attempted_calculation |
|
22 | - * @throws RestException |
|
23 | - */ |
|
24 | - protected function verifyCurrentUserCan($required_permission, $attempted_calculation) |
|
25 | - { |
|
26 | - if (! current_user_can($required_permission)) { |
|
27 | - throw new RestException( |
|
28 | - 'permission_denied', |
|
29 | - sprintf( |
|
30 | - __( |
|
31 | - // @codingStandardsIgnoreStart |
|
32 | - 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', |
|
33 | - // @codingStandardsIgnoreEnd |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - $attempted_calculation, |
|
37 | - EEH_Inflector::pluralize_and_lower($this->getResourceName()), |
|
38 | - $required_permission |
|
39 | - ) |
|
40 | - ); |
|
41 | - } |
|
42 | - } |
|
19 | + /** |
|
20 | + * @param $required_permission |
|
21 | + * @param $attempted_calculation |
|
22 | + * @throws RestException |
|
23 | + */ |
|
24 | + protected function verifyCurrentUserCan($required_permission, $attempted_calculation) |
|
25 | + { |
|
26 | + if (! current_user_can($required_permission)) { |
|
27 | + throw new RestException( |
|
28 | + 'permission_denied', |
|
29 | + sprintf( |
|
30 | + __( |
|
31 | + // @codingStandardsIgnoreStart |
|
32 | + 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', |
|
33 | + // @codingStandardsIgnoreEnd |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + $attempted_calculation, |
|
37 | + EEH_Inflector::pluralize_and_lower($this->getResourceName()), |
|
38 | + $required_permission |
|
39 | + ) |
|
40 | + ); |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * Gets the name of the resource of the called class |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getResourceName() |
|
51 | - { |
|
52 | - return substr(__CLASS__, strrpos(__CLASS__, '\\') + 1); |
|
53 | - } |
|
45 | + /** |
|
46 | + * Gets the name of the resource of the called class |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getResourceName() |
|
51 | + { |
|
52 | + return substr(__CLASS__, strrpos(__CLASS__, '\\') + 1); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Returns an array to be used for the schema for the calculated fields. |
|
57 | - * @since 4.9.68.p |
|
58 | - * @return array keys are calculated field names (eg "optimum_sales_at_start") values are arrays { |
|
59 | - * @type string $description |
|
60 | - * @type string $type, eg "string", "int", "boolean", "object", "array", etc |
|
61 | - * } |
|
62 | - */ |
|
63 | - public function schemaForCalculations() |
|
64 | - { |
|
65 | - return array(); |
|
66 | - } |
|
55 | + /** |
|
56 | + * Returns an array to be used for the schema for the calculated fields. |
|
57 | + * @since 4.9.68.p |
|
58 | + * @return array keys are calculated field names (eg "optimum_sales_at_start") values are arrays { |
|
59 | + * @type string $description |
|
60 | + * @type string $type, eg "string", "int", "boolean", "object", "array", etc |
|
61 | + * } |
|
62 | + */ |
|
63 | + public function schemaForCalculations() |
|
64 | + { |
|
65 | + return array(); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Returns the json schema for the given calculation index. |
|
70 | - * |
|
71 | - * @since 4.9.68.p |
|
72 | - * @param $calculation_index |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function schemaForCalculation($calculation_index) |
|
76 | - { |
|
77 | - $schema_map = $this->schemaForCalculations(); |
|
78 | - return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array(); |
|
79 | - } |
|
68 | + /** |
|
69 | + * Returns the json schema for the given calculation index. |
|
70 | + * |
|
71 | + * @since 4.9.68.p |
|
72 | + * @param $calculation_index |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function schemaForCalculation($calculation_index) |
|
76 | + { |
|
77 | + $schema_map = $this->schemaForCalculations(); |
|
78 | + return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array(); |
|
79 | + } |
|
80 | 80 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function spotsTaken($wpdb_row, $request, $controller) |
177 | 177 | { |
178 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
178 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
179 | 179 | throw new EE_Error( |
180 | 180 | sprintf( |
181 | 181 | __( |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
219 | 219 | { |
220 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
220 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
221 | 221 | throw new EE_Error( |
222 | 222 | sprintf( |
223 | 223 | __( |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
262 | 262 | { |
263 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
263 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
264 | 264 | throw new EE_Error( |
265 | 265 | sprintf( |
266 | 266 | __( |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
296 | 296 | { |
297 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
297 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
298 | 298 | throw new EE_Error( |
299 | 299 | sprintf( |
300 | 300 | __( |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | */ |
414 | 414 | protected function calculateImageData($wpdb_row, $image_size) |
415 | 415 | { |
416 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
416 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
417 | 417 | throw new EE_Error( |
418 | 418 | sprintf( |
419 | 419 | __( |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | $EVT_ID = $wpdb_row['Event_CPT.ID']; |
430 | 430 | $attachment_id = get_post_thumbnail_id($EVT_ID); |
431 | 431 | $data = wp_get_attachment_image_src($attachment_id, $image_size); |
432 | - if (! $data) { |
|
432 | + if ( ! $data) { |
|
433 | 433 | return null; |
434 | 434 | } |
435 | 435 | $generated = true; |
@@ -26,571 +26,571 @@ |
||
26 | 26 | */ |
27 | 27 | class Event extends EventCalculationBase |
28 | 28 | { |
29 | - /** |
|
30 | - * @var EEM_Event |
|
31 | - */ |
|
32 | - protected $event_model; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var EEM_Registration |
|
36 | - */ |
|
37 | - protected $registration_model; |
|
38 | - public function __construct(EEM_Event $event_model, EEM_Registration $registration_model) |
|
39 | - { |
|
40 | - $this->event_model = $event_model; |
|
41 | - $this->registration_model = $registration_model; |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Calculates the total spaces on the event (not subtracting sales, but taking |
|
46 | - * sales into account; so this is the optimum sales that CAN still be achieved) |
|
47 | - * See EE_Event::total_available_spaces( true ); |
|
48 | - * |
|
49 | - * @param array $wpdb_row |
|
50 | - * @param WP_REST_Request $request |
|
51 | - * @param EventControllerBase $controller |
|
52 | - * @return int |
|
53 | - * @throws EE_Error |
|
54 | - * @throws DomainException |
|
55 | - * @throws InvalidDataTypeException |
|
56 | - * @throws InvalidInterfaceException |
|
57 | - * @throws UnexpectedEntityException |
|
58 | - * @throws InvalidArgumentException |
|
59 | - */ |
|
60 | - public function optimumSalesAtStart($wpdb_row, $request, $controller) |
|
61 | - { |
|
62 | - $event_obj = null; |
|
63 | - if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
64 | - $event_obj = $this->event_model->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
65 | - } |
|
66 | - if ($event_obj instanceof EE_Event) { |
|
67 | - return $event_obj->total_available_spaces(); |
|
68 | - } |
|
69 | - throw new EE_Error( |
|
70 | - sprintf( |
|
71 | - __( |
|
72 | - // @codingStandardsIgnoreStart |
|
73 | - 'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', |
|
74 | - // @codingStandardsIgnoreEnd |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - $wpdb_row['Event_CPT.ID'], |
|
78 | - print_r($wpdb_row, true) |
|
79 | - ) |
|
80 | - ); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Calculates the total spaces on the event (ignoring all sales; so this is the optimum |
|
86 | - * sales that COULD have been achieved) |
|
87 | - * See EE_Event::total_available_spaces( true ); |
|
88 | - * |
|
89 | - * @param array $wpdb_row |
|
90 | - * @param WP_REST_Request $request |
|
91 | - * @param EventControllerBase $controller |
|
92 | - * @return int |
|
93 | - * @throws DomainException |
|
94 | - * @throws EE_Error |
|
95 | - * @throws InvalidArgumentException |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - * @throws InvalidInterfaceException |
|
98 | - * @throws UnexpectedEntityException |
|
99 | - */ |
|
100 | - public function optimumSalesNow($wpdb_row, $request, $controller) |
|
101 | - { |
|
102 | - $event_obj = null; |
|
103 | - if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
104 | - $event_obj = $this->event_model->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
105 | - } |
|
106 | - if ($event_obj instanceof EE_Event) { |
|
107 | - return $event_obj->total_available_spaces(true); |
|
108 | - } |
|
109 | - throw new EE_Error( |
|
110 | - sprintf( |
|
111 | - __( |
|
112 | - // @codingStandardsIgnoreStart |
|
113 | - 'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', |
|
114 | - // @codingStandardsIgnoreEnd |
|
115 | - 'event_espresso' |
|
116 | - ), |
|
117 | - $wpdb_row['Event_CPT.ID'], |
|
118 | - print_r($wpdb_row, true) |
|
119 | - ) |
|
120 | - ); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * Like optimum_sales_now, but minus total sales so far. |
|
126 | - * See EE_Event::spaces_remaining_for_sale( true ); |
|
127 | - * |
|
128 | - * @param array $wpdb_row |
|
129 | - * @param WP_REST_Request $request |
|
130 | - * @param EventControllerBase $controller |
|
131 | - * @return int |
|
132 | - * @throws DomainException |
|
133 | - * @throws EE_Error |
|
134 | - * @throws InvalidArgumentException |
|
135 | - * @throws InvalidDataTypeException |
|
136 | - * @throws InvalidInterfaceException |
|
137 | - * @throws UnexpectedEntityException |
|
138 | - */ |
|
139 | - public function spacesRemaining($wpdb_row, $request, $controller) |
|
140 | - { |
|
141 | - $event_obj = null; |
|
142 | - if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
143 | - $event_obj = $this->event_model->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
144 | - } |
|
145 | - if ($event_obj instanceof EE_Event) { |
|
146 | - return $event_obj->spaces_remaining_for_sale(); |
|
147 | - } |
|
148 | - throw new EE_Error( |
|
149 | - sprintf( |
|
150 | - __( |
|
151 | - // @codingStandardsIgnoreStart |
|
152 | - 'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', |
|
153 | - // @codingStandardsIgnoreEnd |
|
154 | - 'event_espresso' |
|
155 | - ), |
|
156 | - $wpdb_row['Event_CPT.ID'], |
|
157 | - print_r($wpdb_row, true) |
|
158 | - ) |
|
159 | - ); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * Counts the number of approved registrations for this event (regardless |
|
165 | - * of how many datetimes each registrations' ticket purchase is for) |
|
166 | - * |
|
167 | - * @param array $wpdb_row |
|
168 | - * @param WP_REST_Request $request |
|
169 | - * @param EventControllerBase $controller |
|
170 | - * @return int |
|
171 | - * @throws EE_Error |
|
172 | - * @throws InvalidArgumentException |
|
173 | - * @throws InvalidDataTypeException |
|
174 | - * @throws InvalidInterfaceException |
|
175 | - */ |
|
176 | - public function spotsTaken($wpdb_row, $request, $controller) |
|
177 | - { |
|
178 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
179 | - throw new EE_Error( |
|
180 | - sprintf( |
|
181 | - __( |
|
182 | - // @codingStandardsIgnoreStart |
|
183 | - 'Cannot calculate spots_taken because the database row %1$s does not have a valid entry for "Event_CPT.ID"', |
|
184 | - // @codingStandardsIgnoreEnd |
|
185 | - 'event_espresso' |
|
186 | - ), |
|
187 | - print_r($wpdb_row, true) |
|
188 | - ) |
|
189 | - ); |
|
190 | - } |
|
191 | - return $this->registration_model->count( |
|
192 | - array( |
|
193 | - array( |
|
194 | - 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
195 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
196 | - ), |
|
197 | - ), |
|
198 | - 'REG_ID', |
|
199 | - true |
|
200 | - ); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * Counts the number of pending-payment registrations for this event (regardless |
|
206 | - * of how many datetimes each registrations' ticket purchase is for) |
|
207 | - * |
|
208 | - * @param array $wpdb_row |
|
209 | - * @param WP_REST_Request $request |
|
210 | - * @param EventControllerBase $controller |
|
211 | - * @return int |
|
212 | - * @throws EE_Error |
|
213 | - * @throws InvalidArgumentException |
|
214 | - * @throws InvalidDataTypeException |
|
215 | - * @throws InvalidInterfaceException |
|
216 | - * @throws RestException |
|
217 | - */ |
|
218 | - public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
|
219 | - { |
|
220 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
221 | - throw new EE_Error( |
|
222 | - sprintf( |
|
223 | - __( |
|
224 | - // @codingStandardsIgnoreStart |
|
225 | - 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
226 | - // @codingStandardsIgnoreEnd |
|
227 | - 'event_espresso' |
|
228 | - ), |
|
229 | - print_r($wpdb_row, true) |
|
230 | - ) |
|
231 | - ); |
|
232 | - } |
|
233 | - $this->verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment'); |
|
234 | - return $this->registration_model->count( |
|
235 | - array( |
|
236 | - array( |
|
237 | - 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
238 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
239 | - ), |
|
240 | - ), |
|
241 | - 'REG_ID', |
|
242 | - true |
|
243 | - ); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Counts all the registrations who have checked into one of this events' datetimes |
|
249 | - * See EE_Event::total_available_spaces( false ); |
|
250 | - * |
|
251 | - * @param array $wpdb_row |
|
252 | - * @param WP_REST_Request $request |
|
253 | - * @param EventControllerBase $controller |
|
254 | - * @return int|null if permission denied |
|
255 | - * @throws EE_Error |
|
256 | - * @throws InvalidArgumentException |
|
257 | - * @throws InvalidDataTypeException |
|
258 | - * @throws InvalidInterfaceException |
|
259 | - * @throws RestException |
|
260 | - */ |
|
261 | - public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
|
262 | - { |
|
263 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
264 | - throw new EE_Error( |
|
265 | - sprintf( |
|
266 | - __( |
|
267 | - // @codingStandardsIgnoreStart |
|
268 | - 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
269 | - // @codingStandardsIgnoreEnd |
|
270 | - 'event_espresso' |
|
271 | - ), |
|
272 | - print_r($wpdb_row, true) |
|
273 | - ) |
|
274 | - ); |
|
275 | - } |
|
276 | - $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count'); |
|
277 | - return $this->registration_model->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true); |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * Counts all the registrations who have checked out of one of this events' datetimes |
|
283 | - * See EE_Event::total_available_spaces( false ); |
|
284 | - * |
|
285 | - * @param array $wpdb_row |
|
286 | - * @param WP_REST_Request $request |
|
287 | - * @param EventControllerBase $controller |
|
288 | - * @return int |
|
289 | - * @throws EE_Error |
|
290 | - * @throws InvalidArgumentException |
|
291 | - * @throws InvalidDataTypeException |
|
292 | - * @throws InvalidInterfaceException |
|
293 | - * @throws RestException |
|
294 | - */ |
|
295 | - public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
|
296 | - { |
|
297 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
298 | - throw new EE_Error( |
|
299 | - sprintf( |
|
300 | - __( |
|
301 | - // @codingStandardsIgnoreStart |
|
302 | - 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
303 | - // @codingStandardsIgnoreEnd |
|
304 | - 'event_espresso' |
|
305 | - ), |
|
306 | - print_r($wpdb_row, true) |
|
307 | - ) |
|
308 | - ); |
|
309 | - } |
|
310 | - $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count'); |
|
311 | - return $this->registration_model->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false); |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * Gets the thumbnail image |
|
317 | - * |
|
318 | - * @param array $wpdb_row |
|
319 | - * @param WP_REST_Request $request |
|
320 | - * @param EventControllerBase $controller |
|
321 | - * @return array |
|
322 | - * @throws EE_Error |
|
323 | - */ |
|
324 | - public function imageThumbnail($wpdb_row, $request, $controller) |
|
325 | - { |
|
326 | - return self::calculateImageData($wpdb_row, 'thumbnail'); |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * Gets the medium image |
|
332 | - * |
|
333 | - * @param array $wpdb_row |
|
334 | - * @param WP_REST_Request $request |
|
335 | - * @param EventControllerBase $controller |
|
336 | - * @return array |
|
337 | - * @throws EE_Error |
|
338 | - */ |
|
339 | - public function imageMedium($wpdb_row, $request, $controller) |
|
340 | - { |
|
341 | - return self::calculateImageData($wpdb_row, 'medium'); |
|
342 | - } |
|
343 | - |
|
344 | - |
|
345 | - /** |
|
346 | - * Gets the medium-large image |
|
347 | - * |
|
348 | - * @param array $wpdb_row |
|
349 | - * @param WP_REST_Request $request |
|
350 | - * @param EventControllerBase $controller |
|
351 | - * @return array |
|
352 | - * @throws EE_Error |
|
353 | - */ |
|
354 | - public function imageMediumLarge($wpdb_row, $request, $controller) |
|
355 | - { |
|
356 | - return self::calculateImageData($wpdb_row, 'medium_large'); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * Gets the large image |
|
362 | - * |
|
363 | - * @param array $wpdb_row |
|
364 | - * @param WP_REST_Request $request |
|
365 | - * @param EventControllerBase $controller |
|
366 | - * @return array |
|
367 | - * @throws EE_Error |
|
368 | - */ |
|
369 | - public function imageLarge($wpdb_row, $request, $controller) |
|
370 | - { |
|
371 | - return self::calculateImageData($wpdb_row, 'large'); |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * Gets the post-thumbnail image |
|
377 | - * |
|
378 | - * @param array $wpdb_row |
|
379 | - * @param WP_REST_Request $request |
|
380 | - * @param EventControllerBase $controller |
|
381 | - * @return array |
|
382 | - * @throws EE_Error |
|
383 | - */ |
|
384 | - public function imagePostThumbnail($wpdb_row, $request, $controller) |
|
385 | - { |
|
386 | - return self::calculateImageData($wpdb_row, 'post-thumbnail'); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - /** |
|
391 | - * Gets the full size image |
|
392 | - * |
|
393 | - * @param array $wpdb_row |
|
394 | - * @param WP_REST_Request $request |
|
395 | - * @param EventControllerBase $controller |
|
396 | - * @return array |
|
397 | - * @throws EE_Error |
|
398 | - */ |
|
399 | - public function imageFull($wpdb_row, $request, $controller) |
|
400 | - { |
|
401 | - return self::calculateImageData($wpdb_row, 'full'); |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * Gets image specs and formats them for the display in the API, |
|
407 | - * according to the image size requested |
|
408 | - * |
|
409 | - * @param array $wpdb_row |
|
410 | - * @param string $image_size one of these: thumbnail, medium, medium_large, large, post-thumbnail, full |
|
411 | - * @return array|false if no such image exists. If array it will have keys 'url', 'width', 'height' and 'original' |
|
412 | - * @throws EE_Error |
|
413 | - */ |
|
414 | - protected function calculateImageData($wpdb_row, $image_size) |
|
415 | - { |
|
416 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
417 | - throw new EE_Error( |
|
418 | - sprintf( |
|
419 | - __( |
|
420 | - // @codingStandardsIgnoreStart |
|
421 | - 'Cannot calculate image because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
422 | - // @codingStandardsIgnoreEnd |
|
423 | - 'event_espresso' |
|
424 | - ), |
|
425 | - print_r($wpdb_row, true) |
|
426 | - ) |
|
427 | - ); |
|
428 | - } |
|
429 | - $EVT_ID = $wpdb_row['Event_CPT.ID']; |
|
430 | - $attachment_id = get_post_thumbnail_id($EVT_ID); |
|
431 | - $data = wp_get_attachment_image_src($attachment_id, $image_size); |
|
432 | - if (! $data) { |
|
433 | - return null; |
|
434 | - } |
|
435 | - $generated = true; |
|
436 | - if (isset($data[3])) { |
|
437 | - $generated = $data[3]; |
|
438 | - } |
|
439 | - return array( |
|
440 | - 'url' => $data[0], |
|
441 | - 'width' => $data[1], |
|
442 | - 'height' => $data[2], |
|
443 | - 'generated' => $generated, |
|
444 | - ); |
|
445 | - } |
|
446 | - |
|
447 | - |
|
448 | - /** |
|
449 | - * Returns true if the array of data contains 'Event_CPT.ID'. False otherwise |
|
450 | - * |
|
451 | - * @param array $wpdb_row |
|
452 | - * @return bool |
|
453 | - */ |
|
454 | - protected function wpdbRowHasEventId($wpdb_row) |
|
455 | - { |
|
456 | - return (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID'])); |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - /** |
|
461 | - * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
462 | - * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
463 | - * |
|
464 | - * @since 4.9.68.p |
|
465 | - * @return array |
|
466 | - */ |
|
467 | - public function schemaForCalculations() |
|
468 | - { |
|
469 | - $image_object_properties = array( |
|
470 | - 'url' => array( |
|
471 | - 'type' => 'string', |
|
472 | - ), |
|
473 | - 'width' => array( |
|
474 | - 'type' => 'number', |
|
475 | - ), |
|
476 | - 'height' => array( |
|
477 | - 'type' => 'number', |
|
478 | - ), |
|
479 | - 'generated' => array( |
|
480 | - 'type' => 'boolean', |
|
481 | - ), |
|
482 | - ); |
|
483 | - return array( |
|
484 | - 'optimum_sales_at_start' => array( |
|
485 | - 'description' => esc_html__( |
|
486 | - 'The total spaces on the event (not subtracting sales, but taking sales into account; so this is the optimum sales that CAN still be achieved.', |
|
487 | - 'event_espresso' |
|
488 | - ), |
|
489 | - 'type' => 'number', |
|
490 | - 'protected' => true, |
|
491 | - ), |
|
492 | - 'optimum_sales_now' => array( |
|
493 | - 'description' => esc_html__( |
|
494 | - 'The total spaces on the event (ignoring all sales; so this is the optimum sales that could have been achieved.', |
|
495 | - 'event_espresso' |
|
496 | - ), |
|
497 | - 'type' => 'number', |
|
498 | - 'protected' => true, |
|
499 | - ), |
|
500 | - 'spaces_remaining' => array( |
|
501 | - 'description' => esc_html__( |
|
502 | - 'The optimum_sales_number result, minus total sales so far.', |
|
503 | - 'event_espresso' |
|
504 | - ), |
|
505 | - 'type' => 'number', |
|
506 | - 'protected' => true, |
|
507 | - ), |
|
508 | - 'spots_taken' => array( |
|
509 | - 'description' => esc_html__( |
|
510 | - 'The number of approved registrations for this event (regardless of how many datetimes each registration\'s ticket purchase is for)', |
|
511 | - 'event_espresso' |
|
512 | - ), |
|
513 | - 'type' => 'number', |
|
514 | - 'protected' => true, |
|
515 | - ), |
|
516 | - 'spots_taken_pending_payment' => array( |
|
517 | - 'description' => esc_html__( |
|
518 | - 'The number of pending-payment registrations for this event (regardless of how many datetimes each registration\'s ticket purchase is for)', |
|
519 | - 'event_espresso' |
|
520 | - ), |
|
521 | - 'type' => 'number', |
|
522 | - 'protected' => true, |
|
523 | - ), |
|
524 | - 'registrations_checked_in_count' => array( |
|
525 | - 'description' => esc_html__( |
|
526 | - 'The count of all the registrations who have checked into one of this event\'s datetimes.', |
|
527 | - 'event_espresso' |
|
528 | - ), |
|
529 | - 'type' => 'number', |
|
530 | - 'protected' => true, |
|
531 | - ), |
|
532 | - 'registrations_checked_out_count' => array( |
|
533 | - 'description' => esc_html__( |
|
534 | - 'The count of all registrations who have checked out of one of this event\'s datetimes.', |
|
535 | - 'event_espresso' |
|
536 | - ), |
|
537 | - 'type' => 'number', |
|
538 | - 'protected' => true, |
|
539 | - ), |
|
540 | - 'image_thumbnail' => array( |
|
541 | - 'description' => esc_html__( |
|
542 | - 'The thumbnail image data.', |
|
543 | - 'event_espresso' |
|
544 | - ), |
|
545 | - 'type' => 'object', |
|
546 | - 'properties' => $image_object_properties, |
|
547 | - 'additionalProperties' => false, |
|
548 | - ), |
|
549 | - 'image_medium' => array( |
|
550 | - 'description' => esc_html__( |
|
551 | - 'The medium image data.', |
|
552 | - 'event_espresso' |
|
553 | - ), |
|
554 | - 'type' => 'object', |
|
555 | - 'properties' => $image_object_properties, |
|
556 | - 'additionalProperties' => false, |
|
557 | - ), |
|
558 | - 'image_medium_large' => array( |
|
559 | - 'description' => esc_html__( |
|
560 | - 'The medium-large image data.', |
|
561 | - 'event_espresso' |
|
562 | - ), |
|
563 | - 'type' => 'object', |
|
564 | - 'properties' => $image_object_properties, |
|
565 | - 'additionalProperties' => false, |
|
566 | - ), |
|
567 | - 'image_large' => array( |
|
568 | - 'description' => esc_html__( |
|
569 | - 'The large image data.', |
|
570 | - 'event_espresso' |
|
571 | - ), |
|
572 | - 'type' => 'object', |
|
573 | - 'properties' => $image_object_properties, |
|
574 | - 'additionalProperties' => false, |
|
575 | - ), |
|
576 | - 'image_post_thumbnail' => array( |
|
577 | - 'description' => esc_html__( |
|
578 | - 'The post-thumbnail image data.', |
|
579 | - 'event_espresso' |
|
580 | - ), |
|
581 | - 'type' => 'object', |
|
582 | - 'properties' => $image_object_properties, |
|
583 | - 'additionalProperties' => false, |
|
584 | - ), |
|
585 | - 'image_full' => array( |
|
586 | - 'description' => esc_html__( |
|
587 | - 'The full size image data', |
|
588 | - 'event_espresso' |
|
589 | - ), |
|
590 | - 'type' => 'object', |
|
591 | - 'properties' => $image_object_properties, |
|
592 | - 'additionalProperties' => false, |
|
593 | - ), |
|
594 | - ); |
|
595 | - } |
|
29 | + /** |
|
30 | + * @var EEM_Event |
|
31 | + */ |
|
32 | + protected $event_model; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var EEM_Registration |
|
36 | + */ |
|
37 | + protected $registration_model; |
|
38 | + public function __construct(EEM_Event $event_model, EEM_Registration $registration_model) |
|
39 | + { |
|
40 | + $this->event_model = $event_model; |
|
41 | + $this->registration_model = $registration_model; |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Calculates the total spaces on the event (not subtracting sales, but taking |
|
46 | + * sales into account; so this is the optimum sales that CAN still be achieved) |
|
47 | + * See EE_Event::total_available_spaces( true ); |
|
48 | + * |
|
49 | + * @param array $wpdb_row |
|
50 | + * @param WP_REST_Request $request |
|
51 | + * @param EventControllerBase $controller |
|
52 | + * @return int |
|
53 | + * @throws EE_Error |
|
54 | + * @throws DomainException |
|
55 | + * @throws InvalidDataTypeException |
|
56 | + * @throws InvalidInterfaceException |
|
57 | + * @throws UnexpectedEntityException |
|
58 | + * @throws InvalidArgumentException |
|
59 | + */ |
|
60 | + public function optimumSalesAtStart($wpdb_row, $request, $controller) |
|
61 | + { |
|
62 | + $event_obj = null; |
|
63 | + if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
64 | + $event_obj = $this->event_model->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
65 | + } |
|
66 | + if ($event_obj instanceof EE_Event) { |
|
67 | + return $event_obj->total_available_spaces(); |
|
68 | + } |
|
69 | + throw new EE_Error( |
|
70 | + sprintf( |
|
71 | + __( |
|
72 | + // @codingStandardsIgnoreStart |
|
73 | + 'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', |
|
74 | + // @codingStandardsIgnoreEnd |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + $wpdb_row['Event_CPT.ID'], |
|
78 | + print_r($wpdb_row, true) |
|
79 | + ) |
|
80 | + ); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Calculates the total spaces on the event (ignoring all sales; so this is the optimum |
|
86 | + * sales that COULD have been achieved) |
|
87 | + * See EE_Event::total_available_spaces( true ); |
|
88 | + * |
|
89 | + * @param array $wpdb_row |
|
90 | + * @param WP_REST_Request $request |
|
91 | + * @param EventControllerBase $controller |
|
92 | + * @return int |
|
93 | + * @throws DomainException |
|
94 | + * @throws EE_Error |
|
95 | + * @throws InvalidArgumentException |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + * @throws InvalidInterfaceException |
|
98 | + * @throws UnexpectedEntityException |
|
99 | + */ |
|
100 | + public function optimumSalesNow($wpdb_row, $request, $controller) |
|
101 | + { |
|
102 | + $event_obj = null; |
|
103 | + if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
104 | + $event_obj = $this->event_model->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
105 | + } |
|
106 | + if ($event_obj instanceof EE_Event) { |
|
107 | + return $event_obj->total_available_spaces(true); |
|
108 | + } |
|
109 | + throw new EE_Error( |
|
110 | + sprintf( |
|
111 | + __( |
|
112 | + // @codingStandardsIgnoreStart |
|
113 | + 'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', |
|
114 | + // @codingStandardsIgnoreEnd |
|
115 | + 'event_espresso' |
|
116 | + ), |
|
117 | + $wpdb_row['Event_CPT.ID'], |
|
118 | + print_r($wpdb_row, true) |
|
119 | + ) |
|
120 | + ); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * Like optimum_sales_now, but minus total sales so far. |
|
126 | + * See EE_Event::spaces_remaining_for_sale( true ); |
|
127 | + * |
|
128 | + * @param array $wpdb_row |
|
129 | + * @param WP_REST_Request $request |
|
130 | + * @param EventControllerBase $controller |
|
131 | + * @return int |
|
132 | + * @throws DomainException |
|
133 | + * @throws EE_Error |
|
134 | + * @throws InvalidArgumentException |
|
135 | + * @throws InvalidDataTypeException |
|
136 | + * @throws InvalidInterfaceException |
|
137 | + * @throws UnexpectedEntityException |
|
138 | + */ |
|
139 | + public function spacesRemaining($wpdb_row, $request, $controller) |
|
140 | + { |
|
141 | + $event_obj = null; |
|
142 | + if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
143 | + $event_obj = $this->event_model->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
144 | + } |
|
145 | + if ($event_obj instanceof EE_Event) { |
|
146 | + return $event_obj->spaces_remaining_for_sale(); |
|
147 | + } |
|
148 | + throw new EE_Error( |
|
149 | + sprintf( |
|
150 | + __( |
|
151 | + // @codingStandardsIgnoreStart |
|
152 | + 'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', |
|
153 | + // @codingStandardsIgnoreEnd |
|
154 | + 'event_espresso' |
|
155 | + ), |
|
156 | + $wpdb_row['Event_CPT.ID'], |
|
157 | + print_r($wpdb_row, true) |
|
158 | + ) |
|
159 | + ); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * Counts the number of approved registrations for this event (regardless |
|
165 | + * of how many datetimes each registrations' ticket purchase is for) |
|
166 | + * |
|
167 | + * @param array $wpdb_row |
|
168 | + * @param WP_REST_Request $request |
|
169 | + * @param EventControllerBase $controller |
|
170 | + * @return int |
|
171 | + * @throws EE_Error |
|
172 | + * @throws InvalidArgumentException |
|
173 | + * @throws InvalidDataTypeException |
|
174 | + * @throws InvalidInterfaceException |
|
175 | + */ |
|
176 | + public function spotsTaken($wpdb_row, $request, $controller) |
|
177 | + { |
|
178 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
179 | + throw new EE_Error( |
|
180 | + sprintf( |
|
181 | + __( |
|
182 | + // @codingStandardsIgnoreStart |
|
183 | + 'Cannot calculate spots_taken because the database row %1$s does not have a valid entry for "Event_CPT.ID"', |
|
184 | + // @codingStandardsIgnoreEnd |
|
185 | + 'event_espresso' |
|
186 | + ), |
|
187 | + print_r($wpdb_row, true) |
|
188 | + ) |
|
189 | + ); |
|
190 | + } |
|
191 | + return $this->registration_model->count( |
|
192 | + array( |
|
193 | + array( |
|
194 | + 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
195 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
196 | + ), |
|
197 | + ), |
|
198 | + 'REG_ID', |
|
199 | + true |
|
200 | + ); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * Counts the number of pending-payment registrations for this event (regardless |
|
206 | + * of how many datetimes each registrations' ticket purchase is for) |
|
207 | + * |
|
208 | + * @param array $wpdb_row |
|
209 | + * @param WP_REST_Request $request |
|
210 | + * @param EventControllerBase $controller |
|
211 | + * @return int |
|
212 | + * @throws EE_Error |
|
213 | + * @throws InvalidArgumentException |
|
214 | + * @throws InvalidDataTypeException |
|
215 | + * @throws InvalidInterfaceException |
|
216 | + * @throws RestException |
|
217 | + */ |
|
218 | + public function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
|
219 | + { |
|
220 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
221 | + throw new EE_Error( |
|
222 | + sprintf( |
|
223 | + __( |
|
224 | + // @codingStandardsIgnoreStart |
|
225 | + 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
226 | + // @codingStandardsIgnoreEnd |
|
227 | + 'event_espresso' |
|
228 | + ), |
|
229 | + print_r($wpdb_row, true) |
|
230 | + ) |
|
231 | + ); |
|
232 | + } |
|
233 | + $this->verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment'); |
|
234 | + return $this->registration_model->count( |
|
235 | + array( |
|
236 | + array( |
|
237 | + 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
238 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
239 | + ), |
|
240 | + ), |
|
241 | + 'REG_ID', |
|
242 | + true |
|
243 | + ); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Counts all the registrations who have checked into one of this events' datetimes |
|
249 | + * See EE_Event::total_available_spaces( false ); |
|
250 | + * |
|
251 | + * @param array $wpdb_row |
|
252 | + * @param WP_REST_Request $request |
|
253 | + * @param EventControllerBase $controller |
|
254 | + * @return int|null if permission denied |
|
255 | + * @throws EE_Error |
|
256 | + * @throws InvalidArgumentException |
|
257 | + * @throws InvalidDataTypeException |
|
258 | + * @throws InvalidInterfaceException |
|
259 | + * @throws RestException |
|
260 | + */ |
|
261 | + public function registrationsCheckedInCount($wpdb_row, $request, $controller) |
|
262 | + { |
|
263 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
264 | + throw new EE_Error( |
|
265 | + sprintf( |
|
266 | + __( |
|
267 | + // @codingStandardsIgnoreStart |
|
268 | + 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
269 | + // @codingStandardsIgnoreEnd |
|
270 | + 'event_espresso' |
|
271 | + ), |
|
272 | + print_r($wpdb_row, true) |
|
273 | + ) |
|
274 | + ); |
|
275 | + } |
|
276 | + $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count'); |
|
277 | + return $this->registration_model->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true); |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * Counts all the registrations who have checked out of one of this events' datetimes |
|
283 | + * See EE_Event::total_available_spaces( false ); |
|
284 | + * |
|
285 | + * @param array $wpdb_row |
|
286 | + * @param WP_REST_Request $request |
|
287 | + * @param EventControllerBase $controller |
|
288 | + * @return int |
|
289 | + * @throws EE_Error |
|
290 | + * @throws InvalidArgumentException |
|
291 | + * @throws InvalidDataTypeException |
|
292 | + * @throws InvalidInterfaceException |
|
293 | + * @throws RestException |
|
294 | + */ |
|
295 | + public function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
|
296 | + { |
|
297 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
298 | + throw new EE_Error( |
|
299 | + sprintf( |
|
300 | + __( |
|
301 | + // @codingStandardsIgnoreStart |
|
302 | + 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
303 | + // @codingStandardsIgnoreEnd |
|
304 | + 'event_espresso' |
|
305 | + ), |
|
306 | + print_r($wpdb_row, true) |
|
307 | + ) |
|
308 | + ); |
|
309 | + } |
|
310 | + $this->verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count'); |
|
311 | + return $this->registration_model->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false); |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * Gets the thumbnail image |
|
317 | + * |
|
318 | + * @param array $wpdb_row |
|
319 | + * @param WP_REST_Request $request |
|
320 | + * @param EventControllerBase $controller |
|
321 | + * @return array |
|
322 | + * @throws EE_Error |
|
323 | + */ |
|
324 | + public function imageThumbnail($wpdb_row, $request, $controller) |
|
325 | + { |
|
326 | + return self::calculateImageData($wpdb_row, 'thumbnail'); |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * Gets the medium image |
|
332 | + * |
|
333 | + * @param array $wpdb_row |
|
334 | + * @param WP_REST_Request $request |
|
335 | + * @param EventControllerBase $controller |
|
336 | + * @return array |
|
337 | + * @throws EE_Error |
|
338 | + */ |
|
339 | + public function imageMedium($wpdb_row, $request, $controller) |
|
340 | + { |
|
341 | + return self::calculateImageData($wpdb_row, 'medium'); |
|
342 | + } |
|
343 | + |
|
344 | + |
|
345 | + /** |
|
346 | + * Gets the medium-large image |
|
347 | + * |
|
348 | + * @param array $wpdb_row |
|
349 | + * @param WP_REST_Request $request |
|
350 | + * @param EventControllerBase $controller |
|
351 | + * @return array |
|
352 | + * @throws EE_Error |
|
353 | + */ |
|
354 | + public function imageMediumLarge($wpdb_row, $request, $controller) |
|
355 | + { |
|
356 | + return self::calculateImageData($wpdb_row, 'medium_large'); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * Gets the large image |
|
362 | + * |
|
363 | + * @param array $wpdb_row |
|
364 | + * @param WP_REST_Request $request |
|
365 | + * @param EventControllerBase $controller |
|
366 | + * @return array |
|
367 | + * @throws EE_Error |
|
368 | + */ |
|
369 | + public function imageLarge($wpdb_row, $request, $controller) |
|
370 | + { |
|
371 | + return self::calculateImageData($wpdb_row, 'large'); |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * Gets the post-thumbnail image |
|
377 | + * |
|
378 | + * @param array $wpdb_row |
|
379 | + * @param WP_REST_Request $request |
|
380 | + * @param EventControllerBase $controller |
|
381 | + * @return array |
|
382 | + * @throws EE_Error |
|
383 | + */ |
|
384 | + public function imagePostThumbnail($wpdb_row, $request, $controller) |
|
385 | + { |
|
386 | + return self::calculateImageData($wpdb_row, 'post-thumbnail'); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * Gets the full size image |
|
392 | + * |
|
393 | + * @param array $wpdb_row |
|
394 | + * @param WP_REST_Request $request |
|
395 | + * @param EventControllerBase $controller |
|
396 | + * @return array |
|
397 | + * @throws EE_Error |
|
398 | + */ |
|
399 | + public function imageFull($wpdb_row, $request, $controller) |
|
400 | + { |
|
401 | + return self::calculateImageData($wpdb_row, 'full'); |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * Gets image specs and formats them for the display in the API, |
|
407 | + * according to the image size requested |
|
408 | + * |
|
409 | + * @param array $wpdb_row |
|
410 | + * @param string $image_size one of these: thumbnail, medium, medium_large, large, post-thumbnail, full |
|
411 | + * @return array|false if no such image exists. If array it will have keys 'url', 'width', 'height' and 'original' |
|
412 | + * @throws EE_Error |
|
413 | + */ |
|
414 | + protected function calculateImageData($wpdb_row, $image_size) |
|
415 | + { |
|
416 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
417 | + throw new EE_Error( |
|
418 | + sprintf( |
|
419 | + __( |
|
420 | + // @codingStandardsIgnoreStart |
|
421 | + 'Cannot calculate image because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
422 | + // @codingStandardsIgnoreEnd |
|
423 | + 'event_espresso' |
|
424 | + ), |
|
425 | + print_r($wpdb_row, true) |
|
426 | + ) |
|
427 | + ); |
|
428 | + } |
|
429 | + $EVT_ID = $wpdb_row['Event_CPT.ID']; |
|
430 | + $attachment_id = get_post_thumbnail_id($EVT_ID); |
|
431 | + $data = wp_get_attachment_image_src($attachment_id, $image_size); |
|
432 | + if (! $data) { |
|
433 | + return null; |
|
434 | + } |
|
435 | + $generated = true; |
|
436 | + if (isset($data[3])) { |
|
437 | + $generated = $data[3]; |
|
438 | + } |
|
439 | + return array( |
|
440 | + 'url' => $data[0], |
|
441 | + 'width' => $data[1], |
|
442 | + 'height' => $data[2], |
|
443 | + 'generated' => $generated, |
|
444 | + ); |
|
445 | + } |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * Returns true if the array of data contains 'Event_CPT.ID'. False otherwise |
|
450 | + * |
|
451 | + * @param array $wpdb_row |
|
452 | + * @return bool |
|
453 | + */ |
|
454 | + protected function wpdbRowHasEventId($wpdb_row) |
|
455 | + { |
|
456 | + return (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID'])); |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + /** |
|
461 | + * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
462 | + * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
463 | + * |
|
464 | + * @since 4.9.68.p |
|
465 | + * @return array |
|
466 | + */ |
|
467 | + public function schemaForCalculations() |
|
468 | + { |
|
469 | + $image_object_properties = array( |
|
470 | + 'url' => array( |
|
471 | + 'type' => 'string', |
|
472 | + ), |
|
473 | + 'width' => array( |
|
474 | + 'type' => 'number', |
|
475 | + ), |
|
476 | + 'height' => array( |
|
477 | + 'type' => 'number', |
|
478 | + ), |
|
479 | + 'generated' => array( |
|
480 | + 'type' => 'boolean', |
|
481 | + ), |
|
482 | + ); |
|
483 | + return array( |
|
484 | + 'optimum_sales_at_start' => array( |
|
485 | + 'description' => esc_html__( |
|
486 | + 'The total spaces on the event (not subtracting sales, but taking sales into account; so this is the optimum sales that CAN still be achieved.', |
|
487 | + 'event_espresso' |
|
488 | + ), |
|
489 | + 'type' => 'number', |
|
490 | + 'protected' => true, |
|
491 | + ), |
|
492 | + 'optimum_sales_now' => array( |
|
493 | + 'description' => esc_html__( |
|
494 | + 'The total spaces on the event (ignoring all sales; so this is the optimum sales that could have been achieved.', |
|
495 | + 'event_espresso' |
|
496 | + ), |
|
497 | + 'type' => 'number', |
|
498 | + 'protected' => true, |
|
499 | + ), |
|
500 | + 'spaces_remaining' => array( |
|
501 | + 'description' => esc_html__( |
|
502 | + 'The optimum_sales_number result, minus total sales so far.', |
|
503 | + 'event_espresso' |
|
504 | + ), |
|
505 | + 'type' => 'number', |
|
506 | + 'protected' => true, |
|
507 | + ), |
|
508 | + 'spots_taken' => array( |
|
509 | + 'description' => esc_html__( |
|
510 | + 'The number of approved registrations for this event (regardless of how many datetimes each registration\'s ticket purchase is for)', |
|
511 | + 'event_espresso' |
|
512 | + ), |
|
513 | + 'type' => 'number', |
|
514 | + 'protected' => true, |
|
515 | + ), |
|
516 | + 'spots_taken_pending_payment' => array( |
|
517 | + 'description' => esc_html__( |
|
518 | + 'The number of pending-payment registrations for this event (regardless of how many datetimes each registration\'s ticket purchase is for)', |
|
519 | + 'event_espresso' |
|
520 | + ), |
|
521 | + 'type' => 'number', |
|
522 | + 'protected' => true, |
|
523 | + ), |
|
524 | + 'registrations_checked_in_count' => array( |
|
525 | + 'description' => esc_html__( |
|
526 | + 'The count of all the registrations who have checked into one of this event\'s datetimes.', |
|
527 | + 'event_espresso' |
|
528 | + ), |
|
529 | + 'type' => 'number', |
|
530 | + 'protected' => true, |
|
531 | + ), |
|
532 | + 'registrations_checked_out_count' => array( |
|
533 | + 'description' => esc_html__( |
|
534 | + 'The count of all registrations who have checked out of one of this event\'s datetimes.', |
|
535 | + 'event_espresso' |
|
536 | + ), |
|
537 | + 'type' => 'number', |
|
538 | + 'protected' => true, |
|
539 | + ), |
|
540 | + 'image_thumbnail' => array( |
|
541 | + 'description' => esc_html__( |
|
542 | + 'The thumbnail image data.', |
|
543 | + 'event_espresso' |
|
544 | + ), |
|
545 | + 'type' => 'object', |
|
546 | + 'properties' => $image_object_properties, |
|
547 | + 'additionalProperties' => false, |
|
548 | + ), |
|
549 | + 'image_medium' => array( |
|
550 | + 'description' => esc_html__( |
|
551 | + 'The medium image data.', |
|
552 | + 'event_espresso' |
|
553 | + ), |
|
554 | + 'type' => 'object', |
|
555 | + 'properties' => $image_object_properties, |
|
556 | + 'additionalProperties' => false, |
|
557 | + ), |
|
558 | + 'image_medium_large' => array( |
|
559 | + 'description' => esc_html__( |
|
560 | + 'The medium-large image data.', |
|
561 | + 'event_espresso' |
|
562 | + ), |
|
563 | + 'type' => 'object', |
|
564 | + 'properties' => $image_object_properties, |
|
565 | + 'additionalProperties' => false, |
|
566 | + ), |
|
567 | + 'image_large' => array( |
|
568 | + 'description' => esc_html__( |
|
569 | + 'The large image data.', |
|
570 | + 'event_espresso' |
|
571 | + ), |
|
572 | + 'type' => 'object', |
|
573 | + 'properties' => $image_object_properties, |
|
574 | + 'additionalProperties' => false, |
|
575 | + ), |
|
576 | + 'image_post_thumbnail' => array( |
|
577 | + 'description' => esc_html__( |
|
578 | + 'The post-thumbnail image data.', |
|
579 | + 'event_espresso' |
|
580 | + ), |
|
581 | + 'type' => 'object', |
|
582 | + 'properties' => $image_object_properties, |
|
583 | + 'additionalProperties' => false, |
|
584 | + ), |
|
585 | + 'image_full' => array( |
|
586 | + 'description' => esc_html__( |
|
587 | + 'The full size image data', |
|
588 | + 'event_espresso' |
|
589 | + ), |
|
590 | + 'type' => 'object', |
|
591 | + 'properties' => $image_object_properties, |
|
592 | + 'additionalProperties' => false, |
|
593 | + ), |
|
594 | + ); |
|
595 | + } |
|
596 | 596 | } |
@@ -24,92 +24,92 @@ |
||
24 | 24 | { |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * the actual shortcode tag that gets registered with WordPress |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getTag() |
|
33 | - { |
|
34 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
35 | - } |
|
27 | + /** |
|
28 | + * the actual shortcode tag that gets registered with WordPress |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getTag() |
|
33 | + { |
|
34 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * the time in seconds to cache the results of the processShortcode() method |
|
40 | - * 0 means the processShortcode() results will NOT be cached at all |
|
41 | - * |
|
42 | - * @return int |
|
43 | - */ |
|
44 | - public function cacheExpiration() |
|
45 | - { |
|
46 | - return 0; |
|
47 | - } |
|
38 | + /** |
|
39 | + * the time in seconds to cache the results of the processShortcode() method |
|
40 | + * 0 means the processShortcode() results will NOT be cached at all |
|
41 | + * |
|
42 | + * @return int |
|
43 | + */ |
|
44 | + public function cacheExpiration() |
|
45 | + { |
|
46 | + return 0; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
52 | - * this may be required for shortcodes that utilize a corresponding module, |
|
53 | - * and need to enqueue assets for that module |
|
54 | - * |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function initializeShortcode() |
|
58 | - { |
|
59 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
60 | - $this->shortcodeHasBeenInitialized(); |
|
61 | - } |
|
50 | + /** |
|
51 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
52 | + * this may be required for shortcodes that utilize a corresponding module, |
|
53 | + * and need to enqueue assets for that module |
|
54 | + * |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function initializeShortcode() |
|
58 | + { |
|
59 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
60 | + $this->shortcodeHasBeenInitialized(); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * callback that runs when the shortcode is encountered in post content. |
|
66 | - * IMPORTANT !!! |
|
67 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
68 | - * |
|
69 | - * @param array $attributes |
|
70 | - * @return string |
|
71 | - * @throws InvalidArgumentException |
|
72 | - * @throws EE_Error |
|
73 | - * @throws InvalidDataTypeException |
|
74 | - * @throws InvalidInterfaceException |
|
75 | - * @throws ReflectionException |
|
76 | - * @throws Exception |
|
77 | - */ |
|
78 | - public function processShortcode($attributes = array()) |
|
79 | - { |
|
80 | - extract($attributes, EXTR_OVERWRITE); |
|
81 | - $event_id = isset($event_id) ? $event_id : 0; |
|
82 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
83 | - if (! $event instanceof EE_Event) { |
|
84 | - if (WP_DEBUG === true && current_user_can('edit_pages')) { |
|
85 | - new ExceptionStackTraceDisplay( |
|
86 | - new InvalidArgumentException( |
|
87 | - sprintf( |
|
88 | - esc_html__( |
|
89 | - 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.', |
|
90 | - 'event_espresso' |
|
91 | - ), |
|
92 | - $this->getTag(), |
|
93 | - $event_id, |
|
94 | - 'event_id', |
|
95 | - '<br />' |
|
96 | - ) |
|
97 | - ) |
|
98 | - ); |
|
99 | - return ''; |
|
100 | - } |
|
101 | - return sprintf( |
|
102 | - esc_html__( |
|
103 | - 'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.', |
|
104 | - 'event_espresso' |
|
105 | - ), |
|
106 | - $event_id |
|
107 | - ); |
|
108 | - } |
|
109 | - ob_start(); |
|
110 | - do_action('AHEE_event_details_before_post', $event_id); |
|
111 | - espresso_ticket_selector($event); |
|
112 | - do_action('AHEE_event_details_after_post'); |
|
113 | - return ob_get_clean(); |
|
114 | - } |
|
64 | + /** |
|
65 | + * callback that runs when the shortcode is encountered in post content. |
|
66 | + * IMPORTANT !!! |
|
67 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
68 | + * |
|
69 | + * @param array $attributes |
|
70 | + * @return string |
|
71 | + * @throws InvalidArgumentException |
|
72 | + * @throws EE_Error |
|
73 | + * @throws InvalidDataTypeException |
|
74 | + * @throws InvalidInterfaceException |
|
75 | + * @throws ReflectionException |
|
76 | + * @throws Exception |
|
77 | + */ |
|
78 | + public function processShortcode($attributes = array()) |
|
79 | + { |
|
80 | + extract($attributes, EXTR_OVERWRITE); |
|
81 | + $event_id = isset($event_id) ? $event_id : 0; |
|
82 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
83 | + if (! $event instanceof EE_Event) { |
|
84 | + if (WP_DEBUG === true && current_user_can('edit_pages')) { |
|
85 | + new ExceptionStackTraceDisplay( |
|
86 | + new InvalidArgumentException( |
|
87 | + sprintf( |
|
88 | + esc_html__( |
|
89 | + 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.', |
|
90 | + 'event_espresso' |
|
91 | + ), |
|
92 | + $this->getTag(), |
|
93 | + $event_id, |
|
94 | + 'event_id', |
|
95 | + '<br />' |
|
96 | + ) |
|
97 | + ) |
|
98 | + ); |
|
99 | + return ''; |
|
100 | + } |
|
101 | + return sprintf( |
|
102 | + esc_html__( |
|
103 | + 'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.', |
|
104 | + 'event_espresso' |
|
105 | + ), |
|
106 | + $event_id |
|
107 | + ); |
|
108 | + } |
|
109 | + ob_start(); |
|
110 | + do_action('AHEE_event_details_before_post', $event_id); |
|
111 | + espresso_ticket_selector($event); |
|
112 | + do_action('AHEE_event_details_after_post'); |
|
113 | + return ob_get_clean(); |
|
114 | + } |
|
115 | 115 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | extract($attributes, EXTR_OVERWRITE); |
81 | 81 | $event_id = isset($event_id) ? $event_id : 0; |
82 | 82 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
83 | - if (! $event instanceof EE_Event) { |
|
83 | + if ( ! $event instanceof EE_Event) { |
|
84 | 84 | if (WP_DEBUG === true && current_user_can('edit_pages')) { |
85 | 85 | new ExceptionStackTraceDisplay( |
86 | 86 | new InvalidArgumentException( |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
260 | 260 | 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
261 | 261 | 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
262 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
262 | + 'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css', |
|
263 | 263 | 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
264 | 264 | ); |
265 | 265 | $this->_deregister_wp_hooks(); |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | $invoice_name = $this->_subject; |
324 | 324 | |
325 | 325 | // only load dompdf if nobody else has yet... |
326 | - if (! class_exists('Dompdf\Dompdf')) { |
|
327 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
326 | + if ( ! class_exists('Dompdf\Dompdf')) { |
|
327 | + require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php'); |
|
328 | 328 | Dompdf\Autoloader::register(); |
329 | 329 | } |
330 | 330 | $options = new Dompdf\Options(); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $dompdf->loadHtml($content); |
337 | 337 | $dompdf->render(); |
338 | 338 | // forcing the browser to open a download dialog. |
339 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
339 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => true)); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 |
@@ -15,349 +15,349 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * The following are the properties that this messenger requires for generating pdf |
|
20 | - */ |
|
21 | - |
|
22 | - /** |
|
23 | - * This is the pdf body generated by the template via the message type. |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $_content; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $_subject; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @return EE_Pdf_messenger |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - // set properties |
|
44 | - $this->name = 'pdf'; |
|
45 | - $this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
46 | - $this->label = array( |
|
47 | - 'singular' => __('PDF', 'event_espresso'), |
|
48 | - 'plural' => __('PDFs', 'event_espresso') |
|
49 | - ); |
|
50 | - $this->activate_on_install = true; |
|
51 | - |
|
52 | - parent::__construct(); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * PDF Messenger desires execution immediately. |
|
58 | - * @see parent::send_now() for documentation. |
|
59 | - * @since 4.9.0 |
|
60 | - * @return bool |
|
61 | - */ |
|
62 | - public function send_now() |
|
63 | - { |
|
64 | - return true; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * HTML Messenger allows an empty to field. |
|
70 | - * @see parent::allow_empty_to_field() for documentation |
|
71 | - * @since 4.9.0 |
|
72 | - * @return bool |
|
73 | - */ |
|
74 | - public function allow_empty_to_field() |
|
75 | - { |
|
76 | - return true; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @see abstract declaration in EE_messenger for details. |
|
82 | - */ |
|
83 | - protected function _set_admin_pages() |
|
84 | - { |
|
85 | - $this->admin_registered_pages = array('events_edit' => false); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @see abstract declaration in EE_messenger for details. |
|
91 | - */ |
|
92 | - protected function _set_valid_shortcodes() |
|
93 | - { |
|
94 | - $this->_valid_shortcodes = array(); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @see abstract declaration in EE_messenger for details. |
|
100 | - */ |
|
101 | - protected function _set_validator_config() |
|
102 | - { |
|
103 | - $this->_validator_config = array( |
|
104 | - 'subject' => array( |
|
105 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
106 | - ), |
|
107 | - 'content' => array( |
|
108 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
109 | - ), |
|
110 | - 'attendee_list' => array( |
|
111 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
112 | - 'required' => array('[ATTENDEE_LIST]') |
|
113 | - ), |
|
114 | - 'event_list' => array( |
|
115 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
116 | - 'required' => array('[EVENT_LIST]') |
|
117 | - ), |
|
118 | - 'ticket_list' => array( |
|
119 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
120 | - 'required' => array('[TICKET_LIST]') |
|
121 | - ), |
|
122 | - 'datetime_list' => array( |
|
123 | - 'shortcodes' => array('datetime'), |
|
124 | - 'required' => array('[DATETIME_LIST]') |
|
125 | - ), |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
132 | - * |
|
133 | - * @return void. |
|
134 | - */ |
|
135 | - public function enqueue_scripts_styles() |
|
136 | - { |
|
137 | - parent::enqueue_scripts_styles(); |
|
138 | - do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * _set_template_fields |
|
144 | - * This sets up the fields that a messenger requires for the message to go out. |
|
145 | - * |
|
146 | - * @access protected |
|
147 | - * @return void |
|
148 | - */ |
|
149 | - protected function _set_template_fields() |
|
150 | - { |
|
151 | - // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
152 | - $this->_template_fields = array( |
|
153 | - 'subject' => array( |
|
154 | - 'input' => 'text', |
|
155 | - 'label' => __('Page Title', 'event_espresso'), |
|
156 | - 'type' => 'string', |
|
157 | - 'required' => true, |
|
158 | - 'validation' => true, |
|
159 | - 'css_class' => 'large-text', |
|
160 | - 'format' => '%s' |
|
161 | - ), |
|
162 | - 'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
163 | - 'extra' => array( |
|
164 | - 'content' => array( |
|
165 | - 'main' => array( |
|
166 | - 'input' => 'wp_editor', |
|
167 | - 'label' => __('Main Content', 'event_espresso'), |
|
168 | - 'type' => 'string', |
|
169 | - 'required' => true, |
|
170 | - 'validation' => true, |
|
171 | - 'format' => '%s', |
|
172 | - 'rows' => '15' |
|
173 | - ), |
|
174 | - 'event_list' => array( |
|
175 | - 'input' => 'wp_editor', |
|
176 | - 'label' => '[EVENT_LIST]', |
|
177 | - 'type' => 'string', |
|
178 | - 'required' => true, |
|
179 | - 'validation' => true, |
|
180 | - 'format' => '%s', |
|
181 | - 'rows' => '15', |
|
182 | - 'shortcodes_required' => array('[EVENT_LIST]') |
|
183 | - ), |
|
184 | - 'attendee_list' => array( |
|
185 | - 'input' => 'textarea', |
|
186 | - 'label' => '[ATTENDEE_LIST]', |
|
187 | - 'type' => 'string', |
|
188 | - 'required' => true, |
|
189 | - 'validation' => true, |
|
190 | - 'format' => '%s', |
|
191 | - 'css_class' => 'large-text', |
|
192 | - 'rows' => '5', |
|
193 | - 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
194 | - ), |
|
195 | - 'ticket_list' => array( |
|
196 | - 'input' => 'textarea', |
|
197 | - 'label' => '[TICKET_LIST]', |
|
198 | - 'type' => 'string', |
|
199 | - 'required' => true, |
|
200 | - 'validation' => true, |
|
201 | - 'format' => '%s', |
|
202 | - 'css_class' => 'large-text', |
|
203 | - 'rows' => '10', |
|
204 | - 'shortcodes_required' => array('[TICKET_LIST]') |
|
205 | - ), |
|
206 | - 'datetime_list' => array( |
|
207 | - 'input' => 'textarea', |
|
208 | - 'label' => '[DATETIME_LIST]', |
|
209 | - 'type' => 'string', |
|
210 | - 'required' => true, |
|
211 | - 'validation' => true, |
|
212 | - 'format' => '%s', |
|
213 | - 'css_class' => 'large-text', |
|
214 | - 'rows' => '10', |
|
215 | - 'shortcodes_required' => array('[DATETIME_LIST]') |
|
216 | - ) |
|
217 | - ) |
|
218 | - ) |
|
219 | - ); |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * @see definition of this method in parent |
|
225 | - * |
|
226 | - * @since 4.5.0 |
|
227 | - * |
|
228 | - */ |
|
229 | - protected function _set_default_message_types() |
|
230 | - { |
|
231 | - // note currently PDF is only a secondary messenger so it never has any associated message types. |
|
232 | - $this->_default_message_types = array(); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * @see definition of this method in parent |
|
238 | - * |
|
239 | - * @since 4.5.0 |
|
240 | - */ |
|
241 | - protected function _set_valid_message_types() |
|
242 | - { |
|
243 | - $this->_valid_message_types = array(); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Generates html version of the message content and then sends it to the pdf generator. |
|
249 | - * |
|
250 | - * |
|
251 | - * @since 4.5.0 |
|
252 | - * |
|
253 | - * @return string. |
|
254 | - */ |
|
255 | - protected function _send_message() |
|
256 | - { |
|
257 | - $this->_template_args = array( |
|
258 | - 'page_title' => $this->_subject, |
|
259 | - 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
|
260 | - 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
|
261 | - 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
|
262 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
263 | - 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
|
264 | - ); |
|
265 | - $this->_deregister_wp_hooks(); |
|
266 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
267 | - $content = $this->_get_main_template(); |
|
18 | + /** |
|
19 | + * The following are the properties that this messenger requires for generating pdf |
|
20 | + */ |
|
21 | + |
|
22 | + /** |
|
23 | + * This is the pdf body generated by the template via the message type. |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $_content; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $_subject; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @return EE_Pdf_messenger |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + // set properties |
|
44 | + $this->name = 'pdf'; |
|
45 | + $this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
46 | + $this->label = array( |
|
47 | + 'singular' => __('PDF', 'event_espresso'), |
|
48 | + 'plural' => __('PDFs', 'event_espresso') |
|
49 | + ); |
|
50 | + $this->activate_on_install = true; |
|
51 | + |
|
52 | + parent::__construct(); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * PDF Messenger desires execution immediately. |
|
58 | + * @see parent::send_now() for documentation. |
|
59 | + * @since 4.9.0 |
|
60 | + * @return bool |
|
61 | + */ |
|
62 | + public function send_now() |
|
63 | + { |
|
64 | + return true; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * HTML Messenger allows an empty to field. |
|
70 | + * @see parent::allow_empty_to_field() for documentation |
|
71 | + * @since 4.9.0 |
|
72 | + * @return bool |
|
73 | + */ |
|
74 | + public function allow_empty_to_field() |
|
75 | + { |
|
76 | + return true; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @see abstract declaration in EE_messenger for details. |
|
82 | + */ |
|
83 | + protected function _set_admin_pages() |
|
84 | + { |
|
85 | + $this->admin_registered_pages = array('events_edit' => false); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @see abstract declaration in EE_messenger for details. |
|
91 | + */ |
|
92 | + protected function _set_valid_shortcodes() |
|
93 | + { |
|
94 | + $this->_valid_shortcodes = array(); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @see abstract declaration in EE_messenger for details. |
|
100 | + */ |
|
101 | + protected function _set_validator_config() |
|
102 | + { |
|
103 | + $this->_validator_config = array( |
|
104 | + 'subject' => array( |
|
105 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
106 | + ), |
|
107 | + 'content' => array( |
|
108 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
109 | + ), |
|
110 | + 'attendee_list' => array( |
|
111 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
112 | + 'required' => array('[ATTENDEE_LIST]') |
|
113 | + ), |
|
114 | + 'event_list' => array( |
|
115 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
116 | + 'required' => array('[EVENT_LIST]') |
|
117 | + ), |
|
118 | + 'ticket_list' => array( |
|
119 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
120 | + 'required' => array('[TICKET_LIST]') |
|
121 | + ), |
|
122 | + 'datetime_list' => array( |
|
123 | + 'shortcodes' => array('datetime'), |
|
124 | + 'required' => array('[DATETIME_LIST]') |
|
125 | + ), |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
132 | + * |
|
133 | + * @return void. |
|
134 | + */ |
|
135 | + public function enqueue_scripts_styles() |
|
136 | + { |
|
137 | + parent::enqueue_scripts_styles(); |
|
138 | + do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * _set_template_fields |
|
144 | + * This sets up the fields that a messenger requires for the message to go out. |
|
145 | + * |
|
146 | + * @access protected |
|
147 | + * @return void |
|
148 | + */ |
|
149 | + protected function _set_template_fields() |
|
150 | + { |
|
151 | + // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
152 | + $this->_template_fields = array( |
|
153 | + 'subject' => array( |
|
154 | + 'input' => 'text', |
|
155 | + 'label' => __('Page Title', 'event_espresso'), |
|
156 | + 'type' => 'string', |
|
157 | + 'required' => true, |
|
158 | + 'validation' => true, |
|
159 | + 'css_class' => 'large-text', |
|
160 | + 'format' => '%s' |
|
161 | + ), |
|
162 | + 'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
163 | + 'extra' => array( |
|
164 | + 'content' => array( |
|
165 | + 'main' => array( |
|
166 | + 'input' => 'wp_editor', |
|
167 | + 'label' => __('Main Content', 'event_espresso'), |
|
168 | + 'type' => 'string', |
|
169 | + 'required' => true, |
|
170 | + 'validation' => true, |
|
171 | + 'format' => '%s', |
|
172 | + 'rows' => '15' |
|
173 | + ), |
|
174 | + 'event_list' => array( |
|
175 | + 'input' => 'wp_editor', |
|
176 | + 'label' => '[EVENT_LIST]', |
|
177 | + 'type' => 'string', |
|
178 | + 'required' => true, |
|
179 | + 'validation' => true, |
|
180 | + 'format' => '%s', |
|
181 | + 'rows' => '15', |
|
182 | + 'shortcodes_required' => array('[EVENT_LIST]') |
|
183 | + ), |
|
184 | + 'attendee_list' => array( |
|
185 | + 'input' => 'textarea', |
|
186 | + 'label' => '[ATTENDEE_LIST]', |
|
187 | + 'type' => 'string', |
|
188 | + 'required' => true, |
|
189 | + 'validation' => true, |
|
190 | + 'format' => '%s', |
|
191 | + 'css_class' => 'large-text', |
|
192 | + 'rows' => '5', |
|
193 | + 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
194 | + ), |
|
195 | + 'ticket_list' => array( |
|
196 | + 'input' => 'textarea', |
|
197 | + 'label' => '[TICKET_LIST]', |
|
198 | + 'type' => 'string', |
|
199 | + 'required' => true, |
|
200 | + 'validation' => true, |
|
201 | + 'format' => '%s', |
|
202 | + 'css_class' => 'large-text', |
|
203 | + 'rows' => '10', |
|
204 | + 'shortcodes_required' => array('[TICKET_LIST]') |
|
205 | + ), |
|
206 | + 'datetime_list' => array( |
|
207 | + 'input' => 'textarea', |
|
208 | + 'label' => '[DATETIME_LIST]', |
|
209 | + 'type' => 'string', |
|
210 | + 'required' => true, |
|
211 | + 'validation' => true, |
|
212 | + 'format' => '%s', |
|
213 | + 'css_class' => 'large-text', |
|
214 | + 'rows' => '10', |
|
215 | + 'shortcodes_required' => array('[DATETIME_LIST]') |
|
216 | + ) |
|
217 | + ) |
|
218 | + ) |
|
219 | + ); |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * @see definition of this method in parent |
|
225 | + * |
|
226 | + * @since 4.5.0 |
|
227 | + * |
|
228 | + */ |
|
229 | + protected function _set_default_message_types() |
|
230 | + { |
|
231 | + // note currently PDF is only a secondary messenger so it never has any associated message types. |
|
232 | + $this->_default_message_types = array(); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * @see definition of this method in parent |
|
238 | + * |
|
239 | + * @since 4.5.0 |
|
240 | + */ |
|
241 | + protected function _set_valid_message_types() |
|
242 | + { |
|
243 | + $this->_valid_message_types = array(); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Generates html version of the message content and then sends it to the pdf generator. |
|
249 | + * |
|
250 | + * |
|
251 | + * @since 4.5.0 |
|
252 | + * |
|
253 | + * @return string. |
|
254 | + */ |
|
255 | + protected function _send_message() |
|
256 | + { |
|
257 | + $this->_template_args = array( |
|
258 | + 'page_title' => $this->_subject, |
|
259 | + 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
|
260 | + 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
|
261 | + 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
|
262 | + 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
263 | + 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
|
264 | + ); |
|
265 | + $this->_deregister_wp_hooks(); |
|
266 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
267 | + $content = $this->_get_main_template(); |
|
268 | 268 | // die( $content ); |
269 | - $this->_do_pdf($content); |
|
270 | - exit(0); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
276 | - * |
|
277 | - * @since 4.5.0 |
|
278 | - * |
|
279 | - * @return void |
|
280 | - */ |
|
281 | - protected function _deregister_wp_hooks() |
|
282 | - { |
|
283 | - remove_all_actions('wp_head'); |
|
284 | - remove_all_actions('wp_footer'); |
|
285 | - remove_all_actions('wp_print_footer_scripts'); |
|
286 | - remove_all_actions('wp_enqueue_scripts'); |
|
287 | - global $wp_scripts, $wp_styles; |
|
288 | - $wp_scripts = $wp_styles = array(); |
|
289 | - |
|
290 | - // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
291 | - add_action('wp_head', 'wp_enqueue_scripts'); |
|
292 | - add_action('wp_footer', 'wp_print_footer_scripts'); |
|
293 | - add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * Overwrite parent _get_main_template for pdf purposes. |
|
299 | - * |
|
300 | - * @since 4.5.0 |
|
301 | - * |
|
302 | - * @param bool $preview |
|
303 | - * @return string |
|
304 | - */ |
|
305 | - protected function _get_main_template($preview = false) |
|
306 | - { |
|
307 | - $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
308 | - // add message type to template_args |
|
309 | - $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
310 | - return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * This takes care of loading the dompdf library and generating the actual pdf |
|
316 | - * |
|
317 | - * @param string $content This is the generated html content being converted into a pdf. |
|
318 | - * |
|
319 | - * @return void |
|
320 | - */ |
|
321 | - protected function _do_pdf($content = '') |
|
322 | - { |
|
323 | - $invoice_name = $this->_subject; |
|
324 | - |
|
325 | - // only load dompdf if nobody else has yet... |
|
326 | - if (! class_exists('Dompdf\Dompdf')) { |
|
327 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
328 | - Dompdf\Autoloader::register(); |
|
329 | - } |
|
330 | - $options = new Dompdf\Options(); |
|
331 | - $options->set('isRemoteEnabled', true); |
|
332 | - $options->set('isJavascriptEnabled', false); |
|
333 | - if (defined('DOMPDF_FONT_DIR')) { |
|
334 | - $options->setFontDir(DOMPDF_FONT_DIR); |
|
335 | - $options->setFontCache(DOMPDF_FONT_DIR); |
|
336 | - } |
|
337 | - // Allow changing the paper size. |
|
338 | - if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
339 | - $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE); |
|
340 | - } |
|
341 | - $dompdf = new Dompdf\Dompdf($options); |
|
342 | - // Remove all spaces between HTML tags |
|
343 | - $content = preg_replace('/>\s+</', '><', $content); |
|
344 | - $dompdf->loadHtml($content); |
|
345 | - $dompdf->render(); |
|
346 | - // forcing the browser to open a download dialog. |
|
347 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * @return string |
|
353 | - */ |
|
354 | - protected function _preview() |
|
355 | - { |
|
356 | - return $this->_send_message(); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - protected function _set_admin_settings_fields() |
|
361 | - { |
|
362 | - } |
|
269 | + $this->_do_pdf($content); |
|
270 | + exit(0); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
276 | + * |
|
277 | + * @since 4.5.0 |
|
278 | + * |
|
279 | + * @return void |
|
280 | + */ |
|
281 | + protected function _deregister_wp_hooks() |
|
282 | + { |
|
283 | + remove_all_actions('wp_head'); |
|
284 | + remove_all_actions('wp_footer'); |
|
285 | + remove_all_actions('wp_print_footer_scripts'); |
|
286 | + remove_all_actions('wp_enqueue_scripts'); |
|
287 | + global $wp_scripts, $wp_styles; |
|
288 | + $wp_scripts = $wp_styles = array(); |
|
289 | + |
|
290 | + // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
291 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
292 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
293 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * Overwrite parent _get_main_template for pdf purposes. |
|
299 | + * |
|
300 | + * @since 4.5.0 |
|
301 | + * |
|
302 | + * @param bool $preview |
|
303 | + * @return string |
|
304 | + */ |
|
305 | + protected function _get_main_template($preview = false) |
|
306 | + { |
|
307 | + $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
308 | + // add message type to template_args |
|
309 | + $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
310 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * This takes care of loading the dompdf library and generating the actual pdf |
|
316 | + * |
|
317 | + * @param string $content This is the generated html content being converted into a pdf. |
|
318 | + * |
|
319 | + * @return void |
|
320 | + */ |
|
321 | + protected function _do_pdf($content = '') |
|
322 | + { |
|
323 | + $invoice_name = $this->_subject; |
|
324 | + |
|
325 | + // only load dompdf if nobody else has yet... |
|
326 | + if (! class_exists('Dompdf\Dompdf')) { |
|
327 | + require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
328 | + Dompdf\Autoloader::register(); |
|
329 | + } |
|
330 | + $options = new Dompdf\Options(); |
|
331 | + $options->set('isRemoteEnabled', true); |
|
332 | + $options->set('isJavascriptEnabled', false); |
|
333 | + if (defined('DOMPDF_FONT_DIR')) { |
|
334 | + $options->setFontDir(DOMPDF_FONT_DIR); |
|
335 | + $options->setFontCache(DOMPDF_FONT_DIR); |
|
336 | + } |
|
337 | + // Allow changing the paper size. |
|
338 | + if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
339 | + $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE); |
|
340 | + } |
|
341 | + $dompdf = new Dompdf\Dompdf($options); |
|
342 | + // Remove all spaces between HTML tags |
|
343 | + $content = preg_replace('/>\s+</', '><', $content); |
|
344 | + $dompdf->loadHtml($content); |
|
345 | + $dompdf->render(); |
|
346 | + // forcing the browser to open a download dialog. |
|
347 | + $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * @return string |
|
353 | + */ |
|
354 | + protected function _preview() |
|
355 | + { |
|
356 | + return $this->_send_message(); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + protected function _set_admin_settings_fields() |
|
361 | + { |
|
362 | + } |
|
363 | 363 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | 7 => "union.css", |
84 | 84 | ); |
85 | 85 | // Get the CSS file |
86 | - if (isset($themes[ $theme_requested ])) { |
|
87 | - $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
86 | + if (isset($themes[$theme_requested])) { |
|
87 | + $template_args['invoice_css'] = $themes[$theme_requested]; |
|
88 | 88 | } else { |
89 | 89 | $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
90 | 90 | 'legacy_invoice_css', |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | ); |
94 | 94 | } |
95 | 95 | |
96 | - if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
97 | - $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
96 | + if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) { |
|
97 | + $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/'; |
|
98 | 98 | } else { |
99 | - $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
99 | + $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/'; |
|
100 | 100 | } |
101 | 101 | $primary_attendee = $this->transaction->primary_registration()->attendee(); |
102 | 102 | |
103 | 103 | $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
104 | 104 | $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty( |
105 | 105 | 'address_1' |
106 | - ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2'); |
|
106 | + ) : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2'); |
|
107 | 107 | $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
108 | 108 | $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
109 | 109 | $EE->CFG->organization->STA_ID |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | if ($template_args['amount_pd'] != $template_args['total_cost']) { |
150 | 150 | // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']); |
151 | 151 | $tax_items = $this->transaction->tax_items(); |
152 | - if (! empty($tax_items)) { |
|
152 | + if ( ! empty($tax_items)) { |
|
153 | 153 | foreach ($tax_items as $tax) { |
154 | 154 | $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
155 | 155 | } |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
184 | 184 | array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID())) |
185 | 185 | ); |
186 | - $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
186 | + $ticket_line_items_per_event[$event_id] = $line_items_for_this_event; |
|
187 | 187 | foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
188 | 188 | $ticket = $line_item->ticket(); |
189 | 189 | $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
190 | 190 | array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID())) |
191 | 191 | ); |
192 | - $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
192 | + $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket; |
|
193 | 193 | } |
194 | 194 | $venues_for_events = array_merge($venues_for_events, $event->venues()); |
195 | 195 | } |
@@ -219,21 +219,21 @@ discard block |
||
219 | 219 | // Get the HTML as an object |
220 | 220 | $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
221 | 221 | $template_header = EEH_Template::locate_template( |
222 | - $templates_relative_path . 'invoice_header.template.php', |
|
222 | + $templates_relative_path.'invoice_header.template.php', |
|
223 | 223 | $template_args, |
224 | 224 | true, |
225 | 225 | true |
226 | 226 | ); |
227 | 227 | if (isset($_GET['receipt'])) { |
228 | 228 | $template_body = EEH_Template::locate_template( |
229 | - $templates_relative_path . 'receipt_body.template.php', |
|
229 | + $templates_relative_path.'receipt_body.template.php', |
|
230 | 230 | $template_args, |
231 | 231 | true, |
232 | 232 | true |
233 | 233 | ); |
234 | 234 | } else { |
235 | 235 | $template_body = EEH_Template::locate_template( |
236 | - $templates_relative_path . 'invoice_body.template.php', |
|
236 | + $templates_relative_path.'invoice_body.template.php', |
|
237 | 237 | $template_args, |
238 | 238 | true, |
239 | 239 | true |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | |
244 | 244 | $template_footer = EEH_Template::locate_template( |
245 | - $templates_relative_path . 'invoice_footer.template.php', |
|
245 | + $templates_relative_path.'invoice_footer.template.php', |
|
246 | 246 | $template_args, |
247 | 247 | true, |
248 | 248 | true |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
258 | 258 | |
259 | 259 | // Check if debugging or mobile is set |
260 | - if (! empty($_REQUEST['html'])) { |
|
260 | + if ( ! empty($_REQUEST['html'])) { |
|
261 | 261 | echo $content; |
262 | 262 | exit(0); |
263 | 263 | } |
264 | - $invoice_name = $template_args['organization'] . ' ' . __( |
|
264 | + $invoice_name = $template_args['organization'].' '.__( |
|
265 | 265 | 'Invoice #', |
266 | 266 | 'event_espresso' |
267 | - ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name']; |
|
267 | + ).$template_args['registration_code'].__(' for ', 'event_espresso').$template_args['name']; |
|
268 | 268 | $invoice_name = str_replace(' ', '_', $invoice_name); |
269 | 269 | // Create the PDF |
270 | 270 | if (array_key_exists('html', $_GET)) { |
271 | 271 | echo $content; |
272 | 272 | } else { |
273 | 273 | // only load dompdf if nobody else has yet... |
274 | - if (! class_exists('Dompdf\Dompdf')) { |
|
275 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
274 | + if ( ! class_exists('Dompdf\Dompdf')) { |
|
275 | + require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php'); |
|
276 | 276 | Dompdf\Autoloader::register(); |
277 | 277 | } |
278 | 278 | $options = new Dompdf\Options(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $dompdf = new Dompdf\Dompdf($options); |
282 | 282 | $dompdf->loadHtml($content); |
283 | 283 | $dompdf->render(); |
284 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download)); |
|
284 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => $download)); |
|
285 | 285 | } |
286 | 286 | exit(0); |
287 | 287 | } |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | true, |
320 | 320 | $EE->CFG->organization->logo_url |
321 | 321 | ); |
322 | - if (! empty($invoice_logo_url)) { |
|
322 | + if ( ! empty($invoice_logo_url)) { |
|
323 | 323 | $image_size = getimagesize($invoice_logo_url); |
324 | - $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
324 | + $invoice_logo_image = '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> '; |
|
325 | 325 | } else { |
326 | 326 | $invoice_logo_image = ''; |
327 | 327 | } |
@@ -354,14 +354,14 @@ discard block |
||
354 | 354 | $this->registration->reg_code(), |
355 | 355 | $this->transaction->ID(), |
356 | 356 | $primary_attendee->full_name(), |
357 | - (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
358 | - : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
357 | + (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
358 | + : EE_GATEWAYS_URL.'Invoice/lib/templates/', |
|
359 | 359 | $this->registration->invoice_url(), |
360 | 360 | // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
361 | 361 | $invoice_logo_image, |
362 | 362 | empty($EE->CFG->organization->address_2) |
363 | 363 | ? $EE->CFG->organization->get_pretty('address_1') |
364 | - : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
364 | + : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty( |
|
365 | 365 | 'address_2' |
366 | 366 | ), |
367 | 367 | $EE->CFG->organization->get_pretty('city'), |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | $find = array(' '); |
399 | 399 | $replace = array('-'); |
400 | 400 | $row_id = strtolower(str_replace($find, $replace, $text)); |
401 | - $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
402 | - $html .= '<td class="item_r">' . $text . '</td>'; |
|
403 | - $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
401 | + $html .= '<tr id="'.$row_id.'-tr"><td colspan="4"> </td>'; |
|
402 | + $html .= '<td class="item_r">'.$text.'</td>'; |
|
403 | + $html .= '<td class="item_r">'.$total_cost.'</td>'; |
|
404 | 404 | $html .= '</tr>'; |
405 | 405 | return $html; |
406 | 406 | } |
@@ -9,405 +9,405 @@ |
||
9 | 9 | class Invoice |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * |
|
14 | - * @var EE_Registration |
|
15 | - */ |
|
16 | - private $registration; |
|
17 | - /** |
|
18 | - * |
|
19 | - * @var EE_Transaction |
|
20 | - */ |
|
21 | - private $transaction; |
|
22 | - /** |
|
23 | - * |
|
24 | - * @var EE_Payment_Method |
|
25 | - */ |
|
26 | - private $invoice_payment_method; |
|
27 | - private $EE; |
|
12 | + /** |
|
13 | + * |
|
14 | + * @var EE_Registration |
|
15 | + */ |
|
16 | + private $registration; |
|
17 | + /** |
|
18 | + * |
|
19 | + * @var EE_Transaction |
|
20 | + */ |
|
21 | + private $transaction; |
|
22 | + /** |
|
23 | + * |
|
24 | + * @var EE_Payment_Method |
|
25 | + */ |
|
26 | + private $invoice_payment_method; |
|
27 | + private $EE; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * Invoice constructor. |
|
32 | - * |
|
33 | - * @deprecated 4.9.13 |
|
34 | - * @param int $url_link |
|
35 | - */ |
|
36 | - public function __construct($url_link = 0) |
|
37 | - { |
|
38 | - EE_Error::doing_it_wrong( |
|
39 | - __CLASS__, |
|
40 | - esc_html__( |
|
41 | - 'This class has been deprecated and replaced by the new Messages library.', |
|
42 | - 'event_espresso' |
|
43 | - ), |
|
44 | - '4.9.12', |
|
45 | - '5.0.0' |
|
46 | - ); |
|
47 | - if ( |
|
48 | - $this->registration = EE_Registry::instance()->load_model( |
|
49 | - 'Registration' |
|
50 | - )->get_registration_for_reg_url_link($url_link) |
|
51 | - ) { |
|
52 | - $this->transaction = $this->registration->transaction(); |
|
53 | - // get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE); |
|
54 | - $payment_settings = EE_Config::instance()->gateway->payment_settings; |
|
55 | - $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice'); |
|
56 | - } else { |
|
57 | - EE_Error::add_error( |
|
58 | - __( |
|
59 | - 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - __FILE__, |
|
63 | - __FUNCTION__, |
|
64 | - __LINE__ |
|
65 | - ); |
|
66 | - } |
|
67 | - } |
|
30 | + /** |
|
31 | + * Invoice constructor. |
|
32 | + * |
|
33 | + * @deprecated 4.9.13 |
|
34 | + * @param int $url_link |
|
35 | + */ |
|
36 | + public function __construct($url_link = 0) |
|
37 | + { |
|
38 | + EE_Error::doing_it_wrong( |
|
39 | + __CLASS__, |
|
40 | + esc_html__( |
|
41 | + 'This class has been deprecated and replaced by the new Messages library.', |
|
42 | + 'event_espresso' |
|
43 | + ), |
|
44 | + '4.9.12', |
|
45 | + '5.0.0' |
|
46 | + ); |
|
47 | + if ( |
|
48 | + $this->registration = EE_Registry::instance()->load_model( |
|
49 | + 'Registration' |
|
50 | + )->get_registration_for_reg_url_link($url_link) |
|
51 | + ) { |
|
52 | + $this->transaction = $this->registration->transaction(); |
|
53 | + // get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE); |
|
54 | + $payment_settings = EE_Config::instance()->gateway->payment_settings; |
|
55 | + $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice'); |
|
56 | + } else { |
|
57 | + EE_Error::add_error( |
|
58 | + __( |
|
59 | + 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', |
|
60 | + 'event_espresso' |
|
61 | + ), |
|
62 | + __FILE__, |
|
63 | + __FUNCTION__, |
|
64 | + __LINE__ |
|
65 | + ); |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - public function send_invoice($download = false) |
|
70 | - { |
|
71 | - $template_args = array(); |
|
72 | - $EE = EE_Registry::instance(); |
|
69 | + public function send_invoice($download = false) |
|
70 | + { |
|
71 | + $template_args = array(); |
|
72 | + $EE = EE_Registry::instance(); |
|
73 | 73 | |
74 | - // allow the request to override the default theme defined in the invoice settings |
|
75 | - $theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint( |
|
76 | - $_REQUEST['theme'] |
|
77 | - ) : null; |
|
78 | - $themes = array( |
|
79 | - 1 => "simple.css", |
|
80 | - 2 => "bauhaus.css", |
|
81 | - 3 => "ejs.css", |
|
82 | - 4 => "horizon.css", |
|
83 | - 5 => "lola.css", |
|
84 | - 6 => "tranquility.css", |
|
85 | - 7 => "union.css", |
|
86 | - ); |
|
87 | - // Get the CSS file |
|
88 | - if (isset($themes[ $theme_requested ])) { |
|
89 | - $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
90 | - } else { |
|
91 | - $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
|
92 | - 'legacy_invoice_css', |
|
93 | - true, |
|
94 | - 'simple.css' |
|
95 | - ); |
|
96 | - } |
|
74 | + // allow the request to override the default theme defined in the invoice settings |
|
75 | + $theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint( |
|
76 | + $_REQUEST['theme'] |
|
77 | + ) : null; |
|
78 | + $themes = array( |
|
79 | + 1 => "simple.css", |
|
80 | + 2 => "bauhaus.css", |
|
81 | + 3 => "ejs.css", |
|
82 | + 4 => "horizon.css", |
|
83 | + 5 => "lola.css", |
|
84 | + 6 => "tranquility.css", |
|
85 | + 7 => "union.css", |
|
86 | + ); |
|
87 | + // Get the CSS file |
|
88 | + if (isset($themes[ $theme_requested ])) { |
|
89 | + $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
90 | + } else { |
|
91 | + $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
|
92 | + 'legacy_invoice_css', |
|
93 | + true, |
|
94 | + 'simple.css' |
|
95 | + ); |
|
96 | + } |
|
97 | 97 | |
98 | - if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
99 | - $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
100 | - } else { |
|
101 | - $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
102 | - } |
|
103 | - $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
98 | + if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
99 | + $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
100 | + } else { |
|
101 | + $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
102 | + } |
|
103 | + $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
104 | 104 | |
105 | - $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
|
106 | - $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty( |
|
107 | - 'address_1' |
|
108 | - ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2'); |
|
109 | - $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
|
110 | - $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
|
111 | - $EE->CFG->organization->STA_ID |
|
112 | - ); |
|
113 | - $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID( |
|
114 | - $EE->CFG->organization->CNT_ISO |
|
115 | - ); |
|
116 | - $template_args['zip'] = $EE->CFG->organization->get_pretty('zip'); |
|
117 | - $template_args['email'] = $EE->CFG->organization->get_pretty('email'); |
|
105 | + $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
|
106 | + $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty( |
|
107 | + 'address_1' |
|
108 | + ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2'); |
|
109 | + $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
|
110 | + $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
|
111 | + $EE->CFG->organization->STA_ID |
|
112 | + ); |
|
113 | + $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID( |
|
114 | + $EE->CFG->organization->CNT_ISO |
|
115 | + ); |
|
116 | + $template_args['zip'] = $EE->CFG->organization->get_pretty('zip'); |
|
117 | + $template_args['email'] = $EE->CFG->organization->get_pretty('email'); |
|
118 | 118 | |
119 | - $template_args['registration_code'] = $this->registration->reg_code(); |
|
120 | - $template_args['registration_date'] = $this->registration->date(); |
|
121 | - $template_args['name'] = $primary_attendee->full_name(); |
|
122 | - $template_args['attendee_address'] = $primary_attendee->address(); |
|
123 | - $template_args['attendee_address2'] = $primary_attendee->address2(); |
|
124 | - $template_args['attendee_city'] = $primary_attendee->city(); |
|
125 | - $attendee_state = $primary_attendee->state_obj(); |
|
126 | - if ($attendee_state) { |
|
127 | - $attendee_state_name = $attendee_state->name(); |
|
128 | - } else { |
|
129 | - $attendee_state_name = ''; |
|
130 | - } |
|
131 | - $template_args['attendee_state'] = $attendee_state_name; |
|
132 | - $template_args['attendee_zip'] = $primary_attendee->zip(); |
|
119 | + $template_args['registration_code'] = $this->registration->reg_code(); |
|
120 | + $template_args['registration_date'] = $this->registration->date(); |
|
121 | + $template_args['name'] = $primary_attendee->full_name(); |
|
122 | + $template_args['attendee_address'] = $primary_attendee->address(); |
|
123 | + $template_args['attendee_address2'] = $primary_attendee->address2(); |
|
124 | + $template_args['attendee_city'] = $primary_attendee->city(); |
|
125 | + $attendee_state = $primary_attendee->state_obj(); |
|
126 | + if ($attendee_state) { |
|
127 | + $attendee_state_name = $attendee_state->name(); |
|
128 | + } else { |
|
129 | + $attendee_state_name = ''; |
|
130 | + } |
|
131 | + $template_args['attendee_state'] = $attendee_state_name; |
|
132 | + $template_args['attendee_zip'] = $primary_attendee->zip(); |
|
133 | 133 | |
134 | - $template_args['ship_name'] = $template_args['name']; |
|
135 | - $template_args['ship_address'] = $template_args['attendee_address']; |
|
136 | - $template_args['ship_city'] = $template_args['attendee_city']; |
|
137 | - $template_args['ship_state'] = $template_args['attendee_state']; |
|
138 | - $template_args['ship_zip'] = $template_args['attendee_zip']; |
|
134 | + $template_args['ship_name'] = $template_args['name']; |
|
135 | + $template_args['ship_address'] = $template_args['attendee_address']; |
|
136 | + $template_args['ship_city'] = $template_args['attendee_city']; |
|
137 | + $template_args['ship_state'] = $template_args['attendee_state']; |
|
138 | + $template_args['ship_zip'] = $template_args['attendee_zip']; |
|
139 | 139 | |
140 | - $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', ''); |
|
141 | - $template_args['transaction'] = $this->transaction; |
|
142 | - $template_args['amount_pd'] = $this->transaction->paid(); |
|
143 | - $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid(); |
|
144 | - $template_args['payments'] = $this->transaction->approved_payments(); |
|
145 | - $template_args['net_total'] = ''; |
|
146 | - $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url(); |
|
147 | - $template_args['retry_payment_url'] = $this->registration->payment_overview_url(); |
|
148 | - $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description( |
|
149 | - $this->transaction->total_line_item() |
|
150 | - ); |
|
151 | - if ($template_args['amount_pd'] != $template_args['total_cost']) { |
|
152 | - // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']); |
|
153 | - $tax_items = $this->transaction->tax_items(); |
|
154 | - if (! empty($tax_items)) { |
|
155 | - foreach ($tax_items as $tax) { |
|
156 | - $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
|
157 | - } |
|
158 | - } |
|
140 | + $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', ''); |
|
141 | + $template_args['transaction'] = $this->transaction; |
|
142 | + $template_args['amount_pd'] = $this->transaction->paid(); |
|
143 | + $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid(); |
|
144 | + $template_args['payments'] = $this->transaction->approved_payments(); |
|
145 | + $template_args['net_total'] = ''; |
|
146 | + $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url(); |
|
147 | + $template_args['retry_payment_url'] = $this->registration->payment_overview_url(); |
|
148 | + $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description( |
|
149 | + $this->transaction->total_line_item() |
|
150 | + ); |
|
151 | + if ($template_args['amount_pd'] != $template_args['total_cost']) { |
|
152 | + // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']); |
|
153 | + $tax_items = $this->transaction->tax_items(); |
|
154 | + if (! empty($tax_items)) { |
|
155 | + foreach ($tax_items as $tax) { |
|
156 | + $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
|
157 | + } |
|
158 | + } |
|
159 | 159 | |
160 | - $difference = $template_args['amount_pd'] - $template_args['total_cost']; |
|
161 | - if ($difference < 0) { |
|
162 | - $text = __('Discount', 'event_espresso'); |
|
163 | - } else { |
|
164 | - $text = __('Extra', 'event_espresso'); |
|
165 | - } |
|
166 | - $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference); |
|
167 | - } |
|
160 | + $difference = $template_args['amount_pd'] - $template_args['total_cost']; |
|
161 | + if ($difference < 0) { |
|
162 | + $text = __('Discount', 'event_espresso'); |
|
163 | + } else { |
|
164 | + $text = __('Extra', 'event_espresso'); |
|
165 | + } |
|
166 | + $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference); |
|
167 | + } |
|
168 | 168 | |
169 | - $template_args['currency_symbol'] = $EE->CFG->currency->sign; |
|
170 | - $template_args['template_payment_instructions'] = wpautop( |
|
171 | - stripslashes_deep( |
|
172 | - html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES) |
|
173 | - ) |
|
174 | - ); |
|
175 | - $template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true); |
|
176 | - if (isset($_GET['receipt'])) { |
|
177 | - // receipt-specific stuff |
|
178 | - $events_for_txn = EEM_Event::instance()->get_all( |
|
179 | - array(array('Registration.TXN_ID' => $this->transaction->ID())) |
|
180 | - ); |
|
181 | - $ticket_line_items_per_event = array(); |
|
182 | - $registrations_per_line_item = array(); |
|
183 | - $venues_for_events = array(); |
|
184 | - foreach ($events_for_txn as $event_id => $event) { |
|
185 | - $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
|
186 | - array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID())) |
|
187 | - ); |
|
188 | - $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
189 | - foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
|
190 | - $ticket = $line_item->ticket(); |
|
191 | - $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
|
192 | - array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID())) |
|
193 | - ); |
|
194 | - $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
195 | - } |
|
196 | - $venues_for_events = array_merge($venues_for_events, $event->venues()); |
|
197 | - } |
|
198 | - $tax_total_line_item = EEM_Line_Item::instance()->get_one( |
|
199 | - array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total)) |
|
200 | - ); |
|
201 | - $questions_to_skip = array( |
|
202 | - EEM_Attendee::system_question_fname, |
|
203 | - EEM_Attendee::system_question_lname, |
|
204 | - EEM_Attendee::system_question_email, |
|
205 | - ); |
|
169 | + $template_args['currency_symbol'] = $EE->CFG->currency->sign; |
|
170 | + $template_args['template_payment_instructions'] = wpautop( |
|
171 | + stripslashes_deep( |
|
172 | + html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES) |
|
173 | + ) |
|
174 | + ); |
|
175 | + $template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true); |
|
176 | + if (isset($_GET['receipt'])) { |
|
177 | + // receipt-specific stuff |
|
178 | + $events_for_txn = EEM_Event::instance()->get_all( |
|
179 | + array(array('Registration.TXN_ID' => $this->transaction->ID())) |
|
180 | + ); |
|
181 | + $ticket_line_items_per_event = array(); |
|
182 | + $registrations_per_line_item = array(); |
|
183 | + $venues_for_events = array(); |
|
184 | + foreach ($events_for_txn as $event_id => $event) { |
|
185 | + $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
|
186 | + array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID())) |
|
187 | + ); |
|
188 | + $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
189 | + foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
|
190 | + $ticket = $line_item->ticket(); |
|
191 | + $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
|
192 | + array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID())) |
|
193 | + ); |
|
194 | + $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
195 | + } |
|
196 | + $venues_for_events = array_merge($venues_for_events, $event->venues()); |
|
197 | + } |
|
198 | + $tax_total_line_item = EEM_Line_Item::instance()->get_one( |
|
199 | + array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total)) |
|
200 | + ); |
|
201 | + $questions_to_skip = array( |
|
202 | + EEM_Attendee::system_question_fname, |
|
203 | + EEM_Attendee::system_question_lname, |
|
204 | + EEM_Attendee::system_question_email, |
|
205 | + ); |
|
206 | 206 | |
207 | 207 | |
208 | - $template_args['events_for_txn'] = $events_for_txn; |
|
209 | - $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event; |
|
210 | - $template_args['registrations_per_line_item'] = $registrations_per_line_item; |
|
211 | - $template_args['venues_for_events'] = $venues_for_events; |
|
212 | - $template_args['tax_total_line_item'] = $tax_total_line_item; |
|
213 | - $template_args['questions_to_skip'] = $questions_to_skip; |
|
214 | - // d($template_args); |
|
215 | - $template_args['download_link'] = $this->registration->receipt_url('download'); |
|
216 | - } else { |
|
217 | - // it's just an invoice we're accessing |
|
218 | - $template_args['download_link'] = $this->registration->invoice_url('download'); |
|
219 | - } |
|
208 | + $template_args['events_for_txn'] = $events_for_txn; |
|
209 | + $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event; |
|
210 | + $template_args['registrations_per_line_item'] = $registrations_per_line_item; |
|
211 | + $template_args['venues_for_events'] = $venues_for_events; |
|
212 | + $template_args['tax_total_line_item'] = $tax_total_line_item; |
|
213 | + $template_args['questions_to_skip'] = $questions_to_skip; |
|
214 | + // d($template_args); |
|
215 | + $template_args['download_link'] = $this->registration->receipt_url('download'); |
|
216 | + } else { |
|
217 | + // it's just an invoice we're accessing |
|
218 | + $template_args['download_link'] = $this->registration->invoice_url('download'); |
|
219 | + } |
|
220 | 220 | |
221 | - // Get the HTML as an object |
|
222 | - $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
223 | - $template_header = EEH_Template::locate_template( |
|
224 | - $templates_relative_path . 'invoice_header.template.php', |
|
225 | - $template_args, |
|
226 | - true, |
|
227 | - true |
|
228 | - ); |
|
229 | - if (isset($_GET['receipt'])) { |
|
230 | - $template_body = EEH_Template::locate_template( |
|
231 | - $templates_relative_path . 'receipt_body.template.php', |
|
232 | - $template_args, |
|
233 | - true, |
|
234 | - true |
|
235 | - ); |
|
236 | - } else { |
|
237 | - $template_body = EEH_Template::locate_template( |
|
238 | - $templates_relative_path . 'invoice_body.template.php', |
|
239 | - $template_args, |
|
240 | - true, |
|
241 | - true |
|
242 | - ); |
|
243 | - } |
|
221 | + // Get the HTML as an object |
|
222 | + $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
223 | + $template_header = EEH_Template::locate_template( |
|
224 | + $templates_relative_path . 'invoice_header.template.php', |
|
225 | + $template_args, |
|
226 | + true, |
|
227 | + true |
|
228 | + ); |
|
229 | + if (isset($_GET['receipt'])) { |
|
230 | + $template_body = EEH_Template::locate_template( |
|
231 | + $templates_relative_path . 'receipt_body.template.php', |
|
232 | + $template_args, |
|
233 | + true, |
|
234 | + true |
|
235 | + ); |
|
236 | + } else { |
|
237 | + $template_body = EEH_Template::locate_template( |
|
238 | + $templates_relative_path . 'invoice_body.template.php', |
|
239 | + $template_args, |
|
240 | + true, |
|
241 | + true |
|
242 | + ); |
|
243 | + } |
|
244 | 244 | |
245 | 245 | |
246 | - $template_footer = EEH_Template::locate_template( |
|
247 | - $templates_relative_path . 'invoice_footer.template.php', |
|
248 | - $template_args, |
|
249 | - true, |
|
250 | - true |
|
251 | - ); |
|
246 | + $template_footer = EEH_Template::locate_template( |
|
247 | + $templates_relative_path . 'invoice_footer.template.php', |
|
248 | + $template_args, |
|
249 | + true, |
|
250 | + true |
|
251 | + ); |
|
252 | 252 | |
253 | - $copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1; |
|
253 | + $copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1; |
|
254 | 254 | |
255 | - $content = $this->espresso_replace_invoice_shortcodes($template_header); |
|
256 | - for ($x = 1; $x <= $copies; $x++) { |
|
257 | - $content .= $this->espresso_replace_invoice_shortcodes($template_body); |
|
258 | - } |
|
259 | - $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
|
255 | + $content = $this->espresso_replace_invoice_shortcodes($template_header); |
|
256 | + for ($x = 1; $x <= $copies; $x++) { |
|
257 | + $content .= $this->espresso_replace_invoice_shortcodes($template_body); |
|
258 | + } |
|
259 | + $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
|
260 | 260 | |
261 | - // Check if debugging or mobile is set |
|
262 | - if (! empty($_REQUEST['html'])) { |
|
263 | - echo $content; |
|
264 | - exit(0); |
|
265 | - } |
|
266 | - $invoice_name = $template_args['organization'] . ' ' . __( |
|
267 | - 'Invoice #', |
|
268 | - 'event_espresso' |
|
269 | - ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name']; |
|
270 | - $invoice_name = str_replace(' ', '_', $invoice_name); |
|
271 | - // Create the PDF |
|
272 | - if (array_key_exists('html', $_GET)) { |
|
273 | - echo $content; |
|
274 | - } else { |
|
275 | - // only load dompdf if nobody else has yet... |
|
276 | - if (! class_exists('Dompdf\Dompdf')) { |
|
277 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
278 | - Dompdf\Autoloader::register(); |
|
279 | - } |
|
280 | - $options = new Dompdf\Options(); |
|
281 | - $options->set('isRemoteEnabled', true); |
|
282 | - $options->set('isJavascriptEnabled', false); |
|
283 | - if (defined('DOMPDF_FONT_DIR')) { |
|
284 | - $options->setFontDir(DOMPDF_FONT_DIR); |
|
285 | - $options->setFontCache(DOMPDF_FONT_DIR); |
|
286 | - } |
|
287 | - $dompdf = new Dompdf\Dompdf($options); |
|
288 | - $dompdf->loadHtml($content); |
|
289 | - $dompdf->render(); |
|
290 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download)); |
|
291 | - } |
|
292 | - exit(0); |
|
293 | - } |
|
261 | + // Check if debugging or mobile is set |
|
262 | + if (! empty($_REQUEST['html'])) { |
|
263 | + echo $content; |
|
264 | + exit(0); |
|
265 | + } |
|
266 | + $invoice_name = $template_args['organization'] . ' ' . __( |
|
267 | + 'Invoice #', |
|
268 | + 'event_espresso' |
|
269 | + ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name']; |
|
270 | + $invoice_name = str_replace(' ', '_', $invoice_name); |
|
271 | + // Create the PDF |
|
272 | + if (array_key_exists('html', $_GET)) { |
|
273 | + echo $content; |
|
274 | + } else { |
|
275 | + // only load dompdf if nobody else has yet... |
|
276 | + if (! class_exists('Dompdf\Dompdf')) { |
|
277 | + require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
278 | + Dompdf\Autoloader::register(); |
|
279 | + } |
|
280 | + $options = new Dompdf\Options(); |
|
281 | + $options->set('isRemoteEnabled', true); |
|
282 | + $options->set('isJavascriptEnabled', false); |
|
283 | + if (defined('DOMPDF_FONT_DIR')) { |
|
284 | + $options->setFontDir(DOMPDF_FONT_DIR); |
|
285 | + $options->setFontCache(DOMPDF_FONT_DIR); |
|
286 | + } |
|
287 | + $dompdf = new Dompdf\Dompdf($options); |
|
288 | + $dompdf->loadHtml($content); |
|
289 | + $dompdf->render(); |
|
290 | + $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download)); |
|
291 | + } |
|
292 | + exit(0); |
|
293 | + } |
|
294 | 294 | |
295 | - /** |
|
296 | - * Checks if this line item, or any of its children, actually has a description. |
|
297 | - * If none do, then the template can decide to not show any description column |
|
298 | - * |
|
299 | - * @param EE_Line_Item $line_item |
|
300 | - * @return boolean |
|
301 | - */ |
|
302 | - public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) |
|
303 | - { |
|
304 | - if ($line_item->desc()) { |
|
305 | - return true; |
|
306 | - } else { |
|
307 | - foreach ($line_item->children() as $child_line_item) { |
|
308 | - if ($this->check_if_any_line_items_have_a_description($child_line_item)) { |
|
309 | - return true; |
|
310 | - } |
|
311 | - } |
|
312 | - // well, if I and my children don't have descriptions, I guess not |
|
313 | - return false; |
|
314 | - } |
|
315 | - } |
|
295 | + /** |
|
296 | + * Checks if this line item, or any of its children, actually has a description. |
|
297 | + * If none do, then the template can decide to not show any description column |
|
298 | + * |
|
299 | + * @param EE_Line_Item $line_item |
|
300 | + * @return boolean |
|
301 | + */ |
|
302 | + public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) |
|
303 | + { |
|
304 | + if ($line_item->desc()) { |
|
305 | + return true; |
|
306 | + } else { |
|
307 | + foreach ($line_item->children() as $child_line_item) { |
|
308 | + if ($this->check_if_any_line_items_have_a_description($child_line_item)) { |
|
309 | + return true; |
|
310 | + } |
|
311 | + } |
|
312 | + // well, if I and my children don't have descriptions, I guess not |
|
313 | + return false; |
|
314 | + } |
|
315 | + } |
|
316 | 316 | |
317 | 317 | // Perform the shortcode replacement |
318 | - public function espresso_replace_invoice_shortcodes($content) |
|
319 | - { |
|
318 | + public function espresso_replace_invoice_shortcodes($content) |
|
319 | + { |
|
320 | 320 | |
321 | - $EE = EE_Registry::instance(); |
|
322 | - // Create the logo |
|
323 | - $invoice_logo_url = $this->invoice_payment_method->get_extra_meta( |
|
324 | - 'pdf_logo_image', |
|
325 | - true, |
|
326 | - $EE->CFG->organization->logo_url |
|
327 | - ); |
|
328 | - if (! empty($invoice_logo_url)) { |
|
329 | - $image_size = getimagesize($invoice_logo_url); |
|
330 | - $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
331 | - } else { |
|
332 | - $invoice_logo_image = ''; |
|
333 | - } |
|
334 | - $SearchValues = array( |
|
335 | - "[organization]", |
|
336 | - "[registration_code]", |
|
337 | - "[transaction_id]", |
|
338 | - "[name]", |
|
339 | - "[base_url]", |
|
340 | - "[download_link]", |
|
341 | - "[invoice_logo_image]", |
|
342 | - "[street]", |
|
343 | - "[city]", |
|
344 | - "[state]", |
|
345 | - "[zip]", |
|
346 | - "[email]", |
|
347 | - "[vat]", |
|
348 | - "[registration_date]", |
|
349 | - "[instructions]", |
|
350 | - ); |
|
351 | - $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
352 | - $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); |
|
353 | - if ($org_state) { |
|
354 | - $org_state_name = $org_state->name(); |
|
355 | - } else { |
|
356 | - $org_state_name = ''; |
|
357 | - } |
|
358 | - $ReplaceValues = array( |
|
359 | - $EE->CFG->organization->get_pretty('name'), |
|
360 | - $this->registration->reg_code(), |
|
361 | - $this->transaction->ID(), |
|
362 | - $primary_attendee->full_name(), |
|
363 | - (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
364 | - : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
365 | - $this->registration->invoice_url(), |
|
366 | - // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
|
367 | - $invoice_logo_image, |
|
368 | - empty($EE->CFG->organization->address_2) |
|
369 | - ? $EE->CFG->organization->get_pretty('address_1') |
|
370 | - : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
371 | - 'address_2' |
|
372 | - ), |
|
373 | - $EE->CFG->organization->get_pretty('city'), |
|
374 | - $org_state_name, |
|
375 | - $EE->CFG->organization->get_pretty('zip'), |
|
376 | - $EE->CFG->organization->get_pretty('email'), |
|
377 | - $EE->CFG->organization->vat, |
|
378 | - $this->registration->get_i18n_datetime('REG_date', get_option('date_format')), |
|
379 | - $this->invoice_payment_method->get_extra_meta('pdf_instructions', true), |
|
380 | - ); |
|
321 | + $EE = EE_Registry::instance(); |
|
322 | + // Create the logo |
|
323 | + $invoice_logo_url = $this->invoice_payment_method->get_extra_meta( |
|
324 | + 'pdf_logo_image', |
|
325 | + true, |
|
326 | + $EE->CFG->organization->logo_url |
|
327 | + ); |
|
328 | + if (! empty($invoice_logo_url)) { |
|
329 | + $image_size = getimagesize($invoice_logo_url); |
|
330 | + $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
331 | + } else { |
|
332 | + $invoice_logo_image = ''; |
|
333 | + } |
|
334 | + $SearchValues = array( |
|
335 | + "[organization]", |
|
336 | + "[registration_code]", |
|
337 | + "[transaction_id]", |
|
338 | + "[name]", |
|
339 | + "[base_url]", |
|
340 | + "[download_link]", |
|
341 | + "[invoice_logo_image]", |
|
342 | + "[street]", |
|
343 | + "[city]", |
|
344 | + "[state]", |
|
345 | + "[zip]", |
|
346 | + "[email]", |
|
347 | + "[vat]", |
|
348 | + "[registration_date]", |
|
349 | + "[instructions]", |
|
350 | + ); |
|
351 | + $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
352 | + $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); |
|
353 | + if ($org_state) { |
|
354 | + $org_state_name = $org_state->name(); |
|
355 | + } else { |
|
356 | + $org_state_name = ''; |
|
357 | + } |
|
358 | + $ReplaceValues = array( |
|
359 | + $EE->CFG->organization->get_pretty('name'), |
|
360 | + $this->registration->reg_code(), |
|
361 | + $this->transaction->ID(), |
|
362 | + $primary_attendee->full_name(), |
|
363 | + (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
364 | + : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
365 | + $this->registration->invoice_url(), |
|
366 | + // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
|
367 | + $invoice_logo_image, |
|
368 | + empty($EE->CFG->organization->address_2) |
|
369 | + ? $EE->CFG->organization->get_pretty('address_1') |
|
370 | + : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
371 | + 'address_2' |
|
372 | + ), |
|
373 | + $EE->CFG->organization->get_pretty('city'), |
|
374 | + $org_state_name, |
|
375 | + $EE->CFG->organization->get_pretty('zip'), |
|
376 | + $EE->CFG->organization->get_pretty('email'), |
|
377 | + $EE->CFG->organization->vat, |
|
378 | + $this->registration->get_i18n_datetime('REG_date', get_option('date_format')), |
|
379 | + $this->invoice_payment_method->get_extra_meta('pdf_instructions', true), |
|
380 | + ); |
|
381 | 381 | |
382 | - return str_replace($SearchValues, $ReplaceValues, $content); |
|
383 | - } |
|
382 | + return str_replace($SearchValues, $ReplaceValues, $content); |
|
383 | + } |
|
384 | 384 | |
385 | - public function espressoLoadData($items) |
|
386 | - { |
|
387 | - $lines = $items; |
|
388 | - $data = array(); |
|
389 | - foreach ($lines as $line) { |
|
390 | - $data[] = explode(';', chop($line)); |
|
391 | - } |
|
385 | + public function espressoLoadData($items) |
|
386 | + { |
|
387 | + $lines = $items; |
|
388 | + $data = array(); |
|
389 | + foreach ($lines as $line) { |
|
390 | + $data[] = explode(';', chop($line)); |
|
391 | + } |
|
392 | 392 | |
393 | - return $data; |
|
394 | - } |
|
393 | + return $data; |
|
394 | + } |
|
395 | 395 | |
396 | 396 | |
397 | - public function espressoInvoiceTotals($text, $total_cost) |
|
398 | - { |
|
397 | + public function espressoInvoiceTotals($text, $total_cost) |
|
398 | + { |
|
399 | 399 | |
400 | - $html = ''; |
|
401 | - if ($total_cost < 0) { |
|
402 | - $total_cost = (-1) * $total_cost; |
|
403 | - } |
|
404 | - $find = array(' '); |
|
405 | - $replace = array('-'); |
|
406 | - $row_id = strtolower(str_replace($find, $replace, $text)); |
|
407 | - $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
408 | - $html .= '<td class="item_r">' . $text . '</td>'; |
|
409 | - $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
410 | - $html .= '</tr>'; |
|
411 | - return $html; |
|
412 | - } |
|
400 | + $html = ''; |
|
401 | + if ($total_cost < 0) { |
|
402 | + $total_cost = (-1) * $total_cost; |
|
403 | + } |
|
404 | + $find = array(' '); |
|
405 | + $replace = array('-'); |
|
406 | + $row_id = strtolower(str_replace($find, $replace, $text)); |
|
407 | + $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
408 | + $html .= '<td class="item_r">' . $text . '</td>'; |
|
409 | + $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
410 | + $html .= '</tr>'; |
|
411 | + return $html; |
|
412 | + } |
|
413 | 413 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
3 | 3 | $values = EEH_Form_Fields::prep_answer_options( |
4 | - array( |
|
5 | - array('id' => 1, 'text' => __('Yes', 'event_espresso')), |
|
6 | - array('id' => 0, 'text' => __('No', 'event_espresso')), |
|
7 | - ) |
|
4 | + array( |
|
5 | + array('id' => 1, 'text' => __('Yes', 'event_espresso')), |
|
6 | + array('id' => 0, 'text' => __('No', 'event_espresso')), |
|
7 | + ) |
|
8 | 8 | ); |
9 | 9 | ?> |
10 | 10 | |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | <h2 class="ee-admin-settings-hdr"> |
14 | 14 | <?php _e( |
15 | - 'Single Event Pages', |
|
16 | - 'event_espresso' |
|
17 | - ); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?> |
|
15 | + 'Single Event Pages', |
|
16 | + 'event_espresso' |
|
17 | + ); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?> |
|
18 | 18 | </h2> |
19 | 19 | <table class="form-table"> |
20 | 20 | <tbody> |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | </th> |
27 | 27 | <td> |
28 | 28 | <?php echo EEH_Form_Fields::select( |
29 | - 'display_status_banner_single', |
|
30 | - $display_status_banner_single, |
|
31 | - $values, |
|
32 | - 'display_status_banner_single', |
|
33 | - 'display_status_banner_single' |
|
34 | - ); ?> |
|
29 | + 'display_status_banner_single', |
|
30 | + $display_status_banner_single, |
|
31 | + $values, |
|
32 | + 'display_status_banner_single', |
|
33 | + 'display_status_banner_single' |
|
34 | + ); ?> |
|
35 | 35 | <p class="description"><?php |
36 | - _e( |
|
37 | - 'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.', |
|
38 | - 'event_espresso' |
|
39 | - ); ?></p> |
|
36 | + _e( |
|
37 | + 'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.', |
|
38 | + 'event_espresso' |
|
39 | + ); ?></p> |
|
40 | 40 | </td> |
41 | 41 | </tr> |
42 | 42 | |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | <th> |
45 | 45 | <label for="display_venue"> |
46 | 46 | <?php _e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
47 | - 'display_addresses_in_reg_form_info' |
|
48 | - ); ?> |
|
47 | + 'display_addresses_in_reg_form_info' |
|
48 | + ); ?> |
|
49 | 49 | </label> |
50 | 50 | </th> |
51 | 51 | <td> |
52 | 52 | <?php echo EEH_Form_Fields::select( |
53 | - 'display_venue', |
|
54 | - $display_venue, |
|
55 | - $values, |
|
56 | - 'display_venue', |
|
57 | - 'display_venue' |
|
58 | - ); ?> |
|
53 | + 'display_venue', |
|
54 | + $display_venue, |
|
55 | + $values, |
|
56 | + 'display_venue', |
|
57 | + 'display_venue' |
|
58 | + ); ?> |
|
59 | 59 | <p class="description"><?php |
60 | - _e( |
|
61 | - 'Do not use this if you are using the venue shortcodes in your event description.', |
|
62 | - 'event_espresso' |
|
63 | - ); ?></p> |
|
60 | + _e( |
|
61 | + 'Do not use this if you are using the venue shortcodes in your event description.', |
|
62 | + 'event_espresso' |
|
63 | + ); ?></p> |
|
64 | 64 | </td> |
65 | 65 | </tr> |
66 | 66 | |
@@ -72,37 +72,37 @@ discard block |
||
72 | 72 | </th> |
73 | 73 | <td> |
74 | 74 | <?php |
75 | - echo EEH_Form_Fields::select( |
|
76 | - 'use_sortable_display_order', |
|
77 | - $use_sortable_display_order, |
|
78 | - $values, |
|
79 | - 'EED_Events_Single_use_sortable_display_order', |
|
80 | - 'EED_Events_Single_use_sortable_display_order' |
|
81 | - ); |
|
82 | - ?> |
|
75 | + echo EEH_Form_Fields::select( |
|
76 | + 'use_sortable_display_order', |
|
77 | + $use_sortable_display_order, |
|
78 | + $values, |
|
79 | + 'EED_Events_Single_use_sortable_display_order', |
|
80 | + 'EED_Events_Single_use_sortable_display_order' |
|
81 | + ); |
|
82 | + ?> |
|
83 | 83 | </td> |
84 | 84 | </tr> |
85 | 85 | |
86 | 86 | <tr> |
87 | 87 | <th> |
88 | 88 | <?php _e('Display Order', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
89 | - 'display_addresses_in_reg_form_info' |
|
90 | - ); ?> |
|
89 | + 'display_addresses_in_reg_form_info' |
|
90 | + ); ?> |
|
91 | 91 | </th> |
92 | 92 | <td> |
93 | 93 | |
94 | 94 | <?php wp_nonce_field( |
95 | - 'espresso_update_event_single_order', |
|
96 | - 'espresso_update_event_single_order_nonce', |
|
97 | - false |
|
98 | - ); ?> |
|
95 | + 'espresso_update_event_single_order', |
|
96 | + 'espresso_update_event_single_order_nonce', |
|
97 | + false |
|
98 | + ); ?> |
|
99 | 99 | <?php echo $event_single_display_order; ?> |
100 | 100 | |
101 | 101 | <p class="description"><?php |
102 | - _e( |
|
103 | - 'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.', |
|
104 | - 'event_espresso' |
|
105 | - ); ?></p> |
|
102 | + _e( |
|
103 | + 'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.', |
|
104 | + 'event_espresso' |
|
105 | + ); ?></p> |
|
106 | 106 | |
107 | 107 | </td> |
108 | 108 | </tr> |
@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | class URLValidator |
18 | 18 | { |
19 | - /** |
|
20 | - * Returns whether or not the URL is valid |
|
21 | - * @since 4.9.68.p |
|
22 | - * @param $url |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function isValid($url) |
|
26 | - { |
|
27 | - return esc_url_raw($url) === $url; |
|
28 | - } |
|
19 | + /** |
|
20 | + * Returns whether or not the URL is valid |
|
21 | + * @since 4.9.68.p |
|
22 | + * @param $url |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function isValid($url) |
|
26 | + { |
|
27 | + return esc_url_raw($url) === $url; |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | // End of file URLValidator.php |
31 | 31 | // Location: ${NAMESPACE}/URLValidator.php |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | <h2 class="ee-admin-settings-hdr"> |
12 | 12 | <?php _e( |
13 | - 'Countries and States/Provinces', |
|
14 | - 'event_espresso' |
|
15 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
13 | + 'Countries and States/Provinces', |
|
14 | + 'event_espresso' |
|
15 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
16 | 16 | <table class="form-table"> |
17 | 17 | <tbody> |
18 | 18 | <?php echo EEH_Form_Fields::generate_form_input($countries); ?> |
@@ -21,38 +21,38 @@ discard block |
||
21 | 21 | <br/> |
22 | 22 | <p> |
23 | 23 | <?php |
24 | - esc_html_e( |
|
25 | - 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
26 | - 'event_espresso' |
|
27 | - ); |
|
28 | - ?> |
|
24 | + esc_html_e( |
|
25 | + 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
26 | + 'event_espresso' |
|
27 | + ); |
|
28 | + ?> |
|
29 | 29 | </p> |
30 | 30 | <p id="country-currency-setting-disabled-pg" style="display: none;"> |
31 | 31 | <span class="reminder-spn"> |
32 | 32 | <?php printf( |
33 | - esc_html__( |
|
34 | - 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
35 | - 'event_espresso' |
|
36 | - ), |
|
37 | - $CNT_name_for_site |
|
38 | - ); ?> |
|
33 | + esc_html__( |
|
34 | + 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
35 | + 'event_espresso' |
|
36 | + ), |
|
37 | + $CNT_name_for_site |
|
38 | + ); ?> |
|
39 | 39 | </span> |
40 | 40 | </p> |
41 | 41 | <div id="country-details-settings-dv"> |
42 | 42 | <h2 class="ee-admin-settings-hdr"> |
43 | 43 | <?php _e( |
44 | - 'Country Details', |
|
45 | - 'event_espresso' |
|
46 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
44 | + 'Country Details', |
|
45 | + 'event_espresso' |
|
46 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
47 | 47 | <div id="country-details-dv"><?php echo $country_details_settings; ?></div> |
48 | 48 | </div> |
49 | 49 | |
50 | 50 | <div id="country-states-settings-dv"> |
51 | 51 | <h2 class="ee-admin-settings-hdr"> |
52 | 52 | <?php _e( |
53 | - 'States/Provinces', |
|
54 | - 'event_espresso' |
|
55 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
53 | + 'States/Provinces', |
|
54 | + 'event_espresso' |
|
55 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
56 | 56 | <div id="country-states-dv"><?php echo $country_states_settings; ?></div> |
57 | 57 | </div> |
58 | 58 |