@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | //unfortunately, this needs to be done upon INCLUSION of this file, |
10 | 10 | //instead of construction, because it only gets constructed on first page load |
11 | 11 | //(all other times it gets resurrected from a wordpress option) |
12 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
|
12 | +$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*'); |
|
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | 15 | $matches = array(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } elseif ( ! $version_string) { |
68 | 68 | // echo "no version string provided: $version_string"; |
69 | 69 | //no version string provided... this must be pre 4.3 |
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | 71 | } else { |
72 | 72 | // echo "$version_string doesnt apply"; |
73 | 73 | return false; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function schema_changes_before_migration() |
93 | 93 | { |
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
94 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
95 | 95 | $now_in_mysql = current_time('mysql', true); |
96 | 96 | $table_name = 'esp_answer'; |
97 | 97 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = array(); |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[$matches[1]] = $filepath; |
|
15 | + $matches = array(); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | //give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,77 +33,77 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = __("Data Migration to Event Espresso 4.9.0.P", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = __("Data Migration to Event Espresso 4.9.0.P", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | 65 | // echo "$version_string can be migrated from"; |
66 | - return true; |
|
67 | - } elseif ( ! $version_string) { |
|
66 | + return true; |
|
67 | + } elseif ( ! $version_string) { |
|
68 | 68 | // echo "no version string provided: $version_string"; |
69 | - //no version string provided... this must be pre 4.3 |
|
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | - } else { |
|
69 | + //no version string provided... this must be pre 4.3 |
|
70 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + } else { |
|
72 | 72 | // echo "$version_string doesnt apply"; |
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return string|void |
|
81 | - */ |
|
82 | - public function pretty_name() |
|
83 | - { |
|
84 | - return __("Core Data Migration to version 4.9.0", "event_espresso"); |
|
85 | - } |
|
79 | + /** |
|
80 | + * @return string|void |
|
81 | + */ |
|
82 | + public function pretty_name() |
|
83 | + { |
|
84 | + return __("Core Data Migration to version 4.9.0", "event_espresso"); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - public function schema_changes_before_migration() |
|
93 | - { |
|
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | - $now_in_mysql = current_time('mysql', true); |
|
96 | - $table_name = 'esp_answer'; |
|
97 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
89 | + /** |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public function schema_changes_before_migration() |
|
93 | + { |
|
94 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | + $now_in_mysql = current_time('mysql', true); |
|
96 | + $table_name = 'esp_answer'; |
|
97 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | REG_ID int(10) unsigned NOT NULL, |
99 | 99 | QST_ID int(10) unsigned NOT NULL, |
100 | 100 | ANS_value text NOT NULL, |
101 | 101 | PRIMARY KEY (ANS_ID), |
102 | 102 | KEY REG_ID (REG_ID), |
103 | 103 | KEY QST_ID (QST_ID)"; |
104 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
105 | - $table_name = 'esp_attendee_meta'; |
|
106 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
104 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
105 | + $table_name = 'esp_attendee_meta'; |
|
106 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
107 | 107 | ATT_ID bigint(20) unsigned NOT NULL, |
108 | 108 | ATT_fname varchar(45) NOT NULL, |
109 | 109 | ATT_lname varchar(45) NOT NULL, |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | KEY ATT_email (ATT_email), |
121 | 121 | KEY ATT_lname (ATT_lname), |
122 | 122 | KEY ATT_fname (ATT_fname)"; |
123 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
124 | - $table_name = 'esp_checkin'; |
|
125 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
123 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
124 | + $table_name = 'esp_checkin'; |
|
125 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
126 | 126 | REG_ID int(10) unsigned NOT NULL, |
127 | 127 | DTT_ID int(10) unsigned NOT NULL, |
128 | 128 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | PRIMARY KEY (CHK_ID), |
131 | 131 | KEY REG_ID (REG_ID), |
132 | 132 | KEY DTT_ID (DTT_ID)"; |
133 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
134 | - $table_name = 'esp_country'; |
|
135 | - $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
133 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
134 | + $table_name = 'esp_country'; |
|
135 | + $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
136 | 136 | CNT_ISO3 varchar(3) collate utf8_bin NOT NULL, |
137 | 137 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
138 | 138 | CNT_name varchar(45) collate utf8_bin NOT NULL, |
@@ -148,25 +148,25 @@ discard block |
||
148 | 148 | CNT_is_EU tinyint(1) DEFAULT '0', |
149 | 149 | CNT_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CNT_ISO)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - $table_name = 'esp_currency'; |
|
153 | - $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + $table_name = 'esp_currency'; |
|
153 | + $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
154 | 154 | CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar', |
155 | 155 | CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars', |
156 | 156 | CUR_sign varchar(45) collate utf8_bin DEFAULT '$', |
157 | 157 | CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2', |
158 | 158 | CUR_active tinyint(1) DEFAULT '0', |
159 | 159 | PRIMARY KEY (CUR_code)"; |
160 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | - $table_name = 'esp_currency_payment_method'; |
|
162 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
160 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
161 | + $table_name = 'esp_currency_payment_method'; |
|
162 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
163 | 163 | CUR_code varchar(6) collate utf8_bin NOT NULL, |
164 | 164 | PMD_ID int(11) NOT NULL, |
165 | 165 | PRIMARY KEY (CPM_ID), |
166 | 166 | KEY PMD_ID (PMD_ID)"; |
167 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
168 | - $table_name = 'esp_datetime'; |
|
169 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
167 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
168 | + $table_name = 'esp_datetime'; |
|
169 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
170 | 170 | EVT_ID bigint(20) unsigned NOT NULL, |
171 | 171 | DTT_name varchar(255) NOT NULL DEFAULT '', |
172 | 172 | DTT_description text NOT NULL, |
@@ -182,25 +182,25 @@ discard block |
||
182 | 182 | KEY DTT_EVT_start (DTT_EVT_start), |
183 | 183 | KEY EVT_ID (EVT_ID), |
184 | 184 | KEY DTT_is_primary (DTT_is_primary)"; |
185 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | - $table_name = "esp_datetime_ticket"; |
|
187 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
185 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | + $table_name = "esp_datetime_ticket"; |
|
187 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
188 | 188 | DTT_ID int(10) unsigned NOT NULL, |
189 | 189 | TKT_ID int(10) unsigned NOT NULL, |
190 | 190 | PRIMARY KEY (DTK_ID), |
191 | 191 | KEY DTT_ID (DTT_ID), |
192 | 192 | KEY TKT_ID (TKT_ID)"; |
193 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | - $table_name = 'esp_event_message_template'; |
|
195 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
193 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | + $table_name = 'esp_event_message_template'; |
|
195 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
196 | 196 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
197 | 197 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
198 | 198 | PRIMARY KEY (EMT_ID), |
199 | 199 | KEY EVT_ID (EVT_ID), |
200 | 200 | KEY GRP_ID (GRP_ID)"; |
201 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
202 | - $table_name = 'esp_event_meta'; |
|
203 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
201 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
202 | + $table_name = 'esp_event_meta'; |
|
203 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
204 | 204 | EVT_ID bigint(20) unsigned NOT NULL, |
205 | 205 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
206 | 206 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -215,34 +215,34 @@ discard block |
||
215 | 215 | EVT_donations tinyint(1) NULL, |
216 | 216 | PRIMARY KEY (EVTM_ID), |
217 | 217 | KEY EVT_ID (EVT_ID)"; |
218 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
219 | - $table_name = 'esp_event_question_group'; |
|
220 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
218 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
219 | + $table_name = 'esp_event_question_group'; |
|
220 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
221 | 221 | EVT_ID bigint(20) unsigned NOT NULL, |
222 | 222 | QSG_ID int(10) unsigned NOT NULL, |
223 | 223 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
224 | 224 | PRIMARY KEY (EQG_ID), |
225 | 225 | KEY EVT_ID (EVT_ID), |
226 | 226 | KEY QSG_ID (QSG_ID)"; |
227 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
228 | - $table_name = 'esp_event_venue'; |
|
229 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
227 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
228 | + $table_name = 'esp_event_venue'; |
|
229 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | 230 | EVT_ID bigint(20) unsigned NOT NULL, |
231 | 231 | VNU_ID bigint(20) unsigned NOT NULL, |
232 | 232 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
233 | 233 | PRIMARY KEY (EVV_ID)"; |
234 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | - $table_name = 'esp_extra_meta'; |
|
236 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
234 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
235 | + $table_name = 'esp_extra_meta'; |
|
236 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
237 | 237 | OBJ_ID int(11) DEFAULT NULL, |
238 | 238 | EXM_type varchar(45) DEFAULT NULL, |
239 | 239 | EXM_key varchar(45) DEFAULT NULL, |
240 | 240 | EXM_value text, |
241 | 241 | PRIMARY KEY (EXM_ID), |
242 | 242 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
243 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
244 | - $table_name = 'esp_extra_join'; |
|
245 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
243 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
244 | + $table_name = 'esp_extra_join'; |
|
245 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
246 | 246 | EXJ_first_model_id varchar(6) NOT NULL, |
247 | 247 | EXJ_first_model_name varchar(20) NOT NULL, |
248 | 248 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | PRIMARY KEY (EXJ_ID), |
251 | 251 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
252 | 252 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
253 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
254 | - $table_name = 'esp_line_item'; |
|
255 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
253 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
254 | + $table_name = 'esp_line_item'; |
|
255 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
256 | 256 | LIN_code varchar(245) NOT NULL DEFAULT '', |
257 | 257 | TXN_ID int(11) DEFAULT NULL, |
258 | 258 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | PRIMARY KEY (LIN_ID), |
272 | 272 | KEY LIN_code (LIN_code(191)), |
273 | 273 | KEY TXN_ID (TXN_ID)"; |
274 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | - $table_name = 'esp_log'; |
|
276 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
274 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | + $table_name = 'esp_log'; |
|
276 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
277 | 277 | LOG_time datetime DEFAULT NULL, |
278 | 278 | OBJ_ID varchar(45) DEFAULT NULL, |
279 | 279 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | KEY LOG_time (LOG_time), |
285 | 285 | KEY OBJ (OBJ_type,OBJ_ID), |
286 | 286 | KEY LOG_type (LOG_type)"; |
287 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | - $table_name = 'esp_message'; |
|
289 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
287 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | + $table_name = 'esp_message'; |
|
289 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
290 | 290 | GRP_ID int(10) unsigned NULL, |
291 | 291 | MSG_token varchar(255) NULL, |
292 | 292 | TXN_ID int(10) unsigned NULL, |
@@ -318,18 +318,18 @@ discard block |
||
318 | 318 | KEY STS_ID (STS_ID), |
319 | 319 | KEY MSG_created (MSG_created), |
320 | 320 | KEY MSG_modified (MSG_modified)"; |
321 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
322 | - $table_name = 'esp_message_template'; |
|
323 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
321 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
322 | + $table_name = 'esp_message_template'; |
|
323 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
324 | 324 | GRP_ID int(10) unsigned NOT NULL, |
325 | 325 | MTP_context varchar(50) NOT NULL, |
326 | 326 | MTP_template_field varchar(30) NOT NULL, |
327 | 327 | MTP_content text NOT NULL, |
328 | 328 | PRIMARY KEY (MTP_ID), |
329 | 329 | KEY GRP_ID (GRP_ID)"; |
330 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
331 | - $table_name = 'esp_message_template_group'; |
|
332 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
330 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
331 | + $table_name = 'esp_message_template_group'; |
|
332 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
333 | 333 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
334 | 334 | MTP_name varchar(245) NOT NULL DEFAULT '', |
335 | 335 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
342 | 342 | PRIMARY KEY (GRP_ID), |
343 | 343 | KEY MTP_user_id (MTP_user_id)"; |
344 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
345 | - $table_name = 'esp_payment'; |
|
346 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
344 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
345 | + $table_name = 'esp_payment'; |
|
346 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
347 | 347 | TXN_ID int(10) unsigned DEFAULT NULL, |
348 | 348 | STS_ID varchar(3) collate utf8_bin DEFAULT NULL, |
349 | 349 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | PRIMARY KEY (PAY_ID), |
361 | 361 | KEY PAY_timestamp (PAY_timestamp), |
362 | 362 | KEY TXN_ID (TXN_ID)"; |
363 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
364 | - $table_name = 'esp_payment_method'; |
|
365 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
363 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
364 | + $table_name = 'esp_payment_method'; |
|
365 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
366 | 366 | PMD_type varchar(124) DEFAULT NULL, |
367 | 367 | PMD_name varchar(255) DEFAULT NULL, |
368 | 368 | PMD_desc text, |
@@ -378,24 +378,24 @@ discard block |
||
378 | 378 | PRIMARY KEY (PMD_ID), |
379 | 379 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
380 | 380 | KEY PMD_type (PMD_type)"; |
381 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
382 | - $table_name = "esp_ticket_price"; |
|
383 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
381 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
382 | + $table_name = "esp_ticket_price"; |
|
383 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
384 | 384 | TKT_ID int(10) unsigned NOT NULL, |
385 | 385 | PRC_ID int(10) unsigned NOT NULL, |
386 | 386 | PRIMARY KEY (TKP_ID), |
387 | 387 | KEY TKT_ID (TKT_ID), |
388 | 388 | KEY PRC_ID (PRC_ID)"; |
389 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
390 | - $table_name = "esp_ticket_template"; |
|
391 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
389 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
390 | + $table_name = "esp_ticket_template"; |
|
391 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
392 | 392 | TTM_name varchar(45) NOT NULL, |
393 | 393 | TTM_description text, |
394 | 394 | TTM_file varchar(45), |
395 | 395 | PRIMARY KEY (TTM_ID)"; |
396 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
397 | - $table_name = 'esp_question'; |
|
398 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
396 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
397 | + $table_name = 'esp_question'; |
|
398 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
399 | 399 | QST_display_text text NOT NULL, |
400 | 400 | QST_admin_label varchar(255) NOT NULL, |
401 | 401 | QST_system varchar(25) DEFAULT NULL, |
@@ -409,18 +409,18 @@ discard block |
||
409 | 409 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
410 | 410 | PRIMARY KEY (QST_ID), |
411 | 411 | KEY QST_order (QST_order)'; |
412 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
413 | - $table_name = 'esp_question_group_question'; |
|
414 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
412 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
413 | + $table_name = 'esp_question_group_question'; |
|
414 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
415 | 415 | QSG_ID int(10) unsigned NOT NULL, |
416 | 416 | QST_ID int(10) unsigned NOT NULL, |
417 | 417 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
418 | 418 | PRIMARY KEY (QGQ_ID), |
419 | 419 | KEY QST_ID (QST_ID), |
420 | 420 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
421 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
422 | - $table_name = 'esp_question_option'; |
|
423 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
421 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
422 | + $table_name = 'esp_question_option'; |
|
423 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
424 | 424 | QSO_value varchar(255) NOT NULL, |
425 | 425 | QSO_desc text NOT NULL, |
426 | 426 | QST_ID int(10) unsigned NOT NULL, |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | PRIMARY KEY (QSO_ID), |
431 | 431 | KEY QST_ID (QST_ID), |
432 | 432 | KEY QSO_order (QSO_order)"; |
433 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
434 | - $table_name = 'esp_registration'; |
|
435 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
433 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
434 | + $table_name = 'esp_registration'; |
|
435 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
436 | 436 | EVT_ID bigint(20) unsigned NOT NULL, |
437 | 437 | ATT_ID bigint(20) unsigned NOT NULL, |
438 | 438 | TXN_ID int(10) unsigned NOT NULL, |
@@ -456,18 +456,18 @@ discard block |
||
456 | 456 | KEY TKT_ID (TKT_ID), |
457 | 457 | KEY EVT_ID (EVT_ID), |
458 | 458 | KEY STS_ID (STS_ID)"; |
459 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
460 | - $table_name = 'esp_registration_payment'; |
|
461 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
459 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
460 | + $table_name = 'esp_registration_payment'; |
|
461 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
462 | 462 | REG_ID int(10) unsigned NOT NULL, |
463 | 463 | PAY_ID int(10) unsigned NULL, |
464 | 464 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
465 | 465 | PRIMARY KEY (RPY_ID), |
466 | 466 | KEY REG_ID (REG_ID), |
467 | 467 | KEY PAY_ID (PAY_ID)"; |
468 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
469 | - $table_name = 'esp_state'; |
|
470 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
468 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
469 | + $table_name = 'esp_state'; |
|
470 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
471 | 471 | CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
472 | 472 | STA_abbrev varchar(24) collate utf8_bin NOT NULL, |
473 | 473 | STA_name varchar(100) collate utf8_bin NOT NULL, |
@@ -475,9 +475,9 @@ discard block |
||
475 | 475 | PRIMARY KEY (STA_ID), |
476 | 476 | KEY STA_abbrev (STA_abbrev), |
477 | 477 | KEY CNT_ISO (CNT_ISO)"; |
478 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
479 | - $table_name = 'esp_status'; |
|
480 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
478 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
479 | + $table_name = 'esp_status'; |
|
480 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
481 | 481 | STS_code varchar(45) NOT NULL, |
482 | 482 | STS_type varchar(45) NOT NULL, |
483 | 483 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -485,9 +485,9 @@ discard block |
||
485 | 485 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
486 | 486 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
487 | 487 | KEY STS_type (STS_type)"; |
488 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
489 | - $table_name = 'esp_transaction'; |
|
490 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
488 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
489 | + $table_name = 'esp_transaction'; |
|
490 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
491 | 491 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
492 | 492 | TXN_total decimal(10,3) DEFAULT '0.00', |
493 | 493 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -499,9 +499,9 @@ discard block |
||
499 | 499 | PRIMARY KEY (TXN_ID), |
500 | 500 | KEY TXN_timestamp (TXN_timestamp), |
501 | 501 | KEY STS_ID (STS_ID)"; |
502 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
503 | - $table_name = 'esp_venue_meta'; |
|
504 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
502 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
503 | + $table_name = 'esp_venue_meta'; |
|
504 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
505 | 505 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
506 | 506 | VNU_address varchar(255) DEFAULT NULL, |
507 | 507 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | KEY VNU_ID (VNU_ID), |
521 | 521 | KEY STA_ID (STA_ID), |
522 | 522 | KEY CNT_ISO (CNT_ISO)"; |
523 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
524 | - //modified tables |
|
525 | - $table_name = "esp_price"; |
|
526 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
523 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
524 | + //modified tables |
|
525 | + $table_name = "esp_price"; |
|
526 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
527 | 527 | PRT_ID tinyint(3) unsigned NOT NULL, |
528 | 528 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
529 | 529 | PRC_name varchar(245) NOT NULL, |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | PRC_parent int(10) unsigned DEFAULT 0, |
537 | 537 | PRIMARY KEY (PRC_ID), |
538 | 538 | KEY PRT_ID (PRT_ID)"; |
539 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
540 | - $table_name = "esp_price_type"; |
|
541 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
539 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
540 | + $table_name = "esp_price_type"; |
|
541 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
542 | 542 | PRT_name varchar(45) NOT NULL, |
543 | 543 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
544 | 544 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
548 | 548 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
549 | 549 | PRIMARY KEY (PRT_ID)"; |
550 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
551 | - $table_name = "esp_ticket"; |
|
552 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
550 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
551 | + $table_name = "esp_ticket"; |
|
552 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
553 | 553 | TTM_ID int(10) unsigned NOT NULL, |
554 | 554 | TKT_name varchar(245) NOT NULL DEFAULT '', |
555 | 555 | TKT_description text NOT NULL, |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
572 | 572 | PRIMARY KEY (TKT_ID), |
573 | 573 | KEY TKT_start_date (TKT_start_date)"; |
574 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | - $table_name = 'esp_question_group'; |
|
576 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
574 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
575 | + $table_name = 'esp_question_group'; |
|
576 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
577 | 577 | QSG_name varchar(255) NOT NULL, |
578 | 578 | QSG_identifier varchar(100) NOT NULL, |
579 | 579 | QSG_desc text NULL, |
@@ -586,41 +586,41 @@ discard block |
||
586 | 586 | PRIMARY KEY (QSG_ID), |
587 | 587 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
588 | 588 | KEY QSG_order (QSG_order)'; |
589 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
591 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
592 | - //(because many need to convert old string states to foreign keys into the states table) |
|
593 | - $script_4_1_defaults->insert_default_states(); |
|
594 | - $script_4_1_defaults->insert_default_countries(); |
|
595 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
596 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
597 | - $script_4_5_defaults->insert_default_price_types(); |
|
598 | - $script_4_5_defaults->insert_default_prices(); |
|
599 | - $script_4_5_defaults->insert_default_tickets(); |
|
600 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
601 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
602 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
603 | - $script_4_6_defaults->insert_default_currencies(); |
|
604 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
605 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
606 | - $script_4_8_defaults->verify_new_countries(); |
|
607 | - $script_4_8_defaults->verify_new_currencies(); |
|
608 | - return true; |
|
609 | - } |
|
589 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
590 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
591 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
592 | + //(because many need to convert old string states to foreign keys into the states table) |
|
593 | + $script_4_1_defaults->insert_default_states(); |
|
594 | + $script_4_1_defaults->insert_default_countries(); |
|
595 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
596 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
597 | + $script_4_5_defaults->insert_default_price_types(); |
|
598 | + $script_4_5_defaults->insert_default_prices(); |
|
599 | + $script_4_5_defaults->insert_default_tickets(); |
|
600 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
601 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
602 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
603 | + $script_4_6_defaults->insert_default_currencies(); |
|
604 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
605 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
606 | + $script_4_8_defaults->verify_new_countries(); |
|
607 | + $script_4_8_defaults->verify_new_currencies(); |
|
608 | + return true; |
|
609 | + } |
|
610 | 610 | |
611 | 611 | |
612 | 612 | |
613 | - /** |
|
614 | - * @return boolean |
|
615 | - */ |
|
616 | - public function schema_changes_after_migration() |
|
617 | - { |
|
618 | - return true; |
|
619 | - } |
|
613 | + /** |
|
614 | + * @return boolean |
|
615 | + */ |
|
616 | + public function schema_changes_after_migration() |
|
617 | + { |
|
618 | + return true; |
|
619 | + } |
|
620 | 620 | |
621 | 621 | |
622 | 622 | |
623 | - public function migration_page_hooks() |
|
624 | - { |
|
625 | - } |
|
623 | + public function migration_page_hooks() |
|
624 | + { |
|
625 | + } |
|
626 | 626 | } |
627 | 627 | \ No newline at end of file |
@@ -1,36 +1,36 @@ |
||
1 | 1 | <div id="admin-primary-mbox-reg-details-dv" class="admin-primary-mbox-dv"> |
2 | 2 | |
3 | - <?php do_action( 'AHEE__reg_admin_details_main_meta_box_reg_details__top', $REG_ID ); ?> |
|
3 | + <?php do_action('AHEE__reg_admin_details_main_meta_box_reg_details__top', $REG_ID); ?> |
|
4 | 4 | <?php echo $resend_registration_button; ?> |
5 | 5 | <?php echo $view_transaction_button; ?> |
6 | 6 | <br/> |
7 | 7 | |
8 | - <h3 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-clipboard"></span><?php _e( 'Registration Items', 'event_espresso' );?></h3> |
|
8 | + <h3 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-clipboard"></span><?php _e('Registration Items', 'event_espresso'); ?></h3> |
|
9 | 9 | |
10 | 10 | <?php echo $line_item_table; ?> |
11 | 11 | |
12 | 12 | <a id="display-additional-registration-session-info" class="display-the-hidden smaller-text" rel="additional-registration-session-info"> |
13 | - <span class="dashicons dashicons-plus-alt"></span><?php _e( 'view additional registration session details', 'event_espresso' );?> |
|
13 | + <span class="dashicons dashicons-plus-alt"></span><?php _e('view additional registration session details', 'event_espresso'); ?> |
|
14 | 14 | </a> |
15 | 15 | |
16 | 16 | <div id="additional-registration-session-info-dv" class="hidden"> |
17 | 17 | |
18 | 18 | <a id="hide-additional-registration-session-info" class="hide-the-displayed hidden smaller-text" rel="additional-registration-session-info"> |
19 | - <span class="dashicons dashicons-dismiss"></span><?php _e( 'hide additional registration session details', 'event_espresso' );?> |
|
19 | + <span class="dashicons dashicons-dismiss"></span><?php _e('hide additional registration session details', 'event_espresso'); ?> |
|
20 | 20 | </a> |
21 | 21 | <br class="clear"/> |
22 | 22 | |
23 | - <h3 class="admin-primary-mbox-h4"><?php _e( 'Registration Session Details', 'event_espresso' );?></h3> |
|
23 | + <h3 class="admin-primary-mbox-h4"><?php _e('Registration Session Details', 'event_espresso'); ?></h3> |
|
24 | 24 | |
25 | 25 | <table id="admin-primary-mbox-reg-extra-session-info-tbl" class="form-table skinny-rows"> |
26 | 26 | <tbody> |
27 | - <?php foreach ( $reg_details as $key => $reg_detail ) : ?> |
|
27 | + <?php foreach ($reg_details as $key => $reg_detail) : ?> |
|
28 | 28 | <tr> |
29 | 29 | <th> |
30 | - <label for="<?php echo $key;?>"><?php echo $reg_detail['label'];?></label> |
|
30 | + <label for="<?php echo $key; ?>"><?php echo $reg_detail['label']; ?></label> |
|
31 | 31 | </th> |
32 | 32 | <td> |
33 | - <?php echo $reg_detail['value'];?> |
|
33 | + <?php echo $reg_detail['value']; ?> |
|
34 | 34 | </td> |
35 | 35 | </tr> |
36 | 36 | <?php endforeach; // $reg_details?> |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <div id="admin-primary-mbox-dv" class="admin-primary-mbox-dv"> |
2 | 2 | |
3 | 3 | <h3 class="admin-primary-mbox-h4 hdr-has-icon"> |
4 | - <span class="dashicons dashicons-cart"></span><?php _e( 'Transaction Items', 'event_espresso' );?> |
|
4 | + <span class="dashicons dashicons-cart"></span><?php _e('Transaction Items', 'event_espresso'); ?> |
|
5 | 5 | </h3> |
6 | 6 | |
7 | 7 | <div class="admin-primary-mbox-tbl-wrap"> |
@@ -10,27 +10,27 @@ discard block |
||
10 | 10 | </div> |
11 | 11 | |
12 | 12 | <a id="display-additional-transaction-session-info" class="display-the-hidden smaller-text" rel="additional-transaction-session-info"> |
13 | - <span class="dashicons dashicons-plus-alt"></span><?php _e( 'view additional transaction session details', 'event_espresso' );?> |
|
13 | + <span class="dashicons dashicons-plus-alt"></span><?php _e('view additional transaction session details', 'event_espresso'); ?> |
|
14 | 14 | </a> |
15 | 15 | |
16 | 16 | <div id="additional-transaction-session-info-dv" class="hidden"> |
17 | 17 | |
18 | 18 | <a id="hide-additional-transaction-session-info" class="hide-the-displayed hidden smaller-text" rel="additional-transaction-session-info"> |
19 | - <span class="dashicons dashicons-dismiss"></span><?php _e( 'hide additional transaction session details', 'event_espresso' );?> |
|
19 | + <span class="dashicons dashicons-dismiss"></span><?php _e('hide additional transaction session details', 'event_espresso'); ?> |
|
20 | 20 | </a> |
21 | 21 | <br class="clear"/> |
22 | 22 | |
23 | - <h3 class="admin-primary-mbox-h4"><?php _e( 'Transaction Session Details', 'event_espresso' );?></h3> |
|
23 | + <h3 class="admin-primary-mbox-h4"><?php _e('Transaction Session Details', 'event_espresso'); ?></h3> |
|
24 | 24 | |
25 | 25 | <table id="admin-primary-mbox-txn-extra-session-info-tbl" class="form-table skinny-rows"> |
26 | 26 | <tbody> |
27 | - <?php foreach ( $txn_details as $key => $txn_detail ) : ?> |
|
27 | + <?php foreach ($txn_details as $key => $txn_detail) : ?> |
|
28 | 28 | <tr> |
29 | 29 | <th> |
30 | - <label for="<?php echo $key;?>"><?php echo $txn_detail['label'];?></label> |
|
30 | + <label for="<?php echo $key; ?>"><?php echo $txn_detail['label']; ?></label> |
|
31 | 31 | </th> |
32 | 32 | <td> |
33 | - <?php echo $txn_detail['value'];?> |
|
33 | + <?php echo $txn_detail['value']; ?> |
|
34 | 34 | </td> |
35 | 35 | </tr> |
36 | 36 | <?php endforeach; // $txn_details?> |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | <br class="clear"/> |
41 | 41 | |
42 | 42 | |
43 | - <?php if ( $attendee instanceof EE_Attendee && ( $grand_raw_total > 0 || $TXN_status != 'TCM' || ! empty( $payments ) ) ) : ?> |
|
43 | + <?php if ($attendee instanceof EE_Attendee && ($grand_raw_total > 0 || $TXN_status != 'TCM' || ! empty($payments))) : ?> |
|
44 | 44 | |
45 | 45 | <h3 class="admin-primary-mbox-h4 hdr-has-icon"> |
46 | - <span class="ee-icon ee-icon-cash"></span><?php _e( 'Payment Details', 'event_espresso' );?> |
|
46 | + <span class="ee-icon ee-icon-cash"></span><?php _e('Payment Details', 'event_espresso'); ?> |
|
47 | 47 | </h3> |
48 | 48 | |
49 | 49 | <div class="admin-primary-mbox-tbl-wrap"> |
@@ -52,79 +52,79 @@ discard block |
||
52 | 52 | <tr> |
53 | 53 | <th></th> |
54 | 54 | <th class="jst-cntr"></th> |
55 | - <th class="jst-cntr"><?php _e( 'ID', 'event_espresso' );?></th> |
|
56 | - <th class="jst-left"><?php _e( 'Date', 'event_espresso' );?></th> |
|
57 | - <th class="jst-cntr"><?php _e( 'Source', 'event_espresso' );?></th> |
|
58 | - <th class="jst-left"><?php _e( 'Method', 'event_espresso' );?></th> |
|
59 | - <th class="jst-left"><?php _e( 'Gateway Response', 'event_espresso' );?></th> |
|
60 | - <th class="jst-left"><?php _e( 'TXN ID / CHQ #', 'event_espresso' );?></th> |
|
61 | - <th class="jst-left"><?php _e( 'P.O. / S.O. #', 'event_espresso' );?></th> |
|
62 | - <th class="jst-left"><?php _e( 'Notes / Extra Accounting', 'event_espresso' );?></th> |
|
63 | - <!--<th class="jst-left"><?php _e( 'Details', 'event_espresso' );?></th>--> |
|
64 | - <th class="jst-cntr"><?php _e( 'Amount', 'event_espresso' );?></th> |
|
55 | + <th class="jst-cntr"><?php _e('ID', 'event_espresso'); ?></th> |
|
56 | + <th class="jst-left"><?php _e('Date', 'event_espresso'); ?></th> |
|
57 | + <th class="jst-cntr"><?php _e('Source', 'event_espresso'); ?></th> |
|
58 | + <th class="jst-left"><?php _e('Method', 'event_espresso'); ?></th> |
|
59 | + <th class="jst-left"><?php _e('Gateway Response', 'event_espresso'); ?></th> |
|
60 | + <th class="jst-left"><?php _e('TXN ID / CHQ #', 'event_espresso'); ?></th> |
|
61 | + <th class="jst-left"><?php _e('P.O. / S.O. #', 'event_espresso'); ?></th> |
|
62 | + <th class="jst-left"><?php _e('Notes / Extra Accounting', 'event_espresso'); ?></th> |
|
63 | + <!--<th class="jst-left"><?php _e('Details', 'event_espresso'); ?></th>--> |
|
64 | + <th class="jst-cntr"><?php _e('Amount', 'event_espresso'); ?></th> |
|
65 | 65 | </tr> |
66 | 66 | </thead> |
67 | 67 | <tbody> |
68 | - <?php if ( $payments ) : ?> |
|
68 | + <?php if ($payments) : ?> |
|
69 | 69 | <?php $payment_total = 0; ?> |
70 | - <?php foreach ( $payments as $PAY_ID => $payment ) : |
|
71 | - $existing_reg_payment_json = isset( $existing_reg_payments[ $PAY_ID ] ) |
|
72 | - ? wp_json_encode( $existing_reg_payments[ $PAY_ID ] ) |
|
70 | + <?php foreach ($payments as $PAY_ID => $payment) : |
|
71 | + $existing_reg_payment_json = isset($existing_reg_payments[$PAY_ID]) |
|
72 | + ? wp_json_encode($existing_reg_payments[$PAY_ID]) |
|
73 | 73 | : '{}'; |
74 | 74 | ?> |
75 | - <tr id="txn-admin-payment-tr-<?php echo $PAY_ID;?>"> |
|
75 | + <tr id="txn-admin-payment-tr-<?php echo $PAY_ID; ?>"> |
|
76 | 76 | <td> |
77 | 77 | <span id="payment-status-<?php echo $PAY_ID; ?>" class="ee-status-strip-td ee-status-strip pymt-status-<?php echo $payment->STS_ID(); ?>"></span> |
78 | - <div id="payment-STS_ID-<?php echo $PAY_ID;?>" class="hidden"><?php echo $payment->STS_ID();?></div> |
|
79 | - <div id="reg-payments-<?php echo $PAY_ID;?>" class="hidden"><?php echo $existing_reg_payment_json; ?></div> |
|
78 | + <div id="payment-STS_ID-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $payment->STS_ID(); ?></div> |
|
79 | + <div id="reg-payments-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $existing_reg_payment_json; ?></div> |
|
80 | 80 | </td> |
81 | 81 | <td class=" jst-cntr"> |
82 | 82 | <ul class="txn-overview-actions-ul"> |
83 | 83 | <li> |
84 | - <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e( 'Edit Payment', 'event_espresso' );?>" data-payment-id="<?php echo $PAY_ID;?>"> |
|
84 | + <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e('Edit Payment', 'event_espresso'); ?>" data-payment-id="<?php echo $PAY_ID; ?>"> |
|
85 | 85 | <div class="dashicons dashicons-edit" style="margin: 0;"></div> |
86 | 86 | </a> |
87 | 87 | </li> |
88 | 88 | <li> |
89 | - <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e( 'Delete Payment', 'event_espresso' );?>" data-payment-id="<?php echo $PAY_ID;?>"> |
|
89 | + <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e('Delete Payment', 'event_espresso'); ?>" data-payment-id="<?php echo $PAY_ID; ?>"> |
|
90 | 90 | <div class="dashicons dashicons-trash" style="margin: 0;"></div> |
91 | 91 | </a> |
92 | 92 | </li> |
93 | 93 | </ul> |
94 | 94 | </td> |
95 | 95 | <td class=" jst-rght"> |
96 | - <div id="payment-id-<?php echo $PAY_ID;?>"><?php echo $PAY_ID;?></div> |
|
96 | + <div id="payment-id-<?php echo $PAY_ID; ?>"><?php echo $PAY_ID; ?></div> |
|
97 | 97 | </td> |
98 | 98 | <td class=" jst-left"> |
99 | - <div id="payment-date-<?php echo $PAY_ID;?>" class="payment-date-dv"><?php echo $payment->timestamp('Y-m-d', 'g:i a');?></div> |
|
99 | + <div id="payment-date-<?php echo $PAY_ID; ?>" class="payment-date-dv"><?php echo $payment->timestamp('Y-m-d', 'g:i a'); ?></div> |
|
100 | 100 | </td> |
101 | 101 | <td class=" jst-cntr"> |
102 | - <div id="payment-method-<?php echo $PAY_ID;?>"> |
|
103 | - <?php echo $payment->source();?> |
|
102 | + <div id="payment-method-<?php echo $PAY_ID; ?>"> |
|
103 | + <?php echo $payment->source(); ?> |
|
104 | 104 | </div> |
105 | 105 | </td> |
106 | 106 | <td class=" jst-left"> |
107 | - <div id="payment-gateway-<?php echo $PAY_ID;?>"> |
|
108 | - <?php echo $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso');?> |
|
107 | + <div id="payment-gateway-<?php echo $PAY_ID; ?>"> |
|
108 | + <?php echo $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso'); ?> |
|
109 | 109 | </div> |
110 | - <div id="payment-gateway-id-<?php echo $PAY_ID;?>" class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0;?></div> |
|
110 | + <div id="payment-gateway-id-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0; ?></div> |
|
111 | 111 | </td> |
112 | 112 | <td class=" jst-left"> |
113 | - <div id="payment-response-<?php echo $PAY_ID;?>"><?php echo $payment->gateway_response();?></div> |
|
113 | + <div id="payment-response-<?php echo $PAY_ID; ?>"><?php echo $payment->gateway_response(); ?></div> |
|
114 | 114 | </td> |
115 | 115 | <td class=" jst-left"> |
116 | - <div id="payment-txn-id-chq-nmbr-<?php echo $PAY_ID;?>"><?php echo $payment->txn_id_chq_nmbr();?></div> |
|
116 | + <div id="payment-txn-id-chq-nmbr-<?php echo $PAY_ID; ?>"><?php echo $payment->txn_id_chq_nmbr(); ?></div> |
|
117 | 117 | </td> |
118 | 118 | <td class=" jst-left"> |
119 | - <div id="payment-po-nmbr-<?php echo $PAY_ID;?>"><?php echo $payment->po_number();?></div> |
|
119 | + <div id="payment-po-nmbr-<?php echo $PAY_ID; ?>"><?php echo $payment->po_number(); ?></div> |
|
120 | 120 | </td> |
121 | 121 | <td class=" jst-left"> |
122 | - <div id="payment-accntng-<?php echo $PAY_ID;?>"><?php echo $payment->extra_accntng();?></div> |
|
122 | + <div id="payment-accntng-<?php echo $PAY_ID; ?>"><?php echo $payment->extra_accntng(); ?></div> |
|
123 | 123 | </td> |
124 | 124 | <td class=" jst-rght"> |
125 | - <?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-' . $payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?> |
|
126 | - <span class="<?php echo $payment_class;?>"> |
|
127 | - <div id="payment-amount-<?php echo $PAY_ID;?>" style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(), FALSE, FALSE ); ?></div> |
|
125 | + <?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-'.$payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?> |
|
126 | + <span class="<?php echo $payment_class; ?>"> |
|
127 | + <div id="payment-amount-<?php echo $PAY_ID; ?>" style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(), FALSE, FALSE); ?></div> |
|
128 | 128 | </span> |
129 | 129 | </td> |
130 | 130 | </tr> |
@@ -134,25 +134,25 @@ discard block |
||
134 | 134 | <?php endforeach; // $payment?> |
135 | 135 | <?php |
136 | 136 | $pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : ''; |
137 | - $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">' . __( 'This transaction has been overpaid ! ', 'event_espresso' ) . '</span>' : ''; |
|
137 | + $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">'.__('This transaction has been overpaid ! ', 'event_espresso').'</span>' : ''; |
|
138 | 138 | ?> |
139 | 139 | <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr hidden"> |
140 | 140 | <td class=" jst-rght" colspan="11"> |
141 | - <span class="important-notice"><?php _e( 'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso' ); ?></span> |
|
141 | + <span class="important-notice"><?php _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso'); ?></span> |
|
142 | 142 | </td> |
143 | 143 | </tr> |
144 | - <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php echo $pay_totals_class;?>"> |
|
145 | - <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo $overpaid . sprintf( __( 'Payments Total %s', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' );?></span></th> |
|
146 | - <th class=" jst-rght"><span id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total, FALSE, FALSE);?></span></th> |
|
144 | + <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php echo $pay_totals_class; ?>"> |
|
145 | + <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo $overpaid.sprintf(__('Payments Total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); ?></span></th> |
|
146 | + <th class=" jst-rght"><span id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total, FALSE, FALSE); ?></span></th> |
|
147 | 147 | </tr> |
148 | 148 | <?php else : ?> |
149 | 149 | <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr"> |
150 | 150 | <td class=" jst-rght" colspan="11"> |
151 | - <span class="important-notice"><?php _e( 'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso' ); ?></span> |
|
151 | + <span class="important-notice"><?php _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso'); ?></span> |
|
152 | 152 | </td> |
153 | 153 | </tr> |
154 | 154 | <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden"> |
155 | - <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo __( 'Payments Total', 'event_espresso' );?></span></th> |
|
155 | + <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo __('Payments Total', 'event_espresso'); ?></span></th> |
|
156 | 156 | <th class=" jst-rght"><span id="txn-admin-payment-total"></span></th> |
157 | 157 | </tr> |
158 | 158 | <?php endif; // $payments?> |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | <td class=" jst-cntr"> |
166 | 166 | <ul class="txn-overview-actions-ul"> |
167 | 167 | <li> |
168 | - <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e( 'Edit Payment', 'event_espresso' );?>" data-payment-id="PAY_ID"> |
|
168 | + <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e('Edit Payment', 'event_espresso'); ?>" data-payment-id="PAY_ID"> |
|
169 | 169 | <div class="dashicons dashicons-edit" style="margin: 0;"></div> |
170 | 170 | </a> |
171 | 171 | </li> |
172 | 172 | <li> |
173 | - <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e( 'Delete Payment', 'event_espresso' );?>" data-payment-id="PAY_ID"> |
|
173 | + <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e('Delete Payment', 'event_espresso'); ?>" data-payment-id="PAY_ID"> |
|
174 | 174 | <div class="dashicons dashicons-trash" style="margin: 0;"></div> |
175 | 175 | </a> |
176 | 176 | </li> |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | <ul id="txn-admin-payment-options-ul"> |
218 | 218 | <li> |
219 | 219 | <a id="display-txn-admin-apply-payment" class="button-primary no-icon no-hide" rel="txn-admin-apply-payment" > <!--display-the-hidden --> |
220 | - <?php _e( 'Apply Payment', 'event_espresso' );?> |
|
220 | + <?php _e('Apply Payment', 'event_espresso'); ?> |
|
221 | 221 | </a> |
222 | 222 | </li> |
223 | 223 | <li> |
224 | 224 | <a id="display-txn-admin-apply-refund" class="button-secondary no-icon no-hide" rel="txn-admin-apply-refund" > <!--display-the-hidden --> |
225 | - <?php _e( 'Apply Refund', 'event_espresso' );?> |
|
225 | + <?php _e('Apply Refund', 'event_espresso'); ?> |
|
226 | 226 | </a> |
227 | 227 | </li> |
228 | 228 | </ul> |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | |
233 | 233 | <h2 id="admin-modal-dialog-apply-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
234 | 234 | <div class="ee-icon ee-icon-cash-add float-left"></div> |
235 | - <?php echo __( 'Apply a Payment to Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
235 | + <?php echo __('Apply a Payment to Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
236 | 236 | </h2> |
237 | 237 | |
238 | 238 | <h2 id="admin-modal-dialog-edit-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
239 | 239 | <div class="ee-icon ee-icon-cash-edit float-left"></div> |
240 | 240 | <?php |
241 | 241 | echo sprintf( |
242 | - __( 'Edit Payment #%s for Transaction #%s', 'event_espresso' ), |
|
242 | + __('Edit Payment #%s for Transaction #%s', 'event_espresso'), |
|
243 | 243 | '<span></span>', |
244 | 244 | $txn_nmbr['value'] |
245 | 245 | ); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | <div class="ee-icon ee-icon-cash-edit float-left"></div> |
251 | 251 | <?php |
252 | 252 | echo sprintf( |
253 | - __( 'Edit Refund #%s for Transaction #%s', 'event_espresso' ), |
|
253 | + __('Edit Refund #%s for Transaction #%s', 'event_espresso'), |
|
254 | 254 | '<span></span>', |
255 | 255 | $txn_nmbr['value'] |
256 | 256 | ); |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | |
260 | 260 | <h2 id="admin-modal-dialog-apply-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
261 | 261 | <div class="ee-icon ee-icon-cash-remove float-left"></div> |
262 | - <?php echo __( 'Apply a Refund to Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
262 | + <?php echo __('Apply a Refund to Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
263 | 263 | </h2> |
264 | 264 | |
265 | 265 | <form name="txn-admin-apply-payment-frm" id="txn-admin-apply-payment-frm" action="<?php echo $apply_payment_form_url; ?>"> |
266 | 266 | <div class="admin-modal-dialog-wrap"> |
267 | 267 | <div class="admin-modal-dialog-inner"> |
268 | 268 | |
269 | - <input type="hidden" name="espresso_apply_payment_nonce" id="espresso_apply_payment_nonce" value="<?php echo wp_create_nonce( 'espresso_apply_payment_nonce' );?>"/> |
|
269 | + <input type="hidden" name="espresso_apply_payment_nonce" id="espresso_apply_payment_nonce" value="<?php echo wp_create_nonce('espresso_apply_payment_nonce'); ?>"/> |
|
270 | 270 | <input type="hidden" name="espresso_ajax" id="espresso-ajax" value="0"/> |
271 | 271 | <input type="hidden" name="noheader" id="txn-admin-noheader-inp" value="0"/> |
272 | 272 | <input type="hidden" name="txn_admin_payment[PAY_ID]" id="txn-admin-payment-payment-id-inp" class="txn-admin-apply-payment-inp" value="0"/> |
@@ -274,108 +274,108 @@ discard block |
||
274 | 274 | <input type="hidden" name="txn_admin_payment[type]" id="txn-admin-payment-type-inp" value="1"/> |
275 | 275 | <input type="hidden" name="txn_admin_payment[details]" id="txn-admin-payment-details-inp" value=""/> |
276 | 276 | <input type="hidden" name="txn_admin_delete_payment_form_url" id="txn-admin-delete-payment-form-url-inp" value="<?php echo $delete_payment_form_url; ?>"/> |
277 | - <input type="hidden" name="txn_admin_todays_date" id="txn-admin-todays-date-inp" value="<?php echo date( 'Y-m-d h:i a', current_time( 'timestamp' )); ?>"/> |
|
277 | + <input type="hidden" name="txn_admin_todays_date" id="txn-admin-todays-date-inp" value="<?php echo date('Y-m-d h:i a', current_time('timestamp')); ?>"/> |
|
278 | 278 | |
279 | 279 | <div class="txn-admin-apply-payment-date-dv admin-modal-dialog-row"> |
280 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
281 | - <label for="txn-admin-payment-date-inp" class=""><?php _e( 'Payment Date', 'event_espresso' );?></label> |
|
282 | - <input name="[date]txn_admin_payment" id="txn-admin-payment-date-inp" class="txn-admin-apply-payment-inp required" type="text" value="<?php echo date( 'Y-m-d g:i a', current_time( 'timestamp' )); ?>"/> |
|
283 | - <p class="description"><?php _e( 'The date the payment was actually made on', 'event_espresso' );?></p> |
|
280 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
281 | + <label for="txn-admin-payment-date-inp" class=""><?php _e('Payment Date', 'event_espresso'); ?></label> |
|
282 | + <input name="[date]txn_admin_payment" id="txn-admin-payment-date-inp" class="txn-admin-apply-payment-inp required" type="text" value="<?php echo date('Y-m-d g:i a', current_time('timestamp')); ?>"/> |
|
283 | + <p class="description"><?php _e('The date the payment was actually made on', 'event_espresso'); ?></p> |
|
284 | 284 | </div> |
285 | 285 | |
286 | 286 | <div class="txn-admin-apply-payment-amount-dv admin-modal-dialog-row"> |
287 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
288 | - <label for="txn-admin-payment-amount-inp" class=""><?php _e( 'Amount', 'event_espresso' );?></label> |
|
287 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
288 | + <label for="txn-admin-payment-amount-inp" class=""><?php _e('Amount', 'event_espresso'); ?></label> |
|
289 | 289 | <input name="txn_admin_payment[amount]" id="txn-admin-payment-amount-inp" class="txn-admin-apply-payment-inp required" type="text" value=""/> |
290 | - <p class="description"><?php _e( 'The amount of the payment', 'event_espresso' );?></p> |
|
290 | + <p class="description"><?php _e('The amount of the payment', 'event_espresso'); ?></p> |
|
291 | 291 | </div> |
292 | 292 | |
293 | 293 | <div class="txn-admin-apply-payment-method-dv admin-modal-dialog-row"> |
294 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
295 | - <label for="txn-admin-payment-method-inp" class=""><?php _e( 'Method of Payment', 'event_espresso' );?></label> |
|
294 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
295 | + <label for="txn-admin-payment-method-inp" class=""><?php _e('Method of Payment', 'event_espresso'); ?></label> |
|
296 | 296 | <select name="txn_admin_payment[PMD_ID]" id="txn-admin-payment-method-slct" class="txn-admin-apply-payment-slct required" type="text" > |
297 | - <?php foreach ( $payment_methods as $method ) : ?> |
|
297 | + <?php foreach ($payment_methods as $method) : ?> |
|
298 | 298 | <?php $selected = $method->slug() == 'cash' ? ' selected="selected"' : ''; ?> |
299 | - <option id="payment-method-opt-<?php echo $method->slug(); ?>" value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key( $method->admin_desc() ) ? substr( $method->admin_desc(), 0, 128) : $method->admin_name() ; ?> </option> |
|
299 | + <option id="payment-method-opt-<?php echo $method->slug(); ?>" value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key($method->admin_desc()) ? substr($method->admin_desc(), 0, 128) : $method->admin_name(); ?> </option> |
|
300 | 300 | <?php endforeach; ?> |
301 | 301 | </select> |
302 | - <p class="description"><?php _e( 'Whether the payment was made via PayPal, Credit Card, Cheque, or Cash', 'event_espresso' );?></p> |
|
302 | + <p class="description"><?php _e('Whether the payment was made via PayPal, Credit Card, Cheque, or Cash', 'event_espresso'); ?></p> |
|
303 | 303 | </div> |
304 | 304 | |
305 | 305 | <div class="mop-PP mop-CC mop-CHQ mop"> |
306 | 306 | <div class="txn-admin-apply-payment-gw-txn-id-dv admin-modal-dialog-row"> |
307 | - <label for="txn-admin-payment-txn-id-inp" class=""><?php _e( 'TXN ID / CHQ #', 'event_espresso' );?></label> |
|
307 | + <label for="txn-admin-payment-txn-id-inp" class=""><?php _e('TXN ID / CHQ #', 'event_espresso'); ?></label> |
|
308 | 308 | <input name="txn_admin_payment[txn_id_chq_nmbr]" id="txn-admin-payment-txn-id-chq-nmbr-inp" class="txn-admin-apply-payment-inp" type="text" maxlength="100"/> |
309 | - <p class="description"><?php _e( 'The Transaction ID sent back from the payment gateway, or the Cheque #', 'event_espresso' );?></p> |
|
309 | + <p class="description"><?php _e('The Transaction ID sent back from the payment gateway, or the Cheque #', 'event_espresso'); ?></p> |
|
310 | 310 | </div> |
311 | 311 | </div> |
312 | 312 | |
313 | 313 | <div class="mop-CC mop" style="display:none"> |
314 | 314 | <div class="txn-admin-apply-payment-response-dv admin-modal-dialog-row"> |
315 | - <label for="txn-admin-payment-gateway-response-inp" class=""><?php _e( 'Gateway Response', 'event_espresso' );?></label> |
|
315 | + <label for="txn-admin-payment-gateway-response-inp" class=""><?php _e('Gateway Response', 'event_espresso'); ?></label> |
|
316 | 316 | <input name="txn_admin_payment[gateway_response]" id="txn-admin-payment-gateway-response-inp" class="txn-admin-apply-payment-inp" type="text"/> |
317 | - <p class="description"><?php _e( 'The gateway response string (optional)', 'event_espresso' );?></p> |
|
317 | + <p class="description"><?php _e('The gateway response string (optional)', 'event_espresso'); ?></p> |
|
318 | 318 | </div> |
319 | 319 | </div> |
320 | 320 | |
321 | 321 | <div class="mop-PP mop-CC mop"> |
322 | 322 | <div class="txn-admin-apply-payment-status-dv admin-modal-dialog-row"> |
323 | - <label for="txn-admin-payment-status-inp" class=""><?php _e( 'Payment Status', 'event_espresso' );?></label> |
|
323 | + <label for="txn-admin-payment-status-inp" class=""><?php _e('Payment Status', 'event_espresso'); ?></label> |
|
324 | 324 | <select name="txn_admin_payment[status]" id="txn-admin-payment-status-slct" class="txn-admin-apply-payment-slct" type="text" > |
325 | - <?php foreach ( $payment_status as $STS_ID => $STS_code ) : ?> |
|
325 | + <?php foreach ($payment_status as $STS_ID => $STS_code) : ?> |
|
326 | 326 | <?php $selected = $STS_ID == 'PAP' ? ' selected="selected"' : ''; ?> |
327 | 327 | <option id="payment-status-opt-<?php echo $STS_ID; ?>" value="<?php echo $STS_ID; ?>"<?php echo $selected; ?>><?php echo $STS_code; ?> </option> |
328 | 328 | <?php endforeach; ?> |
329 | 329 | </select> |
330 | - <p class="description"><?php _e( 'Whether the payment was approved, cancelled, declined or failed after submission to the gateway', 'event_espresso' );?></p> |
|
330 | + <p class="description"><?php _e('Whether the payment was approved, cancelled, declined or failed after submission to the gateway', 'event_espresso'); ?></p> |
|
331 | 331 | </div> |
332 | 332 | </div> |
333 | 333 | |
334 | 334 | <div class="txn-admin-apply-payment-po-nmbr-dv admin-modal-dialog-row"> |
335 | - <label for="txn-admin-payment-po-nmbr-inp" class=""><?php _e( 'P.O. / S.O. #', 'event_espresso' );?></label> |
|
335 | + <label for="txn-admin-payment-po-nmbr-inp" class=""><?php _e('P.O. / S.O. #', 'event_espresso'); ?></label> |
|
336 | 336 | <input name="txn_admin_payment[po_number]" id="txn-admin-payment-po-nmbr-inp" class="txn-admin-apply-payment-inp" type="text" maxlength="100"/> |
337 | - <p class="description"><?php _e( 'The Purchase or Sales Order Number if any (optional)', 'event_espresso' );?></p> |
|
337 | + <p class="description"><?php _e('The Purchase or Sales Order Number if any (optional)', 'event_espresso'); ?></p> |
|
338 | 338 | </div> |
339 | 339 | |
340 | 340 | <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
341 | - <label for="txn-admin-payment-accounting-inp" class="last"><?php _e( 'Notes / Extra Accounting', 'event_espresso' );?></label> |
|
341 | + <label for="txn-admin-payment-accounting-inp" class="last"><?php _e('Notes / Extra Accounting', 'event_espresso'); ?></label> |
|
342 | 342 | <input name="txn_admin_payment[accounting]" id="txn-admin-payment-accounting-inp" class="txn-admin-apply-payment-inp" type="text" value="<?php echo $REG_code; ?>" maxlength="100"/> <input type="hidden" id="txn-admin-reg-code-inp" value="<?php echo $REG_code; ?>"/> |
343 | - <p class="description"><?php _e( 'An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.', 'event_espresso' );?></p> |
|
343 | + <p class="description"><?php _e('An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.', 'event_espresso'); ?></p> |
|
344 | 344 | </div> |
345 | 345 | |
346 | 346 | <div class="txn-admin-apply-payment-registrations-dv admin-modal-dialog-row"> |
347 | - <label for="txn-admin-payment-registrations-inp" class="last"><?php _e( 'Registrations to Apply Payment to:', 'event_espresso' ); ?></label> |
|
347 | + <label for="txn-admin-payment-registrations-inp" class="last"><?php _e('Registrations to Apply Payment to:', 'event_espresso'); ?></label> |
|
348 | 348 | <label class="txn-admin-apply-payment-to-registrations-lbl"> |
349 | 349 | <input type="radio" value="1" id="txn-admin-apply-payment-to-all-registrations-inp" name="txn_admin_payment[apply_to_all_registrations]" checked="checked"/> |
350 | - <?php _e( 'ALL Registrations', 'event_espresso' ); ?> |
|
350 | + <?php _e('ALL Registrations', 'event_espresso'); ?> |
|
351 | 351 | </label> |
352 | 352 | <label class="txn-admin-apply-payment-to-registrations-lbl"> |
353 | 353 | <input type="radio" value="0" id="txn-admin-apply-payment-to-some-registrations-inp" name="txn_admin_payment[apply_to_all_registrations]" /> |
354 | - <?php _e( 'Just the following Registrations', 'event_espresso' ); ?> |
|
354 | + <?php _e('Just the following Registrations', 'event_espresso'); ?> |
|
355 | 355 | </label> |
356 | 356 | <?php echo $registrations_to_apply_payment_to; ?> |
357 | 357 | </div> |
358 | 358 | |
359 | 359 | <div class="txn-admin-payment-reg-status-dv admin-modal-dialog-row"> |
360 | - <label for="txn-admin-payment-reg-status-inp" class="last"><?php _e( 'Change Registration Status?', 'event_espresso' );?></label> |
|
360 | + <label for="txn-admin-payment-reg-status-inp" class="last"><?php _e('Change Registration Status?', 'event_espresso'); ?></label> |
|
361 | 361 | <?php echo $status_change_select; ?> |
362 | - <p class="description"><?php _e( 'If you wish to change the status for the registrations selected above, then select which status from this dropdown.', 'event_espresso' ); ?></p> |
|
362 | + <p class="description"><?php _e('If you wish to change the status for the registrations selected above, then select which status from this dropdown.', 'event_espresso'); ?></p> |
|
363 | 363 | <br/> |
364 | 364 | </div> |
365 | 365 | |
366 | 366 | <div class="txn-admin-apply-payment-send-notifications-dv admin-modal-dialog-row"> |
367 | 367 | |
368 | - <label for="txn-admin-payment-send-notifications-inp" class="last"><?php _e( 'Send Related Messages?', 'event_espresso' );?></label> |
|
368 | + <label for="txn-admin-payment-send-notifications-inp" class="last"><?php _e('Send Related Messages?', 'event_espresso'); ?></label> |
|
369 | 369 | <label class="txn-admin-payment-send-notifications-lbl"> |
370 | 370 | <input type="checkbox" value="1" name="txn_payments[send_notifications]" checked="checked" aria-checked="true" style="vertical-align: middle;"> |
371 | - <?php _e( 'Payment Messages?', 'event_espresso' ); ?> |
|
371 | + <?php _e('Payment Messages?', 'event_espresso'); ?> |
|
372 | 372 | </label> |
373 | 373 | <label class="txn-admin-payment-send-notifications-lbl"> |
374 | 374 | <input type="checkbox" value="1" name="txn_reg_status_change[send_notifications]" style="vertical-align: middle;"> |
375 | - <?php _e( 'Registration Messages?', 'event_espresso' ); ?> |
|
375 | + <?php _e('Registration Messages?', 'event_espresso'); ?> |
|
376 | 376 | </label> |
377 | 377 | <br class="clear-float"/> |
378 | - <p class="description"><?php printf( __('By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.', 'event_espresso'), '<strong>', '</strong>', '<br />' ); ?></p> |
|
378 | + <p class="description"><?php printf(__('By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.', 'event_espresso'), '<strong>', '</strong>', '<br />'); ?></p> |
|
379 | 379 | <label></label> |
380 | 380 | </div> |
381 | 381 | <div class="clear"></div> |
@@ -386,27 +386,27 @@ discard block |
||
386 | 386 | <ul id="admin-modal-dialog-options-ul"> |
387 | 387 | <li> |
388 | 388 | <a id="txn-admin-modal-dialog-apply-payment-lnk" class="button-primary no-icon" style="display:none;" > |
389 | - <?php _e( 'Apply Payment', 'event_espresso' );?> |
|
389 | + <?php _e('Apply Payment', 'event_espresso'); ?> |
|
390 | 390 | </a> |
391 | 391 | </li> |
392 | 392 | <li> |
393 | 393 | <a id="txn-admin-modal-dialog-edit-payment-lnk" class="button-primary no-icon" style="display:none;" > |
394 | - <?php _e( 'Save Payment Details', 'event_espresso' );?> |
|
394 | + <?php _e('Save Payment Details', 'event_espresso'); ?> |
|
395 | 395 | </a> |
396 | 396 | </li> |
397 | 397 | <li> |
398 | 398 | <a id="txn-admin-modal-dialog-edit-refund-lnk" class="button-primary no-icon" style="display:none;" > |
399 | - <?php _e( 'Save Refund Details', 'event_espresso' );?> |
|
399 | + <?php _e('Save Refund Details', 'event_espresso'); ?> |
|
400 | 400 | </a> |
401 | 401 | </li> |
402 | 402 | <li> |
403 | 403 | <a id="txn-admin-modal-dialog-apply-refund-lnk" class="button-primary no-icon" style="display:none;" > |
404 | - <?php _e( 'Apply Refund', 'event_espresso' );?> |
|
404 | + <?php _e('Apply Refund', 'event_espresso'); ?> |
|
405 | 405 | </a> |
406 | 406 | </li> |
407 | 407 | <li> |
408 | 408 | <a id="txn-admin-modal-dialog-cancel-lnk" class="button-secondary no-icon" > |
409 | - <?php _e( 'Cancel', 'event_espresso' );?> |
|
409 | + <?php _e('Cancel', 'event_espresso'); ?> |
|
410 | 410 | </a> |
411 | 411 | </li> |
412 | 412 | <li> |
@@ -423,29 +423,29 @@ discard block |
||
423 | 423 | |
424 | 424 | <h2 id="admin-modal-dialog-delete-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
425 | 425 | <span class="ee-icon ee-icon-cash-add"></span> |
426 | - <?php echo __( 'Delete Payment/Refund for Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
426 | + <?php echo __('Delete Payment/Refund for Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
427 | 427 | </h2> |
428 | 428 | |
429 | 429 | <form name="txn-admin-delete-payment-frm" id="txn-admin-delete-payment-frm" action="<?php echo $delete_payment_url; ?>"> |
430 | 430 | <div class="admin-modal-dialog-wrap"> |
431 | 431 | <div class="admin-modal-dialog-inner"> |
432 | 432 | |
433 | - <input type="hidden" name="espresso_delete_payment_nonce" id="espresso_delete_payment_nonce" value="<?php echo wp_create_nonce( 'espresso_delete_payment_nonce' );?>"/> |
|
433 | + <input type="hidden" name="espresso_delete_payment_nonce" id="espresso_delete_payment_nonce" value="<?php echo wp_create_nonce('espresso_delete_payment_nonce'); ?>"/> |
|
434 | 434 | <input type="hidden" name="delete_espresso_ajax" id="delete-espresso-ajax" value="0"/> |
435 | 435 | <input type="hidden" name="delete_noheader" id="delete-txn-admin-noheader-inp" value="0"/> |
436 | 436 | <input type="hidden" name="delete_txn_admin_payment[PAY_ID]" id="delete-txn-admin-payment-payment-id-inp" class="txn-admin-apply-payment-inp" value="0"/> |
437 | 437 | <input type="hidden" name="delete_txn_admin_payment[TXN_ID]" id="delete-txn-admin-payment-txn-id-inp" value="<?php echo $txn_nmbr['value']; ?>"/> |
438 | 438 | |
439 | 439 | <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
440 | - <label for="delete-txn-admin-payment-reg-status-inp" class="last"><?php _e( 'Change Registration Status?', 'event_espresso' );?></label> |
|
440 | + <label for="delete-txn-admin-payment-reg-status-inp" class="last"><?php _e('Change Registration Status?', 'event_espresso'); ?></label> |
|
441 | 441 | <?php echo $delete_status_change_select; ?> |
442 | - <p class="description"><?php printf( __('If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s', 'event_espresso'), '<strong>', '</strong>' ); ?></p> |
|
442 | + <p class="description"><?php printf(__('If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
443 | 443 | </div> |
444 | 444 | |
445 | 445 | <div class="ee-attention txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
446 | - <label for="delete-txn-admin-payment-accounting-inp" class="last"><?php _e( 'Send Related Messages?', 'event_espresso' );?></label> |
|
446 | + <label for="delete-txn-admin-payment-accounting-inp" class="last"><?php _e('Send Related Messages?', 'event_espresso'); ?></label> |
|
447 | 447 | <input type="checkbox" value="1" name="delete_txn_reg_status_change[send_notifications]"> |
448 | - <p class="description"><?php _e( 'If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.', 'event_espresso' );?></p> |
|
448 | + <p class="description"><?php _e('If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.', 'event_espresso'); ?></p> |
|
449 | 449 | </div> |
450 | 450 | <div class="clear"></div> |
451 | 451 | |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | <ul id="del-admin-modal-dialog-options-ul"> |
456 | 456 | <li> |
457 | 457 | <a id="txn-admin-modal-dialog-delete-lnk" class="button-primary no-icon" style="display:none;" > |
458 | - <?php _e( 'Delete', 'event_espresso' );?> |
|
458 | + <?php _e('Delete', 'event_espresso'); ?> |
|
459 | 459 | </a> |
460 | 460 | </li> |
461 | 461 | <li> |
462 | 462 | <a id="del-txn-admin-modal-dialog-cancel-lnk" class="button-secondary no-icon" > |
463 | - <?php _e( 'Cancel', 'event_espresso' );?> |
|
463 | + <?php _e('Cancel', 'event_espresso'); ?> |
|
464 | 464 | </a> |
465 | 465 | </li> |
466 | 466 | <li> |
@@ -476,30 +476,30 @@ discard block |
||
476 | 476 | <?php endif; // $grand_raw_total > 0?> |
477 | 477 | |
478 | 478 | <?php |
479 | - if ( WP_DEBUG ) { |
|
480 | - $delivered_messages = get_option( 'EED_Messages__payment', array() ); |
|
481 | - if ( isset( $delivered_messages[ $TXN_ID ] )) { |
|
479 | + if (WP_DEBUG) { |
|
480 | + $delivered_messages = get_option('EED_Messages__payment', array()); |
|
481 | + if (isset($delivered_messages[$TXN_ID])) { |
|
482 | 482 | ?> |
483 | - <h4 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-email-alt"></span><?php _e( 'Messages Sent to Primary Registrant', 'event_espresso' );?></h4> |
|
483 | + <h4 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-email-alt"></span><?php _e('Messages Sent to Primary Registrant', 'event_espresso'); ?></h4> |
|
484 | 484 | |
485 | 485 | <div class="admin-primary-mbox-tbl-wrap"> |
486 | 486 | <table class="admin-primary-mbox-tbl"> |
487 | 487 | <thead> |
488 | 488 | <tr> |
489 | - <th class="jst-left"><?php _e( 'Date & Time', 'event_espresso' );?></th> |
|
490 | - <th class="jst-left"><?php _e( 'Message Type', 'event_espresso' );?></th> |
|
491 | - <th class="jst-left"><?php _e( 'Payment Status Upon Sending', 'event_espresso' );?></th> |
|
492 | - <th class="jst-left"><?php _e( 'TXN Status Upon Sending', 'event_espresso' );?></th> |
|
489 | + <th class="jst-left"><?php _e('Date & Time', 'event_espresso'); ?></th> |
|
490 | + <th class="jst-left"><?php _e('Message Type', 'event_espresso'); ?></th> |
|
491 | + <th class="jst-left"><?php _e('Payment Status Upon Sending', 'event_espresso'); ?></th> |
|
492 | + <th class="jst-left"><?php _e('TXN Status Upon Sending', 'event_espresso'); ?></th> |
|
493 | 493 | </tr> |
494 | 494 | </thead> |
495 | 495 | <tbody> |
496 | - <?php foreach ( $delivered_messages[ $TXN_ID ] as $timestamp => $delivered_message ) : |
|
496 | + <?php foreach ($delivered_messages[$TXN_ID] as $timestamp => $delivered_message) : |
|
497 | 497 | ?> |
498 | 498 | <tr> |
499 | - <td class="jst-left"><?php echo date( get_option('date_format') . ' ' . get_option('time_format'), ( $timestamp + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );?></td> |
|
500 | - <td class="jst-left"><?php echo isset( $delivered_message['message_type'] ) ? $delivered_message['message_type'] : '';?></td> |
|
501 | - <td class="jst-left"><?php echo isset( $delivered_message['pay_status'] ) ? $delivered_message['pay_status'] : '';?></td> |
|
502 | - <td class="jst-left"><?php echo isset( $delivered_message['txn_status'] ) ? $delivered_message['txn_status'] : '';?></td> |
|
499 | + <td class="jst-left"><?php echo date(get_option('date_format').' '.get_option('time_format'), ($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))); ?></td> |
|
500 | + <td class="jst-left"><?php echo isset($delivered_message['message_type']) ? $delivered_message['message_type'] : ''; ?></td> |
|
501 | + <td class="jst-left"><?php echo isset($delivered_message['pay_status']) ? $delivered_message['pay_status'] : ''; ?></td> |
|
502 | + <td class="jst-left"><?php echo isset($delivered_message['txn_status']) ? $delivered_message['txn_status'] : ''; ?></td> |
|
503 | 503 | </tr> |
504 | 504 | <?php endforeach; // $delivered_messages?> |
505 | 505 | </tbody> |
@@ -105,41 +105,41 @@ discard block |
||
105 | 105 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
106 | 106 | * @return \EEM_Line_Item |
107 | 107 | */ |
108 | - protected function __construct( $timezone ) { |
|
109 | - $this->singular_item = __('Line Item','event_espresso'); |
|
110 | - $this->plural_item = __('Line Items','event_espresso'); |
|
108 | + protected function __construct($timezone) { |
|
109 | + $this->singular_item = __('Line Item', 'event_espresso'); |
|
110 | + $this->plural_item = __('Line Items', 'event_espresso'); |
|
111 | 111 | |
112 | 112 | $this->_tables = array( |
113 | - 'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID') |
|
113 | + 'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID') |
|
114 | 114 | ); |
115 | - $line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) ); |
|
115 | + $line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event')); |
|
116 | 116 | $this->_fields = array( |
117 | 117 | 'Line_Item' => array( |
118 | - 'LIN_ID' => new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ), |
|
119 | - 'LIN_code' => new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ), |
|
120 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ), |
|
121 | - 'LIN_name' => new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ), |
|
122 | - 'LIN_desc' => new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ), |
|
123 | - 'LIN_unit_price' => new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ), |
|
124 | - 'LIN_percent' => new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ), |
|
125 | - 'LIN_is_taxable' => new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ), |
|
126 | - 'LIN_order' => new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ), |
|
127 | - 'LIN_total' => new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ), |
|
128 | - 'LIN_quantity' => new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ), |
|
129 | - 'LIN_parent' => new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ), |
|
130 | - 'LIN_type' => new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array( |
|
118 | + 'LIN_ID' => new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")), |
|
119 | + 'LIN_code' => new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE), |
|
120 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'), |
|
121 | + 'LIN_name' => new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''), |
|
122 | + 'LIN_desc' => new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE), |
|
123 | + 'LIN_unit_price' => new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0), |
|
124 | + 'LIN_percent' => new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0), |
|
125 | + 'LIN_is_taxable' => new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE), |
|
126 | + 'LIN_order' => new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1), |
|
127 | + 'LIN_total' => new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0), |
|
128 | + 'LIN_quantity' => new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1), |
|
129 | + 'LIN_parent' => new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL), |
|
130 | + 'LIN_type' => new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array( |
|
131 | 131 | self::type_line_item => __("Line Item", "event_espresso"), |
132 | 132 | self::type_sub_line_item => __("Sub-Item", "event_espresso"), |
133 | 133 | self::type_sub_total => __("Subtotal", "event_espresso"), |
134 | 134 | self::type_tax_sub_total => __("Tax Subtotal", "event_espresso"), |
135 | 135 | self::type_tax => __("Tax", "event_espresso"), |
136 | 136 | self::type_total => __("Total", "event_espresso"), |
137 | - self::type_cancellation => __( 'Cancellation', 'event_espresso' ) |
|
137 | + self::type_cancellation => __('Cancellation', 'event_espresso') |
|
138 | 138 | ) |
139 | 139 | ), |
140 | - 'OBJ_ID' => new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ), |
|
141 | - 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ), |
|
142 | - 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
140 | + 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for), |
|
141 | + 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for), |
|
142 | + 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | $this->_model_relations = array( |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ); |
151 | 151 | $this->_model_chain_to_wp_user = 'Transaction.Registration.Event'; |
152 | 152 | $this->_caps_slug = 'transactions'; |
153 | - parent::__construct( $timezone ); |
|
153 | + parent::__construct($timezone); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param EE_Transaction|int $transaction |
162 | 162 | * @return EE_Line_Item[] |
163 | 163 | */ |
164 | - public function get_all_of_type_for_transaction( $line_item_type, $transaction ){ |
|
165 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
166 | - return $this->get_all( array( array( |
|
164 | + public function get_all_of_type_for_transaction($line_item_type, $transaction) { |
|
165 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
166 | + return $this->get_all(array(array( |
|
167 | 167 | 'LIN_type' => $line_item_type, |
168 | 168 | 'TXN_ID' => $transaction |
169 | 169 | ))); |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | * @param EE_Transaction|int $transaction |
178 | 178 | * @return EE_Line_Item[] |
179 | 179 | */ |
180 | - public function get_all_non_ticket_line_items_for_transaction( $transaction ) { |
|
181 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
182 | - return $this->get_all( array( array( |
|
180 | + public function get_all_non_ticket_line_items_for_transaction($transaction) { |
|
181 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
182 | + return $this->get_all(array(array( |
|
183 | 183 | 'LIN_type' => self::type_line_item, |
184 | 184 | 'TXN_ID' => $transaction, |
185 | 185 | 'OR' => array( |
186 | - 'OBJ_type*notticket' => array( '!=', 'Ticket'), |
|
187 | - 'OBJ_type*null' => array( 'IS_NULL' )) |
|
186 | + 'OBJ_type*notticket' => array('!=', 'Ticket'), |
|
187 | + 'OBJ_type*null' => array('IS_NULL')) |
|
188 | 188 | ))); |
189 | 189 | } |
190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * because if there are spam bots afoot there will be LOTS of line items |
195 | 195 | * @return int count of how many deleted |
196 | 196 | */ |
197 | - public function delete_line_items_with_no_transaction(){ |
|
197 | + public function delete_line_items_with_no_transaction() { |
|
198 | 198 | /** @type WPDB $wpdb */ |
199 | 199 | global $wpdb; |
200 | 200 | $time_to_leave_alone = apply_filters( |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | ); |
203 | 203 | $query = $wpdb->prepare( |
204 | 204 | 'DELETE li |
205 | - FROM ' . $this->table() . ' li |
|
206 | - LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID |
|
205 | + FROM ' . $this->table().' li |
|
206 | + LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID |
|
207 | 207 | WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s', |
208 | 208 | // use GMT time because that's what TXN_timestamps are in |
209 | - date( 'Y-m-d H:i:s', time() - $time_to_leave_alone ) |
|
209 | + date('Y-m-d H:i:s', time() - $time_to_leave_alone) |
|
210 | 210 | ); |
211 | - return $wpdb->query( $query ); |
|
211 | + return $wpdb->query($query); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * @param \EE_Base_Class $object |
222 | 222 | * @return EE_Line_Item[] |
223 | 223 | */ |
224 | - public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){ |
|
225 | - return $this->get_all( array( array( |
|
224 | + public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) { |
|
225 | + return $this->get_all(array(array( |
|
226 | 226 | 'TXN_ID' => $TXN_ID, |
227 | - 'OBJ_type' => str_replace( 'EE_', '', get_class( $object )), |
|
227 | + 'OBJ_type' => str_replace('EE_', '', get_class($object)), |
|
228 | 228 | 'OBJ_ID' => $object->ID() |
229 | 229 | ))); |
230 | 230 | } |
@@ -240,16 +240,16 @@ discard block |
||
240 | 240 | * @param array $OBJ_IDs |
241 | 241 | * @return EE_Line_Item[] |
242 | 242 | */ |
243 | - public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){ |
|
243 | + public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) { |
|
244 | 244 | $query_params = array( |
245 | 245 | 'OBJ_type' => $OBJ_type, |
246 | 246 | // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query |
247 | - 'OBJ_ID' => is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs |
|
247 | + 'OBJ_ID' => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs |
|
248 | 248 | ); |
249 | - if ( $TXN_ID ) { |
|
249 | + if ($TXN_ID) { |
|
250 | 250 | $query_params['TXN_ID'] = $TXN_ID; |
251 | 251 | } |
252 | - return $this->get_all( array( $query_params )); |
|
252 | + return $this->get_all(array($query_params)); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * @param EE_Transaction $transaction |
261 | 261 | * @return EE_Line_Item[] |
262 | 262 | */ |
263 | - public function get_all_ticket_line_items_for_transaction( EE_Transaction $transaction ) { |
|
264 | - return $this->get_all( array( |
|
263 | + public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) { |
|
264 | + return $this->get_all(array( |
|
265 | 265 | array( |
266 | 266 | 'TXN_ID' => $transaction->ID(), |
267 | 267 | 'OBJ_type' => 'Ticket', |
268 | 268 | ) |
269 | - ) ); |
|
269 | + )); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | * @param int $TKT_ID |
279 | 279 | * @return \EE_Line_Item |
280 | 280 | */ |
281 | - public function get_ticket_line_item_for_transaction( $TXN_ID, $TKT_ID ) { |
|
282 | - return $this->get_one( array( |
|
281 | + public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) { |
|
282 | + return $this->get_one(array( |
|
283 | 283 | array( |
284 | - 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID( $TXN_ID ), |
|
284 | + 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID($TXN_ID), |
|
285 | 285 | 'OBJ_ID' => $TKT_ID, |
286 | 286 | 'OBJ_type' => 'Ticket', |
287 | 287 | ) |
288 | - ) ); |
|
288 | + )); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @param EE_Promotion $promotion |
301 | 301 | * @return EE_Line_Item |
302 | 302 | */ |
303 | - public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) { |
|
304 | - return $this->get_one( array( |
|
303 | + public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) { |
|
304 | + return $this->get_one(array( |
|
305 | 305 | array( |
306 | 306 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
307 | 307 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | * @param EE_Line_Item $parent_line_item |
323 | 323 | * @return EE_Line_Item[] |
324 | 324 | */ |
325 | - public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) { |
|
326 | - return $this->get_all( array( |
|
325 | + public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) { |
|
326 | + return $this->get_all(array( |
|
327 | 327 | array( |
328 | 328 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
329 | 329 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @param EE_Registration $registration |
341 | 341 | * @return EE_Line_ITem |
342 | 342 | */ |
343 | - public function get_line_item_for_registration( EE_Registration $registration ) { |
|
344 | - return $this->get_one( $this->line_item_for_registration_query_params( $registration )); |
|
343 | + public function get_line_item_for_registration(EE_Registration $registration) { |
|
344 | + return $this->get_one($this->line_item_for_registration_query_params($registration)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | * @param array $original_query_params any extra query params you'd like to be merged with |
351 | 351 | * @return array like EEM_Base::get_all()'s $query_params |
352 | 352 | */ |
353 | - public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) { |
|
354 | - return array_replace_recursive( $original_query_params, array( |
|
353 | + public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) { |
|
354 | + return array_replace_recursive($original_query_params, array( |
|
355 | 355 | array( |
356 | 356 | 'OBJ_ID' => $registration->ticket_ID(), |
357 | 357 | 'OBJ_type' => 'Ticket', |
358 | 358 | 'TXN_ID' => $registration->transaction_ID() |
359 | 359 | ) |
360 | - ) ); |
|
360 | + )); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function add_query_filters() { |
87 | 87 | //add query filters |
88 | - add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 ); |
|
88 | + add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param \WP_Query $WP_Query |
98 | 98 | * @return bool |
99 | 99 | */ |
100 | - public static function apply_query_filters( WP_Query $WP_Query ) { |
|
101 | - return ( isset( $WP_Query->query, $WP_Query->query['post_type'] ) && $WP_Query->query['post_type'] == 'espresso_events' ) || apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ? true : false; |
|
100 | + public static function apply_query_filters(WP_Query $WP_Query) { |
|
101 | + return (isset($WP_Query->query, $WP_Query->query['post_type']) && $WP_Query->query['post_type'] == 'espresso_events') || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false) ? true : false; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | * @access public |
109 | 109 | * @param \WP_Query $WP_Query |
110 | 110 | */ |
111 | - public static function filter_query_parts( WP_Query $WP_Query ) { |
|
111 | + public static function filter_query_parts(WP_Query $WP_Query) { |
|
112 | 112 | //ONLY add our filters if this isn't the main wp_query, because if this is the main wp_query we already have our cpt strategies take care of adding things in. |
113 | - if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) { |
|
113 | + if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) { |
|
114 | 114 | // build event list query |
115 | - add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 ); |
|
116 | - add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 ); |
|
117 | - add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 ); |
|
118 | - add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 ); |
|
119 | - add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 ); |
|
115 | + add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2); |
|
116 | + add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2); |
|
117 | + add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2); |
|
118 | + add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2); |
|
119 | + add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | * @param string $orderby |
132 | 132 | * @param string $sort |
133 | 133 | */ |
134 | - public static function set_query_params( $month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC' ) { |
|
134 | + public static function set_query_params($month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC') { |
|
135 | 135 | self::$_query_params = array(); |
136 | - EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month ); |
|
137 | - EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category ); |
|
138 | - EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired ); |
|
139 | - EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby ); |
|
140 | - EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort ); |
|
136 | + EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month); |
|
137 | + EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category); |
|
138 | + EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired); |
|
139 | + EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby); |
|
140 | + EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param string $month |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - private static function _display_month( $month = '' ) { |
|
153 | - return EE_Registry::instance()->REQ->is_set( 'event_query_month' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_month' ) ) : $month; |
|
152 | + private static function _display_month($month = '') { |
|
153 | + return EE_Registry::instance()->REQ->is_set('event_query_month') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month')) : $month; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * @param string $category |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - private static function _event_category_slug( $category = '' ) { |
|
166 | - return EE_Registry::instance()->REQ->is_set( 'event_query_category' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_category' ) ) : $category; |
|
165 | + private static function _event_category_slug($category = '') { |
|
166 | + return EE_Registry::instance()->REQ->is_set('event_query_category') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category')) : $category; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | * @param bool $show_expired |
176 | 176 | * @return boolean |
177 | 177 | */ |
178 | - private static function _show_expired( $show_expired = FALSE ) { |
|
178 | + private static function _show_expired($show_expired = FALSE) { |
|
179 | 179 | // override default expired option if set via filter |
180 | - $_event_query_show_expired =EE_Registry::instance()->REQ->is_set( 'event_query_show_expired' ) ? EE_Registry::instance()->REQ->get( 'event_query_show_expired' ) : $show_expired; |
|
181 | - return filter_var( $_event_query_show_expired, FILTER_VALIDATE_BOOLEAN ); |
|
180 | + $_event_query_show_expired = EE_Registry::instance()->REQ->is_set('event_query_show_expired') ? EE_Registry::instance()->REQ->get('event_query_show_expired') : $show_expired; |
|
181 | + return filter_var($_event_query_show_expired, FILTER_VALIDATE_BOOLEAN); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | * @param string $orderby |
191 | 191 | * @return array |
192 | 192 | */ |
193 | - private static function _orderby( $orderby = 'start_date' ) { |
|
194 | - $event_query_orderby = EE_Registry::instance()->REQ->is_set( 'event_query_orderby' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_orderby' ) ) : $orderby; |
|
195 | - $event_query_orderby = is_array( $event_query_orderby ) ? $event_query_orderby : explode( ',', $event_query_orderby ); |
|
196 | - $event_query_orderby = array_map( 'trim', $event_query_orderby ); |
|
193 | + private static function _orderby($orderby = 'start_date') { |
|
194 | + $event_query_orderby = EE_Registry::instance()->REQ->is_set('event_query_orderby') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_orderby')) : $orderby; |
|
195 | + $event_query_orderby = is_array($event_query_orderby) ? $event_query_orderby : explode(',', $event_query_orderby); |
|
196 | + $event_query_orderby = array_map('trim', $event_query_orderby); |
|
197 | 197 | return $event_query_orderby; |
198 | 198 | } |
199 | 199 | |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | * @param string $sort |
207 | 207 | * @return array |
208 | 208 | */ |
209 | - private static function _sort( $sort = 'ASC' ) { |
|
210 | - $sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort; |
|
211 | - return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' )) ? strtoupper( $sort ) : 'ASC'; |
|
209 | + private static function _sort($sort = 'ASC') { |
|
210 | + $sort = EE_Registry::instance()->REQ->is_set('event_query_sort') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_sort')) : $sort; |
|
211 | + return in_array($sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($sort) : 'ASC'; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return array array of clauses |
223 | 223 | */ |
224 | - public static function posts_clauses( $clauses, WP_Query $wp_query ) { |
|
225 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
224 | + public static function posts_clauses($clauses, WP_Query $wp_query) { |
|
225 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
226 | 226 | global $wpdb; |
227 | - $clauses['groupby'] = $wpdb->posts . '.ID '; |
|
227 | + $clauses['groupby'] = $wpdb->posts.'.ID '; |
|
228 | 228 | } |
229 | 229 | return $clauses; |
230 | 230 | } |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | * @param WP_Query $wp_query |
240 | 240 | * @return string |
241 | 241 | */ |
242 | - public static function posts_fields( $SQL, WP_Query $wp_query ) { |
|
243 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
242 | + public static function posts_fields($SQL, WP_Query $wp_query) { |
|
243 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
244 | 244 | // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
245 | - $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby ); |
|
245 | + $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby); |
|
246 | 246 | } |
247 | 247 | return $SQL; |
248 | 248 | } |
@@ -257,29 +257,29 @@ discard block |
||
257 | 257 | * @internal param bool|string $mixed $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet |
258 | 258 | * @return string |
259 | 259 | */ |
260 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
261 | - $SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ; |
|
262 | - foreach( (array)$orderby_params as $orderby ) { |
|
263 | - switch ( $orderby ) { |
|
260 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
261 | + $SQL = ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date '; |
|
262 | + foreach ((array) $orderby_params as $orderby) { |
|
263 | + switch ($orderby) { |
|
264 | 264 | |
265 | 265 | case 'ticket_start' : |
266 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ; |
|
266 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date'; |
|
267 | 267 | break; |
268 | 268 | |
269 | 269 | case 'ticket_end' : |
270 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ; |
|
270 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date'; |
|
271 | 271 | break; |
272 | 272 | |
273 | 273 | case 'venue_title' : |
274 | - $SQL .= ', Venue.post_title AS venue_title' ; |
|
274 | + $SQL .= ', Venue.post_title AS venue_title'; |
|
275 | 275 | break; |
276 | 276 | |
277 | 277 | case 'city' : |
278 | - $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ; |
|
278 | + $SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city'; |
|
279 | 279 | break; |
280 | 280 | |
281 | 281 | case 'state' : |
282 | - $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ; |
|
282 | + $SQL .= ', '.EEM_State::instance()->table().'.STA_name'; |
|
283 | 283 | break; |
284 | 284 | |
285 | 285 | } |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | * @param WP_Query $wp_query |
298 | 298 | * @return string |
299 | 299 | */ |
300 | - public static function posts_join( $SQL = '', WP_Query $wp_query ) { |
|
301 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
300 | + public static function posts_join($SQL = '', WP_Query $wp_query) { |
|
301 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
302 | 302 | // Category |
303 | - $SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired ); |
|
304 | - $SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category ); |
|
305 | - $SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby ); |
|
303 | + $SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired); |
|
304 | + $SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category); |
|
305 | + $SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby); |
|
306 | 306 | } |
307 | 307 | return $SQL; |
308 | 308 | } |
@@ -317,11 +317,11 @@ discard block |
||
317 | 317 | * @param boolean $show_expired if TRUE, then displayed past events |
318 | 318 | * @return string |
319 | 319 | */ |
320 | - public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) { |
|
321 | - if ( ! $show_expired ) { |
|
322 | - $join = EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
323 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
324 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
320 | + public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) { |
|
321 | + if ( ! $show_expired) { |
|
322 | + $join = EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
323 | + if (strpos($SQL, $join) === FALSE) { |
|
324 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) '; |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | return $SQL; |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | * @param string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet |
338 | 338 | * @return string |
339 | 339 | */ |
340 | - public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) { |
|
341 | - if ( ! empty( $join_terms ) ) { |
|
340 | + public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') { |
|
341 | + if ( ! empty($join_terms)) { |
|
342 | 342 | global $wpdb; |
343 | 343 | $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
344 | 344 | $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
@@ -358,25 +358,25 @@ discard block |
||
358 | 358 | * @param array $orderby_params |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) { |
|
362 | - foreach ( (array)$orderby_params as $orderby ) { |
|
363 | - switch ( $orderby ) { |
|
361 | + public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) { |
|
362 | + foreach ((array) $orderby_params as $orderby) { |
|
363 | + switch ($orderby) { |
|
364 | 364 | case 'ticket_start' : |
365 | 365 | case 'ticket_end' : |
366 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() ); |
|
367 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )'; |
|
366 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name()); |
|
367 | + $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' = '.EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' )'; |
|
368 | 368 | break; |
369 | 369 | case 'venue_title' : |
370 | 370 | case 'city' : |
371 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL ); |
|
371 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
372 | 372 | break; |
373 | 373 | case 'state' : |
374 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL ); |
|
375 | - $SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL ); |
|
374 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
375 | + $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL); |
|
376 | 376 | break; |
377 | 377 | case 'start_date' : |
378 | 378 | default : |
379 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' ); |
|
379 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID'); |
|
380 | 380 | break; |
381 | 381 | |
382 | 382 | } |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | * @param string $join |
395 | 395 | * @return string |
396 | 396 | */ |
397 | - protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) { |
|
398 | - if ( ! empty( $join )) { |
|
399 | - $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
400 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
401 | - return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
397 | + protected static function _posts_join_for_datetime($SQL = '', $join = '') { |
|
398 | + if ( ! empty($join)) { |
|
399 | + $join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
400 | + if (strpos($SQL, $join) === FALSE) { |
|
401 | + return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )'; |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | return ''; |
@@ -413,13 +413,13 @@ discard block |
||
413 | 413 | * @param string $SQL |
414 | 414 | * @return string |
415 | 415 | */ |
416 | - protected static function _posts_join_for_event_venue( $SQL = '' ) { |
|
416 | + protected static function _posts_join_for_event_venue($SQL = '') { |
|
417 | 417 | // Event Venue table name |
418 | 418 | $event_venue_table = EEM_Event_Venue::instance()->table(); |
419 | 419 | // generate conditions for: Event <=> Event Venue JOIN clause |
420 | - $event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ' . $event_venue_table . '.' . EEM_Event::instance()->primary_key_name(); |
|
420 | + $event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '.$event_venue_table.'.'.EEM_Event::instance()->primary_key_name(); |
|
421 | 421 | // don't add joins if they have already been added |
422 | - if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) { |
|
422 | + if (strpos($SQL, $event_to_event_venue_join) === FALSE) { |
|
423 | 423 | // Venue table name |
424 | 424 | $venue_table = EEM_Venue::instance()->table(); |
425 | 425 | // Venue table pk |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | $venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )"; |
433 | 433 | // generate JOIN clause for: Venue <=> Venue Meta |
434 | 434 | $venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )"; |
435 | - unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table ); |
|
435 | + unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table); |
|
436 | 436 | return $venue_SQL; |
437 | 437 | } |
438 | - unset( $event_venue_table, $event_to_event_venue_join ); |
|
438 | + unset($event_venue_table, $event_to_event_venue_join); |
|
439 | 439 | return ''; |
440 | 440 | } |
441 | 441 | |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @param string $SQL |
449 | 449 | * @return string |
450 | 450 | */ |
451 | - protected static function _posts_join_for_venue_state( $SQL = '' ) { |
|
451 | + protected static function _posts_join_for_venue_state($SQL = '') { |
|
452 | 452 | // Venue Meta table name |
453 | 453 | $venue_meta_table = EEM_Venue::instance()->second_table(); |
454 | 454 | // State table name |
@@ -456,16 +456,16 @@ discard block |
||
456 | 456 | // State table pk |
457 | 457 | $state_table_pk = EEM_State::instance()->primary_key_name(); |
458 | 458 | // verify vars |
459 | - if ( $venue_meta_table && $state_table && $state_table_pk ) { |
|
459 | + if ($venue_meta_table && $state_table && $state_table_pk) { |
|
460 | 460 | // like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID |
461 | 461 | $join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk"; |
462 | 462 | // don't add join if it has already been added |
463 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
464 | - unset( $state_table_pk, $venue_meta_table, $venue_table_pk ); |
|
463 | + if (strpos($SQL, $join) === FALSE) { |
|
464 | + unset($state_table_pk, $venue_meta_table, $venue_table_pk); |
|
465 | 465 | return " LEFT JOIN $state_table ON ( $join )"; |
466 | 466 | } |
467 | 467 | } |
468 | - unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk ); |
|
468 | + unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk); |
|
469 | 469 | return ''; |
470 | 470 | } |
471 | 471 | |
@@ -479,14 +479,14 @@ discard block |
||
479 | 479 | * @param WP_Query $wp_query |
480 | 480 | * @return string |
481 | 481 | */ |
482 | - public static function posts_where( $SQL = '', WP_Query $wp_query ) { |
|
483 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
482 | + public static function posts_where($SQL = '', WP_Query $wp_query) { |
|
483 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
484 | 484 | // Show Expired ? |
485 | - $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired ); |
|
485 | + $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired); |
|
486 | 486 | // Category |
487 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category ); |
|
487 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category); |
|
488 | 488 | // Start Date |
489 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month ); |
|
489 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month); |
|
490 | 490 | } |
491 | 491 | return $SQL; |
492 | 492 | } |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | * @param boolean $show_expired if TRUE, then displayed past events |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
504 | - return ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . current_time( 'mysql', TRUE ) . '" ' : ''; |
|
503 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
504 | + return ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.current_time('mysql', TRUE).'" ' : ''; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -513,9 +513,9 @@ discard block |
||
513 | 513 | * @param boolean $event_category_slug |
514 | 514 | * @return string |
515 | 515 | */ |
516 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
516 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
517 | 517 | global $wpdb; |
518 | - return ! empty( $event_category_slug ) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : ''; |
|
518 | + return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : ''; |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -527,13 +527,13 @@ discard block |
||
527 | 527 | * @param boolean $month |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
530 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
531 | 531 | $SQL = ''; |
532 | - if ( ! empty( $month ) ) { |
|
532 | + if ( ! empty($month)) { |
|
533 | 533 | // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
534 | - $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start <= "' . date( 'Y-m-t 23:59:59', strtotime( $month ) ) . '"'; |
|
534 | + $SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start <= "'.date('Y-m-t 23:59:59', strtotime($month)).'"'; |
|
535 | 535 | // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
536 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end >= "' . date( 'Y-m-01 0:0:00', strtotime( $month ) ) . '" '; |
|
536 | + $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end >= "'.date('Y-m-01 0:0:00', strtotime($month)).'" '; |
|
537 | 537 | } |
538 | 538 | return $SQL; |
539 | 539 | } |
@@ -548,9 +548,9 @@ discard block |
||
548 | 548 | * @param WP_Query $wp_query |
549 | 549 | * @return string |
550 | 550 | */ |
551 | - public static function posts_orderby( $SQL = '', WP_Query $wp_query ) { |
|
552 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
553 | - $SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort ); |
|
551 | + public static function posts_orderby($SQL = '', WP_Query $wp_query) { |
|
552 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
553 | + $SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort); |
|
554 | 554 | } |
555 | 555 | return $SQL; |
556 | 556 | } |
@@ -581,63 +581,63 @@ discard block |
||
581 | 581 | * @param string $sort |
582 | 582 | * @return string |
583 | 583 | */ |
584 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
584 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
585 | 585 | global $wpdb; |
586 | 586 | $SQL = ''; |
587 | 587 | $counter = 0; |
588 | 588 | //make sure 'orderby' is set in query params |
589 | - if ( ! isset( self::$_query_params['orderby'] )) { |
|
589 | + if ( ! isset(self::$_query_params['orderby'])) { |
|
590 | 590 | self::$_query_params['orderby'] = array(); |
591 | 591 | } |
592 | 592 | // loop thru $orderby_params (type cast as array) |
593 | - foreach ( (array)$orderby_params as $orderby ) { |
|
593 | + foreach ((array) $orderby_params as $orderby) { |
|
594 | 594 | // check if we have already added this param |
595 | - if ( isset( self::$_query_params['orderby'][ $orderby ] )) { |
|
595 | + if (isset(self::$_query_params['orderby'][$orderby])) { |
|
596 | 596 | // if so then remove from the $orderby_params so that the count() method below is accurate |
597 | - unset( $orderby_params[ $orderby ] ); |
|
597 | + unset($orderby_params[$orderby]); |
|
598 | 598 | // then bump ahead to the next param |
599 | 599 | continue; |
600 | 600 | } |
601 | 601 | // this will ad a comma depending on whether this is the first or last param |
602 | - $glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', '; |
|
602 | + $glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', '; |
|
603 | 603 | // ok what's we dealing with? |
604 | - switch ( $orderby ) { |
|
604 | + switch ($orderby) { |
|
605 | 605 | case 'id' : |
606 | 606 | case 'ID' : |
607 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
607 | + $SQL .= $glue.$wpdb->posts.'.ID '.$sort; |
|
608 | 608 | break; |
609 | 609 | case 'end_date' : |
610 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
610 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort; |
|
611 | 611 | break; |
612 | 612 | case 'event_name' : |
613 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
613 | + $SQL .= $glue.$wpdb->posts.'.post_title '.$sort; |
|
614 | 614 | break; |
615 | 615 | case 'category_slug' : |
616 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
616 | + $SQL .= $glue.$wpdb->terms.'.slug '.$sort; |
|
617 | 617 | break; |
618 | 618 | case 'ticket_start' : |
619 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
619 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort; |
|
620 | 620 | break; |
621 | 621 | case 'ticket_end' : |
622 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
622 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort; |
|
623 | 623 | break; |
624 | 624 | case 'venue_title' : |
625 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
625 | + $SQL .= $glue.'venue_title '.$sort; |
|
626 | 626 | break; |
627 | 627 | case 'city' : |
628 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
628 | + $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort; |
|
629 | 629 | break; |
630 | 630 | case 'state' : |
631 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
631 | + $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort; |
|
632 | 632 | break; |
633 | 633 | case 'start_date' : |
634 | 634 | default : |
635 | - $SQL .= $glue . ' event_start_date ' . $sort; |
|
635 | + $SQL .= $glue.' event_start_date '.$sort; |
|
636 | 636 | break; |
637 | 637 | } |
638 | 638 | // add to array of orderby params that have been added |
639 | - self::$_query_params['orderby'][ $orderby ] = TRUE; |
|
640 | - $counter ++; |
|
639 | + self::$_query_params['orderby'][$orderby] = TRUE; |
|
640 | + $counter++; |
|
641 | 641 | } |
642 | 642 | return $SQL; |
643 | 643 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @return string |
54 | 54 | * @throws \EE_Error |
55 | 55 | */ |
56 | - public static function get_valid_timezone_string( $timezone_string = '' ) { |
|
56 | + public static function get_valid_timezone_string($timezone_string = '') { |
|
57 | 57 | // if passed a value, then use that, else get WP option |
58 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
58 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
59 | 59 | // value from above exists, use that, else get timezone string from gmt_offset |
60 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | - EEH_DTT_Helper::validate_timezone( $timezone_string ); |
|
60 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_gmt_offset(); |
|
61 | + EEH_DTT_Helper::validate_timezone($timezone_string); |
|
62 | 62 | return $timezone_string; |
63 | 63 | } |
64 | 64 | |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | * @return bool |
75 | 75 | * @throws \EE_Error |
76 | 76 | */ |
77 | - public static function validate_timezone( $timezone_string, $throw_error = true ) { |
|
77 | + public static function validate_timezone($timezone_string, $throw_error = true) { |
|
78 | 78 | // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it |
79 | 79 | try { |
80 | - new DateTimeZone( $timezone_string ); |
|
81 | - } catch ( Exception $e ) { |
|
80 | + new DateTimeZone($timezone_string); |
|
81 | + } catch (Exception $e) { |
|
82 | 82 | // sometimes we take exception to exceptions |
83 | - if ( ! $throw_error ) { |
|
83 | + if ( ! $throw_error) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | throw new EE_Error( |
87 | 87 | sprintf( |
88 | - __( 'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
88 | + __('The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
89 | 89 | $timezone_string, |
90 | 90 | '<a href="http://www.php.net/manual/en/timezones.php">', |
91 | 91 | '</a>' |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @param string $gmt_offset |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public static function get_timezone_string_from_gmt_offset( $gmt_offset = '' ) { |
|
107 | + public static function get_timezone_string_from_gmt_offset($gmt_offset = '') { |
|
108 | 108 | $timezone_string = 'UTC'; |
109 | - $gmt_offset = ! empty( $gmt_offset ) ? $gmt_offset : get_option( 'gmt_offset' ); |
|
110 | - if ( $gmt_offset !== '' ) { |
|
109 | + $gmt_offset = ! empty($gmt_offset) ? $gmt_offset : get_option('gmt_offset'); |
|
110 | + if ($gmt_offset !== '') { |
|
111 | 111 | // convert GMT offset to seconds |
112 | 112 | $gmt_offset = $gmt_offset * HOUR_IN_SECONDS; |
113 | 113 | // account for WP offsets that aren't valid UTC |
114 | - $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets( $gmt_offset ); |
|
114 | + $gmt_offset = EEH_DTT_Helper::adjust_invalid_gmt_offsets($gmt_offset); |
|
115 | 115 | // although we don't know the TZ abbreviation, we know the UTC offset |
116 | - $timezone_string = timezone_name_from_abbr( null, $gmt_offset ); |
|
116 | + $timezone_string = timezone_name_from_abbr(null, $gmt_offset); |
|
117 | 117 | } |
118 | 118 | // better have a valid timezone string by now, but if not, sigh... loop thru the timezone_abbreviations_list()... |
119 | - $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list( $gmt_offset ); |
|
119 | + $timezone_string = $timezone_string !== false ? $timezone_string : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset); |
|
120 | 120 | return $timezone_string; |
121 | 121 | } |
122 | 122 | |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | * @return int seconds offset |
128 | 128 | */ |
129 | 129 | public static function get_site_timezone_gmt_offset() { |
130 | - $timezone_string = get_option( 'timezone_string' ); |
|
131 | - if ( $timezone_string ) { |
|
130 | + $timezone_string = get_option('timezone_string'); |
|
131 | + if ($timezone_string) { |
|
132 | 132 | try { |
133 | - $timezone = new DateTimeZone( $timezone_string ); |
|
134 | - return $timezone->getOffset( new DateTime() ); //in WordPress DateTime defaults to UTC |
|
135 | - } catch( Exception $e ){} |
|
133 | + $timezone = new DateTimeZone($timezone_string); |
|
134 | + return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC |
|
135 | + } catch (Exception $e) {} |
|
136 | 136 | } |
137 | - $offset = get_option( 'gmt_offset' ); |
|
138 | - return (int) ( $offset * HOUR_IN_SECONDS ); |
|
137 | + $offset = get_option('gmt_offset'); |
|
138 | + return (int) ($offset * HOUR_IN_SECONDS); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | * @param int $gmt_offset |
148 | 148 | * @return int |
149 | 149 | */ |
150 | - public static function adjust_invalid_gmt_offsets( $gmt_offset = 0 ) { |
|
150 | + public static function adjust_invalid_gmt_offsets($gmt_offset = 0) { |
|
151 | 151 | //make sure $gmt_offset is int |
152 | 152 | $gmt_offset = (int) $gmt_offset; |
153 | - switch ( $gmt_offset ) { |
|
153 | + switch ($gmt_offset) { |
|
154 | 154 | |
155 | 155 | // case -30600 : |
156 | 156 | // $gmt_offset = -28800; |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | * @return string |
203 | 203 | * @throws \EE_Error |
204 | 204 | */ |
205 | - public static function get_timezone_string_from_abbreviations_list( $gmt_offset = 0 ) { |
|
205 | + public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0) { |
|
206 | 206 | $abbreviations = timezone_abbreviations_list(); |
207 | - foreach ( $abbreviations as $abbreviation ) { |
|
208 | - foreach ( $abbreviation as $city ) { |
|
209 | - if ( $city['offset'] === $gmt_offset && $city['dst'] === FALSE ) { |
|
207 | + foreach ($abbreviations as $abbreviation) { |
|
208 | + foreach ($abbreviation as $city) { |
|
209 | + if ($city['offset'] === $gmt_offset && $city['dst'] === FALSE) { |
|
210 | 210 | // check if the timezone is valid but don't throw any errors if it isn't |
211 | - if ( EEH_DTT_Helper::validate_timezone( $city['timezone_id'], false ) ) { |
|
211 | + if (EEH_DTT_Helper::validate_timezone($city['timezone_id'], false)) { |
|
212 | 212 | return $city['timezone_id']; |
213 | 213 | } |
214 | 214 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | throw new EE_Error( |
218 | 218 | sprintf( |
219 | - __( 'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso' ), |
|
219 | + __('The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used', 'event_espresso'), |
|
220 | 220 | $gmt_offset, |
221 | 221 | '<a href="http://www.php.net/manual/en/timezones.php">', |
222 | 222 | '</a>' |
@@ -230,23 +230,23 @@ discard block |
||
230 | 230 | * @access public |
231 | 231 | * @param string $timezone_string |
232 | 232 | */ |
233 | - public static function timezone_select_input( $timezone_string = '' ) { |
|
233 | + public static function timezone_select_input($timezone_string = '') { |
|
234 | 234 | // get WP date time format |
235 | - $datetime_format = get_option('date_format') . ' ' . get_option('time_format'); |
|
235 | + $datetime_format = get_option('date_format').' '.get_option('time_format'); |
|
236 | 236 | // if passed a value, then use that, else get WP option |
237 | - $timezone_string = ! empty( $timezone_string ) ? $timezone_string : get_option( 'timezone_string' ); |
|
237 | + $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string'); |
|
238 | 238 | // check if the timezone is valid but don't throw any errors if it isn't |
239 | - $timezone_string = EEH_DTT_Helper::validate_timezone( $timezone_string, false ); |
|
239 | + $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false); |
|
240 | 240 | $gmt_offset = get_option('gmt_offset'); |
241 | 241 | |
242 | 242 | $check_zone_info = true; |
243 | - if ( empty( $timezone_string )) { |
|
243 | + if (empty($timezone_string)) { |
|
244 | 244 | // Create a UTC+- zone if no timezone string exists |
245 | 245 | $check_zone_info = false; |
246 | - if ( $gmt_offset > 0 ) { |
|
247 | - $timezone_string = 'UTC+' . $gmt_offset; |
|
248 | - } elseif ( $gmt_offset < 0 ) { |
|
249 | - $timezone_string = 'UTC' . $gmt_offset; |
|
246 | + if ($gmt_offset > 0) { |
|
247 | + $timezone_string = 'UTC+'.$gmt_offset; |
|
248 | + } elseif ($gmt_offset < 0) { |
|
249 | + $timezone_string = 'UTC'.$gmt_offset; |
|
250 | 250 | } else { |
251 | 251 | $timezone_string = 'UTC'; |
252 | 252 | } |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | __('%1$sUTC%2$s time is %3$s'), |
269 | 269 | '<abbr title="Coordinated Universal Time">', |
270 | 270 | '</abbr>', |
271 | - '<code>' . date_i18n( $datetime_format , false, true ) . '</code>' |
|
271 | + '<code>'.date_i18n($datetime_format, false, true).'</code>' |
|
272 | 272 | ); |
273 | 273 | ?></span> |
274 | - <?php if ( ! empty( $timezone_string ) || ! empty( $gmt_offset )) : ?> |
|
275 | - <br /><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n( $datetime_format ) . '</code>' ); ?></span> |
|
274 | + <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?> |
|
275 | + <br /><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span> |
|
276 | 276 | <?php endif; ?> |
277 | 277 | |
278 | 278 | <?php if ($check_zone_info && $timezone_string) : ?> |
@@ -304,10 +304,9 @@ discard block |
||
304 | 304 | |
305 | 305 | if ($found) { |
306 | 306 | $message = $tr['isdst'] ? |
307 | - __(' Daylight saving time begins on: %s.' ) : |
|
308 | - __(' Standard time begins on: %s.'); |
|
307 | + __(' Daylight saving time begins on: %s.') : __(' Standard time begins on: %s.'); |
|
309 | 308 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
310 | - printf( $message, '<code >' . date_i18n( $datetime_format, $tr['ts'] + ( $tz_offset - $tr['offset'] ) ). '</code >' ); |
|
309 | + printf($message, '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'); |
|
311 | 310 | } else { |
312 | 311 | _e('This timezone does not observe daylight saving time.'); |
313 | 312 | } |
@@ -337,14 +336,14 @@ discard block |
||
337 | 336 | * |
338 | 337 | * @return int $unix_timestamp with the offset applied for the given timezone. |
339 | 338 | */ |
340 | - public static function get_timestamp_with_offset( $unix_timestamp = 0, $timezone_string = '' ) { |
|
339 | + public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '') { |
|
341 | 340 | $unix_timestamp = $unix_timestamp === 0 ? time() : (int) $unix_timestamp; |
342 | - $timezone_string = self::get_valid_timezone_string( $timezone_string ); |
|
343 | - $TimeZone = new DateTimeZone( $timezone_string ); |
|
341 | + $timezone_string = self::get_valid_timezone_string($timezone_string); |
|
342 | + $TimeZone = new DateTimeZone($timezone_string); |
|
344 | 343 | |
345 | - $DateTime = new DateTime( '@' . $unix_timestamp, $TimeZone ); |
|
346 | - $offset = timezone_offset_get( $TimeZone, $DateTime ); |
|
347 | - return (int)$DateTime->format( 'U' ) + (int)$offset; |
|
344 | + $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone); |
|
345 | + $offset = timezone_offset_get($TimeZone, $DateTime); |
|
346 | + return (int) $DateTime->format('U') + (int) $offset; |
|
348 | 347 | } |
349 | 348 | |
350 | 349 | |
@@ -359,17 +358,17 @@ discard block |
||
359 | 358 | * @param string $datetime_field_name the datetime fieldname to be manipulated |
360 | 359 | * @return EE_Base_Class |
361 | 360 | */ |
362 | - protected static function _set_date_time_field( EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name ) { |
|
361 | + protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name) { |
|
363 | 362 | // grab current datetime format |
364 | 363 | $current_format = $obj->get_format(); |
365 | 364 | // set new full timestamp format |
366 | - $obj->set_date_format( EE_Datetime_Field::mysql_date_format ); |
|
367 | - $obj->set_time_format( EE_Datetime_Field::mysql_time_format ); |
|
365 | + $obj->set_date_format(EE_Datetime_Field::mysql_date_format); |
|
366 | + $obj->set_time_format(EE_Datetime_Field::mysql_time_format); |
|
368 | 367 | // set the new date value using a full timestamp format so that no data is lost |
369 | - $obj->set( $datetime_field_name, $DateTime->format( EE_Datetime_Field::mysql_timestamp_format ) ); |
|
368 | + $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format)); |
|
370 | 369 | // reset datetime formats |
371 | - $obj->set_date_format( $current_format[0] ); |
|
372 | - $obj->set_time_format( $current_format[1] ); |
|
370 | + $obj->set_date_format($current_format[0]); |
|
371 | + $obj->set_time_format($current_format[1]); |
|
373 | 372 | return $obj; |
374 | 373 | } |
375 | 374 | |
@@ -386,11 +385,11 @@ discard block |
||
386 | 385 | * @param integer $value what you want to increment the time by |
387 | 386 | * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it (chaining) |
388 | 387 | */ |
389 | - public static function date_time_add( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
388 | + public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
390 | 389 | //get the raw UTC date. |
391 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
392 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value ); |
|
393 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
390 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
391 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value); |
|
392 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
394 | 393 | } |
395 | 394 | |
396 | 395 | |
@@ -405,11 +404,11 @@ discard block |
||
405 | 404 | * @param int $value |
406 | 405 | * @return \EE_Base_Class |
407 | 406 | */ |
408 | - public static function date_time_subtract( EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1 ) { |
|
407 | + public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1) { |
|
409 | 408 | //get the raw UTC date |
410 | - $DateTime = $obj->get_DateTime_object( $datetime_field_name ); |
|
411 | - $DateTime = EEH_DTT_Helper::calc_date( $DateTime, $period, $value, '-' ); |
|
412 | - return EEH_DTT_Helper::_set_date_time_field( $obj, $DateTime, $datetime_field_name ); |
|
409 | + $DateTime = $obj->get_DateTime_object($datetime_field_name); |
|
410 | + $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-'); |
|
411 | + return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name); |
|
413 | 412 | } |
414 | 413 | |
415 | 414 | |
@@ -422,44 +421,44 @@ discard block |
||
422 | 421 | * @return \DateTime return whatever type came in. |
423 | 422 | * @throws \EE_Error |
424 | 423 | */ |
425 | - protected static function _modify_datetime_object( DateTime $DateTime, $period = 'years', $value = 1, $operand = '+' ) { |
|
426 | - if ( ! $DateTime instanceof DateTime ) { |
|
424 | + protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+') { |
|
425 | + if ( ! $DateTime instanceof DateTime) { |
|
427 | 426 | throw new EE_Error( |
428 | 427 | sprintf( |
429 | - __( 'Expected a PHP DateTime object, but instead received %1$s', 'event_espresso' ), |
|
430 | - print_r( $DateTime, true ) |
|
428 | + __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'), |
|
429 | + print_r($DateTime, true) |
|
431 | 430 | ) |
432 | 431 | ); |
433 | 432 | } |
434 | - switch ( $period ) { |
|
433 | + switch ($period) { |
|
435 | 434 | case 'years' : |
436 | - $value = 'P' . $value . 'Y'; |
|
435 | + $value = 'P'.$value.'Y'; |
|
437 | 436 | break; |
438 | 437 | case 'months' : |
439 | - $value = 'P' . $value . 'M'; |
|
438 | + $value = 'P'.$value.'M'; |
|
440 | 439 | break; |
441 | 440 | case 'weeks' : |
442 | - $value = 'P' . $value . 'W'; |
|
441 | + $value = 'P'.$value.'W'; |
|
443 | 442 | break; |
444 | 443 | case 'days' : |
445 | - $value = 'P' . $value . 'D'; |
|
444 | + $value = 'P'.$value.'D'; |
|
446 | 445 | break; |
447 | 446 | case 'hours' : |
448 | - $value = 'PT' . $value . 'H'; |
|
447 | + $value = 'PT'.$value.'H'; |
|
449 | 448 | break; |
450 | 449 | case 'minutes' : |
451 | - $value = 'PT' . $value . 'M'; |
|
450 | + $value = 'PT'.$value.'M'; |
|
452 | 451 | break; |
453 | 452 | case 'seconds' : |
454 | - $value = 'PT' . $value . 'S'; |
|
453 | + $value = 'PT'.$value.'S'; |
|
455 | 454 | break; |
456 | 455 | } |
457 | - switch ( $operand ) { |
|
456 | + switch ($operand) { |
|
458 | 457 | case '+': |
459 | - $DateTime->add( new DateInterval( $value ) ); |
|
458 | + $DateTime->add(new DateInterval($value)); |
|
460 | 459 | break; |
461 | 460 | case '-': |
462 | - $DateTime->sub( new DateInterval( $value ) ); |
|
461 | + $DateTime->sub(new DateInterval($value)); |
|
463 | 462 | break; |
464 | 463 | } |
465 | 464 | return $DateTime; |
@@ -475,16 +474,16 @@ discard block |
||
475 | 474 | * @return \DateTime return whatever type came in. |
476 | 475 | * @throws \EE_Error |
477 | 476 | */ |
478 | - protected static function _modify_timestamp( $timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
479 | - if ( ! preg_match( EE_Datetime_Field::unix_timestamp_regex, $timestamp ) ) { |
|
477 | + protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
478 | + if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) { |
|
480 | 479 | throw new EE_Error( |
481 | 480 | sprintf( |
482 | - __( 'Expected a Unix timestamp, but instead received %1$s', 'event_espresso' ), |
|
483 | - print_r( $timestamp, true ) |
|
481 | + __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'), |
|
482 | + print_r($timestamp, true) |
|
484 | 483 | ) |
485 | 484 | ); |
486 | 485 | } |
487 | - switch ( $period ) { |
|
486 | + switch ($period) { |
|
488 | 487 | case 'years' : |
489 | 488 | $value = YEAR_IN_SECONDS * $value; |
490 | 489 | break; |
@@ -504,9 +503,9 @@ discard block |
||
504 | 503 | $value = MINUTE_IN_SECONDS * $value; |
505 | 504 | break; |
506 | 505 | } |
507 | - switch ( $operand ) { |
|
506 | + switch ($operand) { |
|
508 | 507 | case '+': |
509 | - $timestamp += $value; |
|
508 | + $timestamp += $value; |
|
510 | 509 | break; |
511 | 510 | case '-': |
512 | 511 | $timestamp -= $value; |
@@ -526,11 +525,11 @@ discard block |
||
526 | 525 | * @param string $operand What operand you wish to use for the calculation |
527 | 526 | * @return mixed string|DateTime return whatever type came in. |
528 | 527 | */ |
529 | - public static function calc_date( $DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+' ) { |
|
530 | - if ( $DateTime_or_timestamp instanceof DateTime ) { |
|
531 | - return EEH_DTT_Helper::_modify_datetime_object( $DateTime_or_timestamp, $period, $value, $operand ); |
|
532 | - } else if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp )) { |
|
533 | - return EEH_DTT_Helper::_modify_timestamp( $DateTime_or_timestamp, $period, $value, $operand ); |
|
528 | + public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') { |
|
529 | + if ($DateTime_or_timestamp instanceof DateTime) { |
|
530 | + return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); |
|
531 | + } else if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { |
|
532 | + return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); |
|
534 | 533 | } else { |
535 | 534 | //error |
536 | 535 | return $DateTime_or_timestamp; |
@@ -560,24 +559,24 @@ discard block |
||
560 | 559 | * 'moment' => //date and time format. |
561 | 560 | * ) |
562 | 561 | */ |
563 | - public static function convert_php_to_js_and_moment_date_formats( $date_format_string = null, $time_format_string = null ) { |
|
564 | - if ( $date_format_string === null ) { |
|
565 | - $date_format_string = get_option( 'date_format' ); |
|
562 | + public static function convert_php_to_js_and_moment_date_formats($date_format_string = null, $time_format_string = null) { |
|
563 | + if ($date_format_string === null) { |
|
564 | + $date_format_string = get_option('date_format'); |
|
566 | 565 | } |
567 | 566 | |
568 | - if ( $time_format_string === null ) { |
|
569 | - $time_format_string = get_option( 'time_format' ); |
|
567 | + if ($time_format_string === null) { |
|
568 | + $time_format_string = get_option('time_format'); |
|
570 | 569 | } |
571 | 570 | |
572 | - $date_format = self::_php_to_js_moment_converter( $date_format_string ); |
|
573 | - $time_format = self::_php_to_js_moment_converter( $time_format_string ); |
|
571 | + $date_format = self::_php_to_js_moment_converter($date_format_string); |
|
572 | + $time_format = self::_php_to_js_moment_converter($time_format_string); |
|
574 | 573 | |
575 | 574 | return array( |
576 | 575 | 'js' => array( |
577 | 576 | 'date' => $date_format['js'], |
578 | 577 | 'time' => $time_format['js'] |
579 | 578 | ), |
580 | - 'moment' => $date_format['moment'] . ' ' . $time_format['moment' ] |
|
579 | + 'moment' => $date_format['moment'].' '.$time_format['moment'] |
|
581 | 580 | ); |
582 | 581 | } |
583 | 582 | |
@@ -591,7 +590,7 @@ discard block |
||
591 | 590 | * |
592 | 591 | * @return array js and moment formats. |
593 | 592 | */ |
594 | - protected static function _php_to_js_moment_converter( $format_string ) { |
|
593 | + protected static function _php_to_js_moment_converter($format_string) { |
|
595 | 594 | /** |
596 | 595 | * This is a map of symbols for formats. |
597 | 596 | * The index is the php symbol, the equivalent values are in the array. |
@@ -748,15 +747,15 @@ discard block |
||
748 | 747 | $jquery_ui_format = ""; |
749 | 748 | $moment_format = ""; |
750 | 749 | $escaping = false; |
751 | - for ( $i = 0; $i < strlen($format_string); $i++ ) { |
|
750 | + for ($i = 0; $i < strlen($format_string); $i++) { |
|
752 | 751 | $char = $format_string[$i]; |
753 | - if ( $char === '\\' ) { // PHP date format escaping character |
|
752 | + if ($char === '\\') { // PHP date format escaping character |
|
754 | 753 | $i++; |
755 | - if ( $escaping ) { |
|
754 | + if ($escaping) { |
|
756 | 755 | $jquery_ui_format .= $format_string[$i]; |
757 | 756 | $moment_format .= $format_string[$i]; |
758 | 757 | } else { |
759 | - $jquery_ui_format .= '\'' . $format_string[$i]; |
|
758 | + $jquery_ui_format .= '\''.$format_string[$i]; |
|
760 | 759 | $moment_format .= $format_string[$i]; |
761 | 760 | } |
762 | 761 | $escaping = true; |
@@ -775,7 +774,7 @@ discard block |
||
775 | 774 | } |
776 | 775 | } |
777 | 776 | } |
778 | - return array( 'js' => $jquery_ui_format, 'moment' => $moment_format ); |
|
777 | + return array('js' => $jquery_ui_format, 'moment' => $moment_format); |
|
779 | 778 | } |
780 | 779 | |
781 | 780 | |
@@ -790,25 +789,25 @@ discard block |
||
790 | 789 | * errors is returned. So for client code calling, check for is_array() to |
791 | 790 | * indicate failed validations. |
792 | 791 | */ |
793 | - public static function validate_format_string( $format_string ) { |
|
792 | + public static function validate_format_string($format_string) { |
|
794 | 793 | $error_msg = array(); |
795 | 794 | //time format checks |
796 | - switch ( true ) { |
|
797 | - case strpos( $format_string, 'h' ) !== false : |
|
798 | - case strpos( $format_string, 'g' ) !== false : |
|
795 | + switch (true) { |
|
796 | + case strpos($format_string, 'h') !== false : |
|
797 | + case strpos($format_string, 'g') !== false : |
|
799 | 798 | /** |
800 | 799 | * if the time string has a lowercase 'h' which == 12 hour time format and there |
801 | 800 | * is not any ante meridiem format ('a' or 'A'). Then throw an error because its |
802 | 801 | * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am. |
803 | 802 | */ |
804 | - if ( strpos( strtoupper( $format_string ), 'A' ) === false ) { |
|
805 | - $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso' ); |
|
803 | + if (strpos(strtoupper($format_string), 'A') === false) { |
|
804 | + $error_msg[] = __('There is a time format for 12 hour time but no "a" or "A" to indicate am/pm. Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".', 'event_espresso'); |
|
806 | 805 | } |
807 | 806 | break; |
808 | 807 | |
809 | 808 | } |
810 | 809 | |
811 | - return empty( $error_msg ) ? true : $error_msg; |
|
810 | + return empty($error_msg) ? true : $error_msg; |
|
812 | 811 | } |
813 | 812 | |
814 | 813 | |
@@ -830,11 +829,11 @@ discard block |
||
830 | 829 | * @param mixed $date_2 |
831 | 830 | * @return bool |
832 | 831 | */ |
833 | - public static function dates_represent_one_24_hour_date( $date_1, $date_2 ) { |
|
832 | + public static function dates_represent_one_24_hour_date($date_1, $date_2) { |
|
834 | 833 | |
835 | 834 | if ( |
836 | - ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime ) || |
|
837 | - ( $date_1->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' || $date_2->format( EE_Datetime_Field::mysql_time_format ) != '00:00:00' ) |
|
835 | + ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime) || |
|
836 | + ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00' || $date_2->format(EE_Datetime_Field::mysql_time_format) != '00:00:00') |
|
838 | 837 | ) { |
839 | 838 | return false; |
840 | 839 | } |
@@ -851,11 +850,11 @@ discard block |
||
851 | 850 | * @param string $field_for_interval The Database field that is the interval is applied to in the query. |
852 | 851 | * @return string |
853 | 852 | */ |
854 | - public static function get_sql_query_interval_for_offset( $timezone_string, $field_for_interval ) { |
|
853 | + public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval) { |
|
855 | 854 | try { |
856 | 855 | /** need to account for timezone offset on the selects */ |
857 | - $DateTimeZone = new DateTimeZone( $timezone_string ); |
|
858 | - } catch ( Exception $e ) { |
|
856 | + $DateTimeZone = new DateTimeZone($timezone_string); |
|
857 | + } catch (Exception $e) { |
|
859 | 858 | $DateTimeZone = null; |
860 | 859 | } |
861 | 860 | |
@@ -863,10 +862,10 @@ discard block |
||
863 | 862 | * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds. |
864 | 863 | * Hence we do the calc for DateTimeZone::getOffset. |
865 | 864 | */ |
866 | - $offset = $DateTimeZone instanceof DateTimeZone ? ( $DateTimeZone->getOffset( new DateTime('now') ) ) / HOUR_IN_SECONDS : get_option( 'gmt_offset' ); |
|
865 | + $offset = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now'))) / HOUR_IN_SECONDS : get_option('gmt_offset'); |
|
867 | 866 | $query_interval = $offset < 0 |
868 | - ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset*-1 . ' HOUR)' |
|
869 | - : 'DATE_ADD(' . $field_for_interval .', INTERVAL ' . $offset . ' HOUR)'; |
|
867 | + ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)' |
|
868 | + : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)'; |
|
870 | 869 | return $query_interval; |
871 | 870 | } |
872 | 871 | |
@@ -878,47 +877,47 @@ discard block |
||
878 | 877 | * @return string |
879 | 878 | */ |
880 | 879 | public static function get_timezone_string_for_display() { |
881 | - $pretty_timezone = apply_filters( 'FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '' ); |
|
882 | - if( ! empty( $pretty_timezone ) ) { |
|
883 | - return esc_html( $pretty_timezone ); |
|
880 | + $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', ''); |
|
881 | + if ( ! empty($pretty_timezone)) { |
|
882 | + return esc_html($pretty_timezone); |
|
884 | 883 | } |
885 | - $timezone_string = get_option( 'timezone_string' ); |
|
886 | - if( $timezone_string ) { |
|
884 | + $timezone_string = get_option('timezone_string'); |
|
885 | + if ($timezone_string) { |
|
887 | 886 | static $mo_loaded = false; |
888 | 887 | // Load translations for continents and cities just like wp_timezone_choice does |
889 | - if ( ! $mo_loaded ) { |
|
888 | + if ( ! $mo_loaded) { |
|
890 | 889 | $locale = get_locale(); |
891 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
892 | - load_textdomain( 'continents-cities', $mofile ); |
|
890 | + $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo'; |
|
891 | + load_textdomain('continents-cities', $mofile); |
|
893 | 892 | $mo_loaded = true; |
894 | 893 | } |
895 | 894 | //well that was easy. |
896 | - $parts = explode('/', $timezone_string ); |
|
895 | + $parts = explode('/', $timezone_string); |
|
897 | 896 | //remove the continent |
898 | - unset( $parts[0] ); |
|
897 | + unset($parts[0]); |
|
899 | 898 | $t_parts = array(); |
900 | - foreach( $parts as $part ) { |
|
901 | - $t_parts[] = translate( str_replace( '_', ' ', $part ), 'continents-cities' ); |
|
899 | + foreach ($parts as $part) { |
|
900 | + $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities'); |
|
902 | 901 | } |
903 | - return implode( ' - ', $t_parts ); |
|
902 | + return implode(' - ', $t_parts); |
|
904 | 903 | } |
905 | 904 | //they haven't set the timezone string, so let's return a string like "UTC+1" |
906 | - $gmt_offset = get_option( 'gmt_offset' ); |
|
907 | - if( intval( $gmt_offset ) >= 0 ) { |
|
905 | + $gmt_offset = get_option('gmt_offset'); |
|
906 | + if (intval($gmt_offset) >= 0) { |
|
908 | 907 | $prefix = '+'; |
909 | 908 | } else { |
910 | 909 | $prefix = ''; |
911 | 910 | } |
912 | - $parts = explode( '.', (string) $gmt_offset ); |
|
913 | - if( count( $parts ) === 1 ) { |
|
911 | + $parts = explode('.', (string) $gmt_offset); |
|
912 | + if (count($parts) === 1) { |
|
914 | 913 | $parts[1] = '00'; |
915 | 914 | } else { |
916 | 915 | //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25) |
917 | 916 | //to minutes, eg 30 or 15, respectively |
918 | - $hour_fraction = (float)( '0.' . $parts[1] ); |
|
919 | - $parts[1] = (string)$hour_fraction * 60; |
|
917 | + $hour_fraction = (float) ('0.'.$parts[1]); |
|
918 | + $parts[1] = (string) $hour_fraction * 60; |
|
920 | 919 | } |
921 | - return sprintf( __( 'UTC%1$s', 'event_espresso' ), $prefix . implode( ':', $parts ) ); |
|
920 | + return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts)); |
|
922 | 921 | } |
923 | 922 | |
924 | 923 |
@@ -373,7 +373,7 @@ |
||
373 | 373 | * @param int $ATT_ID |
374 | 374 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the |
375 | 375 | * attendee number is required |
376 | - * @return mixed array on success, FALSE on fail |
|
376 | + * @return null|EE_Base_Class array on success, FALSE on fail |
|
377 | 377 | */ |
378 | 378 | public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) |
379 | 379 | { |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -18,699 +18,699 @@ discard block |
||
18 | 18 | class EEM_Registration extends EEM_Soft_Delete_Base |
19 | 19 | { |
20 | 20 | |
21 | - // private instance of the Registration object |
|
22 | - protected static $_instance = null; |
|
23 | - |
|
24 | - /** |
|
25 | - * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values |
|
26 | - * are status codes (eg, approved, cancelled, etc) |
|
27 | - * |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - private static $_reg_status; |
|
31 | - |
|
32 | - /** |
|
33 | - * The value of REG_count for a primary registrant |
|
34 | - */ |
|
35 | - const PRIMARY_REGISTRANT_COUNT = 1; |
|
36 | - |
|
37 | - /** |
|
38 | - * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration. |
|
39 | - * Initial status for registrations when they are first created |
|
40 | - * Payments are NOT allowed. |
|
41 | - * Automatically toggled to whatever the default Event registration status is upon completion of the attendee |
|
42 | - * information reg step NO space reserved. Registration is NOT active |
|
43 | - */ |
|
44 | - const status_id_incomplete = 'RIC'; |
|
45 | - |
|
46 | - /** |
|
47 | - * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration. |
|
48 | - * Payments are NOT allowed. |
|
49 | - * Event Admin must manually toggle STS_ID for it to change |
|
50 | - * No space reserved. |
|
51 | - * Registration is active |
|
52 | - */ |
|
53 | - const status_id_not_approved = 'RNA'; |
|
54 | - |
|
55 | - /** |
|
56 | - * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT . |
|
57 | - * Payments are allowed. |
|
58 | - * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
59 | - * No space reserved. |
|
60 | - * Registration is active |
|
61 | - */ |
|
62 | - const status_id_pending_payment = 'RPP'; |
|
63 | - |
|
64 | - /** |
|
65 | - * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST . |
|
66 | - * Payments are allowed. |
|
67 | - * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
68 | - * No space reserved. |
|
69 | - * Registration is active |
|
70 | - */ |
|
71 | - const status_id_wait_list = 'RWL'; |
|
72 | - |
|
73 | - /** |
|
74 | - * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration. |
|
75 | - * the TXN may or may not be completed ( paid in full ) |
|
76 | - * Payments are allowed. |
|
77 | - * A space IS reserved. |
|
78 | - * Registration is active |
|
79 | - */ |
|
80 | - const status_id_approved = 'RAP'; |
|
81 | - |
|
82 | - /** |
|
83 | - * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee. |
|
84 | - * Payments are NOT allowed. |
|
85 | - * NO space reserved. |
|
86 | - * Registration is NOT active |
|
87 | - */ |
|
88 | - const status_id_cancelled = 'RCN'; |
|
89 | - |
|
90 | - /** |
|
91 | - * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin |
|
92 | - * Payments are NOT allowed. |
|
93 | - * No space reserved. |
|
94 | - * Registration is NOT active |
|
95 | - */ |
|
96 | - const status_id_declined = 'RDC'; |
|
97 | - |
|
98 | - /** |
|
99 | - * @var TableAnalysis $table_analysis |
|
100 | - */ |
|
101 | - protected $_table_analysis; |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * private constructor to prevent direct creation |
|
107 | - * |
|
108 | - * @Constructor |
|
109 | - * @access protected |
|
110 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
111 | - * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
112 | - * date time model field objects. Default is NULL (and will be assumed using the set |
|
113 | - * timezone in the 'timezone_string' wp option) |
|
114 | - */ |
|
115 | - protected function __construct($timezone = null) |
|
116 | - { |
|
117 | - $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
118 | - $this->singular_item = __('Registration', 'event_espresso'); |
|
119 | - $this->plural_item = __('Registrations', 'event_espresso'); |
|
120 | - $this->_tables = array( |
|
121 | - 'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'), |
|
122 | - ); |
|
123 | - $this->_fields = array( |
|
124 | - 'Registration' => array( |
|
125 | - 'REG_ID' => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
126 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, |
|
127 | - 'Event'), |
|
128 | - 'ATT_ID' => new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, |
|
129 | - 0, 'Attendee'), |
|
130 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), |
|
131 | - false, 0, 'Transaction'), |
|
132 | - 'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, |
|
133 | - 0, 'Ticket'), |
|
134 | - 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
135 | - false, EEM_Registration::status_id_incomplete, 'Status'), |
|
136 | - 'REG_date' => new EE_Datetime_Field('REG_date', |
|
137 | - __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
138 | - 'REG_final_price' => new EE_Money_Field('REG_final_price', |
|
139 | - __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
140 | - 'REG_paid' => new EE_Money_Field('REG_paid', |
|
141 | - __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
142 | - 'REG_session' => new EE_Plain_Text_Field('REG_session', |
|
143 | - __('Session ID of registration', 'event_espresso'), false, ''), |
|
144 | - 'REG_code' => new EE_Plain_Text_Field('REG_code', |
|
145 | - __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
146 | - 'REG_url_link' => new EE_Plain_Text_Field('REG_url_link', |
|
147 | - __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
148 | - 'REG_count' => new EE_Integer_Field('REG_count', |
|
149 | - __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
150 | - 'REG_group_size' => new EE_Integer_Field('REG_group_size', |
|
151 | - __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
152 | - 'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going', |
|
153 | - __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
154 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', |
|
155 | - __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false), |
|
156 | - ), |
|
157 | - ); |
|
158 | - $this->_model_relations = array( |
|
159 | - 'Event' => new EE_Belongs_To_Relation(), |
|
160 | - 'Attendee' => new EE_Belongs_To_Relation(), |
|
161 | - 'Transaction' => new EE_Belongs_To_Relation(), |
|
162 | - 'Ticket' => new EE_Belongs_To_Relation(), |
|
163 | - 'Status' => new EE_Belongs_To_Relation(), |
|
164 | - 'Answer' => new EE_Has_Many_Relation(), |
|
165 | - 'Checkin' => new EE_Has_Many_Relation(), |
|
166 | - 'Registration_Payment' => new EE_Has_Many_Relation(), |
|
167 | - 'Payment' => new EE_HABTM_Relation('Registration_Payment'), |
|
168 | - 'Message' => new EE_Has_Many_Any_Relation(false) |
|
169 | - //allow deletes even if there are messages in the queue related |
|
170 | - ); |
|
171 | - $this->_model_chain_to_wp_user = 'Event'; |
|
172 | - parent::__construct($timezone); |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * reg_statuses_that_allow_payment |
|
179 | - * a filterable list of registration statuses that allow a registrant to make a payment |
|
180 | - * |
|
181 | - * @access public |
|
182 | - * @return array |
|
183 | - */ |
|
184 | - public static function reg_statuses_that_allow_payment() |
|
185 | - { |
|
186 | - return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
187 | - EEM_Registration::status_id_approved, |
|
188 | - EEM_Registration::status_id_pending_payment, |
|
189 | - EEM_Registration::status_id_wait_list, |
|
190 | - )); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * inactive_reg_statuses |
|
197 | - * a filterable list of registration statuses that are considered active |
|
198 | - * |
|
199 | - * @access public |
|
200 | - * @return array |
|
201 | - */ |
|
202 | - public static function active_reg_statuses() |
|
203 | - { |
|
204 | - return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
205 | - EEM_Registration::status_id_approved, |
|
206 | - EEM_Registration::status_id_pending_payment, |
|
207 | - EEM_Registration::status_id_wait_list, |
|
208 | - EEM_Registration::status_id_not_approved, |
|
209 | - )); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * inactive_reg_statuses |
|
216 | - * a filterable list of registration statuses that are not considered active |
|
217 | - * |
|
218 | - * @access public |
|
219 | - * @return array |
|
220 | - */ |
|
221 | - public static function inactive_reg_statuses() |
|
222 | - { |
|
223 | - return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
224 | - EEM_Registration::status_id_incomplete, |
|
225 | - EEM_Registration::status_id_cancelled, |
|
226 | - EEM_Registration::status_id_declined, |
|
227 | - )); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * closed_reg_statuses |
|
234 | - * a filterable list of registration statuses that are considered "closed" |
|
235 | - * meaning they should not be considered in any calculations involving monies owing |
|
236 | - * |
|
237 | - * @access public |
|
238 | - * @return array |
|
239 | - */ |
|
240 | - public static function closed_reg_statuses() |
|
241 | - { |
|
242 | - return apply_filters('FHEE__EEM_Registration__closed_reg_statuses', array( |
|
243 | - EEM_Registration::status_id_cancelled, |
|
244 | - EEM_Registration::status_id_declined, |
|
245 | - )); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * get list of registration statuses |
|
252 | - * |
|
253 | - * @access public |
|
254 | - * @param array $exclude The status ids to exclude from the returned results |
|
255 | - * @param bool $translated If true will return the values as singular localized strings |
|
256 | - * @return array |
|
257 | - */ |
|
258 | - public static function reg_status_array($exclude = array(), $translated = false) |
|
259 | - { |
|
260 | - EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
261 | - return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence') |
|
262 | - : self::$_reg_status; |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * get list of registration statuses |
|
269 | - * |
|
270 | - * @access private |
|
271 | - * @param array $exclude |
|
272 | - * @return array |
|
273 | - */ |
|
274 | - private function _get_registration_status_array($exclude = array()) |
|
275 | - { |
|
276 | - //in the very rare circumstance that we are deleting a model's table's data |
|
277 | - //and the table hasn't actually been created, this could have an error |
|
278 | - /** @type WPDB $wpdb */ |
|
279 | - global $wpdb; |
|
280 | - if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
281 | - $SQL = 'SELECT STS_ID, STS_code FROM ' . $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
282 | - $results = $wpdb->get_results($SQL); |
|
283 | - self::$_reg_status = array(); |
|
284 | - foreach ($results as $status) { |
|
285 | - if ( ! in_array($status->STS_ID, $exclude)) { |
|
286 | - self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
287 | - } |
|
288 | - } |
|
289 | - } |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * Gets the injected table analyzer, or throws an exception |
|
296 | - * |
|
297 | - * @return TableAnalysis |
|
298 | - * @throws \EE_Error |
|
299 | - */ |
|
300 | - protected function _get_table_analysis() |
|
301 | - { |
|
302 | - if ($this->_table_analysis instanceof TableAnalysis) { |
|
303 | - return $this->_table_analysis; |
|
304 | - } else { |
|
305 | - throw new \EE_Error(sprintf(__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
306 | - get_class($this))); |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * This returns a wpdb->results array of all registration date month and years matching the incoming query params |
|
314 | - * and grouped by month and year. |
|
315 | - * |
|
316 | - * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
|
317 | - * @return array |
|
318 | - * @throws \EE_Error |
|
319 | - */ |
|
320 | - public function get_reg_months_and_years($where_params) |
|
321 | - { |
|
322 | - $query_params[0] = $where_params; |
|
323 | - $query_params['group_by'] = array('reg_year', 'reg_month'); |
|
324 | - $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
325 | - $columns_to_select = array( |
|
326 | - 'reg_year' => array('YEAR(REG_date)', '%s'), |
|
327 | - 'reg_month' => array('MONTHNAME(REG_date)', '%s'), |
|
328 | - ); |
|
329 | - return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
330 | - } |
|
331 | - |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * retrieve ALL registrations for a particular Attendee from db |
|
336 | - * |
|
337 | - * @access public |
|
338 | - * @param int $ATT_ID |
|
339 | - * @return EE_Registration[] |
|
340 | - */ |
|
341 | - public function get_all_registrations_for_attendee($ATT_ID = 0) |
|
342 | - { |
|
343 | - if ( ! $ATT_ID) { |
|
344 | - return false; |
|
345 | - } |
|
346 | - return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * Gets a registration given their REG_url_link. Yes, this should usually |
|
353 | - * be passed via a GET parameter. |
|
354 | - * |
|
355 | - * @param string $REG_url_link |
|
356 | - * @return EE_Registration |
|
357 | - */ |
|
358 | - public function get_registration_for_reg_url_link($REG_url_link) |
|
359 | - { |
|
360 | - if ( ! $REG_url_link) { |
|
361 | - return false; |
|
362 | - } |
|
363 | - return $this->get_one(array(array('REG_url_link' => $REG_url_link))); |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * retrieve registration for a specific transaction attendee from db |
|
370 | - * |
|
371 | - * @access public |
|
372 | - * @param int $TXN_ID |
|
373 | - * @param int $ATT_ID |
|
374 | - * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the |
|
375 | - * attendee number is required |
|
376 | - * @return mixed array on success, FALSE on fail |
|
377 | - */ |
|
378 | - public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) |
|
379 | - { |
|
380 | - return $this->get_one(array( |
|
381 | - array( |
|
382 | - 'TXN_ID' => $TXN_ID, |
|
383 | - 'ATT_ID' => $ATT_ID, |
|
384 | - ), |
|
385 | - 'limit' => array(min(($att_nmbr - 1), 0), 1), |
|
386 | - )); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * get the number of registrations per day for the Registration Admin page Reports Tab. |
|
393 | - * (doesn't utilize models because it's a fairly specialized query) |
|
394 | - * |
|
395 | - * @access public |
|
396 | - * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
397 | - * @return stdClass[] with properties regDate and total |
|
398 | - */ |
|
399 | - public function get_registrations_per_day_report($period = '-1 month') |
|
400 | - { |
|
401 | - $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
402 | - 'Y-m-d H:i:s', 'UTC'); |
|
403 | - $where = array( |
|
404 | - 'REG_date' => array('>=', $sql_date), |
|
405 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
406 | - ); |
|
407 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
408 | - $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
409 | - } |
|
410 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
411 | - $results = $this->_get_all_wpdb_results(array( |
|
412 | - $where, |
|
413 | - 'group_by' => 'regDate', |
|
414 | - 'order_by' => array('REG_date' => 'ASC'), |
|
415 | - ), OBJECT, array( |
|
416 | - 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
417 | - 'total' => array('count(REG_ID)', '%d'), |
|
418 | - )); |
|
419 | - return $results; |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - |
|
424 | - /** |
|
425 | - * Get the number of registrations per day including the count of registrations for each Registration Status. |
|
426 | - * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
427 | - * |
|
428 | - * @param string $period |
|
429 | - * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
|
430 | - * (i.e. RAP) |
|
431 | - */ |
|
432 | - public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
|
433 | - { |
|
434 | - global $wpdb; |
|
435 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
436 | - $event_table = $wpdb->posts; |
|
437 | - $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
438 | - //prepare the query interval for displaying offset |
|
439 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
440 | - //inner date query |
|
441 | - $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
|
442 | - $inner_where = " WHERE"; |
|
443 | - //exclude events not authored by user if permissions in effect |
|
444 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
445 | - $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
|
446 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
447 | - } |
|
448 | - $inner_where .= " REG_date >= '$sql_date'"; |
|
449 | - $inner_date_query .= $inner_where; |
|
450 | - //start main query |
|
451 | - $select = "SELECT DATE($query_interval) as Registration_REG_date, "; |
|
452 | - $join = ''; |
|
453 | - $join_parts = array(); |
|
454 | - $select_parts = array(); |
|
455 | - //loop through registration stati to do parts for each status. |
|
456 | - foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
457 | - if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
458 | - continue; |
|
459 | - } |
|
460 | - $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
|
461 | - $join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'"; |
|
462 | - } |
|
463 | - //setup the selects |
|
464 | - $select .= implode(', ', $select_parts); |
|
465 | - $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
|
466 | - //setup the joins |
|
467 | - $join .= implode(" LEFT JOIN ", $join_parts); |
|
468 | - //now let's put it all together |
|
469 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
470 | - //and execute it |
|
471 | - $results = $wpdb->get_results($query, ARRAY_A); |
|
472 | - return $results; |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - |
|
477 | - /** |
|
478 | - * get the number of registrations per event for the Registration Admin page Reports Tab |
|
479 | - * |
|
480 | - * @access public |
|
481 | - * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
482 | - * @return stdClass[] each with properties event_name, reg_limit, and total |
|
483 | - */ |
|
484 | - public function get_registrations_per_event_report($period = '-1 month') |
|
485 | - { |
|
486 | - $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
487 | - 'Y-m-d H:i:s', 'UTC'); |
|
488 | - $where = array( |
|
489 | - 'REG_date' => array('>=', $date_sql), |
|
490 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
491 | - ); |
|
492 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
493 | - $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
494 | - } |
|
495 | - $results = $this->_get_all_wpdb_results(array( |
|
496 | - $where, |
|
497 | - 'group_by' => 'Event.EVT_name', |
|
498 | - 'order_by' => 'Event.EVT_name', |
|
499 | - 'limit' => array(0, 24), |
|
500 | - ), OBJECT, array( |
|
501 | - 'event_name' => array('Event_CPT.post_title', '%s'), |
|
502 | - 'total' => array('COUNT(REG_ID)', '%s'), |
|
503 | - )); |
|
504 | - return $results; |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * Get the number of registrations per event grouped by registration status. |
|
511 | - * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
512 | - * |
|
513 | - * @param string $period |
|
514 | - * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
|
515 | - * (i.e. RAP) |
|
516 | - */ |
|
517 | - public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
|
518 | - { |
|
519 | - global $wpdb; |
|
520 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
521 | - $event_table = $wpdb->posts; |
|
522 | - $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
523 | - //inner date query |
|
524 | - $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
|
525 | - $inner_where = " WHERE"; |
|
526 | - //exclude events not authored by user if permissions in effect |
|
527 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
528 | - $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
|
529 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
530 | - } |
|
531 | - $inner_where .= " REG_date >= '$sql_date'"; |
|
532 | - $inner_date_query .= $inner_where; |
|
533 | - //build main query |
|
534 | - $select = "SELECT Event.post_title as Registration_Event, "; |
|
535 | - $join = ''; |
|
536 | - $join_parts = array(); |
|
537 | - $select_parts = array(); |
|
538 | - //loop through registration stati to do parts for each status. |
|
539 | - foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
540 | - if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
541 | - continue; |
|
542 | - } |
|
543 | - $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
|
544 | - $join_parts[] = "$registration_table AS $STS_code ON $STS_code.EVT_ID = dates.EVT_ID AND $STS_code.STS_ID = '$STS_ID' AND $STS_code.REG_date = dates.REG_date"; |
|
545 | - } |
|
546 | - //setup the selects |
|
547 | - $select .= implode(', ', $select_parts); |
|
548 | - $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
|
549 | - //setup remaining joins |
|
550 | - $join .= implode(" LEFT JOIN ", $join_parts); |
|
551 | - //now put it all together |
|
552 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
553 | - //and execute |
|
554 | - $results = $wpdb->get_results($query, ARRAY_A); |
|
555 | - return $results; |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * Returns the EE_Registration of the primary attendee on the transaction id provided |
|
562 | - * |
|
563 | - * @param int $TXN_ID |
|
564 | - * @return EE_Registration |
|
565 | - */ |
|
566 | - public function get_primary_registration_for_transaction_ID($TXN_ID = 0) |
|
567 | - { |
|
568 | - if ( ! $TXN_ID) { |
|
569 | - return false; |
|
570 | - } |
|
571 | - return $this->get_one(array( |
|
572 | - array( |
|
573 | - 'TXN_ID' => $TXN_ID, |
|
574 | - 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT, |
|
575 | - ), |
|
576 | - )); |
|
577 | - } |
|
578 | - |
|
579 | - |
|
580 | - |
|
581 | - /** |
|
582 | - * get_event_registration_count |
|
583 | - * |
|
584 | - * @access public |
|
585 | - * @param int $EVT_ID |
|
586 | - * @param boolean $for_incomplete_payments |
|
587 | - * @return int |
|
588 | - */ |
|
589 | - public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false) |
|
590 | - { |
|
591 | - // we only count approved registrations towards registration limits |
|
592 | - $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
593 | - if ($for_incomplete_payments) { |
|
594 | - $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
595 | - } |
|
596 | - return $this->count($query_params); |
|
597 | - } |
|
598 | - |
|
599 | - |
|
600 | - |
|
601 | - /** |
|
602 | - * Deletes all registrations with no transactions. Note that this needs to be very efficient |
|
603 | - * and so it uses wpdb directly |
|
604 | - * |
|
605 | - * @global WPDB $wpdb |
|
606 | - * @return int number deleted |
|
607 | - */ |
|
608 | - public function delete_registrations_with_no_transaction() |
|
609 | - { |
|
610 | - /** @type WPDB $wpdb */ |
|
611 | - global $wpdb; |
|
612 | - return $wpdb->query('DELETE r FROM ' |
|
613 | - . $this->table() |
|
614 | - . ' r LEFT JOIN ' |
|
615 | - . EEM_Transaction::instance()->table() |
|
616 | - . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL'); |
|
617 | - } |
|
618 | - |
|
619 | - |
|
620 | - |
|
621 | - /** |
|
622 | - * Count registrations checked into (or out of) a datetime |
|
623 | - * |
|
624 | - * @param int $DTT_ID datetime ID |
|
625 | - * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
626 | - * @return int |
|
627 | - */ |
|
628 | - public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) |
|
629 | - { |
|
630 | - global $wpdb; |
|
631 | - //subquery to get latest checkin |
|
632 | - $query = $wpdb->prepare('SELECT ' |
|
633 | - . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
634 | - . 'FROM ' |
|
635 | - . EEM_Checkin::instance() |
|
636 | - ->table() |
|
637 | - . ' AS checkins INNER JOIN' |
|
638 | - . '( SELECT ' |
|
639 | - . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
640 | - . 'REG_ID AS REG_ID ' |
|
641 | - . 'FROM ' |
|
642 | - . EEM_Checkin::instance()->table() |
|
643 | - . ' ' |
|
644 | - . 'WHERE DTT_ID=%d ' |
|
645 | - . 'GROUP BY REG_ID' |
|
646 | - . ') AS most_recent_checkin_per_reg ' |
|
647 | - . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
648 | - . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
649 | - . 'WHERE ' |
|
650 | - . 'checkins.CHK_in=%d', $DTT_ID, $checked_in); |
|
651 | - return (int)$wpdb->get_var($query); |
|
652 | - } |
|
653 | - |
|
654 | - |
|
655 | - |
|
656 | - /** |
|
657 | - * Count registrations checked into (or out of) an event. |
|
658 | - * |
|
659 | - * @param int $EVT_ID event ID |
|
660 | - * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
661 | - * @return int |
|
662 | - */ |
|
663 | - public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) |
|
664 | - { |
|
665 | - global $wpdb; |
|
666 | - //subquery to get latest checkin |
|
667 | - $query = $wpdb->prepare('SELECT ' |
|
668 | - . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
669 | - . 'FROM ' |
|
670 | - . EEM_Checkin::instance() |
|
671 | - ->table() |
|
672 | - . ' AS checkins INNER JOIN' |
|
673 | - . '( SELECT ' |
|
674 | - . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
675 | - . 'REG_ID AS REG_ID ' |
|
676 | - . 'FROM ' |
|
677 | - . EEM_Checkin::instance()->table() |
|
678 | - . ' AS c ' |
|
679 | - . 'INNER JOIN ' |
|
680 | - . EEM_Datetime::instance()->table() |
|
681 | - . ' AS d ' |
|
682 | - . 'ON c.DTT_ID=d.DTT_ID ' |
|
683 | - . 'WHERE d.EVT_ID=%d ' |
|
684 | - . 'GROUP BY REG_ID' |
|
685 | - . ') AS most_recent_checkin_per_reg ' |
|
686 | - . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
687 | - . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
688 | - . 'WHERE ' |
|
689 | - . 'checkins.CHK_in=%d', $EVT_ID, $checked_in); |
|
690 | - return (int)$wpdb->get_var($query); |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - |
|
695 | - /** |
|
696 | - * The purpose of this method is to retrieve an array of |
|
697 | - * EE_Registration objects that represent the latest registration |
|
698 | - * for each ATT_ID given in the function argument. |
|
699 | - * |
|
700 | - * @param array $attendee_ids |
|
701 | - * @return EE_Registration[] |
|
702 | - */ |
|
703 | - public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) |
|
704 | - { |
|
705 | - //first do a native wp_query to get the latest REG_ID's matching these attendees. |
|
706 | - global $wpdb; |
|
707 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
708 | - $attendee_table = $wpdb->posts; |
|
709 | - $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids); |
|
710 | - $attendee_ids = implode(',', $attendee_ids); |
|
711 | - //first we do a query to get the registration ids |
|
712 | - // (because a group by before order by causes the order by to be ignored.) |
|
713 | - $registration_id_query = " |
|
21 | + // private instance of the Registration object |
|
22 | + protected static $_instance = null; |
|
23 | + |
|
24 | + /** |
|
25 | + * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values |
|
26 | + * are status codes (eg, approved, cancelled, etc) |
|
27 | + * |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + private static $_reg_status; |
|
31 | + |
|
32 | + /** |
|
33 | + * The value of REG_count for a primary registrant |
|
34 | + */ |
|
35 | + const PRIMARY_REGISTRANT_COUNT = 1; |
|
36 | + |
|
37 | + /** |
|
38 | + * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration. |
|
39 | + * Initial status for registrations when they are first created |
|
40 | + * Payments are NOT allowed. |
|
41 | + * Automatically toggled to whatever the default Event registration status is upon completion of the attendee |
|
42 | + * information reg step NO space reserved. Registration is NOT active |
|
43 | + */ |
|
44 | + const status_id_incomplete = 'RIC'; |
|
45 | + |
|
46 | + /** |
|
47 | + * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration. |
|
48 | + * Payments are NOT allowed. |
|
49 | + * Event Admin must manually toggle STS_ID for it to change |
|
50 | + * No space reserved. |
|
51 | + * Registration is active |
|
52 | + */ |
|
53 | + const status_id_not_approved = 'RNA'; |
|
54 | + |
|
55 | + /** |
|
56 | + * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT . |
|
57 | + * Payments are allowed. |
|
58 | + * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
59 | + * No space reserved. |
|
60 | + * Registration is active |
|
61 | + */ |
|
62 | + const status_id_pending_payment = 'RPP'; |
|
63 | + |
|
64 | + /** |
|
65 | + * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST . |
|
66 | + * Payments are allowed. |
|
67 | + * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
68 | + * No space reserved. |
|
69 | + * Registration is active |
|
70 | + */ |
|
71 | + const status_id_wait_list = 'RWL'; |
|
72 | + |
|
73 | + /** |
|
74 | + * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration. |
|
75 | + * the TXN may or may not be completed ( paid in full ) |
|
76 | + * Payments are allowed. |
|
77 | + * A space IS reserved. |
|
78 | + * Registration is active |
|
79 | + */ |
|
80 | + const status_id_approved = 'RAP'; |
|
81 | + |
|
82 | + /** |
|
83 | + * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee. |
|
84 | + * Payments are NOT allowed. |
|
85 | + * NO space reserved. |
|
86 | + * Registration is NOT active |
|
87 | + */ |
|
88 | + const status_id_cancelled = 'RCN'; |
|
89 | + |
|
90 | + /** |
|
91 | + * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin |
|
92 | + * Payments are NOT allowed. |
|
93 | + * No space reserved. |
|
94 | + * Registration is NOT active |
|
95 | + */ |
|
96 | + const status_id_declined = 'RDC'; |
|
97 | + |
|
98 | + /** |
|
99 | + * @var TableAnalysis $table_analysis |
|
100 | + */ |
|
101 | + protected $_table_analysis; |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * private constructor to prevent direct creation |
|
107 | + * |
|
108 | + * @Constructor |
|
109 | + * @access protected |
|
110 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
111 | + * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
112 | + * date time model field objects. Default is NULL (and will be assumed using the set |
|
113 | + * timezone in the 'timezone_string' wp option) |
|
114 | + */ |
|
115 | + protected function __construct($timezone = null) |
|
116 | + { |
|
117 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
118 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
119 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
120 | + $this->_tables = array( |
|
121 | + 'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'), |
|
122 | + ); |
|
123 | + $this->_fields = array( |
|
124 | + 'Registration' => array( |
|
125 | + 'REG_ID' => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
126 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, |
|
127 | + 'Event'), |
|
128 | + 'ATT_ID' => new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, |
|
129 | + 0, 'Attendee'), |
|
130 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), |
|
131 | + false, 0, 'Transaction'), |
|
132 | + 'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, |
|
133 | + 0, 'Ticket'), |
|
134 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
135 | + false, EEM_Registration::status_id_incomplete, 'Status'), |
|
136 | + 'REG_date' => new EE_Datetime_Field('REG_date', |
|
137 | + __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
138 | + 'REG_final_price' => new EE_Money_Field('REG_final_price', |
|
139 | + __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
140 | + 'REG_paid' => new EE_Money_Field('REG_paid', |
|
141 | + __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
142 | + 'REG_session' => new EE_Plain_Text_Field('REG_session', |
|
143 | + __('Session ID of registration', 'event_espresso'), false, ''), |
|
144 | + 'REG_code' => new EE_Plain_Text_Field('REG_code', |
|
145 | + __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
146 | + 'REG_url_link' => new EE_Plain_Text_Field('REG_url_link', |
|
147 | + __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
148 | + 'REG_count' => new EE_Integer_Field('REG_count', |
|
149 | + __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
150 | + 'REG_group_size' => new EE_Integer_Field('REG_group_size', |
|
151 | + __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
152 | + 'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going', |
|
153 | + __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
154 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', |
|
155 | + __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false), |
|
156 | + ), |
|
157 | + ); |
|
158 | + $this->_model_relations = array( |
|
159 | + 'Event' => new EE_Belongs_To_Relation(), |
|
160 | + 'Attendee' => new EE_Belongs_To_Relation(), |
|
161 | + 'Transaction' => new EE_Belongs_To_Relation(), |
|
162 | + 'Ticket' => new EE_Belongs_To_Relation(), |
|
163 | + 'Status' => new EE_Belongs_To_Relation(), |
|
164 | + 'Answer' => new EE_Has_Many_Relation(), |
|
165 | + 'Checkin' => new EE_Has_Many_Relation(), |
|
166 | + 'Registration_Payment' => new EE_Has_Many_Relation(), |
|
167 | + 'Payment' => new EE_HABTM_Relation('Registration_Payment'), |
|
168 | + 'Message' => new EE_Has_Many_Any_Relation(false) |
|
169 | + //allow deletes even if there are messages in the queue related |
|
170 | + ); |
|
171 | + $this->_model_chain_to_wp_user = 'Event'; |
|
172 | + parent::__construct($timezone); |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * reg_statuses_that_allow_payment |
|
179 | + * a filterable list of registration statuses that allow a registrant to make a payment |
|
180 | + * |
|
181 | + * @access public |
|
182 | + * @return array |
|
183 | + */ |
|
184 | + public static function reg_statuses_that_allow_payment() |
|
185 | + { |
|
186 | + return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
187 | + EEM_Registration::status_id_approved, |
|
188 | + EEM_Registration::status_id_pending_payment, |
|
189 | + EEM_Registration::status_id_wait_list, |
|
190 | + )); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * inactive_reg_statuses |
|
197 | + * a filterable list of registration statuses that are considered active |
|
198 | + * |
|
199 | + * @access public |
|
200 | + * @return array |
|
201 | + */ |
|
202 | + public static function active_reg_statuses() |
|
203 | + { |
|
204 | + return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
205 | + EEM_Registration::status_id_approved, |
|
206 | + EEM_Registration::status_id_pending_payment, |
|
207 | + EEM_Registration::status_id_wait_list, |
|
208 | + EEM_Registration::status_id_not_approved, |
|
209 | + )); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * inactive_reg_statuses |
|
216 | + * a filterable list of registration statuses that are not considered active |
|
217 | + * |
|
218 | + * @access public |
|
219 | + * @return array |
|
220 | + */ |
|
221 | + public static function inactive_reg_statuses() |
|
222 | + { |
|
223 | + return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
224 | + EEM_Registration::status_id_incomplete, |
|
225 | + EEM_Registration::status_id_cancelled, |
|
226 | + EEM_Registration::status_id_declined, |
|
227 | + )); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * closed_reg_statuses |
|
234 | + * a filterable list of registration statuses that are considered "closed" |
|
235 | + * meaning they should not be considered in any calculations involving monies owing |
|
236 | + * |
|
237 | + * @access public |
|
238 | + * @return array |
|
239 | + */ |
|
240 | + public static function closed_reg_statuses() |
|
241 | + { |
|
242 | + return apply_filters('FHEE__EEM_Registration__closed_reg_statuses', array( |
|
243 | + EEM_Registration::status_id_cancelled, |
|
244 | + EEM_Registration::status_id_declined, |
|
245 | + )); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * get list of registration statuses |
|
252 | + * |
|
253 | + * @access public |
|
254 | + * @param array $exclude The status ids to exclude from the returned results |
|
255 | + * @param bool $translated If true will return the values as singular localized strings |
|
256 | + * @return array |
|
257 | + */ |
|
258 | + public static function reg_status_array($exclude = array(), $translated = false) |
|
259 | + { |
|
260 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
261 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence') |
|
262 | + : self::$_reg_status; |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * get list of registration statuses |
|
269 | + * |
|
270 | + * @access private |
|
271 | + * @param array $exclude |
|
272 | + * @return array |
|
273 | + */ |
|
274 | + private function _get_registration_status_array($exclude = array()) |
|
275 | + { |
|
276 | + //in the very rare circumstance that we are deleting a model's table's data |
|
277 | + //and the table hasn't actually been created, this could have an error |
|
278 | + /** @type WPDB $wpdb */ |
|
279 | + global $wpdb; |
|
280 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
281 | + $SQL = 'SELECT STS_ID, STS_code FROM ' . $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
282 | + $results = $wpdb->get_results($SQL); |
|
283 | + self::$_reg_status = array(); |
|
284 | + foreach ($results as $status) { |
|
285 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
286 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
287 | + } |
|
288 | + } |
|
289 | + } |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * Gets the injected table analyzer, or throws an exception |
|
296 | + * |
|
297 | + * @return TableAnalysis |
|
298 | + * @throws \EE_Error |
|
299 | + */ |
|
300 | + protected function _get_table_analysis() |
|
301 | + { |
|
302 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
303 | + return $this->_table_analysis; |
|
304 | + } else { |
|
305 | + throw new \EE_Error(sprintf(__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
306 | + get_class($this))); |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * This returns a wpdb->results array of all registration date month and years matching the incoming query params |
|
314 | + * and grouped by month and year. |
|
315 | + * |
|
316 | + * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
|
317 | + * @return array |
|
318 | + * @throws \EE_Error |
|
319 | + */ |
|
320 | + public function get_reg_months_and_years($where_params) |
|
321 | + { |
|
322 | + $query_params[0] = $where_params; |
|
323 | + $query_params['group_by'] = array('reg_year', 'reg_month'); |
|
324 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
325 | + $columns_to_select = array( |
|
326 | + 'reg_year' => array('YEAR(REG_date)', '%s'), |
|
327 | + 'reg_month' => array('MONTHNAME(REG_date)', '%s'), |
|
328 | + ); |
|
329 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
330 | + } |
|
331 | + |
|
332 | + |
|
333 | + |
|
334 | + /** |
|
335 | + * retrieve ALL registrations for a particular Attendee from db |
|
336 | + * |
|
337 | + * @access public |
|
338 | + * @param int $ATT_ID |
|
339 | + * @return EE_Registration[] |
|
340 | + */ |
|
341 | + public function get_all_registrations_for_attendee($ATT_ID = 0) |
|
342 | + { |
|
343 | + if ( ! $ATT_ID) { |
|
344 | + return false; |
|
345 | + } |
|
346 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * Gets a registration given their REG_url_link. Yes, this should usually |
|
353 | + * be passed via a GET parameter. |
|
354 | + * |
|
355 | + * @param string $REG_url_link |
|
356 | + * @return EE_Registration |
|
357 | + */ |
|
358 | + public function get_registration_for_reg_url_link($REG_url_link) |
|
359 | + { |
|
360 | + if ( ! $REG_url_link) { |
|
361 | + return false; |
|
362 | + } |
|
363 | + return $this->get_one(array(array('REG_url_link' => $REG_url_link))); |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * retrieve registration for a specific transaction attendee from db |
|
370 | + * |
|
371 | + * @access public |
|
372 | + * @param int $TXN_ID |
|
373 | + * @param int $ATT_ID |
|
374 | + * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the |
|
375 | + * attendee number is required |
|
376 | + * @return mixed array on success, FALSE on fail |
|
377 | + */ |
|
378 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) |
|
379 | + { |
|
380 | + return $this->get_one(array( |
|
381 | + array( |
|
382 | + 'TXN_ID' => $TXN_ID, |
|
383 | + 'ATT_ID' => $ATT_ID, |
|
384 | + ), |
|
385 | + 'limit' => array(min(($att_nmbr - 1), 0), 1), |
|
386 | + )); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * get the number of registrations per day for the Registration Admin page Reports Tab. |
|
393 | + * (doesn't utilize models because it's a fairly specialized query) |
|
394 | + * |
|
395 | + * @access public |
|
396 | + * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
397 | + * @return stdClass[] with properties regDate and total |
|
398 | + */ |
|
399 | + public function get_registrations_per_day_report($period = '-1 month') |
|
400 | + { |
|
401 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
402 | + 'Y-m-d H:i:s', 'UTC'); |
|
403 | + $where = array( |
|
404 | + 'REG_date' => array('>=', $sql_date), |
|
405 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
406 | + ); |
|
407 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
408 | + $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
409 | + } |
|
410 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
411 | + $results = $this->_get_all_wpdb_results(array( |
|
412 | + $where, |
|
413 | + 'group_by' => 'regDate', |
|
414 | + 'order_by' => array('REG_date' => 'ASC'), |
|
415 | + ), OBJECT, array( |
|
416 | + 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
417 | + 'total' => array('count(REG_ID)', '%d'), |
|
418 | + )); |
|
419 | + return $results; |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + |
|
424 | + /** |
|
425 | + * Get the number of registrations per day including the count of registrations for each Registration Status. |
|
426 | + * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
427 | + * |
|
428 | + * @param string $period |
|
429 | + * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
|
430 | + * (i.e. RAP) |
|
431 | + */ |
|
432 | + public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
|
433 | + { |
|
434 | + global $wpdb; |
|
435 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
436 | + $event_table = $wpdb->posts; |
|
437 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
438 | + //prepare the query interval for displaying offset |
|
439 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
440 | + //inner date query |
|
441 | + $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
|
442 | + $inner_where = " WHERE"; |
|
443 | + //exclude events not authored by user if permissions in effect |
|
444 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
445 | + $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
|
446 | + $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
447 | + } |
|
448 | + $inner_where .= " REG_date >= '$sql_date'"; |
|
449 | + $inner_date_query .= $inner_where; |
|
450 | + //start main query |
|
451 | + $select = "SELECT DATE($query_interval) as Registration_REG_date, "; |
|
452 | + $join = ''; |
|
453 | + $join_parts = array(); |
|
454 | + $select_parts = array(); |
|
455 | + //loop through registration stati to do parts for each status. |
|
456 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
457 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
458 | + continue; |
|
459 | + } |
|
460 | + $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
|
461 | + $join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'"; |
|
462 | + } |
|
463 | + //setup the selects |
|
464 | + $select .= implode(', ', $select_parts); |
|
465 | + $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
|
466 | + //setup the joins |
|
467 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
468 | + //now let's put it all together |
|
469 | + $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
470 | + //and execute it |
|
471 | + $results = $wpdb->get_results($query, ARRAY_A); |
|
472 | + return $results; |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + |
|
477 | + /** |
|
478 | + * get the number of registrations per event for the Registration Admin page Reports Tab |
|
479 | + * |
|
480 | + * @access public |
|
481 | + * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
482 | + * @return stdClass[] each with properties event_name, reg_limit, and total |
|
483 | + */ |
|
484 | + public function get_registrations_per_event_report($period = '-1 month') |
|
485 | + { |
|
486 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
487 | + 'Y-m-d H:i:s', 'UTC'); |
|
488 | + $where = array( |
|
489 | + 'REG_date' => array('>=', $date_sql), |
|
490 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
491 | + ); |
|
492 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
493 | + $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
494 | + } |
|
495 | + $results = $this->_get_all_wpdb_results(array( |
|
496 | + $where, |
|
497 | + 'group_by' => 'Event.EVT_name', |
|
498 | + 'order_by' => 'Event.EVT_name', |
|
499 | + 'limit' => array(0, 24), |
|
500 | + ), OBJECT, array( |
|
501 | + 'event_name' => array('Event_CPT.post_title', '%s'), |
|
502 | + 'total' => array('COUNT(REG_ID)', '%s'), |
|
503 | + )); |
|
504 | + return $results; |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * Get the number of registrations per event grouped by registration status. |
|
511 | + * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
512 | + * |
|
513 | + * @param string $period |
|
514 | + * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
|
515 | + * (i.e. RAP) |
|
516 | + */ |
|
517 | + public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
|
518 | + { |
|
519 | + global $wpdb; |
|
520 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
521 | + $event_table = $wpdb->posts; |
|
522 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
523 | + //inner date query |
|
524 | + $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
|
525 | + $inner_where = " WHERE"; |
|
526 | + //exclude events not authored by user if permissions in effect |
|
527 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
528 | + $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
|
529 | + $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
530 | + } |
|
531 | + $inner_where .= " REG_date >= '$sql_date'"; |
|
532 | + $inner_date_query .= $inner_where; |
|
533 | + //build main query |
|
534 | + $select = "SELECT Event.post_title as Registration_Event, "; |
|
535 | + $join = ''; |
|
536 | + $join_parts = array(); |
|
537 | + $select_parts = array(); |
|
538 | + //loop through registration stati to do parts for each status. |
|
539 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
540 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
541 | + continue; |
|
542 | + } |
|
543 | + $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
|
544 | + $join_parts[] = "$registration_table AS $STS_code ON $STS_code.EVT_ID = dates.EVT_ID AND $STS_code.STS_ID = '$STS_ID' AND $STS_code.REG_date = dates.REG_date"; |
|
545 | + } |
|
546 | + //setup the selects |
|
547 | + $select .= implode(', ', $select_parts); |
|
548 | + $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
|
549 | + //setup remaining joins |
|
550 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
551 | + //now put it all together |
|
552 | + $query = $select . $join . ' GROUP BY Registration_Event'; |
|
553 | + //and execute |
|
554 | + $results = $wpdb->get_results($query, ARRAY_A); |
|
555 | + return $results; |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * Returns the EE_Registration of the primary attendee on the transaction id provided |
|
562 | + * |
|
563 | + * @param int $TXN_ID |
|
564 | + * @return EE_Registration |
|
565 | + */ |
|
566 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) |
|
567 | + { |
|
568 | + if ( ! $TXN_ID) { |
|
569 | + return false; |
|
570 | + } |
|
571 | + return $this->get_one(array( |
|
572 | + array( |
|
573 | + 'TXN_ID' => $TXN_ID, |
|
574 | + 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT, |
|
575 | + ), |
|
576 | + )); |
|
577 | + } |
|
578 | + |
|
579 | + |
|
580 | + |
|
581 | + /** |
|
582 | + * get_event_registration_count |
|
583 | + * |
|
584 | + * @access public |
|
585 | + * @param int $EVT_ID |
|
586 | + * @param boolean $for_incomplete_payments |
|
587 | + * @return int |
|
588 | + */ |
|
589 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false) |
|
590 | + { |
|
591 | + // we only count approved registrations towards registration limits |
|
592 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
593 | + if ($for_incomplete_payments) { |
|
594 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
595 | + } |
|
596 | + return $this->count($query_params); |
|
597 | + } |
|
598 | + |
|
599 | + |
|
600 | + |
|
601 | + /** |
|
602 | + * Deletes all registrations with no transactions. Note that this needs to be very efficient |
|
603 | + * and so it uses wpdb directly |
|
604 | + * |
|
605 | + * @global WPDB $wpdb |
|
606 | + * @return int number deleted |
|
607 | + */ |
|
608 | + public function delete_registrations_with_no_transaction() |
|
609 | + { |
|
610 | + /** @type WPDB $wpdb */ |
|
611 | + global $wpdb; |
|
612 | + return $wpdb->query('DELETE r FROM ' |
|
613 | + . $this->table() |
|
614 | + . ' r LEFT JOIN ' |
|
615 | + . EEM_Transaction::instance()->table() |
|
616 | + . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL'); |
|
617 | + } |
|
618 | + |
|
619 | + |
|
620 | + |
|
621 | + /** |
|
622 | + * Count registrations checked into (or out of) a datetime |
|
623 | + * |
|
624 | + * @param int $DTT_ID datetime ID |
|
625 | + * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
626 | + * @return int |
|
627 | + */ |
|
628 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) |
|
629 | + { |
|
630 | + global $wpdb; |
|
631 | + //subquery to get latest checkin |
|
632 | + $query = $wpdb->prepare('SELECT ' |
|
633 | + . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
634 | + . 'FROM ' |
|
635 | + . EEM_Checkin::instance() |
|
636 | + ->table() |
|
637 | + . ' AS checkins INNER JOIN' |
|
638 | + . '( SELECT ' |
|
639 | + . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
640 | + . 'REG_ID AS REG_ID ' |
|
641 | + . 'FROM ' |
|
642 | + . EEM_Checkin::instance()->table() |
|
643 | + . ' ' |
|
644 | + . 'WHERE DTT_ID=%d ' |
|
645 | + . 'GROUP BY REG_ID' |
|
646 | + . ') AS most_recent_checkin_per_reg ' |
|
647 | + . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
648 | + . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
649 | + . 'WHERE ' |
|
650 | + . 'checkins.CHK_in=%d', $DTT_ID, $checked_in); |
|
651 | + return (int)$wpdb->get_var($query); |
|
652 | + } |
|
653 | + |
|
654 | + |
|
655 | + |
|
656 | + /** |
|
657 | + * Count registrations checked into (or out of) an event. |
|
658 | + * |
|
659 | + * @param int $EVT_ID event ID |
|
660 | + * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
661 | + * @return int |
|
662 | + */ |
|
663 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) |
|
664 | + { |
|
665 | + global $wpdb; |
|
666 | + //subquery to get latest checkin |
|
667 | + $query = $wpdb->prepare('SELECT ' |
|
668 | + . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
669 | + . 'FROM ' |
|
670 | + . EEM_Checkin::instance() |
|
671 | + ->table() |
|
672 | + . ' AS checkins INNER JOIN' |
|
673 | + . '( SELECT ' |
|
674 | + . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
675 | + . 'REG_ID AS REG_ID ' |
|
676 | + . 'FROM ' |
|
677 | + . EEM_Checkin::instance()->table() |
|
678 | + . ' AS c ' |
|
679 | + . 'INNER JOIN ' |
|
680 | + . EEM_Datetime::instance()->table() |
|
681 | + . ' AS d ' |
|
682 | + . 'ON c.DTT_ID=d.DTT_ID ' |
|
683 | + . 'WHERE d.EVT_ID=%d ' |
|
684 | + . 'GROUP BY REG_ID' |
|
685 | + . ') AS most_recent_checkin_per_reg ' |
|
686 | + . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
687 | + . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
688 | + . 'WHERE ' |
|
689 | + . 'checkins.CHK_in=%d', $EVT_ID, $checked_in); |
|
690 | + return (int)$wpdb->get_var($query); |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + |
|
695 | + /** |
|
696 | + * The purpose of this method is to retrieve an array of |
|
697 | + * EE_Registration objects that represent the latest registration |
|
698 | + * for each ATT_ID given in the function argument. |
|
699 | + * |
|
700 | + * @param array $attendee_ids |
|
701 | + * @return EE_Registration[] |
|
702 | + */ |
|
703 | + public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) |
|
704 | + { |
|
705 | + //first do a native wp_query to get the latest REG_ID's matching these attendees. |
|
706 | + global $wpdb; |
|
707 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
708 | + $attendee_table = $wpdb->posts; |
|
709 | + $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids); |
|
710 | + $attendee_ids = implode(',', $attendee_ids); |
|
711 | + //first we do a query to get the registration ids |
|
712 | + // (because a group by before order by causes the order by to be ignored.) |
|
713 | + $registration_id_query = " |
|
714 | 714 | SELECT registrations.registration_ids as registration_id |
715 | 715 | FROM ( |
716 | 716 | SELECT |
@@ -724,23 +724,23 @@ discard block |
||
724 | 724 | ) AS registrations |
725 | 725 | GROUP BY registrations.attendee_ids |
726 | 726 | "; |
727 | - $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A); |
|
728 | - if (empty($registration_ids)) { |
|
729 | - return array(); |
|
730 | - } |
|
731 | - $ids_for_model_query = array(); |
|
732 | - //let's flatten the ids so they can be used in the model query. |
|
733 | - foreach ($registration_ids as $registration_id) { |
|
734 | - if (isset($registration_id['registration_id'])) { |
|
735 | - $ids_for_model_query[] = $registration_id['registration_id']; |
|
736 | - } |
|
737 | - } |
|
738 | - //construct query |
|
739 | - $_where = array( |
|
740 | - 'REG_ID' => array('IN', $ids_for_model_query), |
|
741 | - ); |
|
742 | - return $this->get_all(array($_where)); |
|
743 | - } |
|
727 | + $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A); |
|
728 | + if (empty($registration_ids)) { |
|
729 | + return array(); |
|
730 | + } |
|
731 | + $ids_for_model_query = array(); |
|
732 | + //let's flatten the ids so they can be used in the model query. |
|
733 | + foreach ($registration_ids as $registration_id) { |
|
734 | + if (isset($registration_id['registration_id'])) { |
|
735 | + $ids_for_model_query[] = $registration_id['registration_id']; |
|
736 | + } |
|
737 | + } |
|
738 | + //construct query |
|
739 | + $_where = array( |
|
740 | + 'REG_ID' => array('IN', $ids_for_model_query), |
|
741 | + ); |
|
742 | + return $this->get_all(array($_where)); |
|
743 | + } |
|
744 | 744 | |
745 | 745 | |
746 | 746 |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | //and the table hasn't actually been created, this could have an error |
278 | 278 | /** @type WPDB $wpdb */ |
279 | 279 | global $wpdb; |
280 | - if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
281 | - $SQL = 'SELECT STS_ID, STS_code FROM ' . $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
280 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) { |
|
281 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
282 | 282 | $results = $wpdb->get_results($SQL); |
283 | 283 | self::$_reg_status = array(); |
284 | 284 | foreach ($results as $status) { |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | 'group_by' => 'regDate', |
414 | 414 | 'order_by' => array('REG_date' => 'ASC'), |
415 | 415 | ), OBJECT, array( |
416 | - 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
416 | + 'regDate' => array('DATE('.$query_interval.')', '%s'), |
|
417 | 417 | 'total' => array('count(REG_ID)', '%d'), |
418 | 418 | )); |
419 | 419 | return $results; |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
433 | 433 | { |
434 | 434 | global $wpdb; |
435 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
435 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
436 | 436 | $event_table = $wpdb->posts; |
437 | 437 | $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
438 | 438 | //prepare the query interval for displaying offset |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | //exclude events not authored by user if permissions in effect |
444 | 444 | if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
445 | 445 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
446 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
446 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
447 | 447 | } |
448 | 448 | $inner_where .= " REG_date >= '$sql_date'"; |
449 | 449 | $inner_date_query .= $inner_where; |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | //setup the joins |
467 | 467 | $join .= implode(" LEFT JOIN ", $join_parts); |
468 | 468 | //now let's put it all together |
469 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
469 | + $query = $select.$join.' GROUP BY Registration_REG_date'; |
|
470 | 470 | //and execute it |
471 | 471 | $results = $wpdb->get_results($query, ARRAY_A); |
472 | 472 | return $results; |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
518 | 518 | { |
519 | 519 | global $wpdb; |
520 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
520 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
521 | 521 | $event_table = $wpdb->posts; |
522 | 522 | $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
523 | 523 | //inner date query |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | //exclude events not authored by user if permissions in effect |
527 | 527 | if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
528 | 528 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
529 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
529 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
530 | 530 | } |
531 | 531 | $inner_where .= " REG_date >= '$sql_date'"; |
532 | 532 | $inner_date_query .= $inner_where; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | //setup remaining joins |
550 | 550 | $join .= implode(" LEFT JOIN ", $join_parts); |
551 | 551 | //now put it all together |
552 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
552 | + $query = $select.$join.' GROUP BY Registration_Event'; |
|
553 | 553 | //and execute |
554 | 554 | $results = $wpdb->get_results($query, ARRAY_A); |
555 | 555 | return $results; |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
649 | 649 | . 'WHERE ' |
650 | 650 | . 'checkins.CHK_in=%d', $DTT_ID, $checked_in); |
651 | - return (int)$wpdb->get_var($query); |
|
651 | + return (int) $wpdb->get_var($query); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
688 | 688 | . 'WHERE ' |
689 | 689 | . 'checkins.CHK_in=%d', $EVT_ID, $checked_in); |
690 | - return (int)$wpdb->get_var($query); |
|
690 | + return (int) $wpdb->get_var($query); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | |
@@ -704,9 +704,9 @@ discard block |
||
704 | 704 | { |
705 | 705 | //first do a native wp_query to get the latest REG_ID's matching these attendees. |
706 | 706 | global $wpdb; |
707 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
707 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
708 | 708 | $attendee_table = $wpdb->posts; |
709 | - $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids); |
|
709 | + $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int) $attendee_ids); |
|
710 | 710 | $attendee_ids = implode(',', $attendee_ids); |
711 | 711 | //first we do a query to get the registration ids |
712 | 712 | // (because a group by before order by causes the order by to be ignored.) |
@@ -418,7 +418,7 @@ |
||
418 | 418 | * In this case, we delete the temporary file |
419 | 419 | * |
420 | 420 | * @param JobParameters $job_parameters |
421 | - * @return boolean |
|
421 | + * @return JobStepResponse |
|
422 | 422 | */ |
423 | 423 | public function cleanup_job(JobParameters $job_parameters) |
424 | 424 | { |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
18 | 18 | |
19 | 19 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
20 | - exit('No direct script access allowed'); |
|
20 | + exit('No direct script access allowed'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -25,408 +25,408 @@ discard block |
||
25 | 25 | class RegistrationsReport extends JobHandlerFile |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Performs any necessary setup for starting the job. This is also a good |
|
30 | - * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
31 | - * when continue_job will be called |
|
32 | - * |
|
33 | - * @param JobParameters $job_parameters |
|
34 | - * @throws BatchRequestException |
|
35 | - * @return JobStepResponse |
|
36 | - */ |
|
37 | - public function create_job(JobParameters $job_parameters) |
|
38 | - { |
|
39 | - $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
40 | - if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
41 | - throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso')); |
|
42 | - } |
|
43 | - $filepath = $this->create_file_from_job_with_name($job_parameters->job_id(), |
|
44 | - $this->get_filename_from_event($event_id)); |
|
45 | - $job_parameters->add_extra_data('filepath', $filepath); |
|
46 | - $question_data_for_columns = $this->_get_questions_for_report($event_id); |
|
47 | - $job_parameters->add_extra_data('questions_data', $question_data_for_columns); |
|
48 | - $job_parameters->set_job_size($this->count_units_to_process($event_id)); |
|
49 | - //we should also set the header columns |
|
50 | - $csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('questions_data')); |
|
51 | - \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
52 | - //if we actually processed a row there, record it |
|
53 | - if ($job_parameters->job_size()) { |
|
54 | - $job_parameters->mark_processed(1); |
|
55 | - } |
|
56 | - return new JobStepResponse($job_parameters, |
|
57 | - __('Registrations report started successfully...', 'event_espresso')); |
|
58 | - } |
|
28 | + /** |
|
29 | + * Performs any necessary setup for starting the job. This is also a good |
|
30 | + * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
31 | + * when continue_job will be called |
|
32 | + * |
|
33 | + * @param JobParameters $job_parameters |
|
34 | + * @throws BatchRequestException |
|
35 | + * @return JobStepResponse |
|
36 | + */ |
|
37 | + public function create_job(JobParameters $job_parameters) |
|
38 | + { |
|
39 | + $event_id = intval($job_parameters->request_datum('EVT_ID', '0')); |
|
40 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) { |
|
41 | + throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso')); |
|
42 | + } |
|
43 | + $filepath = $this->create_file_from_job_with_name($job_parameters->job_id(), |
|
44 | + $this->get_filename_from_event($event_id)); |
|
45 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
46 | + $question_data_for_columns = $this->_get_questions_for_report($event_id); |
|
47 | + $job_parameters->add_extra_data('questions_data', $question_data_for_columns); |
|
48 | + $job_parameters->set_job_size($this->count_units_to_process($event_id)); |
|
49 | + //we should also set the header columns |
|
50 | + $csv_data_for_row = $this->get_csv_data_for($event_id, 0, 1, $job_parameters->extra_datum('questions_data')); |
|
51 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
52 | + //if we actually processed a row there, record it |
|
53 | + if ($job_parameters->job_size()) { |
|
54 | + $job_parameters->mark_processed(1); |
|
55 | + } |
|
56 | + return new JobStepResponse($job_parameters, |
|
57 | + __('Registrations report started successfully...', 'event_espresso')); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * Creates teh filename form the event id (or lack thereof) |
|
64 | - * |
|
65 | - * @param int $event_id |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - protected function get_filename_from_event($event_id) |
|
69 | - { |
|
70 | - if ($event_id) { |
|
71 | - $event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
72 | - if ( ! $event_slug) { |
|
73 | - $event_slug = __('unknown', 'event_espresso'); |
|
74 | - } |
|
75 | - } else { |
|
76 | - $event_slug = __('all', 'event_espresso'); |
|
77 | - } |
|
78 | - return sprintf("registrations-for-%s.csv", $event_slug); |
|
79 | - } |
|
62 | + /** |
|
63 | + * Creates teh filename form the event id (or lack thereof) |
|
64 | + * |
|
65 | + * @param int $event_id |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + protected function get_filename_from_event($event_id) |
|
69 | + { |
|
70 | + if ($event_id) { |
|
71 | + $event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
72 | + if ( ! $event_slug) { |
|
73 | + $event_slug = __('unknown', 'event_espresso'); |
|
74 | + } |
|
75 | + } else { |
|
76 | + $event_slug = __('all', 'event_espresso'); |
|
77 | + } |
|
78 | + return sprintf("registrations-for-%s.csv", $event_slug); |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Gets the questions which are to be used for this report, so they |
|
85 | - * can be remembered for later |
|
86 | - * |
|
87 | - * @param int|null $event_id |
|
88 | - * @return array of wpdb results for questions which are to be used for this report |
|
89 | - */ |
|
90 | - protected function _get_questions_for_report($event_id) |
|
91 | - { |
|
92 | - $question_query_params = array( |
|
93 | - array( |
|
94 | - 'Answer.ANS_ID' => array('IS_NOT_NULL'), |
|
95 | - ), |
|
96 | - 'group_by' => array('QST_ID'), |
|
97 | - ); |
|
98 | - if ($event_id) { |
|
99 | - $question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id; |
|
100 | - } |
|
101 | - return \EEM_Question::instance()->get_all_wpdb_results($question_query_params); |
|
102 | - } |
|
83 | + /** |
|
84 | + * Gets the questions which are to be used for this report, so they |
|
85 | + * can be remembered for later |
|
86 | + * |
|
87 | + * @param int|null $event_id |
|
88 | + * @return array of wpdb results for questions which are to be used for this report |
|
89 | + */ |
|
90 | + protected function _get_questions_for_report($event_id) |
|
91 | + { |
|
92 | + $question_query_params = array( |
|
93 | + array( |
|
94 | + 'Answer.ANS_ID' => array('IS_NOT_NULL'), |
|
95 | + ), |
|
96 | + 'group_by' => array('QST_ID'), |
|
97 | + ); |
|
98 | + if ($event_id) { |
|
99 | + $question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id; |
|
100 | + } |
|
101 | + return \EEM_Question::instance()->get_all_wpdb_results($question_query_params); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * Performs another step of the job |
|
108 | - * |
|
109 | - * @param JobParameters $job_parameters |
|
110 | - * @param int $batch_size |
|
111 | - * @return JobStepResponse |
|
112 | - * @throws \EE_Error |
|
113 | - */ |
|
114 | - public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
115 | - { |
|
116 | - $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'), |
|
117 | - $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('questions_data')); |
|
118 | - \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
119 | - $units_processed = count($csv_data); |
|
120 | - $job_parameters->mark_processed($units_processed); |
|
121 | - $extra_response_data = array( |
|
122 | - 'file_url' => '', |
|
123 | - ); |
|
124 | - if ($units_processed < $batch_size) { |
|
125 | - $job_parameters->set_status(JobParameters::status_complete); |
|
126 | - $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
127 | - } |
|
128 | - return new JobStepResponse($job_parameters, |
|
129 | - sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)), |
|
130 | - $extra_response_data); |
|
131 | - } |
|
106 | + /** |
|
107 | + * Performs another step of the job |
|
108 | + * |
|
109 | + * @param JobParameters $job_parameters |
|
110 | + * @param int $batch_size |
|
111 | + * @return JobStepResponse |
|
112 | + * @throws \EE_Error |
|
113 | + */ |
|
114 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50) |
|
115 | + { |
|
116 | + $csv_data = $this->get_csv_data_for($job_parameters->request_datum('EVT_ID', '0'), |
|
117 | + $job_parameters->units_processed(), $batch_size, $job_parameters->extra_datum('questions_data')); |
|
118 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
119 | + $units_processed = count($csv_data); |
|
120 | + $job_parameters->mark_processed($units_processed); |
|
121 | + $extra_response_data = array( |
|
122 | + 'file_url' => '', |
|
123 | + ); |
|
124 | + if ($units_processed < $batch_size) { |
|
125 | + $job_parameters->set_status(JobParameters::status_complete); |
|
126 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
127 | + } |
|
128 | + return new JobStepResponse($job_parameters, |
|
129 | + sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count($csv_data)), |
|
130 | + $extra_response_data); |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | 134 | |
135 | - /** |
|
136 | - * Gets the csv data for a batch of registrations |
|
137 | - * |
|
138 | - * @param int|null $event_id |
|
139 | - * @param int $offset |
|
140 | - * @param int $limit |
|
141 | - * @param array $questions_for_these_regs_rows results of $wpdb->get_results( $something, ARRAY_A) when querying |
|
142 | - * for questions |
|
143 | - * @return array top-level keys are numeric, next-level keys are column headers |
|
144 | - */ |
|
145 | - function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) |
|
146 | - { |
|
147 | - $reg_fields_to_include = array( |
|
148 | - 'TXN_ID', |
|
149 | - 'ATT_ID', |
|
150 | - 'REG_ID', |
|
151 | - 'REG_date', |
|
152 | - 'REG_code', |
|
153 | - 'REG_count', |
|
154 | - 'REG_final_price', |
|
155 | - ); |
|
156 | - $att_fields_to_include = array( |
|
157 | - 'ATT_fname', |
|
158 | - 'ATT_lname', |
|
159 | - 'ATT_email', |
|
160 | - 'ATT_address', |
|
161 | - 'ATT_address2', |
|
162 | - 'ATT_city', |
|
163 | - 'STA_ID', |
|
164 | - 'CNT_ISO', |
|
165 | - 'ATT_zip', |
|
166 | - 'ATT_phone', |
|
167 | - ); |
|
168 | - $registrations_csv_ready_array = array(); |
|
169 | - $reg_model = \EE_Registry::instance()->load_model('Registration'); |
|
170 | - $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
171 | - array( |
|
172 | - 'OR' => array( |
|
173 | - //don't include registrations from failed or abandoned transactions... |
|
174 | - 'Transaction.STS_ID' => array( |
|
175 | - 'NOT IN', |
|
176 | - array( |
|
177 | - \EEM_Transaction::failed_status_code, |
|
178 | - \EEM_Transaction::abandoned_status_code, |
|
179 | - ), |
|
180 | - ), |
|
181 | - //unless the registration is approved, in which case include it regardless of transaction status |
|
182 | - 'STS_ID' => \EEM_Registration::status_id_approved, |
|
183 | - ), |
|
184 | - 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
185 | - ), |
|
186 | - 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
187 | - 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
188 | - 'limit' => array($offset, $limit), |
|
189 | - 'caps' => \EEM_Base::caps_read_admin, |
|
190 | - ), $event_id); |
|
191 | - if ($event_id) { |
|
192 | - $query_params[0]['EVT_ID'] = $event_id; |
|
193 | - } else { |
|
194 | - $query_params['force_join'][] = 'Event'; |
|
195 | - } |
|
196 | - $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
197 | - //get all questions which relate to someone in this group |
|
198 | - $registration_ids = array(); |
|
199 | - foreach ($registration_rows as $reg_row) { |
|
200 | - $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
201 | - } |
|
202 | - foreach ($registration_rows as $reg_row) { |
|
203 | - if (is_array($reg_row)) { |
|
204 | - $reg_csv_array = array(); |
|
205 | - if ( ! $event_id) { |
|
206 | - //get the event's name and Id |
|
207 | - $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), |
|
208 | - \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', |
|
209 | - $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
210 | - } |
|
211 | - $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
212 | - /*@var $reg_row EE_Registration */ |
|
213 | - foreach ($reg_fields_to_include as $field_name) { |
|
214 | - $field = $reg_model->field_settings_for($field_name); |
|
215 | - if ($field_name == 'REG_final_price') { |
|
216 | - $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
217 | - $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
218 | - } elseif ($field_name == 'REG_count') { |
|
219 | - $value = sprintf(__('%s of %s', 'event_espresso'), |
|
220 | - \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', |
|
221 | - $reg_row['Registration.REG_count']), |
|
222 | - \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', |
|
223 | - $reg_row['Registration.REG_group_size'])); |
|
224 | - } elseif ($field_name == 'REG_date') { |
|
225 | - $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
226 | - $reg_row['Registration.REG_date'], 'no_html'); |
|
227 | - } else { |
|
228 | - $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
229 | - $reg_row[$field->get_qualified_column()]); |
|
230 | - } |
|
231 | - $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
|
232 | - if ($field_name == 'REG_final_price') { |
|
233 | - //add a column named Currency after the final price |
|
234 | - $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
|
235 | - } |
|
236 | - } |
|
237 | - //get pretty status |
|
238 | - $stati = \EEM_Status::instance()->localized_status(array( |
|
239 | - $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
240 | - $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'), |
|
241 | - ), false, 'sentence'); |
|
242 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
243 | - //get pretty transaction status |
|
244 | - $reg_csv_array[__("Transaction Status", |
|
245 | - 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
246 | - $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg |
|
247 | - ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', |
|
248 | - $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00'; |
|
249 | - $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg |
|
250 | - ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', |
|
251 | - $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00'; |
|
252 | - $payment_methods = array(); |
|
253 | - $gateway_txn_ids_etc = array(); |
|
254 | - $payment_times = array(); |
|
255 | - if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
256 | - $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array( |
|
257 | - array( |
|
258 | - 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
259 | - 'STS_ID' => \EEM_Payment::status_id_approved, |
|
260 | - ), |
|
261 | - 'force_join' => array('Payment_Method'), |
|
262 | - ), ARRAY_A, |
|
263 | - 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'); |
|
264 | - foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
265 | - $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
266 | - ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
267 | - $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
268 | - ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
269 | - $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
270 | - ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
271 | - } |
|
272 | - } |
|
273 | - $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
274 | - $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
275 | - $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
276 | - //get whether or not the user has checked in |
|
277 | - $reg_csv_array[__("Check-Ins", |
|
278 | - "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
279 | - //get ticket of registration and its price |
|
280 | - $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
|
281 | - if ($reg_row['Ticket.TKT_ID']) { |
|
282 | - $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', |
|
283 | - $reg_row['Ticket.TKT_name']); |
|
284 | - $datetimes_strings = array(); |
|
285 | - foreach ( |
|
286 | - \EEM_Datetime::instance() |
|
287 | - ->get_all_wpdb_results(array( |
|
288 | - array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), |
|
289 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
290 | - 'default_where_conditions' => 'none', |
|
291 | - )) as $datetime |
|
292 | - ) { |
|
293 | - $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), |
|
294 | - 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
295 | - } |
|
296 | - } else { |
|
297 | - $ticket_name = __('Unknown', 'event_espresso'); |
|
298 | - $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
299 | - } |
|
300 | - $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
|
301 | - $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
|
302 | - //get datetime(s) of registration |
|
303 | - //add attendee columns |
|
304 | - foreach ($att_fields_to_include as $att_field_name) { |
|
305 | - $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
306 | - if ($reg_row['Attendee_CPT.ID']) { |
|
307 | - if ($att_field_name == 'STA_ID') { |
|
308 | - $value = \EEM_State::instance() |
|
309 | - ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), |
|
310 | - 'STA_name'); |
|
311 | - } elseif ($att_field_name == 'CNT_ISO') { |
|
312 | - $value = \EEM_Country::instance() |
|
313 | - ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), |
|
314 | - 'CNT_name'); |
|
315 | - } else { |
|
316 | - $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), |
|
317 | - $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
318 | - } |
|
319 | - } else { |
|
320 | - $value = ''; |
|
321 | - } |
|
322 | - $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
323 | - } |
|
324 | - //make sure each registration has the same questions in the same order |
|
325 | - foreach ($questions_for_these_regs_rows as $question_row) { |
|
326 | - if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
327 | - $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
328 | - } |
|
329 | - } |
|
330 | - $answers = \EEM_Answer::instance()->get_all_wpdb_results(array( |
|
331 | - array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
332 | - 'force_join' => array('Question'), |
|
333 | - )); |
|
334 | - //now fill out the questions THEY answered |
|
335 | - foreach ($answers as $answer_row) { |
|
336 | - if ($answer_row['Question.QST_ID']) { |
|
337 | - $question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(), |
|
338 | - 'QST_admin_label', $answer_row['Question.QST_admin_label']); |
|
339 | - } else { |
|
340 | - $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
341 | - } |
|
342 | - if (isset($answer_row['Question.QST_type']) |
|
343 | - && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
344 | - ) { |
|
345 | - $reg_csv_array[$question_label] = \EEM_State::instance() |
|
346 | - ->get_state_name_by_ID($answer_row['Answer.ANS_value']); |
|
347 | - } else { |
|
348 | - //this isn't for html, so don't show html entities |
|
349 | - $reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(), |
|
350 | - 'ANS_value', $answer_row['Answer.ANS_value'])); |
|
351 | - } |
|
352 | - } |
|
353 | - $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', |
|
354 | - $reg_csv_array, $reg_row); |
|
355 | - } |
|
356 | - } |
|
357 | - //if we couldn't export anything, we want to at least show the column headers |
|
358 | - if (empty($registrations_csv_ready_array)) { |
|
359 | - $reg_csv_array = array(); |
|
360 | - $model_and_fields_to_include = array( |
|
361 | - 'Registration' => $reg_fields_to_include, |
|
362 | - 'Attendee' => $att_fields_to_include, |
|
363 | - ); |
|
364 | - foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
365 | - $model = \EE_Registry::instance()->load_model($model_name); |
|
366 | - foreach ($field_list as $field_name) { |
|
367 | - $field = $model->field_settings_for($field_name); |
|
368 | - $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
369 | - } |
|
370 | - } |
|
371 | - $registrations_csv_ready_array[] = $reg_csv_array; |
|
372 | - } |
|
373 | - return $registrations_csv_ready_array; |
|
374 | - } |
|
135 | + /** |
|
136 | + * Gets the csv data for a batch of registrations |
|
137 | + * |
|
138 | + * @param int|null $event_id |
|
139 | + * @param int $offset |
|
140 | + * @param int $limit |
|
141 | + * @param array $questions_for_these_regs_rows results of $wpdb->get_results( $something, ARRAY_A) when querying |
|
142 | + * for questions |
|
143 | + * @return array top-level keys are numeric, next-level keys are column headers |
|
144 | + */ |
|
145 | + function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) |
|
146 | + { |
|
147 | + $reg_fields_to_include = array( |
|
148 | + 'TXN_ID', |
|
149 | + 'ATT_ID', |
|
150 | + 'REG_ID', |
|
151 | + 'REG_date', |
|
152 | + 'REG_code', |
|
153 | + 'REG_count', |
|
154 | + 'REG_final_price', |
|
155 | + ); |
|
156 | + $att_fields_to_include = array( |
|
157 | + 'ATT_fname', |
|
158 | + 'ATT_lname', |
|
159 | + 'ATT_email', |
|
160 | + 'ATT_address', |
|
161 | + 'ATT_address2', |
|
162 | + 'ATT_city', |
|
163 | + 'STA_ID', |
|
164 | + 'CNT_ISO', |
|
165 | + 'ATT_zip', |
|
166 | + 'ATT_phone', |
|
167 | + ); |
|
168 | + $registrations_csv_ready_array = array(); |
|
169 | + $reg_model = \EE_Registry::instance()->load_model('Registration'); |
|
170 | + $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
171 | + array( |
|
172 | + 'OR' => array( |
|
173 | + //don't include registrations from failed or abandoned transactions... |
|
174 | + 'Transaction.STS_ID' => array( |
|
175 | + 'NOT IN', |
|
176 | + array( |
|
177 | + \EEM_Transaction::failed_status_code, |
|
178 | + \EEM_Transaction::abandoned_status_code, |
|
179 | + ), |
|
180 | + ), |
|
181 | + //unless the registration is approved, in which case include it regardless of transaction status |
|
182 | + 'STS_ID' => \EEM_Registration::status_id_approved, |
|
183 | + ), |
|
184 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
185 | + ), |
|
186 | + 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
187 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
188 | + 'limit' => array($offset, $limit), |
|
189 | + 'caps' => \EEM_Base::caps_read_admin, |
|
190 | + ), $event_id); |
|
191 | + if ($event_id) { |
|
192 | + $query_params[0]['EVT_ID'] = $event_id; |
|
193 | + } else { |
|
194 | + $query_params['force_join'][] = 'Event'; |
|
195 | + } |
|
196 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
197 | + //get all questions which relate to someone in this group |
|
198 | + $registration_ids = array(); |
|
199 | + foreach ($registration_rows as $reg_row) { |
|
200 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
201 | + } |
|
202 | + foreach ($registration_rows as $reg_row) { |
|
203 | + if (is_array($reg_row)) { |
|
204 | + $reg_csv_array = array(); |
|
205 | + if ( ! $event_id) { |
|
206 | + //get the event's name and Id |
|
207 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), |
|
208 | + \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', |
|
209 | + $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
210 | + } |
|
211 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
212 | + /*@var $reg_row EE_Registration */ |
|
213 | + foreach ($reg_fields_to_include as $field_name) { |
|
214 | + $field = $reg_model->field_settings_for($field_name); |
|
215 | + if ($field_name == 'REG_final_price') { |
|
216 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
217 | + $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
218 | + } elseif ($field_name == 'REG_count') { |
|
219 | + $value = sprintf(__('%s of %s', 'event_espresso'), |
|
220 | + \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', |
|
221 | + $reg_row['Registration.REG_count']), |
|
222 | + \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', |
|
223 | + $reg_row['Registration.REG_group_size'])); |
|
224 | + } elseif ($field_name == 'REG_date') { |
|
225 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
226 | + $reg_row['Registration.REG_date'], 'no_html'); |
|
227 | + } else { |
|
228 | + $value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, |
|
229 | + $reg_row[$field->get_qualified_column()]); |
|
230 | + } |
|
231 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value; |
|
232 | + if ($field_name == 'REG_final_price') { |
|
233 | + //add a column named Currency after the final price |
|
234 | + $reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code; |
|
235 | + } |
|
236 | + } |
|
237 | + //get pretty status |
|
238 | + $stati = \EEM_Status::instance()->localized_status(array( |
|
239 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
240 | + $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'), |
|
241 | + ), false, 'sentence'); |
|
242 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
243 | + //get pretty transaction status |
|
244 | + $reg_csv_array[__("Transaction Status", |
|
245 | + 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
246 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg |
|
247 | + ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', |
|
248 | + $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00'; |
|
249 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg |
|
250 | + ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', |
|
251 | + $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00'; |
|
252 | + $payment_methods = array(); |
|
253 | + $gateway_txn_ids_etc = array(); |
|
254 | + $payment_times = array(); |
|
255 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
256 | + $payments_info = \EEM_Payment::instance()->get_all_wpdb_results(array( |
|
257 | + array( |
|
258 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
259 | + 'STS_ID' => \EEM_Payment::status_id_approved, |
|
260 | + ), |
|
261 | + 'force_join' => array('Payment_Method'), |
|
262 | + ), ARRAY_A, |
|
263 | + 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'); |
|
264 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
265 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) |
|
266 | + ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
267 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) |
|
268 | + ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
269 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) |
|
270 | + ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
271 | + } |
|
272 | + } |
|
273 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
274 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
275 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
276 | + //get whether or not the user has checked in |
|
277 | + $reg_csv_array[__("Check-Ins", |
|
278 | + "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
279 | + //get ticket of registration and its price |
|
280 | + $ticket_model = \EE_Registry::instance()->load_model('Ticket'); |
|
281 | + if ($reg_row['Ticket.TKT_ID']) { |
|
282 | + $ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', |
|
283 | + $reg_row['Ticket.TKT_name']); |
|
284 | + $datetimes_strings = array(); |
|
285 | + foreach ( |
|
286 | + \EEM_Datetime::instance() |
|
287 | + ->get_all_wpdb_results(array( |
|
288 | + array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), |
|
289 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
290 | + 'default_where_conditions' => 'none', |
|
291 | + )) as $datetime |
|
292 | + ) { |
|
293 | + $datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), |
|
294 | + 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
295 | + } |
|
296 | + } else { |
|
297 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
298 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
299 | + } |
|
300 | + $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
|
301 | + $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
|
302 | + //get datetime(s) of registration |
|
303 | + //add attendee columns |
|
304 | + foreach ($att_fields_to_include as $att_field_name) { |
|
305 | + $field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name); |
|
306 | + if ($reg_row['Attendee_CPT.ID']) { |
|
307 | + if ($att_field_name == 'STA_ID') { |
|
308 | + $value = \EEM_State::instance() |
|
309 | + ->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), |
|
310 | + 'STA_name'); |
|
311 | + } elseif ($att_field_name == 'CNT_ISO') { |
|
312 | + $value = \EEM_Country::instance() |
|
313 | + ->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), |
|
314 | + 'CNT_name'); |
|
315 | + } else { |
|
316 | + $value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), |
|
317 | + $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
318 | + } |
|
319 | + } else { |
|
320 | + $value = ''; |
|
321 | + } |
|
322 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value; |
|
323 | + } |
|
324 | + //make sure each registration has the same questions in the same order |
|
325 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
326 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
327 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
328 | + } |
|
329 | + } |
|
330 | + $answers = \EEM_Answer::instance()->get_all_wpdb_results(array( |
|
331 | + array('REG_ID' => $reg_row['Registration.REG_ID']), |
|
332 | + 'force_join' => array('Question'), |
|
333 | + )); |
|
334 | + //now fill out the questions THEY answered |
|
335 | + foreach ($answers as $answer_row) { |
|
336 | + if ($answer_row['Question.QST_ID']) { |
|
337 | + $question_label = \EEH_Export::prepare_value_from_db_for_display(\EEM_Question::instance(), |
|
338 | + 'QST_admin_label', $answer_row['Question.QST_admin_label']); |
|
339 | + } else { |
|
340 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
341 | + } |
|
342 | + if (isset($answer_row['Question.QST_type']) |
|
343 | + && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state |
|
344 | + ) { |
|
345 | + $reg_csv_array[$question_label] = \EEM_State::instance() |
|
346 | + ->get_state_name_by_ID($answer_row['Answer.ANS_value']); |
|
347 | + } else { |
|
348 | + //this isn't for html, so don't show html entities |
|
349 | + $reg_csv_array[$question_label] = html_entity_decode(\EEH_Export::prepare_value_from_db_for_display(\EEM_Answer::instance(), |
|
350 | + 'ANS_value', $answer_row['Answer.ANS_value'])); |
|
351 | + } |
|
352 | + } |
|
353 | + $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', |
|
354 | + $reg_csv_array, $reg_row); |
|
355 | + } |
|
356 | + } |
|
357 | + //if we couldn't export anything, we want to at least show the column headers |
|
358 | + if (empty($registrations_csv_ready_array)) { |
|
359 | + $reg_csv_array = array(); |
|
360 | + $model_and_fields_to_include = array( |
|
361 | + 'Registration' => $reg_fields_to_include, |
|
362 | + 'Attendee' => $att_fields_to_include, |
|
363 | + ); |
|
364 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
365 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
366 | + foreach ($field_list as $field_name) { |
|
367 | + $field = $model->field_settings_for($field_name); |
|
368 | + $reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null; |
|
369 | + } |
|
370 | + } |
|
371 | + $registrations_csv_ready_array[] = $reg_csv_array; |
|
372 | + } |
|
373 | + return $registrations_csv_ready_array; |
|
374 | + } |
|
375 | 375 | |
376 | 376 | |
377 | 377 | |
378 | - /** |
|
379 | - * Counts total unit to process |
|
380 | - * |
|
381 | - * @param int $event_id |
|
382 | - * @return int |
|
383 | - */ |
|
384 | - public function count_units_to_process($event_id) |
|
385 | - { |
|
386 | - //use the legacy filter |
|
387 | - $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
388 | - array( |
|
389 | - 'OR' => array( |
|
390 | - //don't include registrations from failed or abandoned transactions... |
|
391 | - 'Transaction.STS_ID' => array( |
|
392 | - 'NOT IN', |
|
393 | - array( |
|
394 | - \EEM_Transaction::failed_status_code, |
|
395 | - \EEM_Transaction::abandoned_status_code, |
|
396 | - ), |
|
397 | - ), |
|
398 | - //unless the registration is approved, in which case include it regardless of transaction status |
|
399 | - 'STS_ID' => \EEM_Registration::status_id_approved, |
|
400 | - ), |
|
401 | - 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
402 | - ), |
|
403 | - 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
404 | - 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
405 | - 'caps' => \EEM_Base::caps_read_admin, |
|
406 | - ), $event_id); |
|
407 | - if ($event_id) { |
|
408 | - $query_params[0]['EVT_ID'] = $event_id; |
|
409 | - } else { |
|
410 | - $query_params['force_join'][] = 'Event'; |
|
411 | - } |
|
412 | - return \EEM_Registration::instance()->count($query_params); |
|
413 | - } |
|
378 | + /** |
|
379 | + * Counts total unit to process |
|
380 | + * |
|
381 | + * @param int $event_id |
|
382 | + * @return int |
|
383 | + */ |
|
384 | + public function count_units_to_process($event_id) |
|
385 | + { |
|
386 | + //use the legacy filter |
|
387 | + $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array( |
|
388 | + array( |
|
389 | + 'OR' => array( |
|
390 | + //don't include registrations from failed or abandoned transactions... |
|
391 | + 'Transaction.STS_ID' => array( |
|
392 | + 'NOT IN', |
|
393 | + array( |
|
394 | + \EEM_Transaction::failed_status_code, |
|
395 | + \EEM_Transaction::abandoned_status_code, |
|
396 | + ), |
|
397 | + ), |
|
398 | + //unless the registration is approved, in which case include it regardless of transaction status |
|
399 | + 'STS_ID' => \EEM_Registration::status_id_approved, |
|
400 | + ), |
|
401 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)), |
|
402 | + ), |
|
403 | + 'order_by' => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'), |
|
404 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
405 | + 'caps' => \EEM_Base::caps_read_admin, |
|
406 | + ), $event_id); |
|
407 | + if ($event_id) { |
|
408 | + $query_params[0]['EVT_ID'] = $event_id; |
|
409 | + } else { |
|
410 | + $query_params['force_join'][] = 'Event'; |
|
411 | + } |
|
412 | + return \EEM_Registration::instance()->count($query_params); |
|
413 | + } |
|
414 | 414 | |
415 | 415 | |
416 | 416 | |
417 | - /** |
|
418 | - * Performs any clean-up logic when we know the job is completed. |
|
419 | - * In this case, we delete the temporary file |
|
420 | - * |
|
421 | - * @param JobParameters $job_parameters |
|
422 | - * @return boolean |
|
423 | - */ |
|
424 | - public function cleanup_job(JobParameters $job_parameters) |
|
425 | - { |
|
426 | - $this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
427 | - true, 'd'); |
|
428 | - return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
429 | - } |
|
417 | + /** |
|
418 | + * Performs any clean-up logic when we know the job is completed. |
|
419 | + * In this case, we delete the temporary file |
|
420 | + * |
|
421 | + * @param JobParameters $job_parameters |
|
422 | + * @return boolean |
|
423 | + */ |
|
424 | + public function cleanup_job(JobParameters $job_parameters) |
|
425 | + { |
|
426 | + $this->_file_helper->delete(\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
427 | + true, 'd'); |
|
428 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
429 | + } |
|
430 | 430 | } |
431 | 431 | |
432 | 432 |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | { |
587 | 587 | //style |
588 | 588 | //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
589 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
589 | + wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), |
|
590 | 590 | EVENT_ESPRESSO_VERSION); |
591 | 591 | wp_enqueue_style('espresso_reg'); |
592 | 592 | //script |
593 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
593 | + wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', |
|
594 | 594 | array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
595 | 595 | wp_enqueue_script('espresso_reg'); |
596 | 596 | } |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | public function load_scripts_styles_contact_list() |
625 | 625 | { |
626 | 626 | wp_deregister_style('espresso_reg'); |
627 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
627 | + wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), |
|
628 | 628 | EVENT_ESPRESSO_VERSION); |
629 | 629 | wp_enqueue_style('espresso_att'); |
630 | 630 | } |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | |
634 | 634 | public function load_scripts_styles_new_registration() |
635 | 635 | { |
636 | - wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
636 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), |
|
637 | 637 | EVENT_ESPRESSO_VERSION, true); |
638 | 638 | wp_enqueue_script('ee-spco-for-admin'); |
639 | 639 | add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
@@ -833,31 +833,31 @@ discard block |
||
833 | 833 | } |
834 | 834 | $sc_items = array( |
835 | 835 | 'approved_status' => array( |
836 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
836 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
837 | 837 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
838 | 838 | ), |
839 | 839 | 'pending_status' => array( |
840 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
840 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
841 | 841 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
842 | 842 | ), |
843 | 843 | 'wait_list' => array( |
844 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
844 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
845 | 845 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
846 | 846 | ), |
847 | 847 | 'incomplete_status' => array( |
848 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
848 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
849 | 849 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
850 | 850 | ), |
851 | 851 | 'not_approved' => array( |
852 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
852 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
853 | 853 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
854 | 854 | ), |
855 | 855 | 'declined_status' => array( |
856 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
856 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
857 | 857 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
858 | 858 | ), |
859 | 859 | 'cancelled_status' => array( |
860 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
860 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
861 | 861 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
862 | 862 | ), |
863 | 863 | ); |
@@ -878,17 +878,17 @@ discard block |
||
878 | 878 | if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
879 | 879 | 'espresso_registrations_new_registration', $EVT_ID) |
880 | 880 | ) { |
881 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
881 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button('new_registration', 'add-registrant', |
|
882 | 882 | array('event_id' => $EVT_ID), 'add-new-h2'); |
883 | 883 | } |
884 | 884 | $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
885 | 885 | if ($event instanceof EE_Event) { |
886 | 886 | $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
887 | 887 | 'event_espresso'), '<h3 style="line-height:1.5em;">', |
888 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
888 | + '<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce(array( |
|
889 | 889 | 'action' => 'edit', |
890 | 890 | 'post' => $event->ID(), |
891 | - ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
891 | + ), EVENTS_ADMIN_URL).'"> '.$event->get('EVT_name').' </a> ', '</h3>'); |
|
892 | 892 | } |
893 | 893 | $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
894 | 894 | $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
898 | 898 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
899 | 899 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
900 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
900 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
901 | 901 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
902 | 902 | } |
903 | 903 | } |
@@ -948,13 +948,13 @@ discard block |
||
948 | 948 | { |
949 | 949 | $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 |
950 | 950 | ? absint($this->_req_data['event_id']) : false; |
951 | - $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int)$this->_req_data['EVT_CAT'] > 0 |
|
951 | + $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 |
|
952 | 952 | ? absint($this->_req_data['EVT_CAT']) : false; |
953 | 953 | $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null; |
954 | 954 | $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) |
955 | 955 | : false; |
956 | 956 | $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) |
957 | - : false;//should be like 2013-april |
|
957 | + : false; //should be like 2013-april |
|
958 | 958 | $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? true : false; |
959 | 959 | $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? true : false; |
960 | 960 | $start_date = false; |
@@ -1018,9 +1018,9 @@ discard block |
||
1018 | 1018 | 'BETWEEN', |
1019 | 1019 | array( |
1020 | 1020 | EEM_Registration::instance() |
1021 | - ->convert_datetime_for_query('REG_date', $curdate . $time_start, 'Y-m-d H:i:s'), |
|
1021 | + ->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'), |
|
1022 | 1022 | EEM_Registration::instance() |
1023 | - ->convert_datetime_for_query('REG_date', $curdate . $time_end, 'Y-m-d H:i:s'), |
|
1023 | + ->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'), |
|
1024 | 1024 | ), |
1025 | 1025 | ); |
1026 | 1026 | } elseif ($this_month_a || $this_month) { |
@@ -1031,10 +1031,10 @@ discard block |
||
1031 | 1031 | array( |
1032 | 1032 | EEM_Registration::instance() |
1033 | 1033 | ->convert_datetime_for_query('REG_date', |
1034 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s'), |
|
1034 | + $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'), |
|
1035 | 1035 | EEM_Registration::instance() |
1036 | 1036 | ->convert_datetime_for_query('REG_date', |
1037 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
1037 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, |
|
1038 | 1038 | 'Y-m-d H:i:s'), |
1039 | 1039 | ), |
1040 | 1040 | ); |
@@ -1042,16 +1042,16 @@ discard block |
||
1042 | 1042 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1043 | 1043 | $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : ''; |
1044 | 1044 | $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
1045 | - $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01')); |
|
1045 | + $days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01')); |
|
1046 | 1046 | $_where['REG_date'] = array( |
1047 | 1047 | 'BETWEEN', |
1048 | 1048 | array( |
1049 | 1049 | EEM_Registration::instance() |
1050 | - ->convert_datetime_for_query('REG_date', $year_r . '-' . $month_r . '-01 00:00:00', |
|
1050 | + ->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', |
|
1051 | 1051 | 'Y-m-d H:i:s'), |
1052 | 1052 | EEM_Registration::instance() |
1053 | 1053 | ->convert_datetime_for_query('REG_date', |
1054 | - $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s'), |
|
1054 | + $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s'), |
|
1055 | 1055 | ), |
1056 | 1056 | ); |
1057 | 1057 | } elseif ($start_date && $end_date) { |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | throw new EE_Error("not yet supported"); |
1063 | 1063 | } |
1064 | 1064 | if ( ! empty($this->_req_data['s'])) { |
1065 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1065 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1066 | 1066 | $_where['OR'] = array( |
1067 | 1067 | 'Event.EVT_name' => array('LIKE', $sstr), |
1068 | 1068 | 'Event.EVT_desc' => array('LIKE', $sstr), |
@@ -1123,16 +1123,16 @@ discard block |
||
1123 | 1123 | $event_name = $first_registration->event_obj()->name(); |
1124 | 1124 | $event_date = $first_registration->date_obj() |
1125 | 1125 | ->start_date_and_time('l F j, Y,', |
1126 | - 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1126 | + 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1127 | 1127 | // edit event link |
1128 | 1128 | if ($event_name != '') { |
1129 | 1129 | $edit_event_url = self::add_query_args_and_nonce(array( |
1130 | 1130 | 'action' => 'edit_event', |
1131 | 1131 | 'EVT_ID' => $EVT_ID, |
1132 | 1132 | ), EVENTS_ADMIN_URL); |
1133 | - $edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__('Edit ', |
|
1134 | - 'event_espresso') . $event_name . '">' . __('Edit Event', 'event_espresso') . '</a>'; |
|
1135 | - $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>'; |
|
1133 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', |
|
1134 | + 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
1135 | + $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
1136 | 1136 | } |
1137 | 1137 | $back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL); |
1138 | 1138 | $back_2_reg_lnk = '<a href="' |
@@ -1144,9 +1144,9 @@ discard block |
||
1144 | 1144 | . '</a>'; |
1145 | 1145 | $this->_template_args['before_admin_page_content'] = ' |
1146 | 1146 | <div id="admin-page-header"> |
1147 | - <h1><span class="small-text not-bold">' . __('Event: ', 'event_espresso') . '</span>' . $event_name . '</h1> |
|
1148 | - <h3><span class="small-text not-bold">' . __('Date: ', 'event_espresso') . '</span>' . $event_date . '</h3> |
|
1149 | - <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
|
1147 | + <h1><span class="small-text not-bold">' . __('Event: ', 'event_espresso').'</span>'.$event_name.'</h1> |
|
1148 | + <h3><span class="small-text not-bold">' . __('Date: ', 'event_espresso').'</span>'.$event_date.'</h3> |
|
1149 | + <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span> |
|
1150 | 1150 | </div> |
1151 | 1151 | '; |
1152 | 1152 | } |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | '_REG_ID' => $previous_reg['REG_ID'], |
1218 | 1218 | ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
1219 | 1219 | // grab header |
1220 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
1220 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
1221 | 1221 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1222 | 1222 | $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
1223 | 1223 | $this->_template_args, true); |
@@ -1294,8 +1294,8 @@ discard block |
||
1294 | 1294 | 'default' => $this->_registration->ID(), |
1295 | 1295 | )), |
1296 | 1296 | 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
1297 | - 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
1298 | - '', 'status-' . $this->_registration->status_ID(), |
|
1297 | + 'event_espresso')))).EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
1298 | + '', 'status-'.$this->_registration->status_ID(), |
|
1299 | 1299 | 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
1300 | 1300 | 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
1301 | 1301 | 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
@@ -1383,9 +1383,9 @@ discard block |
||
1383 | 1383 | { |
1384 | 1384 | if (isset($this->_req_data['reg_status_change_form'])) { |
1385 | 1385 | $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
1386 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
1386 | + ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
1387 | 1387 | } else { |
1388 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
1388 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
1389 | 1389 | } |
1390 | 1390 | $success = $this->_set_registration_status($REG_IDs, $status); |
1391 | 1391 | //notify? |
@@ -1414,7 +1414,7 @@ discard block |
||
1414 | 1414 | { |
1415 | 1415 | $success = false; |
1416 | 1416 | // typecast $REG_IDs |
1417 | - $REG_IDs = (array)$REG_IDs; |
|
1417 | + $REG_IDs = (array) $REG_IDs; |
|
1418 | 1418 | if ( ! empty($REG_IDs)) { |
1419 | 1419 | $success = true; |
1420 | 1420 | // set default status if none is passed |
@@ -1714,7 +1714,7 @@ discard block |
||
1714 | 1714 | ), REG_ADMIN_URL); |
1715 | 1715 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1716 | 1716 | $this->_template_args['event_id'] = $this->_registration->event_ID(); |
1717 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1717 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1718 | 1718 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
1719 | 1719 | } |
1720 | 1720 | |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
1738 | 1738 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
1739 | 1739 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1740 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1740 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1741 | 1741 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
1742 | 1742 | } |
1743 | 1743 | } |
@@ -1754,7 +1754,7 @@ discard block |
||
1754 | 1754 | */ |
1755 | 1755 | public function form_before_question_group($output) |
1756 | 1756 | { |
1757 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1757 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
1758 | 1758 | __('This method would have been protected but was used on a filter callback' |
1759 | 1759 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
1760 | 1760 | '4.8.32.rc.000'); |
@@ -1776,7 +1776,7 @@ discard block |
||
1776 | 1776 | */ |
1777 | 1777 | public function form_after_question_group($output) |
1778 | 1778 | { |
1779 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1779 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
1780 | 1780 | __('This method would have been protected but was used on a filter callback' |
1781 | 1781 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
1782 | 1782 | '4.8.32.rc.000'); |
@@ -1811,14 +1811,14 @@ discard block |
||
1811 | 1811 | */ |
1812 | 1812 | public function form_form_field_label_wrap($label) |
1813 | 1813 | { |
1814 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1814 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
1815 | 1815 | __('This method would have been protected but was used on a filter callback' |
1816 | 1816 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
1817 | 1817 | '4.8.32.rc.000'); |
1818 | 1818 | return ' |
1819 | 1819 | <tr> |
1820 | 1820 | <th> |
1821 | - ' . $label . ' |
|
1821 | + ' . $label.' |
|
1822 | 1822 | </th>'; |
1823 | 1823 | } |
1824 | 1824 | |
@@ -1834,13 +1834,13 @@ discard block |
||
1834 | 1834 | */ |
1835 | 1835 | public function form_form_field_input__wrap($input) |
1836 | 1836 | { |
1837 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1837 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FUNCTION__, |
|
1838 | 1838 | __('This method would have been protected but was used on a filter callback' |
1839 | 1839 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
1840 | 1840 | '4.8.32.rc.000'); |
1841 | 1841 | return ' |
1842 | 1842 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
1843 | - ' . $input . ' |
|
1843 | + ' . $input.' |
|
1844 | 1844 | </td> |
1845 | 1845 | </tr>'; |
1846 | 1846 | } |
@@ -1882,7 +1882,7 @@ discard block |
||
1882 | 1882 | protected function _get_reg_custom_questions_form($REG_ID) |
1883 | 1883 | { |
1884 | 1884 | if ( ! $this->_reg_custom_questions_form) { |
1885 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
1885 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
1886 | 1886 | $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance() |
1887 | 1887 | ->get_one_by_ID($REG_ID)); |
1888 | 1888 | $this->_reg_custom_questions_form->_construct_finalize(null, null); |
@@ -1973,10 +1973,10 @@ discard block |
||
1973 | 1973 | : EEM_Attendee::instance() |
1974 | 1974 | ->create_default_object(); |
1975 | 1975 | $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
1976 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1977 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1978 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1979 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1976 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1977 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1978 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1979 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1980 | 1980 | $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
1981 | 1981 | $attendee->full_address_as_array()); |
1982 | 1982 | $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
1991 | 1991 | // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
1992 | 1992 | } |
1993 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
1993 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
1994 | 1994 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
1995 | 1995 | } |
1996 | 1996 | |
@@ -2020,9 +2020,9 @@ discard block |
||
2020 | 2020 | $primary_registration = null; |
2021 | 2021 | } |
2022 | 2022 | $this->_template_args['ATT_ID'] = $attendee->ID(); |
2023 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
2024 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
2025 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
2023 | + $this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname; |
|
2024 | + $this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname; |
|
2025 | + $this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email; |
|
2026 | 2026 | $this->_template_args['phone'] = $attendee->phone(); |
2027 | 2027 | $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
2028 | 2028 | //edit link |
@@ -2039,7 +2039,7 @@ discard block |
||
2039 | 2039 | ), REG_ADMIN_URL) : ''; |
2040 | 2040 | $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
2041 | 2041 | $this->_template_args['att_check'] = $att_check; |
2042 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
2042 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
2043 | 2043 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
2044 | 2044 | } |
2045 | 2045 | |
@@ -2274,7 +2274,7 @@ discard block |
||
2274 | 2274 | $this->_return_json(); |
2275 | 2275 | } |
2276 | 2276 | // grab header |
2277 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
2277 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
2278 | 2278 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
2279 | 2279 | $this->_template_args, true); |
2280 | 2280 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
@@ -2297,7 +2297,7 @@ discard block |
||
2297 | 2297 | 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
2298 | 2298 | '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
2299 | 2299 | return ' |
2300 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
2300 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
2301 | 2301 | <script > |
2302 | 2302 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
2303 | 2303 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2518,7 +2518,7 @@ discard block |
||
2518 | 2518 | public function get_attendees($per_page, $count = false, $trash = false) |
2519 | 2519 | { |
2520 | 2520 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
2521 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
2521 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
2522 | 2522 | $ATT_MDL = EEM_Attendee::instance(); |
2523 | 2523 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
2524 | 2524 | switch ($this->_req_data['orderby']) { |
@@ -2552,7 +2552,7 @@ discard block |
||
2552 | 2552 | ? $this->_req_data['perpage'] : $per_page; |
2553 | 2553 | $_where = array(); |
2554 | 2554 | if ( ! empty($this->_req_data['s'])) { |
2555 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2555 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2556 | 2556 | $_where['OR'] = array( |
2557 | 2557 | 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
2558 | 2558 | 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
@@ -2643,8 +2643,8 @@ discard block |
||
2643 | 2643 | 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
2644 | 2644 | ); |
2645 | 2645 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
2646 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2647 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2646 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2647 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2648 | 2648 | $EE_Export = EE_Export::instance($this->_req_data); |
2649 | 2649 | $EE_Export->export(); |
2650 | 2650 | } |
@@ -2655,8 +2655,8 @@ discard block |
||
2655 | 2655 | |
2656 | 2656 | public function _contact_list_export() |
2657 | 2657 | { |
2658 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2659 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2658 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2659 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2660 | 2660 | $EE_Export = EE_Export::instance($this->_req_data); |
2661 | 2661 | $EE_Export->export_attendees(); |
2662 | 2662 | } |
@@ -2674,8 +2674,8 @@ discard block |
||
2674 | 2674 | 'return_url' => urlencode($this->_req_data['return_url']), |
2675 | 2675 | ))); |
2676 | 2676 | } else { |
2677 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2678 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2677 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2678 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2679 | 2679 | $EE_Export = EE_Export::instance($this->_req_data); |
2680 | 2680 | $EE_Export->report_attendees(); |
2681 | 2681 | } |
@@ -2733,7 +2733,7 @@ discard block |
||
2733 | 2733 | $updated_fields = array( |
2734 | 2734 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
2735 | 2735 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
2736 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
2736 | + 'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
2737 | 2737 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
2738 | 2738 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
2739 | 2739 | 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
@@ -2822,7 +2822,7 @@ discard block |
||
2822 | 2822 | { |
2823 | 2823 | //get attendee object ( should already have it ) |
2824 | 2824 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2825 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
2825 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
2826 | 2826 | EEH_Template::display_template($template, $this->_template_args); |
2827 | 2827 | } |
2828 | 2828 | |
@@ -2864,7 +2864,7 @@ discard block |
||
2864 | 2864 | 'input_prefix' => '', |
2865 | 2865 | 'append_qstn_id' => false, |
2866 | 2866 | ))); |
2867 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
2867 | + $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
2868 | 2868 | EEH_Template::display_template($template, $this->_template_args); |
2869 | 2869 | } |
2870 | 2870 | |
@@ -2880,7 +2880,7 @@ discard block |
||
2880 | 2880 | { |
2881 | 2881 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2882 | 2882 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
2883 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
2883 | + $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
2884 | 2884 | EEH_Template::display_template($template, $this->_template_args); |
2885 | 2885 | } |
2886 | 2886 | |
@@ -2895,7 +2895,7 @@ discard block |
||
2895 | 2895 | public function after_title_form_fields($post) |
2896 | 2896 | { |
2897 | 2897 | if ($post->post_type == 'espresso_attendees') { |
2898 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
2898 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
2899 | 2899 | $template_args['attendee'] = $this->_cpt_model_obj; |
2900 | 2900 | EEH_Template::display_template($template, $template_args); |
2901 | 2901 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -24,1772 +24,1772 @@ discard block |
||
24 | 24 | class Registrations_Admin_Page extends EE_Admin_Page_CPT |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var EE_Registration |
|
29 | - */ |
|
30 | - private $_registration; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var EE_Event |
|
34 | - */ |
|
35 | - private $_reg_event; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var EE_Session |
|
39 | - */ |
|
40 | - private $_session; |
|
41 | - |
|
42 | - private static $_reg_status; |
|
43 | - |
|
44 | - /** |
|
45 | - * Form for displaying the custom questions for this registration. |
|
46 | - * This gets used a few times throughout the request so its best to cache it |
|
47 | - * |
|
48 | - * @var EE_Registration_Custom_Questions_Form |
|
49 | - */ |
|
50 | - protected $_reg_custom_questions_form = null; |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * constructor |
|
56 | - * |
|
57 | - * @Constructor |
|
58 | - * @access public |
|
59 | - * @param bool $routing |
|
60 | - * @return Registrations_Admin_Page |
|
61 | - */ |
|
62 | - public function __construct($routing = true) |
|
63 | - { |
|
64 | - parent::__construct($routing); |
|
65 | - add_action('wp_loaded', array($this, 'wp_loaded')); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - public function wp_loaded() |
|
71 | - { |
|
72 | - // when adding a new registration... |
|
73 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
74 | - EE_System::do_not_cache(); |
|
75 | - if ( ! isset($this->_req_data['processing_registration']) |
|
76 | - || absint($this->_req_data['processing_registration']) !== 1 |
|
77 | - ) { |
|
78 | - // and it's NOT the attendee information reg step |
|
79 | - // force cookie expiration by setting time to last week |
|
80 | - setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
81 | - // and update the global |
|
82 | - $_COOKIE['ee_registration_added'] = 0; |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - protected function _init_page_props() |
|
90 | - { |
|
91 | - $this->page_slug = REG_PG_SLUG; |
|
92 | - $this->_admin_base_url = REG_ADMIN_URL; |
|
93 | - $this->_admin_base_path = REG_ADMIN; |
|
94 | - $this->page_label = __('Registrations', 'event_espresso'); |
|
95 | - $this->_cpt_routes = array( |
|
96 | - 'add_new_attendee' => 'espresso_attendees', |
|
97 | - 'edit_attendee' => 'espresso_attendees', |
|
98 | - 'insert_attendee' => 'espresso_attendees', |
|
99 | - 'update_attendee' => 'espresso_attendees', |
|
100 | - ); |
|
101 | - $this->_cpt_model_names = array( |
|
102 | - 'add_new_attendee' => 'EEM_Attendee', |
|
103 | - 'edit_attendee' => 'EEM_Attendee', |
|
104 | - ); |
|
105 | - $this->_cpt_edit_routes = array( |
|
106 | - 'espresso_attendees' => 'edit_attendee', |
|
107 | - ); |
|
108 | - $this->_pagenow_map = array( |
|
109 | - 'add_new_attendee' => 'post-new.php', |
|
110 | - 'edit_attendee' => 'post.php', |
|
111 | - 'trash' => 'post.php', |
|
112 | - ); |
|
113 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
114 | - //add filters so that the comment urls don't take users to a confusing 404 page |
|
115 | - add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - |
|
120 | - public function clear_comment_link($link, $comment, $args) |
|
121 | - { |
|
122 | - //gotta make sure this only happens on this route |
|
123 | - $post_type = get_post_type($comment->comment_post_ID); |
|
124 | - if ($post_type === 'espresso_attendees') { |
|
125 | - return '#commentsdiv'; |
|
126 | - } |
|
127 | - return $link; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - protected function _ajax_hooks() |
|
133 | - { |
|
134 | - //todo: all hooks for registrations ajax goes in here |
|
135 | - add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - protected function _define_page_props() |
|
141 | - { |
|
142 | - $this->_admin_page_title = $this->page_label; |
|
143 | - $this->_labels = array( |
|
144 | - 'buttons' => array( |
|
145 | - 'add-registrant' => __('Add New Registration', 'event_espresso'), |
|
146 | - 'add-attendee' => __('Add Contact', 'event_espresso'), |
|
147 | - 'edit' => __('Edit Contact', 'event_espresso'), |
|
148 | - 'report' => __("Event Registrations CSV Report", "event_espresso"), |
|
149 | - 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
150 | - 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
151 | - 'contact_list_export' => __("Export Data", "event_espresso"), |
|
152 | - ), |
|
153 | - 'publishbox' => array( |
|
154 | - 'add_new_attendee' => __("Add Contact Record", 'event_espresso'), |
|
155 | - 'edit_attendee' => __("Update Contact Record", 'event_espresso'), |
|
156 | - ), |
|
157 | - 'hide_add_button_on_cpt_route' => array( |
|
158 | - 'edit_attendee' => true, |
|
159 | - ), |
|
160 | - ); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * grab url requests and route them |
|
167 | - * |
|
168 | - * @access private |
|
169 | - * @return void |
|
170 | - */ |
|
171 | - public function _set_page_routes() |
|
172 | - { |
|
173 | - $this->_get_registration_status_array(); |
|
174 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
175 | - ? $this->_req_data['_REG_ID'] : 0; |
|
176 | - $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
177 | - ? $this->_req_data['ATT_ID'] : 0; |
|
178 | - $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] |
|
179 | - : $att_id; |
|
180 | - $this->_page_routes = array( |
|
181 | - 'default' => array( |
|
182 | - 'func' => '_registrations_overview_list_table', |
|
183 | - 'capability' => 'ee_read_registrations', |
|
184 | - ), |
|
185 | - 'view_registration' => array( |
|
186 | - 'func' => '_registration_details', |
|
187 | - 'capability' => 'ee_read_registration', |
|
188 | - 'obj_id' => $reg_id, |
|
189 | - ), |
|
190 | - 'edit_registration' => array( |
|
191 | - 'func' => '_update_attendee_registration_form', |
|
192 | - 'noheader' => true, |
|
193 | - 'headers_sent_route' => 'view_registration', |
|
194 | - 'capability' => 'ee_edit_registration', |
|
195 | - 'obj_id' => $reg_id, |
|
196 | - '_REG_ID' => $reg_id, |
|
197 | - ), |
|
198 | - 'trash_registrations' => array( |
|
199 | - 'func' => '_trash_or_restore_registrations', |
|
200 | - 'args' => array('trash' => true), |
|
201 | - 'noheader' => true, |
|
202 | - 'capability' => 'ee_delete_registrations', |
|
203 | - ), |
|
204 | - 'restore_registrations' => array( |
|
205 | - 'func' => '_trash_or_restore_registrations', |
|
206 | - 'args' => array('trash' => false), |
|
207 | - 'noheader' => true, |
|
208 | - 'capability' => 'ee_delete_registrations', |
|
209 | - ), |
|
210 | - 'delete_registrations' => array( |
|
211 | - 'func' => '_delete_registrations', |
|
212 | - 'noheader' => true, |
|
213 | - 'capability' => 'ee_delete_registrations', |
|
214 | - ), |
|
215 | - 'new_registration' => array( |
|
216 | - 'func' => 'new_registration', |
|
217 | - 'capability' => 'ee_edit_registrations', |
|
218 | - ), |
|
219 | - 'process_reg_step' => array( |
|
220 | - 'func' => 'process_reg_step', |
|
221 | - 'noheader' => true, |
|
222 | - 'capability' => 'ee_edit_registrations', |
|
223 | - ), |
|
224 | - 'redirect_to_txn' => array( |
|
225 | - 'func' => 'redirect_to_txn', |
|
226 | - 'noheader' => true, |
|
227 | - 'capability' => 'ee_edit_registrations', |
|
228 | - ), |
|
229 | - 'change_reg_status' => array( |
|
230 | - 'func' => '_change_reg_status', |
|
231 | - 'noheader' => true, |
|
232 | - 'capability' => 'ee_edit_registration', |
|
233 | - 'obj_id' => $reg_id, |
|
234 | - ), |
|
235 | - 'approve_registration' => array( |
|
236 | - 'func' => 'approve_registration', |
|
237 | - 'noheader' => true, |
|
238 | - 'capability' => 'ee_edit_registration', |
|
239 | - 'obj_id' => $reg_id, |
|
240 | - ), |
|
241 | - 'approve_and_notify_registration' => array( |
|
242 | - 'func' => 'approve_registration', |
|
243 | - 'noheader' => true, |
|
244 | - 'args' => array(true), |
|
245 | - 'capability' => 'ee_edit_registration', |
|
246 | - 'obj_id' => $reg_id, |
|
247 | - ), |
|
248 | - 'decline_registration' => array( |
|
249 | - 'func' => 'decline_registration', |
|
250 | - 'noheader' => true, |
|
251 | - 'capability' => 'ee_edit_registration', |
|
252 | - 'obj_id' => $reg_id, |
|
253 | - ), |
|
254 | - 'decline_and_notify_registration' => array( |
|
255 | - 'func' => 'decline_registration', |
|
256 | - 'noheader' => true, |
|
257 | - 'args' => array(true), |
|
258 | - 'capability' => 'ee_edit_registration', |
|
259 | - 'obj_id' => $reg_id, |
|
260 | - ), |
|
261 | - 'pending_registration' => array( |
|
262 | - 'func' => 'pending_registration', |
|
263 | - 'noheader' => true, |
|
264 | - 'capability' => 'ee_edit_registration', |
|
265 | - 'obj_id' => $reg_id, |
|
266 | - ), |
|
267 | - 'pending_and_notify_registration' => array( |
|
268 | - 'func' => 'pending_registration', |
|
269 | - 'noheader' => true, |
|
270 | - 'args' => array(true), |
|
271 | - 'capability' => 'ee_edit_registration', |
|
272 | - 'obj_id' => $reg_id, |
|
273 | - ), |
|
274 | - 'no_approve_registration' => array( |
|
275 | - 'func' => 'not_approve_registration', |
|
276 | - 'noheader' => true, |
|
277 | - 'capability' => 'ee_edit_registration', |
|
278 | - 'obj_id' => $reg_id, |
|
279 | - ), |
|
280 | - 'no_approve_and_notify_registration' => array( |
|
281 | - 'func' => 'not_approve_registration', |
|
282 | - 'noheader' => true, |
|
283 | - 'args' => array(true), |
|
284 | - 'capability' => 'ee_edit_registration', |
|
285 | - 'obj_id' => $reg_id, |
|
286 | - ), |
|
287 | - 'cancel_registration' => array( |
|
288 | - 'func' => 'cancel_registration', |
|
289 | - 'noheader' => true, |
|
290 | - 'capability' => 'ee_edit_registration', |
|
291 | - 'obj_id' => $reg_id, |
|
292 | - ), |
|
293 | - 'cancel_and_notify_registration' => array( |
|
294 | - 'func' => 'cancel_registration', |
|
295 | - 'noheader' => true, |
|
296 | - 'args' => array(true), |
|
297 | - 'capability' => 'ee_edit_registration', |
|
298 | - 'obj_id' => $reg_id, |
|
299 | - ), |
|
300 | - 'contact_list' => array( |
|
301 | - 'func' => '_attendee_contact_list_table', |
|
302 | - 'capability' => 'ee_read_contacts', |
|
303 | - ), |
|
304 | - 'add_new_attendee' => array( |
|
305 | - 'func' => '_create_new_cpt_item', |
|
306 | - 'args' => array( |
|
307 | - 'new_attendee' => true, |
|
308 | - 'capability' => 'ee_edit_contacts', |
|
309 | - ), |
|
310 | - ), |
|
311 | - 'edit_attendee' => array( |
|
312 | - 'func' => '_edit_cpt_item', |
|
313 | - 'capability' => 'ee_edit_contacts', |
|
314 | - 'obj_id' => $att_id, |
|
315 | - ), |
|
316 | - 'duplicate_attendee' => array( |
|
317 | - 'func' => '_duplicate_attendee', |
|
318 | - 'noheader' => true, |
|
319 | - 'capability' => 'ee_edit_contacts', |
|
320 | - 'obj_id' => $att_id, |
|
321 | - ), |
|
322 | - 'insert_attendee' => array( |
|
323 | - 'func' => '_insert_or_update_attendee', |
|
324 | - 'args' => array( |
|
325 | - 'new_attendee' => true, |
|
326 | - ), |
|
327 | - 'noheader' => true, |
|
328 | - 'capability' => 'ee_edit_contacts', |
|
329 | - ), |
|
330 | - 'update_attendee' => array( |
|
331 | - 'func' => '_insert_or_update_attendee', |
|
332 | - 'args' => array( |
|
333 | - 'new_attendee' => false, |
|
334 | - ), |
|
335 | - 'noheader' => true, |
|
336 | - 'capability' => 'ee_edit_contacts', |
|
337 | - 'obj_id' => $att_id, |
|
338 | - ), |
|
339 | - 'trash_attendees' => array( |
|
340 | - 'func' => '_trash_or_restore_attendees', |
|
341 | - 'args' => array( |
|
342 | - 'trash' => true, |
|
343 | - ), |
|
344 | - 'noheader' => true, |
|
345 | - 'capability' => 'ee_delete_contacts', |
|
346 | - 'obj_id' => $att_id, |
|
347 | - ), |
|
348 | - 'restore_attendees' => array( |
|
349 | - 'func' => '_trash_or_restore_attendees', |
|
350 | - 'args' => array( |
|
351 | - 'trash' => false, |
|
352 | - ), |
|
353 | - 'noheader' => true, |
|
354 | - 'capability' => 'ee_delete_contacts', |
|
355 | - 'obj_id' => $att_id, |
|
356 | - ), |
|
357 | - 'resend_registration' => array( |
|
358 | - 'func' => '_resend_registration', |
|
359 | - 'noheader' => true, |
|
360 | - 'capability' => 'ee_send_message', |
|
361 | - ), |
|
362 | - 'registrations_report' => array( |
|
363 | - 'func' => '_registrations_report', |
|
364 | - 'noheader' => true, |
|
365 | - 'capability' => 'ee_read_registrations', |
|
366 | - ), |
|
367 | - 'contact_list_export' => array( |
|
368 | - 'func' => '_contact_list_export', |
|
369 | - 'noheader' => true, |
|
370 | - 'capability' => 'export', |
|
371 | - ), |
|
372 | - 'contact_list_report' => array( |
|
373 | - 'func' => '_contact_list_report', |
|
374 | - 'noheader' => true, |
|
375 | - 'capability' => 'ee_read_contacts', |
|
376 | - ), |
|
377 | - ); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - |
|
382 | - protected function _set_page_config() |
|
383 | - { |
|
384 | - $this->_page_config = array( |
|
385 | - 'default' => array( |
|
386 | - 'nav' => array( |
|
387 | - 'label' => __('Overview', 'event_espresso'), |
|
388 | - 'order' => 5, |
|
389 | - ), |
|
390 | - 'help_tabs' => array( |
|
391 | - 'registrations_overview_help_tab' => array( |
|
392 | - 'title' => __('Registrations Overview', 'event_espresso'), |
|
393 | - 'filename' => 'registrations_overview', |
|
394 | - ), |
|
395 | - 'registrations_overview_table_column_headings_help_tab' => array( |
|
396 | - 'title' => __('Registrations Table Column Headings', 'event_espresso'), |
|
397 | - 'filename' => 'registrations_overview_table_column_headings', |
|
398 | - ), |
|
399 | - 'registrations_overview_filters_help_tab' => array( |
|
400 | - 'title' => __('Registration Filters', 'event_espresso'), |
|
401 | - 'filename' => 'registrations_overview_filters', |
|
402 | - ), |
|
403 | - 'registrations_overview_views_help_tab' => array( |
|
404 | - 'title' => __('Registration Views', 'event_espresso'), |
|
405 | - 'filename' => 'registrations_overview_views', |
|
406 | - ), |
|
407 | - 'registrations_regoverview_other_help_tab' => array( |
|
408 | - 'title' => __('Registrations Other', 'event_espresso'), |
|
409 | - 'filename' => 'registrations_overview_other', |
|
410 | - ), |
|
411 | - ), |
|
412 | - 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
413 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
414 | - 'list_table' => 'EE_Registrations_List_Table', |
|
415 | - 'require_nonce' => false, |
|
416 | - ), |
|
417 | - 'view_registration' => array( |
|
418 | - 'nav' => array( |
|
419 | - 'label' => __('REG Details', 'event_espresso'), |
|
420 | - 'order' => 15, |
|
421 | - 'url' => isset($this->_req_data['_REG_ID']) |
|
422 | - ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
423 | - : $this->_admin_base_url, |
|
424 | - 'persistent' => false, |
|
425 | - ), |
|
426 | - 'help_tabs' => array( |
|
427 | - 'registrations_details_help_tab' => array( |
|
428 | - 'title' => __('Registration Details', 'event_espresso'), |
|
429 | - 'filename' => 'registrations_details', |
|
430 | - ), |
|
431 | - 'registrations_details_table_help_tab' => array( |
|
432 | - 'title' => __('Registration Details Table', 'event_espresso'), |
|
433 | - 'filename' => 'registrations_details_table', |
|
434 | - ), |
|
435 | - 'registrations_details_form_answers_help_tab' => array( |
|
436 | - 'title' => __('Registration Form Answers', 'event_espresso'), |
|
437 | - 'filename' => 'registrations_details_form_answers', |
|
438 | - ), |
|
439 | - 'registrations_details_registrant_details_help_tab' => array( |
|
440 | - 'title' => __('Contact Details', 'event_espresso'), |
|
441 | - 'filename' => 'registrations_details_registrant_details', |
|
442 | - ), |
|
443 | - ), |
|
444 | - 'help_tour' => array('Registration_Details_Help_Tour'), |
|
445 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
446 | - array('_registration_details_metaboxes')), |
|
447 | - 'require_nonce' => false, |
|
448 | - ), |
|
449 | - 'new_registration' => array( |
|
450 | - 'nav' => array( |
|
451 | - 'label' => __('Add New Registration', 'event_espresso'), |
|
452 | - 'url' => '#', |
|
453 | - 'order' => 15, |
|
454 | - 'persistent' => false, |
|
455 | - ), |
|
456 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
457 | - 'labels' => array( |
|
458 | - 'publishbox' => __('Save Registration', 'event_espresso'), |
|
459 | - ), |
|
460 | - 'require_nonce' => false, |
|
461 | - ), |
|
462 | - 'add_new_attendee' => array( |
|
463 | - 'nav' => array( |
|
464 | - 'label' => __('Add Contact', 'event_espresso'), |
|
465 | - 'order' => 15, |
|
466 | - 'persistent' => false, |
|
467 | - ), |
|
468 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
469 | - array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
470 | - 'require_nonce' => false, |
|
471 | - ), |
|
472 | - 'edit_attendee' => array( |
|
473 | - 'nav' => array( |
|
474 | - 'label' => __('Edit Contact', 'event_espresso'), |
|
475 | - 'order' => 15, |
|
476 | - 'persistent' => false, |
|
477 | - 'url' => isset($this->_req_data['ATT_ID']) |
|
478 | - ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
479 | - : $this->_admin_base_url, |
|
480 | - ), |
|
481 | - 'metaboxes' => array('attendee_editor_metaboxes'), |
|
482 | - 'require_nonce' => false, |
|
483 | - ), |
|
484 | - 'contact_list' => array( |
|
485 | - 'nav' => array( |
|
486 | - 'label' => __('Contact List', 'event_espresso'), |
|
487 | - 'order' => 20, |
|
488 | - ), |
|
489 | - 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
490 | - 'help_tabs' => array( |
|
491 | - 'registrations_contact_list_help_tab' => array( |
|
492 | - 'title' => __('Registrations Contact List', 'event_espresso'), |
|
493 | - 'filename' => 'registrations_contact_list', |
|
494 | - ), |
|
495 | - 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
496 | - 'title' => __('Contact List Table Column Headings', 'event_espresso'), |
|
497 | - 'filename' => 'registrations_contact_list_table_column_headings', |
|
498 | - ), |
|
499 | - 'registrations_contact_list_views_help_tab' => array( |
|
500 | - 'title' => __('Contact List Views', 'event_espresso'), |
|
501 | - 'filename' => 'registrations_contact_list_views', |
|
502 | - ), |
|
503 | - 'registrations_contact_list_other_help_tab' => array( |
|
504 | - 'title' => __('Contact List Other', 'event_espresso'), |
|
505 | - 'filename' => 'registrations_contact_list_other', |
|
506 | - ), |
|
507 | - ), |
|
508 | - 'help_tour' => array('Contact_List_Help_Tour'), |
|
509 | - 'metaboxes' => array(), |
|
510 | - 'require_nonce' => false, |
|
511 | - ), |
|
512 | - //override default cpt routes |
|
513 | - 'create_new' => '', |
|
514 | - 'edit' => '', |
|
515 | - ); |
|
516 | - } |
|
517 | - |
|
518 | - |
|
519 | - |
|
520 | - /** |
|
521 | - * The below methods aren't used by this class currently |
|
522 | - */ |
|
523 | - protected function _add_screen_options() |
|
524 | - { |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - |
|
529 | - protected function _add_feature_pointers() |
|
530 | - { |
|
531 | - } |
|
532 | - |
|
533 | - |
|
534 | - |
|
535 | - public function admin_init() |
|
536 | - { |
|
537 | - EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', |
|
538 | - 'event_espresso'); |
|
539 | - } |
|
540 | - |
|
541 | - |
|
542 | - |
|
543 | - public function admin_notices() |
|
544 | - { |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - |
|
549 | - public function admin_footer_scripts() |
|
550 | - { |
|
551 | - } |
|
552 | - |
|
553 | - |
|
554 | - |
|
555 | - /** |
|
556 | - * get list of registration statuses |
|
557 | - * |
|
558 | - * @access private |
|
559 | - * @return void |
|
560 | - */ |
|
561 | - private function _get_registration_status_array() |
|
562 | - { |
|
563 | - self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
564 | - } |
|
565 | - |
|
566 | - |
|
567 | - |
|
568 | - protected function _add_screen_options_default() |
|
569 | - { |
|
570 | - $this->_per_page_screen_option(); |
|
571 | - } |
|
572 | - |
|
573 | - |
|
574 | - |
|
575 | - protected function _add_screen_options_contact_list() |
|
576 | - { |
|
577 | - $page_title = $this->_admin_page_title; |
|
578 | - $this->_admin_page_title = __("Contacts", 'event_espresso'); |
|
579 | - $this->_per_page_screen_option(); |
|
580 | - $this->_admin_page_title = $page_title; |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - |
|
585 | - public function load_scripts_styles() |
|
586 | - { |
|
587 | - //style |
|
588 | - //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
589 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
590 | - EVENT_ESPRESSO_VERSION); |
|
591 | - wp_enqueue_style('espresso_reg'); |
|
592 | - //script |
|
593 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
594 | - array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
|
595 | - wp_enqueue_script('espresso_reg'); |
|
596 | - } |
|
597 | - |
|
598 | - |
|
599 | - |
|
600 | - public function load_scripts_styles_edit_attendee() |
|
601 | - { |
|
602 | - //stuff to only show up on our attendee edit details page. |
|
603 | - $attendee_details_translations = array( |
|
604 | - 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
605 | - $this->_cpt_model_obj->get_datetime('ATT_created')), |
|
606 | - ); |
|
607 | - wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
608 | - wp_enqueue_script('jquery-validate'); |
|
609 | - } |
|
610 | - |
|
611 | - |
|
612 | - |
|
613 | - public function load_scripts_styles_view_registration() |
|
614 | - { |
|
615 | - //styles |
|
616 | - wp_enqueue_style('espresso-ui-theme'); |
|
617 | - //scripts |
|
618 | - $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
619 | - $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
620 | - } |
|
621 | - |
|
622 | - |
|
623 | - |
|
624 | - public function load_scripts_styles_contact_list() |
|
625 | - { |
|
626 | - wp_deregister_style('espresso_reg'); |
|
627 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
628 | - EVENT_ESPRESSO_VERSION); |
|
629 | - wp_enqueue_style('espresso_att'); |
|
630 | - } |
|
631 | - |
|
632 | - |
|
633 | - |
|
634 | - public function load_scripts_styles_new_registration() |
|
635 | - { |
|
636 | - wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
637 | - EVENT_ESPRESSO_VERSION, true); |
|
638 | - wp_enqueue_script('ee-spco-for-admin'); |
|
639 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
640 | - EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
641 | - EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
642 | - EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
643 | - } |
|
644 | - |
|
645 | - |
|
646 | - |
|
647 | - public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
648 | - { |
|
649 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
650 | - } |
|
651 | - |
|
652 | - |
|
653 | - |
|
654 | - public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
655 | - { |
|
656 | - add_filter('FHEE_load_EE_messages', '__return_true'); |
|
657 | - } |
|
658 | - |
|
659 | - |
|
660 | - |
|
661 | - protected function _set_list_table_views_default() |
|
662 | - { |
|
663 | - //for notification related bulk actions we need to make sure only active messengers have an option. |
|
664 | - EED_Messages::set_autoloaders(); |
|
665 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
666 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
667 | - $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
668 | - //key= bulk_action_slug, value= message type. |
|
669 | - $match_array = array( |
|
670 | - 'approve_registration' => 'registration', |
|
671 | - 'decline_registration' => 'declined_registration', |
|
672 | - 'pending_registration' => 'pending_approval', |
|
673 | - 'no_approve_registration' => 'not_approved_registration', |
|
674 | - 'cancel_registration' => 'cancelled_registration', |
|
675 | - ); |
|
676 | - /** setup reg status bulk actions **/ |
|
677 | - $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
|
678 | - if (in_array($match_array['approve_registration'], $active_mts) |
|
679 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
680 | - ) { |
|
681 | - $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', |
|
682 | - 'event_espresso'); |
|
683 | - } |
|
684 | - $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
|
685 | - if (in_array($match_array['decline_registration'], $active_mts) |
|
686 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
687 | - ) { |
|
688 | - $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', |
|
689 | - 'event_espresso'); |
|
690 | - } |
|
691 | - $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
|
692 | - if (in_array($match_array['pending_registration'], $active_mts) |
|
693 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
694 | - ) { |
|
695 | - $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', |
|
696 | - 'event_espresso'); |
|
697 | - } |
|
698 | - $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
|
699 | - if (in_array($match_array['no_approve_registration'], $active_mts) |
|
700 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
701 | - ) { |
|
702 | - $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', |
|
703 | - 'event_espresso'); |
|
704 | - } |
|
705 | - $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
|
706 | - if (in_array($match_array['cancel_registration'], $active_mts) |
|
707 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
708 | - ) { |
|
709 | - $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', |
|
710 | - 'event_espresso'); |
|
711 | - } |
|
712 | - $this->_views = array( |
|
713 | - 'all' => array( |
|
714 | - 'slug' => 'all', |
|
715 | - 'label' => __('View All Registrations', 'event_espresso'), |
|
716 | - 'count' => 0, |
|
717 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
718 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
719 | - )), |
|
720 | - ), |
|
721 | - 'month' => array( |
|
722 | - 'slug' => 'month', |
|
723 | - 'label' => __('This Month', 'event_espresso'), |
|
724 | - 'count' => 0, |
|
725 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
726 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
727 | - )), |
|
728 | - ), |
|
729 | - 'today' => array( |
|
730 | - 'slug' => 'today', |
|
731 | - 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
732 | - 'count' => 0, |
|
733 | - 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
734 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
735 | - )), |
|
736 | - ), |
|
737 | - ); |
|
738 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
739 | - 'espresso_registrations_delete_registration') |
|
740 | - ) { |
|
741 | - $this->_views['incomplete'] = array( |
|
742 | - 'slug' => 'incomplete', |
|
743 | - 'label' => __('Incomplete', 'event_espresso'), |
|
744 | - 'count' => 0, |
|
745 | - 'bulk_action' => array( |
|
746 | - 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
747 | - ), |
|
748 | - ); |
|
749 | - $this->_views['trash'] = array( |
|
750 | - 'slug' => 'trash', |
|
751 | - 'label' => __('Trash', 'event_espresso'), |
|
752 | - 'count' => 0, |
|
753 | - 'bulk_action' => array( |
|
754 | - 'restore_registrations' => __('Restore Registrations', 'event_espresso'), |
|
755 | - 'delete_registrations' => __('Delete Registrations Permanently', 'event_espresso'), |
|
756 | - ), |
|
757 | - ); |
|
758 | - } |
|
759 | - } |
|
760 | - |
|
761 | - |
|
762 | - |
|
763 | - protected function _set_list_table_views_contact_list() |
|
764 | - { |
|
765 | - $this->_views = array( |
|
766 | - 'in_use' => array( |
|
767 | - 'slug' => 'in_use', |
|
768 | - 'label' => __('In Use', 'event_espresso'), |
|
769 | - 'count' => 0, |
|
770 | - 'bulk_action' => array( |
|
771 | - 'trash_attendees' => __('Move to Trash', 'event_espresso'), |
|
772 | - ), |
|
773 | - ), |
|
774 | - ); |
|
775 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
776 | - 'espresso_registrations_trash_attendees') |
|
777 | - ) { |
|
778 | - $this->_views['trash'] = array( |
|
779 | - 'slug' => 'trash', |
|
780 | - 'label' => __('Trash', 'event_espresso'), |
|
781 | - 'count' => 0, |
|
782 | - 'bulk_action' => array( |
|
783 | - 'restore_attendees' => __('Restore from Trash', 'event_espresso'), |
|
784 | - ), |
|
785 | - ); |
|
786 | - } |
|
787 | - } |
|
788 | - |
|
789 | - |
|
790 | - |
|
791 | - protected function _registration_legend_items() |
|
792 | - { |
|
793 | - $fc_items = array( |
|
794 | - 'star-icon' => array( |
|
795 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
796 | - 'desc' => __('This is the Primary Registrant', 'event_espresso'), |
|
797 | - ), |
|
798 | - 'view_details' => array( |
|
799 | - 'class' => 'dashicons dashicons-clipboard', |
|
800 | - 'desc' => __('View Registration Details', 'event_espresso'), |
|
801 | - ), |
|
802 | - 'edit_attendee' => array( |
|
803 | - 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
804 | - 'desc' => __('Edit Contact Details', 'event_espresso'), |
|
805 | - ), |
|
806 | - 'view_transaction' => array( |
|
807 | - 'class' => 'dashicons dashicons-cart', |
|
808 | - 'desc' => __('View Transaction Details', 'event_espresso'), |
|
809 | - ), |
|
810 | - 'view_invoice' => array( |
|
811 | - 'class' => 'dashicons dashicons-media-spreadsheet', |
|
812 | - 'desc' => __('View Transaction Invoice', 'event_espresso'), |
|
813 | - ), |
|
814 | - ); |
|
815 | - if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
816 | - 'espresso_registrations_resend_registration') |
|
817 | - ) { |
|
818 | - $fc_items['resend_registration'] = array( |
|
819 | - 'class' => 'dashicons dashicons-email-alt', |
|
820 | - 'desc' => __('Resend Registration Details', 'event_espresso'), |
|
821 | - ); |
|
822 | - } else { |
|
823 | - $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
824 | - } |
|
825 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
826 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
827 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
828 | - $fc_items['view_related_messages'] = array( |
|
829 | - 'class' => $related_for_icon['css_class'], |
|
830 | - 'desc' => $related_for_icon['label'], |
|
831 | - ); |
|
832 | - } |
|
833 | - } |
|
834 | - $sc_items = array( |
|
835 | - 'approved_status' => array( |
|
836 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
837 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
838 | - ), |
|
839 | - 'pending_status' => array( |
|
840 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
841 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
842 | - ), |
|
843 | - 'wait_list' => array( |
|
844 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
845 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
846 | - ), |
|
847 | - 'incomplete_status' => array( |
|
848 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
849 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
|
850 | - ), |
|
851 | - 'not_approved' => array( |
|
852 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
853 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
854 | - ), |
|
855 | - 'declined_status' => array( |
|
856 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
857 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
858 | - ), |
|
859 | - 'cancelled_status' => array( |
|
860 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
861 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
862 | - ), |
|
863 | - ); |
|
864 | - return array_merge($fc_items, $sc_items); |
|
865 | - } |
|
866 | - |
|
867 | - |
|
868 | - |
|
869 | - /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
870 | - /** |
|
871 | - * @throws \EE_Error |
|
872 | - */ |
|
873 | - protected function _registrations_overview_list_table() |
|
874 | - { |
|
875 | - $this->_template_args['admin_page_header'] = ''; |
|
876 | - $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
877 | - if ($EVT_ID) { |
|
878 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
|
879 | - 'espresso_registrations_new_registration', $EVT_ID) |
|
880 | - ) { |
|
881 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
882 | - array('event_id' => $EVT_ID), 'add-new-h2'); |
|
883 | - } |
|
884 | - $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
885 | - if ($event instanceof EE_Event) { |
|
886 | - $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
|
887 | - 'event_espresso'), '<h3 style="line-height:1.5em;">', |
|
888 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
889 | - 'action' => 'edit', |
|
890 | - 'post' => $event->ID(), |
|
891 | - ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
892 | - } |
|
893 | - $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
894 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
895 | - if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
896 | - $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
897 | - $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
898 | - $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
899 | - $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
900 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
901 | - $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
902 | - } |
|
903 | - } |
|
904 | - $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
905 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
906 | - } |
|
907 | - |
|
908 | - |
|
909 | - |
|
910 | - /** |
|
911 | - * This sets the _registration property for the registration details screen |
|
912 | - * |
|
913 | - * @access private |
|
914 | - * @return bool |
|
915 | - */ |
|
916 | - private function _set_registration_object() |
|
917 | - { |
|
918 | - //get out if we've already set the object |
|
919 | - if (is_object($this->_registration)) { |
|
920 | - return true; |
|
921 | - } |
|
922 | - $REG = EEM_Registration::instance(); |
|
923 | - $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
924 | - if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
925 | - return true; |
|
926 | - } else { |
|
927 | - $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
928 | - 'event_espresso'), $REG_ID); |
|
929 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
930 | - $this->_registration = null; |
|
931 | - return false; |
|
932 | - } |
|
933 | - } |
|
934 | - |
|
935 | - |
|
936 | - |
|
937 | - /** |
|
938 | - * get registrations for given parameters (used by list table) |
|
939 | - * |
|
940 | - * @param int $per_page how many registrations displayed per page |
|
941 | - * @param boolean $count return the count or objects |
|
942 | - * @param boolean $this_month whether to return for just this month |
|
943 | - * @param boolean $today whether to return results for just today |
|
944 | - * @throws \EE_Error |
|
945 | - * @return mixed (int|array) int = count || array of registration objects |
|
946 | - */ |
|
947 | - public function get_registrations($per_page = 10, $count = false, $this_month = false, $today = false) |
|
948 | - { |
|
949 | - $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 |
|
950 | - ? absint($this->_req_data['event_id']) : false; |
|
951 | - $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int)$this->_req_data['EVT_CAT'] > 0 |
|
952 | - ? absint($this->_req_data['EVT_CAT']) : false; |
|
953 | - $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null; |
|
954 | - $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) |
|
955 | - : false; |
|
956 | - $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) |
|
957 | - : false;//should be like 2013-april |
|
958 | - $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? true : false; |
|
959 | - $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? true : false; |
|
960 | - $start_date = false; |
|
961 | - $end_date = false; |
|
962 | - $_where = array(); |
|
963 | - $trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? true : false; |
|
964 | - $incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? true : false; |
|
965 | - //set orderby |
|
966 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
967 | - switch ($this->_req_data['orderby']) { |
|
968 | - case '_REG_ID': |
|
969 | - $orderby = 'REG_ID'; |
|
970 | - break; |
|
971 | - case '_Reg_status': |
|
972 | - $orderby = 'STS_ID'; |
|
973 | - break; |
|
974 | - case 'ATT_fname': |
|
975 | - $orderby = 'Attendee.ATT_lname'; |
|
976 | - break; |
|
977 | - case 'event_name': |
|
978 | - $orderby = 'Event.EVT_name'; |
|
979 | - break; |
|
980 | - case 'DTT_EVT_start': |
|
981 | - $orderby = 'Event.Datetime.DTT_EVT_start'; |
|
982 | - break; |
|
983 | - default: //'REG_date' |
|
984 | - $orderby = 'REG_date'; |
|
985 | - } |
|
986 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
987 | - : 'DESC'; |
|
988 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
989 | - ? $this->_req_data['paged'] : 1; |
|
990 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
991 | - ? $this->_req_data['perpage'] : $per_page; |
|
992 | - $offset = ($current_page - 1) * $per_page; |
|
993 | - $limit = $count ? null : array($offset, $per_page); |
|
994 | - if ($EVT_ID) { |
|
995 | - $_where['EVT_ID'] = $EVT_ID; |
|
996 | - } |
|
997 | - if ($CAT_ID) { |
|
998 | - $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID; |
|
999 | - } |
|
1000 | - //if DTT is included we filter by that datetime. |
|
1001 | - if ($DTT_ID) { |
|
1002 | - $_where['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
1003 | - } |
|
1004 | - if ($incomplete) { |
|
1005 | - $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
1006 | - } else if ( ! $trash) { |
|
1007 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
1008 | - } |
|
1009 | - if ($reg_status) { |
|
1010 | - $_where['STS_ID'] = $reg_status; |
|
1011 | - } |
|
1012 | - $this_year_r = date('Y', current_time('timestamp')); |
|
1013 | - $time_start = ' 00:00:00'; |
|
1014 | - $time_end = ' 23:59:59'; |
|
1015 | - if ($today_a || $today) { |
|
1016 | - $curdate = date('Y-m-d', current_time('timestamp')); |
|
1017 | - $_where['REG_date'] = array( |
|
1018 | - 'BETWEEN', |
|
1019 | - array( |
|
1020 | - EEM_Registration::instance() |
|
1021 | - ->convert_datetime_for_query('REG_date', $curdate . $time_start, 'Y-m-d H:i:s'), |
|
1022 | - EEM_Registration::instance() |
|
1023 | - ->convert_datetime_for_query('REG_date', $curdate . $time_end, 'Y-m-d H:i:s'), |
|
1024 | - ), |
|
1025 | - ); |
|
1026 | - } elseif ($this_month_a || $this_month) { |
|
1027 | - $this_month_r = date('m', current_time('timestamp')); |
|
1028 | - $days_this_month = date('t', current_time('timestamp')); |
|
1029 | - $_where['REG_date'] = array( |
|
1030 | - 'BETWEEN', |
|
1031 | - array( |
|
1032 | - EEM_Registration::instance() |
|
1033 | - ->convert_datetime_for_query('REG_date', |
|
1034 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s'), |
|
1035 | - EEM_Registration::instance() |
|
1036 | - ->convert_datetime_for_query('REG_date', |
|
1037 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
1038 | - 'Y-m-d H:i:s'), |
|
1039 | - ), |
|
1040 | - ); |
|
1041 | - } elseif ($month_range) { |
|
1042 | - $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1043 | - $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : ''; |
|
1044 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1045 | - $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01')); |
|
1046 | - $_where['REG_date'] = array( |
|
1047 | - 'BETWEEN', |
|
1048 | - array( |
|
1049 | - EEM_Registration::instance() |
|
1050 | - ->convert_datetime_for_query('REG_date', $year_r . '-' . $month_r . '-01 00:00:00', |
|
1051 | - 'Y-m-d H:i:s'), |
|
1052 | - EEM_Registration::instance() |
|
1053 | - ->convert_datetime_for_query('REG_date', |
|
1054 | - $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s'), |
|
1055 | - ), |
|
1056 | - ); |
|
1057 | - } elseif ($start_date && $end_date) { |
|
1058 | - throw new EE_Error("not yet supported"); |
|
1059 | - } elseif ($start_date) { |
|
1060 | - throw new EE_Error("not yet supported"); |
|
1061 | - } elseif ($end_date) { |
|
1062 | - throw new EE_Error("not yet supported"); |
|
1063 | - } |
|
1064 | - if ( ! empty($this->_req_data['s'])) { |
|
1065 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1066 | - $_where['OR'] = array( |
|
1067 | - 'Event.EVT_name' => array('LIKE', $sstr), |
|
1068 | - 'Event.EVT_desc' => array('LIKE', $sstr), |
|
1069 | - 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
1070 | - 'Attendee.ATT_full_name' => array('LIKE', $sstr), |
|
1071 | - 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
1072 | - 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
1073 | - 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
1074 | - 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
1075 | - 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
1076 | - 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
1077 | - 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
1078 | - 'REG_final_price' => array('LIKE', $sstr), |
|
1079 | - 'REG_code' => array('LIKE', $sstr), |
|
1080 | - 'REG_count' => array('LIKE', $sstr), |
|
1081 | - 'REG_group_size' => array('LIKE', $sstr), |
|
1082 | - 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
1083 | - 'Ticket.TKT_description' => array('LIKE', $sstr), |
|
1084 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr), |
|
1085 | - ); |
|
1086 | - } |
|
1087 | - //capability checks |
|
1088 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) { |
|
1089 | - $_where['AND'] = array( |
|
1090 | - 'Event.EVT_wp_user' => get_current_user_id(), |
|
1091 | - ); |
|
1092 | - } |
|
1093 | - if ($count) { |
|
1094 | - if ($trash) { |
|
1095 | - return EEM_Registration::instance()->count_deleted(array($_where)); |
|
1096 | - } else if ($incomplete) { |
|
1097 | - return EEM_Registration::instance()->count(array($_where)); |
|
1098 | - } else { |
|
1099 | - return EEM_Registration::instance()->count(array( |
|
1100 | - $_where, |
|
1101 | - 'default_where_conditions' => 'this_model_only', |
|
1102 | - )); |
|
1103 | - } |
|
1104 | - } else { |
|
1105 | - //make sure we remove default where conditions cause all registrations matching query are returned |
|
1106 | - $query_params = array( |
|
1107 | - $_where, |
|
1108 | - 'order_by' => array($orderby => $sort), |
|
1109 | - 'default_where_conditions' => 'this_model_only', |
|
1110 | - ); |
|
1111 | - if ($per_page !== -1) { |
|
1112 | - $query_params['limit'] = $limit; |
|
1113 | - } |
|
1114 | - $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) |
|
1115 | - : EEM_Registration::instance()->get_all($query_params); |
|
1116 | - if ($EVT_ID |
|
1117 | - && isset($registrations[0]) |
|
1118 | - && $registrations[0] instanceof EE_Registration |
|
1119 | - && $registrations[0]->event_obj() |
|
1120 | - ) { |
|
1121 | - $first_registration = $registrations[0]; |
|
1122 | - //EEH_Debug_Tools::printr( $registrations[0], '$registrations <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
1123 | - $event_name = $first_registration->event_obj()->name(); |
|
1124 | - $event_date = $first_registration->date_obj() |
|
1125 | - ->start_date_and_time('l F j, Y,', |
|
1126 | - 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1127 | - // edit event link |
|
1128 | - if ($event_name != '') { |
|
1129 | - $edit_event_url = self::add_query_args_and_nonce(array( |
|
1130 | - 'action' => 'edit_event', |
|
1131 | - 'EVT_ID' => $EVT_ID, |
|
1132 | - ), EVENTS_ADMIN_URL); |
|
1133 | - $edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__('Edit ', |
|
1134 | - 'event_espresso') . $event_name . '">' . __('Edit Event', 'event_espresso') . '</a>'; |
|
1135 | - $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>'; |
|
1136 | - } |
|
1137 | - $back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL); |
|
1138 | - $back_2_reg_lnk = '<a href="' |
|
1139 | - . $back_2_reg_url |
|
1140 | - . '" title="' |
|
1141 | - . esc_attr__('click to return to viewing all registrations ', 'event_espresso') |
|
1142 | - . '">« ' |
|
1143 | - . __('Back to All Registrations', 'event_espresso') |
|
1144 | - . '</a>'; |
|
1145 | - $this->_template_args['before_admin_page_content'] = ' |
|
27 | + /** |
|
28 | + * @var EE_Registration |
|
29 | + */ |
|
30 | + private $_registration; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var EE_Event |
|
34 | + */ |
|
35 | + private $_reg_event; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var EE_Session |
|
39 | + */ |
|
40 | + private $_session; |
|
41 | + |
|
42 | + private static $_reg_status; |
|
43 | + |
|
44 | + /** |
|
45 | + * Form for displaying the custom questions for this registration. |
|
46 | + * This gets used a few times throughout the request so its best to cache it |
|
47 | + * |
|
48 | + * @var EE_Registration_Custom_Questions_Form |
|
49 | + */ |
|
50 | + protected $_reg_custom_questions_form = null; |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * constructor |
|
56 | + * |
|
57 | + * @Constructor |
|
58 | + * @access public |
|
59 | + * @param bool $routing |
|
60 | + * @return Registrations_Admin_Page |
|
61 | + */ |
|
62 | + public function __construct($routing = true) |
|
63 | + { |
|
64 | + parent::__construct($routing); |
|
65 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + public function wp_loaded() |
|
71 | + { |
|
72 | + // when adding a new registration... |
|
73 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') { |
|
74 | + EE_System::do_not_cache(); |
|
75 | + if ( ! isset($this->_req_data['processing_registration']) |
|
76 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
77 | + ) { |
|
78 | + // and it's NOT the attendee information reg step |
|
79 | + // force cookie expiration by setting time to last week |
|
80 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
81 | + // and update the global |
|
82 | + $_COOKIE['ee_registration_added'] = 0; |
|
83 | + } |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + protected function _init_page_props() |
|
90 | + { |
|
91 | + $this->page_slug = REG_PG_SLUG; |
|
92 | + $this->_admin_base_url = REG_ADMIN_URL; |
|
93 | + $this->_admin_base_path = REG_ADMIN; |
|
94 | + $this->page_label = __('Registrations', 'event_espresso'); |
|
95 | + $this->_cpt_routes = array( |
|
96 | + 'add_new_attendee' => 'espresso_attendees', |
|
97 | + 'edit_attendee' => 'espresso_attendees', |
|
98 | + 'insert_attendee' => 'espresso_attendees', |
|
99 | + 'update_attendee' => 'espresso_attendees', |
|
100 | + ); |
|
101 | + $this->_cpt_model_names = array( |
|
102 | + 'add_new_attendee' => 'EEM_Attendee', |
|
103 | + 'edit_attendee' => 'EEM_Attendee', |
|
104 | + ); |
|
105 | + $this->_cpt_edit_routes = array( |
|
106 | + 'espresso_attendees' => 'edit_attendee', |
|
107 | + ); |
|
108 | + $this->_pagenow_map = array( |
|
109 | + 'add_new_attendee' => 'post-new.php', |
|
110 | + 'edit_attendee' => 'post.php', |
|
111 | + 'trash' => 'post.php', |
|
112 | + ); |
|
113 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
114 | + //add filters so that the comment urls don't take users to a confusing 404 page |
|
115 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + |
|
120 | + public function clear_comment_link($link, $comment, $args) |
|
121 | + { |
|
122 | + //gotta make sure this only happens on this route |
|
123 | + $post_type = get_post_type($comment->comment_post_ID); |
|
124 | + if ($post_type === 'espresso_attendees') { |
|
125 | + return '#commentsdiv'; |
|
126 | + } |
|
127 | + return $link; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + protected function _ajax_hooks() |
|
133 | + { |
|
134 | + //todo: all hooks for registrations ajax goes in here |
|
135 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + protected function _define_page_props() |
|
141 | + { |
|
142 | + $this->_admin_page_title = $this->page_label; |
|
143 | + $this->_labels = array( |
|
144 | + 'buttons' => array( |
|
145 | + 'add-registrant' => __('Add New Registration', 'event_espresso'), |
|
146 | + 'add-attendee' => __('Add Contact', 'event_espresso'), |
|
147 | + 'edit' => __('Edit Contact', 'event_espresso'), |
|
148 | + 'report' => __("Event Registrations CSV Report", "event_espresso"), |
|
149 | + 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
150 | + 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
151 | + 'contact_list_export' => __("Export Data", "event_espresso"), |
|
152 | + ), |
|
153 | + 'publishbox' => array( |
|
154 | + 'add_new_attendee' => __("Add Contact Record", 'event_espresso'), |
|
155 | + 'edit_attendee' => __("Update Contact Record", 'event_espresso'), |
|
156 | + ), |
|
157 | + 'hide_add_button_on_cpt_route' => array( |
|
158 | + 'edit_attendee' => true, |
|
159 | + ), |
|
160 | + ); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * grab url requests and route them |
|
167 | + * |
|
168 | + * @access private |
|
169 | + * @return void |
|
170 | + */ |
|
171 | + public function _set_page_routes() |
|
172 | + { |
|
173 | + $this->_get_registration_status_array(); |
|
174 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
175 | + ? $this->_req_data['_REG_ID'] : 0; |
|
176 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) |
|
177 | + ? $this->_req_data['ATT_ID'] : 0; |
|
178 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] |
|
179 | + : $att_id; |
|
180 | + $this->_page_routes = array( |
|
181 | + 'default' => array( |
|
182 | + 'func' => '_registrations_overview_list_table', |
|
183 | + 'capability' => 'ee_read_registrations', |
|
184 | + ), |
|
185 | + 'view_registration' => array( |
|
186 | + 'func' => '_registration_details', |
|
187 | + 'capability' => 'ee_read_registration', |
|
188 | + 'obj_id' => $reg_id, |
|
189 | + ), |
|
190 | + 'edit_registration' => array( |
|
191 | + 'func' => '_update_attendee_registration_form', |
|
192 | + 'noheader' => true, |
|
193 | + 'headers_sent_route' => 'view_registration', |
|
194 | + 'capability' => 'ee_edit_registration', |
|
195 | + 'obj_id' => $reg_id, |
|
196 | + '_REG_ID' => $reg_id, |
|
197 | + ), |
|
198 | + 'trash_registrations' => array( |
|
199 | + 'func' => '_trash_or_restore_registrations', |
|
200 | + 'args' => array('trash' => true), |
|
201 | + 'noheader' => true, |
|
202 | + 'capability' => 'ee_delete_registrations', |
|
203 | + ), |
|
204 | + 'restore_registrations' => array( |
|
205 | + 'func' => '_trash_or_restore_registrations', |
|
206 | + 'args' => array('trash' => false), |
|
207 | + 'noheader' => true, |
|
208 | + 'capability' => 'ee_delete_registrations', |
|
209 | + ), |
|
210 | + 'delete_registrations' => array( |
|
211 | + 'func' => '_delete_registrations', |
|
212 | + 'noheader' => true, |
|
213 | + 'capability' => 'ee_delete_registrations', |
|
214 | + ), |
|
215 | + 'new_registration' => array( |
|
216 | + 'func' => 'new_registration', |
|
217 | + 'capability' => 'ee_edit_registrations', |
|
218 | + ), |
|
219 | + 'process_reg_step' => array( |
|
220 | + 'func' => 'process_reg_step', |
|
221 | + 'noheader' => true, |
|
222 | + 'capability' => 'ee_edit_registrations', |
|
223 | + ), |
|
224 | + 'redirect_to_txn' => array( |
|
225 | + 'func' => 'redirect_to_txn', |
|
226 | + 'noheader' => true, |
|
227 | + 'capability' => 'ee_edit_registrations', |
|
228 | + ), |
|
229 | + 'change_reg_status' => array( |
|
230 | + 'func' => '_change_reg_status', |
|
231 | + 'noheader' => true, |
|
232 | + 'capability' => 'ee_edit_registration', |
|
233 | + 'obj_id' => $reg_id, |
|
234 | + ), |
|
235 | + 'approve_registration' => array( |
|
236 | + 'func' => 'approve_registration', |
|
237 | + 'noheader' => true, |
|
238 | + 'capability' => 'ee_edit_registration', |
|
239 | + 'obj_id' => $reg_id, |
|
240 | + ), |
|
241 | + 'approve_and_notify_registration' => array( |
|
242 | + 'func' => 'approve_registration', |
|
243 | + 'noheader' => true, |
|
244 | + 'args' => array(true), |
|
245 | + 'capability' => 'ee_edit_registration', |
|
246 | + 'obj_id' => $reg_id, |
|
247 | + ), |
|
248 | + 'decline_registration' => array( |
|
249 | + 'func' => 'decline_registration', |
|
250 | + 'noheader' => true, |
|
251 | + 'capability' => 'ee_edit_registration', |
|
252 | + 'obj_id' => $reg_id, |
|
253 | + ), |
|
254 | + 'decline_and_notify_registration' => array( |
|
255 | + 'func' => 'decline_registration', |
|
256 | + 'noheader' => true, |
|
257 | + 'args' => array(true), |
|
258 | + 'capability' => 'ee_edit_registration', |
|
259 | + 'obj_id' => $reg_id, |
|
260 | + ), |
|
261 | + 'pending_registration' => array( |
|
262 | + 'func' => 'pending_registration', |
|
263 | + 'noheader' => true, |
|
264 | + 'capability' => 'ee_edit_registration', |
|
265 | + 'obj_id' => $reg_id, |
|
266 | + ), |
|
267 | + 'pending_and_notify_registration' => array( |
|
268 | + 'func' => 'pending_registration', |
|
269 | + 'noheader' => true, |
|
270 | + 'args' => array(true), |
|
271 | + 'capability' => 'ee_edit_registration', |
|
272 | + 'obj_id' => $reg_id, |
|
273 | + ), |
|
274 | + 'no_approve_registration' => array( |
|
275 | + 'func' => 'not_approve_registration', |
|
276 | + 'noheader' => true, |
|
277 | + 'capability' => 'ee_edit_registration', |
|
278 | + 'obj_id' => $reg_id, |
|
279 | + ), |
|
280 | + 'no_approve_and_notify_registration' => array( |
|
281 | + 'func' => 'not_approve_registration', |
|
282 | + 'noheader' => true, |
|
283 | + 'args' => array(true), |
|
284 | + 'capability' => 'ee_edit_registration', |
|
285 | + 'obj_id' => $reg_id, |
|
286 | + ), |
|
287 | + 'cancel_registration' => array( |
|
288 | + 'func' => 'cancel_registration', |
|
289 | + 'noheader' => true, |
|
290 | + 'capability' => 'ee_edit_registration', |
|
291 | + 'obj_id' => $reg_id, |
|
292 | + ), |
|
293 | + 'cancel_and_notify_registration' => array( |
|
294 | + 'func' => 'cancel_registration', |
|
295 | + 'noheader' => true, |
|
296 | + 'args' => array(true), |
|
297 | + 'capability' => 'ee_edit_registration', |
|
298 | + 'obj_id' => $reg_id, |
|
299 | + ), |
|
300 | + 'contact_list' => array( |
|
301 | + 'func' => '_attendee_contact_list_table', |
|
302 | + 'capability' => 'ee_read_contacts', |
|
303 | + ), |
|
304 | + 'add_new_attendee' => array( |
|
305 | + 'func' => '_create_new_cpt_item', |
|
306 | + 'args' => array( |
|
307 | + 'new_attendee' => true, |
|
308 | + 'capability' => 'ee_edit_contacts', |
|
309 | + ), |
|
310 | + ), |
|
311 | + 'edit_attendee' => array( |
|
312 | + 'func' => '_edit_cpt_item', |
|
313 | + 'capability' => 'ee_edit_contacts', |
|
314 | + 'obj_id' => $att_id, |
|
315 | + ), |
|
316 | + 'duplicate_attendee' => array( |
|
317 | + 'func' => '_duplicate_attendee', |
|
318 | + 'noheader' => true, |
|
319 | + 'capability' => 'ee_edit_contacts', |
|
320 | + 'obj_id' => $att_id, |
|
321 | + ), |
|
322 | + 'insert_attendee' => array( |
|
323 | + 'func' => '_insert_or_update_attendee', |
|
324 | + 'args' => array( |
|
325 | + 'new_attendee' => true, |
|
326 | + ), |
|
327 | + 'noheader' => true, |
|
328 | + 'capability' => 'ee_edit_contacts', |
|
329 | + ), |
|
330 | + 'update_attendee' => array( |
|
331 | + 'func' => '_insert_or_update_attendee', |
|
332 | + 'args' => array( |
|
333 | + 'new_attendee' => false, |
|
334 | + ), |
|
335 | + 'noheader' => true, |
|
336 | + 'capability' => 'ee_edit_contacts', |
|
337 | + 'obj_id' => $att_id, |
|
338 | + ), |
|
339 | + 'trash_attendees' => array( |
|
340 | + 'func' => '_trash_or_restore_attendees', |
|
341 | + 'args' => array( |
|
342 | + 'trash' => true, |
|
343 | + ), |
|
344 | + 'noheader' => true, |
|
345 | + 'capability' => 'ee_delete_contacts', |
|
346 | + 'obj_id' => $att_id, |
|
347 | + ), |
|
348 | + 'restore_attendees' => array( |
|
349 | + 'func' => '_trash_or_restore_attendees', |
|
350 | + 'args' => array( |
|
351 | + 'trash' => false, |
|
352 | + ), |
|
353 | + 'noheader' => true, |
|
354 | + 'capability' => 'ee_delete_contacts', |
|
355 | + 'obj_id' => $att_id, |
|
356 | + ), |
|
357 | + 'resend_registration' => array( |
|
358 | + 'func' => '_resend_registration', |
|
359 | + 'noheader' => true, |
|
360 | + 'capability' => 'ee_send_message', |
|
361 | + ), |
|
362 | + 'registrations_report' => array( |
|
363 | + 'func' => '_registrations_report', |
|
364 | + 'noheader' => true, |
|
365 | + 'capability' => 'ee_read_registrations', |
|
366 | + ), |
|
367 | + 'contact_list_export' => array( |
|
368 | + 'func' => '_contact_list_export', |
|
369 | + 'noheader' => true, |
|
370 | + 'capability' => 'export', |
|
371 | + ), |
|
372 | + 'contact_list_report' => array( |
|
373 | + 'func' => '_contact_list_report', |
|
374 | + 'noheader' => true, |
|
375 | + 'capability' => 'ee_read_contacts', |
|
376 | + ), |
|
377 | + ); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + |
|
382 | + protected function _set_page_config() |
|
383 | + { |
|
384 | + $this->_page_config = array( |
|
385 | + 'default' => array( |
|
386 | + 'nav' => array( |
|
387 | + 'label' => __('Overview', 'event_espresso'), |
|
388 | + 'order' => 5, |
|
389 | + ), |
|
390 | + 'help_tabs' => array( |
|
391 | + 'registrations_overview_help_tab' => array( |
|
392 | + 'title' => __('Registrations Overview', 'event_espresso'), |
|
393 | + 'filename' => 'registrations_overview', |
|
394 | + ), |
|
395 | + 'registrations_overview_table_column_headings_help_tab' => array( |
|
396 | + 'title' => __('Registrations Table Column Headings', 'event_espresso'), |
|
397 | + 'filename' => 'registrations_overview_table_column_headings', |
|
398 | + ), |
|
399 | + 'registrations_overview_filters_help_tab' => array( |
|
400 | + 'title' => __('Registration Filters', 'event_espresso'), |
|
401 | + 'filename' => 'registrations_overview_filters', |
|
402 | + ), |
|
403 | + 'registrations_overview_views_help_tab' => array( |
|
404 | + 'title' => __('Registration Views', 'event_espresso'), |
|
405 | + 'filename' => 'registrations_overview_views', |
|
406 | + ), |
|
407 | + 'registrations_regoverview_other_help_tab' => array( |
|
408 | + 'title' => __('Registrations Other', 'event_espresso'), |
|
409 | + 'filename' => 'registrations_overview_other', |
|
410 | + ), |
|
411 | + ), |
|
412 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
413 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
414 | + 'list_table' => 'EE_Registrations_List_Table', |
|
415 | + 'require_nonce' => false, |
|
416 | + ), |
|
417 | + 'view_registration' => array( |
|
418 | + 'nav' => array( |
|
419 | + 'label' => __('REG Details', 'event_espresso'), |
|
420 | + 'order' => 15, |
|
421 | + 'url' => isset($this->_req_data['_REG_ID']) |
|
422 | + ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) |
|
423 | + : $this->_admin_base_url, |
|
424 | + 'persistent' => false, |
|
425 | + ), |
|
426 | + 'help_tabs' => array( |
|
427 | + 'registrations_details_help_tab' => array( |
|
428 | + 'title' => __('Registration Details', 'event_espresso'), |
|
429 | + 'filename' => 'registrations_details', |
|
430 | + ), |
|
431 | + 'registrations_details_table_help_tab' => array( |
|
432 | + 'title' => __('Registration Details Table', 'event_espresso'), |
|
433 | + 'filename' => 'registrations_details_table', |
|
434 | + ), |
|
435 | + 'registrations_details_form_answers_help_tab' => array( |
|
436 | + 'title' => __('Registration Form Answers', 'event_espresso'), |
|
437 | + 'filename' => 'registrations_details_form_answers', |
|
438 | + ), |
|
439 | + 'registrations_details_registrant_details_help_tab' => array( |
|
440 | + 'title' => __('Contact Details', 'event_espresso'), |
|
441 | + 'filename' => 'registrations_details_registrant_details', |
|
442 | + ), |
|
443 | + ), |
|
444 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
445 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
446 | + array('_registration_details_metaboxes')), |
|
447 | + 'require_nonce' => false, |
|
448 | + ), |
|
449 | + 'new_registration' => array( |
|
450 | + 'nav' => array( |
|
451 | + 'label' => __('Add New Registration', 'event_espresso'), |
|
452 | + 'url' => '#', |
|
453 | + 'order' => 15, |
|
454 | + 'persistent' => false, |
|
455 | + ), |
|
456 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
457 | + 'labels' => array( |
|
458 | + 'publishbox' => __('Save Registration', 'event_espresso'), |
|
459 | + ), |
|
460 | + 'require_nonce' => false, |
|
461 | + ), |
|
462 | + 'add_new_attendee' => array( |
|
463 | + 'nav' => array( |
|
464 | + 'label' => __('Add Contact', 'event_espresso'), |
|
465 | + 'order' => 15, |
|
466 | + 'persistent' => false, |
|
467 | + ), |
|
468 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, |
|
469 | + array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
470 | + 'require_nonce' => false, |
|
471 | + ), |
|
472 | + 'edit_attendee' => array( |
|
473 | + 'nav' => array( |
|
474 | + 'label' => __('Edit Contact', 'event_espresso'), |
|
475 | + 'order' => 15, |
|
476 | + 'persistent' => false, |
|
477 | + 'url' => isset($this->_req_data['ATT_ID']) |
|
478 | + ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) |
|
479 | + : $this->_admin_base_url, |
|
480 | + ), |
|
481 | + 'metaboxes' => array('attendee_editor_metaboxes'), |
|
482 | + 'require_nonce' => false, |
|
483 | + ), |
|
484 | + 'contact_list' => array( |
|
485 | + 'nav' => array( |
|
486 | + 'label' => __('Contact List', 'event_espresso'), |
|
487 | + 'order' => 20, |
|
488 | + ), |
|
489 | + 'list_table' => 'EE_Attendee_Contact_List_Table', |
|
490 | + 'help_tabs' => array( |
|
491 | + 'registrations_contact_list_help_tab' => array( |
|
492 | + 'title' => __('Registrations Contact List', 'event_espresso'), |
|
493 | + 'filename' => 'registrations_contact_list', |
|
494 | + ), |
|
495 | + 'registrations_contact-list_table_column_headings_help_tab' => array( |
|
496 | + 'title' => __('Contact List Table Column Headings', 'event_espresso'), |
|
497 | + 'filename' => 'registrations_contact_list_table_column_headings', |
|
498 | + ), |
|
499 | + 'registrations_contact_list_views_help_tab' => array( |
|
500 | + 'title' => __('Contact List Views', 'event_espresso'), |
|
501 | + 'filename' => 'registrations_contact_list_views', |
|
502 | + ), |
|
503 | + 'registrations_contact_list_other_help_tab' => array( |
|
504 | + 'title' => __('Contact List Other', 'event_espresso'), |
|
505 | + 'filename' => 'registrations_contact_list_other', |
|
506 | + ), |
|
507 | + ), |
|
508 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
509 | + 'metaboxes' => array(), |
|
510 | + 'require_nonce' => false, |
|
511 | + ), |
|
512 | + //override default cpt routes |
|
513 | + 'create_new' => '', |
|
514 | + 'edit' => '', |
|
515 | + ); |
|
516 | + } |
|
517 | + |
|
518 | + |
|
519 | + |
|
520 | + /** |
|
521 | + * The below methods aren't used by this class currently |
|
522 | + */ |
|
523 | + protected function _add_screen_options() |
|
524 | + { |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + |
|
529 | + protected function _add_feature_pointers() |
|
530 | + { |
|
531 | + } |
|
532 | + |
|
533 | + |
|
534 | + |
|
535 | + public function admin_init() |
|
536 | + { |
|
537 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', |
|
538 | + 'event_espresso'); |
|
539 | + } |
|
540 | + |
|
541 | + |
|
542 | + |
|
543 | + public function admin_notices() |
|
544 | + { |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + |
|
549 | + public function admin_footer_scripts() |
|
550 | + { |
|
551 | + } |
|
552 | + |
|
553 | + |
|
554 | + |
|
555 | + /** |
|
556 | + * get list of registration statuses |
|
557 | + * |
|
558 | + * @access private |
|
559 | + * @return void |
|
560 | + */ |
|
561 | + private function _get_registration_status_array() |
|
562 | + { |
|
563 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), true); |
|
564 | + } |
|
565 | + |
|
566 | + |
|
567 | + |
|
568 | + protected function _add_screen_options_default() |
|
569 | + { |
|
570 | + $this->_per_page_screen_option(); |
|
571 | + } |
|
572 | + |
|
573 | + |
|
574 | + |
|
575 | + protected function _add_screen_options_contact_list() |
|
576 | + { |
|
577 | + $page_title = $this->_admin_page_title; |
|
578 | + $this->_admin_page_title = __("Contacts", 'event_espresso'); |
|
579 | + $this->_per_page_screen_option(); |
|
580 | + $this->_admin_page_title = $page_title; |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + |
|
585 | + public function load_scripts_styles() |
|
586 | + { |
|
587 | + //style |
|
588 | + //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
589 | + wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), |
|
590 | + EVENT_ESPRESSO_VERSION); |
|
591 | + wp_enqueue_style('espresso_reg'); |
|
592 | + //script |
|
593 | + wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', |
|
594 | + array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true); |
|
595 | + wp_enqueue_script('espresso_reg'); |
|
596 | + } |
|
597 | + |
|
598 | + |
|
599 | + |
|
600 | + public function load_scripts_styles_edit_attendee() |
|
601 | + { |
|
602 | + //stuff to only show up on our attendee edit details page. |
|
603 | + $attendee_details_translations = array( |
|
604 | + 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), |
|
605 | + $this->_cpt_model_obj->get_datetime('ATT_created')), |
|
606 | + ); |
|
607 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
608 | + wp_enqueue_script('jquery-validate'); |
|
609 | + } |
|
610 | + |
|
611 | + |
|
612 | + |
|
613 | + public function load_scripts_styles_view_registration() |
|
614 | + { |
|
615 | + //styles |
|
616 | + wp_enqueue_style('espresso-ui-theme'); |
|
617 | + //scripts |
|
618 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
619 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
620 | + } |
|
621 | + |
|
622 | + |
|
623 | + |
|
624 | + public function load_scripts_styles_contact_list() |
|
625 | + { |
|
626 | + wp_deregister_style('espresso_reg'); |
|
627 | + wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), |
|
628 | + EVENT_ESPRESSO_VERSION); |
|
629 | + wp_enqueue_style('espresso_att'); |
|
630 | + } |
|
631 | + |
|
632 | + |
|
633 | + |
|
634 | + public function load_scripts_styles_new_registration() |
|
635 | + { |
|
636 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), |
|
637 | + EVENT_ESPRESSO_VERSION, true); |
|
638 | + wp_enqueue_script('ee-spco-for-admin'); |
|
639 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
640 | + EE_Form_Section_Proper::wp_enqueue_scripts(); |
|
641 | + EED_Ticket_Selector::load_tckt_slctr_assets(); |
|
642 | + EE_Datepicker_Input::enqueue_styles_and_scripts(); |
|
643 | + } |
|
644 | + |
|
645 | + |
|
646 | + |
|
647 | + public function AHEE__EE_Admin_Page__route_admin_request_resend_registration() |
|
648 | + { |
|
649 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
650 | + } |
|
651 | + |
|
652 | + |
|
653 | + |
|
654 | + public function AHEE__EE_Admin_Page__route_admin_request_approve_registration() |
|
655 | + { |
|
656 | + add_filter('FHEE_load_EE_messages', '__return_true'); |
|
657 | + } |
|
658 | + |
|
659 | + |
|
660 | + |
|
661 | + protected function _set_list_table_views_default() |
|
662 | + { |
|
663 | + //for notification related bulk actions we need to make sure only active messengers have an option. |
|
664 | + EED_Messages::set_autoloaders(); |
|
665 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
666 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
667 | + $active_mts = $message_resource_manager->list_of_active_message_types(); |
|
668 | + //key= bulk_action_slug, value= message type. |
|
669 | + $match_array = array( |
|
670 | + 'approve_registration' => 'registration', |
|
671 | + 'decline_registration' => 'declined_registration', |
|
672 | + 'pending_registration' => 'pending_approval', |
|
673 | + 'no_approve_registration' => 'not_approved_registration', |
|
674 | + 'cancel_registration' => 'cancelled_registration', |
|
675 | + ); |
|
676 | + /** setup reg status bulk actions **/ |
|
677 | + $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
|
678 | + if (in_array($match_array['approve_registration'], $active_mts) |
|
679 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
680 | + ) { |
|
681 | + $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', |
|
682 | + 'event_espresso'); |
|
683 | + } |
|
684 | + $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
|
685 | + if (in_array($match_array['decline_registration'], $active_mts) |
|
686 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
687 | + ) { |
|
688 | + $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', |
|
689 | + 'event_espresso'); |
|
690 | + } |
|
691 | + $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
|
692 | + if (in_array($match_array['pending_registration'], $active_mts) |
|
693 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
694 | + ) { |
|
695 | + $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', |
|
696 | + 'event_espresso'); |
|
697 | + } |
|
698 | + $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
|
699 | + if (in_array($match_array['no_approve_registration'], $active_mts) |
|
700 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
701 | + ) { |
|
702 | + $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', |
|
703 | + 'event_espresso'); |
|
704 | + } |
|
705 | + $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
|
706 | + if (in_array($match_array['cancel_registration'], $active_mts) |
|
707 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages') |
|
708 | + ) { |
|
709 | + $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', |
|
710 | + 'event_espresso'); |
|
711 | + } |
|
712 | + $this->_views = array( |
|
713 | + 'all' => array( |
|
714 | + 'slug' => 'all', |
|
715 | + 'label' => __('View All Registrations', 'event_espresso'), |
|
716 | + 'count' => 0, |
|
717 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
718 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
719 | + )), |
|
720 | + ), |
|
721 | + 'month' => array( |
|
722 | + 'slug' => 'month', |
|
723 | + 'label' => __('This Month', 'event_espresso'), |
|
724 | + 'count' => 0, |
|
725 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
726 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
727 | + )), |
|
728 | + ), |
|
729 | + 'today' => array( |
|
730 | + 'slug' => 'today', |
|
731 | + 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
732 | + 'count' => 0, |
|
733 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
734 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
735 | + )), |
|
736 | + ), |
|
737 | + ); |
|
738 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
739 | + 'espresso_registrations_delete_registration') |
|
740 | + ) { |
|
741 | + $this->_views['incomplete'] = array( |
|
742 | + 'slug' => 'incomplete', |
|
743 | + 'label' => __('Incomplete', 'event_espresso'), |
|
744 | + 'count' => 0, |
|
745 | + 'bulk_action' => array( |
|
746 | + 'trash_registrations' => __('Trash Registrations', 'event_espresso'), |
|
747 | + ), |
|
748 | + ); |
|
749 | + $this->_views['trash'] = array( |
|
750 | + 'slug' => 'trash', |
|
751 | + 'label' => __('Trash', 'event_espresso'), |
|
752 | + 'count' => 0, |
|
753 | + 'bulk_action' => array( |
|
754 | + 'restore_registrations' => __('Restore Registrations', 'event_espresso'), |
|
755 | + 'delete_registrations' => __('Delete Registrations Permanently', 'event_espresso'), |
|
756 | + ), |
|
757 | + ); |
|
758 | + } |
|
759 | + } |
|
760 | + |
|
761 | + |
|
762 | + |
|
763 | + protected function _set_list_table_views_contact_list() |
|
764 | + { |
|
765 | + $this->_views = array( |
|
766 | + 'in_use' => array( |
|
767 | + 'slug' => 'in_use', |
|
768 | + 'label' => __('In Use', 'event_espresso'), |
|
769 | + 'count' => 0, |
|
770 | + 'bulk_action' => array( |
|
771 | + 'trash_attendees' => __('Move to Trash', 'event_espresso'), |
|
772 | + ), |
|
773 | + ), |
|
774 | + ); |
|
775 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', |
|
776 | + 'espresso_registrations_trash_attendees') |
|
777 | + ) { |
|
778 | + $this->_views['trash'] = array( |
|
779 | + 'slug' => 'trash', |
|
780 | + 'label' => __('Trash', 'event_espresso'), |
|
781 | + 'count' => 0, |
|
782 | + 'bulk_action' => array( |
|
783 | + 'restore_attendees' => __('Restore from Trash', 'event_espresso'), |
|
784 | + ), |
|
785 | + ); |
|
786 | + } |
|
787 | + } |
|
788 | + |
|
789 | + |
|
790 | + |
|
791 | + protected function _registration_legend_items() |
|
792 | + { |
|
793 | + $fc_items = array( |
|
794 | + 'star-icon' => array( |
|
795 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
796 | + 'desc' => __('This is the Primary Registrant', 'event_espresso'), |
|
797 | + ), |
|
798 | + 'view_details' => array( |
|
799 | + 'class' => 'dashicons dashicons-clipboard', |
|
800 | + 'desc' => __('View Registration Details', 'event_espresso'), |
|
801 | + ), |
|
802 | + 'edit_attendee' => array( |
|
803 | + 'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16', |
|
804 | + 'desc' => __('Edit Contact Details', 'event_espresso'), |
|
805 | + ), |
|
806 | + 'view_transaction' => array( |
|
807 | + 'class' => 'dashicons dashicons-cart', |
|
808 | + 'desc' => __('View Transaction Details', 'event_espresso'), |
|
809 | + ), |
|
810 | + 'view_invoice' => array( |
|
811 | + 'class' => 'dashicons dashicons-media-spreadsheet', |
|
812 | + 'desc' => __('View Transaction Invoice', 'event_espresso'), |
|
813 | + ), |
|
814 | + ); |
|
815 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
816 | + 'espresso_registrations_resend_registration') |
|
817 | + ) { |
|
818 | + $fc_items['resend_registration'] = array( |
|
819 | + 'class' => 'dashicons dashicons-email-alt', |
|
820 | + 'desc' => __('Resend Registration Details', 'event_espresso'), |
|
821 | + ); |
|
822 | + } else { |
|
823 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
824 | + } |
|
825 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
826 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
827 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
828 | + $fc_items['view_related_messages'] = array( |
|
829 | + 'class' => $related_for_icon['css_class'], |
|
830 | + 'desc' => $related_for_icon['label'], |
|
831 | + ); |
|
832 | + } |
|
833 | + } |
|
834 | + $sc_items = array( |
|
835 | + 'approved_status' => array( |
|
836 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
837 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
838 | + ), |
|
839 | + 'pending_status' => array( |
|
840 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
841 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
842 | + ), |
|
843 | + 'wait_list' => array( |
|
844 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
845 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
846 | + ), |
|
847 | + 'incomplete_status' => array( |
|
848 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
849 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'), |
|
850 | + ), |
|
851 | + 'not_approved' => array( |
|
852 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
853 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
854 | + ), |
|
855 | + 'declined_status' => array( |
|
856 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
857 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
858 | + ), |
|
859 | + 'cancelled_status' => array( |
|
860 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
861 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
862 | + ), |
|
863 | + ); |
|
864 | + return array_merge($fc_items, $sc_items); |
|
865 | + } |
|
866 | + |
|
867 | + |
|
868 | + |
|
869 | + /*************************************** REGISTRATION OVERVIEW **************************************/ |
|
870 | + /** |
|
871 | + * @throws \EE_Error |
|
872 | + */ |
|
873 | + protected function _registrations_overview_list_table() |
|
874 | + { |
|
875 | + $this->_template_args['admin_page_header'] = ''; |
|
876 | + $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
877 | + if ($EVT_ID) { |
|
878 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', |
|
879 | + 'espresso_registrations_new_registration', $EVT_ID) |
|
880 | + ) { |
|
881 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant', |
|
882 | + array('event_id' => $EVT_ID), 'add-new-h2'); |
|
883 | + } |
|
884 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
885 | + if ($event instanceof EE_Event) { |
|
886 | + $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s', |
|
887 | + 'event_espresso'), '<h3 style="line-height:1.5em;">', |
|
888 | + '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array( |
|
889 | + 'action' => 'edit', |
|
890 | + 'post' => $event->ID(), |
|
891 | + ), EVENTS_ADMIN_URL) . '"> ' . $event->get('EVT_name') . ' </a> ', '</h3>'); |
|
892 | + } |
|
893 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
894 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
895 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
896 | + $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
897 | + $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
|
898 | + $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
899 | + $this->_template_args['admin_page_header'] .= $datetime->name(); |
|
900 | + $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
901 | + $this->_template_args['admin_page_header'] .= '</span></h3>'; |
|
902 | + } |
|
903 | + } |
|
904 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
905 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
906 | + } |
|
907 | + |
|
908 | + |
|
909 | + |
|
910 | + /** |
|
911 | + * This sets the _registration property for the registration details screen |
|
912 | + * |
|
913 | + * @access private |
|
914 | + * @return bool |
|
915 | + */ |
|
916 | + private function _set_registration_object() |
|
917 | + { |
|
918 | + //get out if we've already set the object |
|
919 | + if (is_object($this->_registration)) { |
|
920 | + return true; |
|
921 | + } |
|
922 | + $REG = EEM_Registration::instance(); |
|
923 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false; |
|
924 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) { |
|
925 | + return true; |
|
926 | + } else { |
|
927 | + $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', |
|
928 | + 'event_espresso'), $REG_ID); |
|
929 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
930 | + $this->_registration = null; |
|
931 | + return false; |
|
932 | + } |
|
933 | + } |
|
934 | + |
|
935 | + |
|
936 | + |
|
937 | + /** |
|
938 | + * get registrations for given parameters (used by list table) |
|
939 | + * |
|
940 | + * @param int $per_page how many registrations displayed per page |
|
941 | + * @param boolean $count return the count or objects |
|
942 | + * @param boolean $this_month whether to return for just this month |
|
943 | + * @param boolean $today whether to return results for just today |
|
944 | + * @throws \EE_Error |
|
945 | + * @return mixed (int|array) int = count || array of registration objects |
|
946 | + */ |
|
947 | + public function get_registrations($per_page = 10, $count = false, $this_month = false, $today = false) |
|
948 | + { |
|
949 | + $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 |
|
950 | + ? absint($this->_req_data['event_id']) : false; |
|
951 | + $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int)$this->_req_data['EVT_CAT'] > 0 |
|
952 | + ? absint($this->_req_data['EVT_CAT']) : false; |
|
953 | + $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null; |
|
954 | + $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) |
|
955 | + : false; |
|
956 | + $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) |
|
957 | + : false;//should be like 2013-april |
|
958 | + $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? true : false; |
|
959 | + $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? true : false; |
|
960 | + $start_date = false; |
|
961 | + $end_date = false; |
|
962 | + $_where = array(); |
|
963 | + $trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? true : false; |
|
964 | + $incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? true : false; |
|
965 | + //set orderby |
|
966 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
967 | + switch ($this->_req_data['orderby']) { |
|
968 | + case '_REG_ID': |
|
969 | + $orderby = 'REG_ID'; |
|
970 | + break; |
|
971 | + case '_Reg_status': |
|
972 | + $orderby = 'STS_ID'; |
|
973 | + break; |
|
974 | + case 'ATT_fname': |
|
975 | + $orderby = 'Attendee.ATT_lname'; |
|
976 | + break; |
|
977 | + case 'event_name': |
|
978 | + $orderby = 'Event.EVT_name'; |
|
979 | + break; |
|
980 | + case 'DTT_EVT_start': |
|
981 | + $orderby = 'Event.Datetime.DTT_EVT_start'; |
|
982 | + break; |
|
983 | + default: //'REG_date' |
|
984 | + $orderby = 'REG_date'; |
|
985 | + } |
|
986 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
987 | + : 'DESC'; |
|
988 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
989 | + ? $this->_req_data['paged'] : 1; |
|
990 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
991 | + ? $this->_req_data['perpage'] : $per_page; |
|
992 | + $offset = ($current_page - 1) * $per_page; |
|
993 | + $limit = $count ? null : array($offset, $per_page); |
|
994 | + if ($EVT_ID) { |
|
995 | + $_where['EVT_ID'] = $EVT_ID; |
|
996 | + } |
|
997 | + if ($CAT_ID) { |
|
998 | + $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID; |
|
999 | + } |
|
1000 | + //if DTT is included we filter by that datetime. |
|
1001 | + if ($DTT_ID) { |
|
1002 | + $_where['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
1003 | + } |
|
1004 | + if ($incomplete) { |
|
1005 | + $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
1006 | + } else if ( ! $trash) { |
|
1007 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
1008 | + } |
|
1009 | + if ($reg_status) { |
|
1010 | + $_where['STS_ID'] = $reg_status; |
|
1011 | + } |
|
1012 | + $this_year_r = date('Y', current_time('timestamp')); |
|
1013 | + $time_start = ' 00:00:00'; |
|
1014 | + $time_end = ' 23:59:59'; |
|
1015 | + if ($today_a || $today) { |
|
1016 | + $curdate = date('Y-m-d', current_time('timestamp')); |
|
1017 | + $_where['REG_date'] = array( |
|
1018 | + 'BETWEEN', |
|
1019 | + array( |
|
1020 | + EEM_Registration::instance() |
|
1021 | + ->convert_datetime_for_query('REG_date', $curdate . $time_start, 'Y-m-d H:i:s'), |
|
1022 | + EEM_Registration::instance() |
|
1023 | + ->convert_datetime_for_query('REG_date', $curdate . $time_end, 'Y-m-d H:i:s'), |
|
1024 | + ), |
|
1025 | + ); |
|
1026 | + } elseif ($this_month_a || $this_month) { |
|
1027 | + $this_month_r = date('m', current_time('timestamp')); |
|
1028 | + $days_this_month = date('t', current_time('timestamp')); |
|
1029 | + $_where['REG_date'] = array( |
|
1030 | + 'BETWEEN', |
|
1031 | + array( |
|
1032 | + EEM_Registration::instance() |
|
1033 | + ->convert_datetime_for_query('REG_date', |
|
1034 | + $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s'), |
|
1035 | + EEM_Registration::instance() |
|
1036 | + ->convert_datetime_for_query('REG_date', |
|
1037 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
1038 | + 'Y-m-d H:i:s'), |
|
1039 | + ), |
|
1040 | + ); |
|
1041 | + } elseif ($month_range) { |
|
1042 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1043 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : ''; |
|
1044 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1045 | + $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01')); |
|
1046 | + $_where['REG_date'] = array( |
|
1047 | + 'BETWEEN', |
|
1048 | + array( |
|
1049 | + EEM_Registration::instance() |
|
1050 | + ->convert_datetime_for_query('REG_date', $year_r . '-' . $month_r . '-01 00:00:00', |
|
1051 | + 'Y-m-d H:i:s'), |
|
1052 | + EEM_Registration::instance() |
|
1053 | + ->convert_datetime_for_query('REG_date', |
|
1054 | + $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s'), |
|
1055 | + ), |
|
1056 | + ); |
|
1057 | + } elseif ($start_date && $end_date) { |
|
1058 | + throw new EE_Error("not yet supported"); |
|
1059 | + } elseif ($start_date) { |
|
1060 | + throw new EE_Error("not yet supported"); |
|
1061 | + } elseif ($end_date) { |
|
1062 | + throw new EE_Error("not yet supported"); |
|
1063 | + } |
|
1064 | + if ( ! empty($this->_req_data['s'])) { |
|
1065 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1066 | + $_where['OR'] = array( |
|
1067 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
1068 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
1069 | + 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
1070 | + 'Attendee.ATT_full_name' => array('LIKE', $sstr), |
|
1071 | + 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
1072 | + 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
1073 | + 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
1074 | + 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
1075 | + 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
1076 | + 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
1077 | + 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
1078 | + 'REG_final_price' => array('LIKE', $sstr), |
|
1079 | + 'REG_code' => array('LIKE', $sstr), |
|
1080 | + 'REG_count' => array('LIKE', $sstr), |
|
1081 | + 'REG_group_size' => array('LIKE', $sstr), |
|
1082 | + 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
1083 | + 'Ticket.TKT_description' => array('LIKE', $sstr), |
|
1084 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr), |
|
1085 | + ); |
|
1086 | + } |
|
1087 | + //capability checks |
|
1088 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) { |
|
1089 | + $_where['AND'] = array( |
|
1090 | + 'Event.EVT_wp_user' => get_current_user_id(), |
|
1091 | + ); |
|
1092 | + } |
|
1093 | + if ($count) { |
|
1094 | + if ($trash) { |
|
1095 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
1096 | + } else if ($incomplete) { |
|
1097 | + return EEM_Registration::instance()->count(array($_where)); |
|
1098 | + } else { |
|
1099 | + return EEM_Registration::instance()->count(array( |
|
1100 | + $_where, |
|
1101 | + 'default_where_conditions' => 'this_model_only', |
|
1102 | + )); |
|
1103 | + } |
|
1104 | + } else { |
|
1105 | + //make sure we remove default where conditions cause all registrations matching query are returned |
|
1106 | + $query_params = array( |
|
1107 | + $_where, |
|
1108 | + 'order_by' => array($orderby => $sort), |
|
1109 | + 'default_where_conditions' => 'this_model_only', |
|
1110 | + ); |
|
1111 | + if ($per_page !== -1) { |
|
1112 | + $query_params['limit'] = $limit; |
|
1113 | + } |
|
1114 | + $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) |
|
1115 | + : EEM_Registration::instance()->get_all($query_params); |
|
1116 | + if ($EVT_ID |
|
1117 | + && isset($registrations[0]) |
|
1118 | + && $registrations[0] instanceof EE_Registration |
|
1119 | + && $registrations[0]->event_obj() |
|
1120 | + ) { |
|
1121 | + $first_registration = $registrations[0]; |
|
1122 | + //EEH_Debug_Tools::printr( $registrations[0], '$registrations <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
1123 | + $event_name = $first_registration->event_obj()->name(); |
|
1124 | + $event_date = $first_registration->date_obj() |
|
1125 | + ->start_date_and_time('l F j, Y,', |
|
1126 | + 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1127 | + // edit event link |
|
1128 | + if ($event_name != '') { |
|
1129 | + $edit_event_url = self::add_query_args_and_nonce(array( |
|
1130 | + 'action' => 'edit_event', |
|
1131 | + 'EVT_ID' => $EVT_ID, |
|
1132 | + ), EVENTS_ADMIN_URL); |
|
1133 | + $edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__('Edit ', |
|
1134 | + 'event_espresso') . $event_name . '">' . __('Edit Event', 'event_espresso') . '</a>'; |
|
1135 | + $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>'; |
|
1136 | + } |
|
1137 | + $back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL); |
|
1138 | + $back_2_reg_lnk = '<a href="' |
|
1139 | + . $back_2_reg_url |
|
1140 | + . '" title="' |
|
1141 | + . esc_attr__('click to return to viewing all registrations ', 'event_espresso') |
|
1142 | + . '">« ' |
|
1143 | + . __('Back to All Registrations', 'event_espresso') |
|
1144 | + . '</a>'; |
|
1145 | + $this->_template_args['before_admin_page_content'] = ' |
|
1146 | 1146 | <div id="admin-page-header"> |
1147 | 1147 | <h1><span class="small-text not-bold">' . __('Event: ', 'event_espresso') . '</span>' . $event_name . '</h1> |
1148 | 1148 | <h3><span class="small-text not-bold">' . __('Date: ', 'event_espresso') . '</span>' . $event_date . '</h3> |
1149 | 1149 | <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
1150 | 1150 | </div> |
1151 | 1151 | '; |
1152 | - } |
|
1153 | - return $registrations; |
|
1154 | - } |
|
1155 | - } |
|
1156 | - |
|
1157 | - |
|
1158 | - |
|
1159 | - public function get_registration_status_array() |
|
1160 | - { |
|
1161 | - return self::$_reg_status; |
|
1162 | - } |
|
1163 | - |
|
1164 | - |
|
1165 | - |
|
1166 | - |
|
1167 | - /*************************************** REGISTRATION DETAILS ***************************************/ |
|
1168 | - /** |
|
1169 | - * generates HTML for the View Registration Details Admin page |
|
1170 | - * |
|
1171 | - * @access protected |
|
1172 | - * @return void |
|
1173 | - */ |
|
1174 | - protected function _registration_details() |
|
1175 | - { |
|
1176 | - $this->_template_args = array(); |
|
1177 | - $this->_set_registration_object(); |
|
1178 | - if (is_object($this->_registration)) { |
|
1179 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
1180 | - : EE_Transaction::new_instance(); |
|
1181 | - $this->_session = $transaction->session_data(); |
|
1182 | - $event_id = $this->_registration->event_ID(); |
|
1183 | - $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
1184 | - $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
1185 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
1186 | - $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
1187 | - $this->_template_args['grand_total'] = $transaction->total(); |
|
1188 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
1189 | - // link back to overview |
|
1190 | - $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
1191 | - $this->_template_args['registration'] = $this->_registration; |
|
1192 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1193 | - 'action' => 'default', |
|
1194 | - 'event_id' => $event_id, |
|
1195 | - ), REG_ADMIN_URL); |
|
1196 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1197 | - 'action' => 'default', |
|
1198 | - 'EVT_ID' => $event_id, |
|
1199 | - 'page' => 'espresso_transactions', |
|
1200 | - ), admin_url('admin.php')); |
|
1201 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1202 | - 'page' => 'espresso_events', |
|
1203 | - 'action' => 'edit', |
|
1204 | - 'post' => $event_id, |
|
1205 | - ), admin_url('admin.php')); |
|
1206 | - //next and previous links |
|
1207 | - $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
1208 | - $this->_template_args['next_registration'] = $next_reg |
|
1209 | - ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
1210 | - 'action' => 'view_registration', |
|
1211 | - '_REG_ID' => $next_reg['REG_ID'], |
|
1212 | - ), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
1213 | - $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
1214 | - $this->_template_args['previous_registration'] = $previous_reg |
|
1215 | - ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
1216 | - 'action' => 'view_registration', |
|
1217 | - '_REG_ID' => $previous_reg['REG_ID'], |
|
1218 | - ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
1219 | - // grab header |
|
1220 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
1221 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
1222 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
1223 | - $this->_template_args, true); |
|
1224 | - } else { |
|
1225 | - $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
1226 | - } |
|
1227 | - // the details template wrapper |
|
1228 | - $this->display_admin_page_with_sidebar(); |
|
1229 | - } |
|
1230 | - |
|
1231 | - |
|
1232 | - |
|
1233 | - protected function _registration_details_metaboxes() |
|
1234 | - { |
|
1235 | - do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
1236 | - $this->_set_registration_object(); |
|
1237 | - $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
1238 | - add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), |
|
1239 | - array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
1240 | - add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), |
|
1241 | - array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1242 | - if ($attendee instanceof EE_Attendee |
|
1243 | - && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox') |
|
1244 | - ) { |
|
1245 | - add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), |
|
1246 | - array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1247 | - } |
|
1248 | - add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), |
|
1249 | - array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
1250 | - if ($this->_registration->group_size() > 1) { |
|
1251 | - add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), |
|
1252 | - array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1253 | - } |
|
1254 | - } |
|
1255 | - |
|
1256 | - |
|
1257 | - |
|
1258 | - /** |
|
1259 | - * set_reg_status_buttons_metabox |
|
1260 | - * |
|
1261 | - * @access protected |
|
1262 | - * @return string |
|
1263 | - * @throws \EE_Error |
|
1264 | - */ |
|
1265 | - public function set_reg_status_buttons_metabox() |
|
1266 | - { |
|
1267 | - $this->_set_registration_object(); |
|
1268 | - $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
1269 | - echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array( |
|
1270 | - 'action' => 'change_reg_status', |
|
1271 | - ), REG_ADMIN_URL)); |
|
1272 | - echo $change_reg_status_form->get_html(); |
|
1273 | - echo $change_reg_status_form->form_close(); |
|
1274 | - } |
|
1275 | - |
|
1276 | - |
|
1277 | - |
|
1278 | - /** |
|
1279 | - * @return EE_Form_Section_Proper |
|
1280 | - */ |
|
1281 | - protected function _generate_reg_status_change_form() |
|
1282 | - { |
|
1283 | - return new EE_Form_Section_Proper(array( |
|
1284 | - 'name' => 'reg_status_change_form', |
|
1285 | - 'html_id' => 'reg-status-change-form', |
|
1286 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1287 | - 'subsections' => array( |
|
1288 | - 'return' => new EE_Hidden_Input(array( |
|
1289 | - 'name' => 'return', |
|
1290 | - 'default' => 'view_registration', |
|
1291 | - )), |
|
1292 | - 'REG_ID' => new EE_Hidden_Input(array( |
|
1293 | - 'name' => 'REG_ID', |
|
1294 | - 'default' => $this->_registration->ID(), |
|
1295 | - )), |
|
1296 | - 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
|
1297 | - 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
1298 | - '', 'status-' . $this->_registration->status_ID(), |
|
1299 | - 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
|
1300 | - 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
|
1301 | - 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
1302 | - 'default' => $this->_registration->status_ID(), |
|
1303 | - )), |
|
1304 | - 'send_notifications' => new EE_Yes_No_Input(array( |
|
1305 | - 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
1306 | - 'default' => false, |
|
1307 | - 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', |
|
1308 | - 'event_espresso'), |
|
1309 | - )), |
|
1310 | - 'submit' => new EE_Submit_Input(array( |
|
1311 | - 'html_class' => 'button-primary', |
|
1312 | - 'html_label_text' => ' ', |
|
1313 | - 'default' => __('Update Registration Status', 'event_espresso'), |
|
1314 | - )), |
|
1315 | - ), |
|
1316 | - )); |
|
1317 | - } |
|
1318 | - |
|
1319 | - |
|
1320 | - |
|
1321 | - /** |
|
1322 | - * Returns an array of all the buttons for the various statuses and switch status actions |
|
1323 | - * |
|
1324 | - * @return string |
|
1325 | - */ |
|
1326 | - protected function _get_current_reg_status_help_text($STS_ID = '') |
|
1327 | - { |
|
1328 | - //$reg_status_help_text = array( |
|
1329 | - // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1330 | - // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1331 | - // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1332 | - // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1333 | - // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1334 | - // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1335 | - //); |
|
1336 | - //Approved |
|
1337 | - //An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant . |
|
1338 | - //Cancelled |
|
1339 | - // A { |
|
1340 | - // cancelled} registration is performed by the registrant . Payments are not allowed, the registration is inactive, and no space is reserved . |
|
1341 | - //Declined |
|
1342 | - //A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved . |
|
1343 | - //Not Approved |
|
1344 | - //A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved . |
|
1345 | - //Pending Payment |
|
1346 | - //A pending registration allows payments . The status will be automatically toggled to approved if the { |
|
1347 | - // payment} is made in full by registrant . |
|
1348 | - } |
|
1349 | - |
|
1350 | - |
|
1351 | - |
|
1352 | - /** |
|
1353 | - * Returns an array of all the buttons for the various statuses and switch status actions |
|
1354 | - * |
|
1355 | - * @return array |
|
1356 | - */ |
|
1357 | - protected function _get_reg_statuses() |
|
1358 | - { |
|
1359 | - $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
1360 | - unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
1361 | - // get current reg status |
|
1362 | - $current_status = $this->_registration->status_ID(); |
|
1363 | - // is registration for free event? This will determine whether to display the pending payment option |
|
1364 | - if ($current_status != EEM_Registration::status_id_pending_payment |
|
1365 | - && $this->_registration->transaction() |
|
1366 | - ->is_free() |
|
1367 | - ) { |
|
1368 | - unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
1369 | - } |
|
1370 | - return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
1371 | - } |
|
1372 | - |
|
1373 | - |
|
1374 | - |
|
1375 | - /** |
|
1376 | - * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
1377 | - * |
|
1378 | - * @param bool $status REG status given for changing registrations to. |
|
1379 | - * @param bool $notify Whether to send messages notifications or not. |
|
1380 | - * @return array (array with reg_id(s) updated and whether update was successful. |
|
1381 | - */ |
|
1382 | - protected function _set_registration_status_from_request($status = false, $notify = false) |
|
1383 | - { |
|
1384 | - if (isset($this->_req_data['reg_status_change_form'])) { |
|
1385 | - $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
1386 | - ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
1387 | - } else { |
|
1388 | - $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
1389 | - } |
|
1390 | - $success = $this->_set_registration_status($REG_IDs, $status); |
|
1391 | - //notify? |
|
1392 | - if ($success |
|
1393 | - && $notify |
|
1394 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
1395 | - 'espresso_registrations_resend_registration') |
|
1396 | - ) { |
|
1397 | - $this->_process_resend_registration(); |
|
1398 | - } |
|
1399 | - return $success; |
|
1400 | - } |
|
1401 | - |
|
1402 | - |
|
1403 | - |
|
1404 | - /** |
|
1405 | - * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
1406 | - * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
1407 | - * |
|
1408 | - * @param array $REG_IDs |
|
1409 | - * @param bool $status |
|
1410 | - * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
1411 | - * the array of updated registrations). |
|
1412 | - */ |
|
1413 | - protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
1414 | - { |
|
1415 | - $success = false; |
|
1416 | - // typecast $REG_IDs |
|
1417 | - $REG_IDs = (array)$REG_IDs; |
|
1418 | - if ( ! empty($REG_IDs)) { |
|
1419 | - $success = true; |
|
1420 | - // set default status if none is passed |
|
1421 | - $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
1422 | - // sanitize $REG_IDs |
|
1423 | - $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
1424 | - //loop through REG_ID's and change status |
|
1425 | - foreach ($REG_IDs as $REG_ID) { |
|
1426 | - $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
1427 | - if ($registration instanceof EE_Registration) { |
|
1428 | - $registration->set_status($status); |
|
1429 | - $result = $registration->save(); |
|
1430 | - // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
1431 | - $success = $result !== false ? $success : false; |
|
1432 | - } |
|
1433 | - } |
|
1434 | - } |
|
1435 | - //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
1436 | - $this->_req_data['_REG_ID'] = $REG_IDs; |
|
1437 | - //return $success and processed registrations |
|
1438 | - return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
1439 | - } |
|
1440 | - |
|
1441 | - |
|
1442 | - |
|
1443 | - /** |
|
1444 | - * Common logic for setting up success message and redirecting to appropriate route |
|
1445 | - * |
|
1446 | - * @param string $STS_ID status id for the registration changed to |
|
1447 | - * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
1448 | - * @return void |
|
1449 | - */ |
|
1450 | - protected function _reg_status_change_return($STS_ID, $notify = false) |
|
1451 | - { |
|
1452 | - $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
1453 | - : array('success' => false); |
|
1454 | - $success = isset($result['success']) && $result['success']; |
|
1455 | - //setup success message |
|
1456 | - if ($success) { |
|
1457 | - if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
1458 | - $msg = sprintf(__('Registration status has been set to %s', 'event_espresso'), |
|
1459 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
1460 | - } else { |
|
1461 | - $msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'), |
|
1462 | - EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
1463 | - } |
|
1464 | - EE_Error::add_success($msg); |
|
1465 | - } else { |
|
1466 | - EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, |
|
1467 | - __LINE__, __FUNCTION__); |
|
1468 | - } |
|
1469 | - if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
1470 | - $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
1471 | - } else { |
|
1472 | - $route = array('action' => 'default'); |
|
1473 | - } |
|
1474 | - //unset nonces |
|
1475 | - foreach ($this->_req_data as $ref => $value) { |
|
1476 | - if (strpos($ref, 'nonce') !== false) { |
|
1477 | - unset($this->_req_data[$ref]); |
|
1478 | - continue; |
|
1479 | - } |
|
1480 | - $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
1481 | - $this->_req_data[$ref] = $value; |
|
1482 | - } |
|
1483 | - //merge request vars so that the reloaded list table contains any existing filter query params |
|
1484 | - $route = array_merge($this->_req_data, $route); |
|
1485 | - $this->_redirect_after_action($success, '', '', $route, true); |
|
1486 | - } |
|
1487 | - |
|
1488 | - |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * incoming reg status change from reg details page. |
|
1492 | - * |
|
1493 | - * @return void |
|
1494 | - */ |
|
1495 | - protected function _change_reg_status() |
|
1496 | - { |
|
1497 | - $this->_req_data['return'] = 'view_registration'; |
|
1498 | - //set notify based on whether the send notifications toggle is set or not |
|
1499 | - $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
1500 | - //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
1501 | - $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
1502 | - ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
1503 | - switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
1504 | - case EEM_Registration::status_id_approved : |
|
1505 | - case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
1506 | - $this->approve_registration($notify); |
|
1507 | - break; |
|
1508 | - case EEM_Registration::status_id_pending_payment : |
|
1509 | - case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
1510 | - $this->pending_registration($notify); |
|
1511 | - break; |
|
1512 | - case EEM_Registration::status_id_not_approved : |
|
1513 | - case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
1514 | - $this->not_approve_registration($notify); |
|
1515 | - break; |
|
1516 | - case EEM_Registration::status_id_declined : |
|
1517 | - case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
1518 | - $this->decline_registration($notify); |
|
1519 | - break; |
|
1520 | - case EEM_Registration::status_id_cancelled : |
|
1521 | - case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
1522 | - $this->cancel_registration($notify); |
|
1523 | - break; |
|
1524 | - case EEM_Registration::status_id_wait_list : |
|
1525 | - case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
1526 | - $this->waitlist_registration($notify); |
|
1527 | - break; |
|
1528 | - case EEM_Registration::status_id_incomplete : |
|
1529 | - default : |
|
1530 | - $result['success'] = false; |
|
1531 | - unset($this->_req_data['return']); |
|
1532 | - $this->_reg_status_change_return('', false); |
|
1533 | - break; |
|
1534 | - } |
|
1535 | - } |
|
1536 | - |
|
1537 | - |
|
1538 | - |
|
1539 | - /** |
|
1540 | - * approve_registration |
|
1541 | - * |
|
1542 | - * @access protected |
|
1543 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
1544 | - * @return void |
|
1545 | - */ |
|
1546 | - protected function approve_registration($notify = false) |
|
1547 | - { |
|
1548 | - $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
1549 | - } |
|
1550 | - |
|
1551 | - |
|
1552 | - |
|
1553 | - /** |
|
1554 | - * decline_registration |
|
1555 | - * |
|
1556 | - * @access protected |
|
1557 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
1558 | - * @return void |
|
1559 | - */ |
|
1560 | - protected function decline_registration($notify = false) |
|
1561 | - { |
|
1562 | - $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
1563 | - } |
|
1564 | - |
|
1565 | - |
|
1566 | - |
|
1567 | - /** |
|
1568 | - * cancel_registration |
|
1569 | - * |
|
1570 | - * @access protected |
|
1571 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
1572 | - * @return void |
|
1573 | - */ |
|
1574 | - protected function cancel_registration($notify = false) |
|
1575 | - { |
|
1576 | - $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
1577 | - } |
|
1578 | - |
|
1579 | - |
|
1580 | - |
|
1581 | - /** |
|
1582 | - * not_approve_registration |
|
1583 | - * |
|
1584 | - * @access protected |
|
1585 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
1586 | - * @return void |
|
1587 | - */ |
|
1588 | - protected function not_approve_registration($notify = false) |
|
1589 | - { |
|
1590 | - $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
1591 | - } |
|
1592 | - |
|
1593 | - |
|
1594 | - |
|
1595 | - /** |
|
1596 | - * decline_registration |
|
1597 | - * |
|
1598 | - * @access protected |
|
1599 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
1600 | - * @return void |
|
1601 | - */ |
|
1602 | - protected function pending_registration($notify = false) |
|
1603 | - { |
|
1604 | - $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
1605 | - } |
|
1606 | - |
|
1607 | - |
|
1608 | - |
|
1609 | - /** |
|
1610 | - * waitlist_registration |
|
1611 | - * |
|
1612 | - * @access protected |
|
1613 | - * @param bool $notify whether or not to notify the registrant about their status change. |
|
1614 | - * @return void |
|
1615 | - */ |
|
1616 | - protected function waitlist_registration($notify = false) |
|
1617 | - { |
|
1618 | - $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
1619 | - } |
|
1620 | - |
|
1621 | - |
|
1622 | - |
|
1623 | - /** |
|
1624 | - * generates HTML for the Registration main meta box |
|
1625 | - * |
|
1626 | - * @access public |
|
1627 | - * @return void |
|
1628 | - */ |
|
1629 | - public function _reg_details_meta_box() |
|
1630 | - { |
|
1631 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
1632 | - EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
1633 | - EE_Registry::instance()->load_helper('Line_Item'); |
|
1634 | - $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
1635 | - : EE_Transaction::new_instance(); |
|
1636 | - $this->_session = $transaction->session_data(); |
|
1637 | - $filters = new EE_Line_Item_Filter_Collection(); |
|
1638 | - //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
1639 | - $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
1640 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item()); |
|
1641 | - $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
1642 | - $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
1643 | - 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
1644 | - $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, |
|
1645 | - array('EE_Registration' => $this->_registration)); |
|
1646 | - $attendee = $this->_registration->attendee(); |
|
1647 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
1648 | - 'espresso_transactions_view_transaction') |
|
1649 | - ) { |
|
1650 | - $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
1651 | - 'action' => 'view_transaction', |
|
1652 | - 'TXN_ID' => $transaction->ID(), |
|
1653 | - ), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right', |
|
1654 | - 'dashicons dashicons-cart'); |
|
1655 | - } else { |
|
1656 | - $this->_template_args['view_transaction_button'] = ''; |
|
1657 | - } |
|
1658 | - if ($attendee instanceof EE_Attendee |
|
1659 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
1660 | - 'espresso_registrations_resend_registration') |
|
1661 | - ) { |
|
1662 | - $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
1663 | - 'action' => 'resend_registration', |
|
1664 | - '_REG_ID' => $this->_registration->ID(), |
|
1665 | - 'redirect_to' => 'view_registration', |
|
1666 | - ), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right', |
|
1667 | - 'dashicons dashicons-email-alt'); |
|
1668 | - } else { |
|
1669 | - $this->_template_args['resend_registration_button'] = ''; |
|
1670 | - } |
|
1671 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
1672 | - $payment = $transaction->get_first_related('Payment'); |
|
1673 | - $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
|
1674 | - $payment_method = $payment->get_first_related('Payment_Method'); |
|
1675 | - $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() |
|
1676 | - : $payment_method; |
|
1677 | - $reg_details = array( |
|
1678 | - 'payment_method' => $payment_method->name(), |
|
1679 | - 'response_msg' => $payment->gateway_response(), |
|
1680 | - 'registration_id' => $this->_registration->get('REG_code'), |
|
1681 | - 'registration_session' => $this->_registration->session_ID(), |
|
1682 | - 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
1683 | - 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
1684 | - ); |
|
1685 | - if (isset($reg_details['registration_id'])) { |
|
1686 | - $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
1687 | - $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
1688 | - $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
1689 | - } |
|
1690 | - if (isset($reg_details['payment_method'])) { |
|
1691 | - $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
1692 | - $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', |
|
1693 | - 'event_espresso'); |
|
1694 | - $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
1695 | - $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
1696 | - $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', |
|
1697 | - 'event_espresso'); |
|
1698 | - $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
1699 | - } |
|
1700 | - $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
1701 | - $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', |
|
1702 | - 'event_espresso'); |
|
1703 | - $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
1704 | - $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
1705 | - $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', |
|
1706 | - 'event_espresso'); |
|
1707 | - $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
1708 | - $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
1709 | - $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso'); |
|
1710 | - $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
1711 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1712 | - 'action' => 'default', |
|
1713 | - 'event_id' => $this->_registration->event_ID(), |
|
1714 | - ), REG_ADMIN_URL); |
|
1715 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
1716 | - $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
1717 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1718 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1719 | - } |
|
1720 | - |
|
1721 | - |
|
1722 | - |
|
1723 | - /** |
|
1724 | - * generates HTML for the Registration Questions meta box. |
|
1725 | - * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
1726 | - * otherwise uses new forms system |
|
1727 | - * |
|
1728 | - * @access public |
|
1729 | - * @return void |
|
1730 | - */ |
|
1731 | - public function _reg_questions_meta_box() |
|
1732 | - { |
|
1733 | - //allow someone to override this method entirely |
|
1734 | - if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
1735 | - $this->_registration)) { |
|
1736 | - $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
1737 | - $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
1738 | - $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
1739 | - $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
1740 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1741 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1742 | - } |
|
1743 | - } |
|
1744 | - |
|
1745 | - |
|
1746 | - |
|
1747 | - /** |
|
1748 | - * form_before_question_group |
|
1749 | - * |
|
1750 | - * @deprecated as of 4.8.32.rc.000 |
|
1751 | - * @access public |
|
1752 | - * @param string $output |
|
1753 | - * @return string |
|
1754 | - */ |
|
1755 | - public function form_before_question_group($output) |
|
1756 | - { |
|
1757 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1758 | - __('This method would have been protected but was used on a filter callback' |
|
1759 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
1760 | - '4.8.32.rc.000'); |
|
1761 | - return ' |
|
1152 | + } |
|
1153 | + return $registrations; |
|
1154 | + } |
|
1155 | + } |
|
1156 | + |
|
1157 | + |
|
1158 | + |
|
1159 | + public function get_registration_status_array() |
|
1160 | + { |
|
1161 | + return self::$_reg_status; |
|
1162 | + } |
|
1163 | + |
|
1164 | + |
|
1165 | + |
|
1166 | + |
|
1167 | + /*************************************** REGISTRATION DETAILS ***************************************/ |
|
1168 | + /** |
|
1169 | + * generates HTML for the View Registration Details Admin page |
|
1170 | + * |
|
1171 | + * @access protected |
|
1172 | + * @return void |
|
1173 | + */ |
|
1174 | + protected function _registration_details() |
|
1175 | + { |
|
1176 | + $this->_template_args = array(); |
|
1177 | + $this->_set_registration_object(); |
|
1178 | + if (is_object($this->_registration)) { |
|
1179 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
1180 | + : EE_Transaction::new_instance(); |
|
1181 | + $this->_session = $transaction->session_data(); |
|
1182 | + $event_id = $this->_registration->event_ID(); |
|
1183 | + $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
|
1184 | + $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
1185 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
1186 | + $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
1187 | + $this->_template_args['grand_total'] = $transaction->total(); |
|
1188 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
1189 | + // link back to overview |
|
1190 | + $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
|
1191 | + $this->_template_args['registration'] = $this->_registration; |
|
1192 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1193 | + 'action' => 'default', |
|
1194 | + 'event_id' => $event_id, |
|
1195 | + ), REG_ADMIN_URL); |
|
1196 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1197 | + 'action' => 'default', |
|
1198 | + 'EVT_ID' => $event_id, |
|
1199 | + 'page' => 'espresso_transactions', |
|
1200 | + ), admin_url('admin.php')); |
|
1201 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1202 | + 'page' => 'espresso_events', |
|
1203 | + 'action' => 'edit', |
|
1204 | + 'post' => $event_id, |
|
1205 | + ), admin_url('admin.php')); |
|
1206 | + //next and previous links |
|
1207 | + $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
1208 | + $this->_template_args['next_registration'] = $next_reg |
|
1209 | + ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
1210 | + 'action' => 'view_registration', |
|
1211 | + '_REG_ID' => $next_reg['REG_ID'], |
|
1212 | + ), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
1213 | + $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
1214 | + $this->_template_args['previous_registration'] = $previous_reg |
|
1215 | + ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
1216 | + 'action' => 'view_registration', |
|
1217 | + '_REG_ID' => $previous_reg['REG_ID'], |
|
1218 | + ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
1219 | + // grab header |
|
1220 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
1221 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
1222 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, |
|
1223 | + $this->_template_args, true); |
|
1224 | + } else { |
|
1225 | + $this->_template_args['admin_page_header'] = $this->display_espresso_notices(); |
|
1226 | + } |
|
1227 | + // the details template wrapper |
|
1228 | + $this->display_admin_page_with_sidebar(); |
|
1229 | + } |
|
1230 | + |
|
1231 | + |
|
1232 | + |
|
1233 | + protected function _registration_details_metaboxes() |
|
1234 | + { |
|
1235 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
1236 | + $this->_set_registration_object(); |
|
1237 | + $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
|
1238 | + add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), |
|
1239 | + array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
1240 | + add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), |
|
1241 | + array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1242 | + if ($attendee instanceof EE_Attendee |
|
1243 | + && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox') |
|
1244 | + ) { |
|
1245 | + add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), |
|
1246 | + array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1247 | + } |
|
1248 | + add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), |
|
1249 | + array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
1250 | + if ($this->_registration->group_size() > 1) { |
|
1251 | + add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), |
|
1252 | + array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1253 | + } |
|
1254 | + } |
|
1255 | + |
|
1256 | + |
|
1257 | + |
|
1258 | + /** |
|
1259 | + * set_reg_status_buttons_metabox |
|
1260 | + * |
|
1261 | + * @access protected |
|
1262 | + * @return string |
|
1263 | + * @throws \EE_Error |
|
1264 | + */ |
|
1265 | + public function set_reg_status_buttons_metabox() |
|
1266 | + { |
|
1267 | + $this->_set_registration_object(); |
|
1268 | + $change_reg_status_form = $this->_generate_reg_status_change_form(); |
|
1269 | + echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array( |
|
1270 | + 'action' => 'change_reg_status', |
|
1271 | + ), REG_ADMIN_URL)); |
|
1272 | + echo $change_reg_status_form->get_html(); |
|
1273 | + echo $change_reg_status_form->form_close(); |
|
1274 | + } |
|
1275 | + |
|
1276 | + |
|
1277 | + |
|
1278 | + /** |
|
1279 | + * @return EE_Form_Section_Proper |
|
1280 | + */ |
|
1281 | + protected function _generate_reg_status_change_form() |
|
1282 | + { |
|
1283 | + return new EE_Form_Section_Proper(array( |
|
1284 | + 'name' => 'reg_status_change_form', |
|
1285 | + 'html_id' => 'reg-status-change-form', |
|
1286 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1287 | + 'subsections' => array( |
|
1288 | + 'return' => new EE_Hidden_Input(array( |
|
1289 | + 'name' => 'return', |
|
1290 | + 'default' => 'view_registration', |
|
1291 | + )), |
|
1292 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
1293 | + 'name' => 'REG_ID', |
|
1294 | + 'default' => $this->_registration->ID(), |
|
1295 | + )), |
|
1296 | + 'current_status' => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status', |
|
1297 | + 'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(), |
|
1298 | + '', 'status-' . $this->_registration->status_ID(), |
|
1299 | + 'line-height: 1em; font-size: 1.5em; font-weight: bold;')))), |
|
1300 | + 'reg_status' => new EE_Select_Input($this->_get_reg_statuses(), array( |
|
1301 | + 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
1302 | + 'default' => $this->_registration->status_ID(), |
|
1303 | + )), |
|
1304 | + 'send_notifications' => new EE_Yes_No_Input(array( |
|
1305 | + 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
1306 | + 'default' => false, |
|
1307 | + 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', |
|
1308 | + 'event_espresso'), |
|
1309 | + )), |
|
1310 | + 'submit' => new EE_Submit_Input(array( |
|
1311 | + 'html_class' => 'button-primary', |
|
1312 | + 'html_label_text' => ' ', |
|
1313 | + 'default' => __('Update Registration Status', 'event_espresso'), |
|
1314 | + )), |
|
1315 | + ), |
|
1316 | + )); |
|
1317 | + } |
|
1318 | + |
|
1319 | + |
|
1320 | + |
|
1321 | + /** |
|
1322 | + * Returns an array of all the buttons for the various statuses and switch status actions |
|
1323 | + * |
|
1324 | + * @return string |
|
1325 | + */ |
|
1326 | + protected function _get_current_reg_status_help_text($STS_ID = '') |
|
1327 | + { |
|
1328 | + //$reg_status_help_text = array( |
|
1329 | + // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1330 | + // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1331 | + // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1332 | + // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1333 | + // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1334 | + // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
|
1335 | + //); |
|
1336 | + //Approved |
|
1337 | + //An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant . |
|
1338 | + //Cancelled |
|
1339 | + // A { |
|
1340 | + // cancelled} registration is performed by the registrant . Payments are not allowed, the registration is inactive, and no space is reserved . |
|
1341 | + //Declined |
|
1342 | + //A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved . |
|
1343 | + //Not Approved |
|
1344 | + //A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved . |
|
1345 | + //Pending Payment |
|
1346 | + //A pending registration allows payments . The status will be automatically toggled to approved if the { |
|
1347 | + // payment} is made in full by registrant . |
|
1348 | + } |
|
1349 | + |
|
1350 | + |
|
1351 | + |
|
1352 | + /** |
|
1353 | + * Returns an array of all the buttons for the various statuses and switch status actions |
|
1354 | + * |
|
1355 | + * @return array |
|
1356 | + */ |
|
1357 | + protected function _get_reg_statuses() |
|
1358 | + { |
|
1359 | + $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
|
1360 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
1361 | + // get current reg status |
|
1362 | + $current_status = $this->_registration->status_ID(); |
|
1363 | + // is registration for free event? This will determine whether to display the pending payment option |
|
1364 | + if ($current_status != EEM_Registration::status_id_pending_payment |
|
1365 | + && $this->_registration->transaction() |
|
1366 | + ->is_free() |
|
1367 | + ) { |
|
1368 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
1369 | + } |
|
1370 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
1371 | + } |
|
1372 | + |
|
1373 | + |
|
1374 | + |
|
1375 | + /** |
|
1376 | + * This method is used when using _REG_ID from request which may or may not be an array of reg_ids. |
|
1377 | + * |
|
1378 | + * @param bool $status REG status given for changing registrations to. |
|
1379 | + * @param bool $notify Whether to send messages notifications or not. |
|
1380 | + * @return array (array with reg_id(s) updated and whether update was successful. |
|
1381 | + */ |
|
1382 | + protected function _set_registration_status_from_request($status = false, $notify = false) |
|
1383 | + { |
|
1384 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
1385 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
1386 | + ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array(); |
|
1387 | + } else { |
|
1388 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array(); |
|
1389 | + } |
|
1390 | + $success = $this->_set_registration_status($REG_IDs, $status); |
|
1391 | + //notify? |
|
1392 | + if ($success |
|
1393 | + && $notify |
|
1394 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
1395 | + 'espresso_registrations_resend_registration') |
|
1396 | + ) { |
|
1397 | + $this->_process_resend_registration(); |
|
1398 | + } |
|
1399 | + return $success; |
|
1400 | + } |
|
1401 | + |
|
1402 | + |
|
1403 | + |
|
1404 | + /** |
|
1405 | + * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an |
|
1406 | + * array). Note, this method does NOT take care of possible notifications. That is required by calling code. |
|
1407 | + * |
|
1408 | + * @param array $REG_IDs |
|
1409 | + * @param bool $status |
|
1410 | + * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as |
|
1411 | + * the array of updated registrations). |
|
1412 | + */ |
|
1413 | + protected function _set_registration_status($REG_IDs = array(), $status = false) |
|
1414 | + { |
|
1415 | + $success = false; |
|
1416 | + // typecast $REG_IDs |
|
1417 | + $REG_IDs = (array)$REG_IDs; |
|
1418 | + if ( ! empty($REG_IDs)) { |
|
1419 | + $success = true; |
|
1420 | + // set default status if none is passed |
|
1421 | + $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
|
1422 | + // sanitize $REG_IDs |
|
1423 | + $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
1424 | + //loop through REG_ID's and change status |
|
1425 | + foreach ($REG_IDs as $REG_ID) { |
|
1426 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
1427 | + if ($registration instanceof EE_Registration) { |
|
1428 | + $registration->set_status($status); |
|
1429 | + $result = $registration->save(); |
|
1430 | + // verifying explicit fails because update *may* just return 0 for 0 rows affected |
|
1431 | + $success = $result !== false ? $success : false; |
|
1432 | + } |
|
1433 | + } |
|
1434 | + } |
|
1435 | + //reset _req_data['_REG_ID'] for any potential future messages notifications |
|
1436 | + $this->_req_data['_REG_ID'] = $REG_IDs; |
|
1437 | + //return $success and processed registrations |
|
1438 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
1439 | + } |
|
1440 | + |
|
1441 | + |
|
1442 | + |
|
1443 | + /** |
|
1444 | + * Common logic for setting up success message and redirecting to appropriate route |
|
1445 | + * |
|
1446 | + * @param string $STS_ID status id for the registration changed to |
|
1447 | + * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
|
1448 | + * @return void |
|
1449 | + */ |
|
1450 | + protected function _reg_status_change_return($STS_ID, $notify = false) |
|
1451 | + { |
|
1452 | + $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
1453 | + : array('success' => false); |
|
1454 | + $success = isset($result['success']) && $result['success']; |
|
1455 | + //setup success message |
|
1456 | + if ($success) { |
|
1457 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
1458 | + $msg = sprintf(__('Registration status has been set to %s', 'event_espresso'), |
|
1459 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
1460 | + } else { |
|
1461 | + $msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'), |
|
1462 | + EEH_Template::pretty_status($STS_ID, false, 'lower')); |
|
1463 | + } |
|
1464 | + EE_Error::add_success($msg); |
|
1465 | + } else { |
|
1466 | + EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, |
|
1467 | + __LINE__, __FUNCTION__); |
|
1468 | + } |
|
1469 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
1470 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
1471 | + } else { |
|
1472 | + $route = array('action' => 'default'); |
|
1473 | + } |
|
1474 | + //unset nonces |
|
1475 | + foreach ($this->_req_data as $ref => $value) { |
|
1476 | + if (strpos($ref, 'nonce') !== false) { |
|
1477 | + unset($this->_req_data[$ref]); |
|
1478 | + continue; |
|
1479 | + } |
|
1480 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
1481 | + $this->_req_data[$ref] = $value; |
|
1482 | + } |
|
1483 | + //merge request vars so that the reloaded list table contains any existing filter query params |
|
1484 | + $route = array_merge($this->_req_data, $route); |
|
1485 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
1486 | + } |
|
1487 | + |
|
1488 | + |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * incoming reg status change from reg details page. |
|
1492 | + * |
|
1493 | + * @return void |
|
1494 | + */ |
|
1495 | + protected function _change_reg_status() |
|
1496 | + { |
|
1497 | + $this->_req_data['return'] = 'view_registration'; |
|
1498 | + //set notify based on whether the send notifications toggle is set or not |
|
1499 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
1500 | + //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
|
1501 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status']) |
|
1502 | + ? $this->_req_data['reg_status_change_form']['reg_status'] : ''; |
|
1503 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
1504 | + case EEM_Registration::status_id_approved : |
|
1505 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
1506 | + $this->approve_registration($notify); |
|
1507 | + break; |
|
1508 | + case EEM_Registration::status_id_pending_payment : |
|
1509 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
1510 | + $this->pending_registration($notify); |
|
1511 | + break; |
|
1512 | + case EEM_Registration::status_id_not_approved : |
|
1513 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
1514 | + $this->not_approve_registration($notify); |
|
1515 | + break; |
|
1516 | + case EEM_Registration::status_id_declined : |
|
1517 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
1518 | + $this->decline_registration($notify); |
|
1519 | + break; |
|
1520 | + case EEM_Registration::status_id_cancelled : |
|
1521 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
1522 | + $this->cancel_registration($notify); |
|
1523 | + break; |
|
1524 | + case EEM_Registration::status_id_wait_list : |
|
1525 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
1526 | + $this->waitlist_registration($notify); |
|
1527 | + break; |
|
1528 | + case EEM_Registration::status_id_incomplete : |
|
1529 | + default : |
|
1530 | + $result['success'] = false; |
|
1531 | + unset($this->_req_data['return']); |
|
1532 | + $this->_reg_status_change_return('', false); |
|
1533 | + break; |
|
1534 | + } |
|
1535 | + } |
|
1536 | + |
|
1537 | + |
|
1538 | + |
|
1539 | + /** |
|
1540 | + * approve_registration |
|
1541 | + * |
|
1542 | + * @access protected |
|
1543 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
1544 | + * @return void |
|
1545 | + */ |
|
1546 | + protected function approve_registration($notify = false) |
|
1547 | + { |
|
1548 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
1549 | + } |
|
1550 | + |
|
1551 | + |
|
1552 | + |
|
1553 | + /** |
|
1554 | + * decline_registration |
|
1555 | + * |
|
1556 | + * @access protected |
|
1557 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
1558 | + * @return void |
|
1559 | + */ |
|
1560 | + protected function decline_registration($notify = false) |
|
1561 | + { |
|
1562 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
1563 | + } |
|
1564 | + |
|
1565 | + |
|
1566 | + |
|
1567 | + /** |
|
1568 | + * cancel_registration |
|
1569 | + * |
|
1570 | + * @access protected |
|
1571 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
1572 | + * @return void |
|
1573 | + */ |
|
1574 | + protected function cancel_registration($notify = false) |
|
1575 | + { |
|
1576 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
1577 | + } |
|
1578 | + |
|
1579 | + |
|
1580 | + |
|
1581 | + /** |
|
1582 | + * not_approve_registration |
|
1583 | + * |
|
1584 | + * @access protected |
|
1585 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
1586 | + * @return void |
|
1587 | + */ |
|
1588 | + protected function not_approve_registration($notify = false) |
|
1589 | + { |
|
1590 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
1591 | + } |
|
1592 | + |
|
1593 | + |
|
1594 | + |
|
1595 | + /** |
|
1596 | + * decline_registration |
|
1597 | + * |
|
1598 | + * @access protected |
|
1599 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
1600 | + * @return void |
|
1601 | + */ |
|
1602 | + protected function pending_registration($notify = false) |
|
1603 | + { |
|
1604 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
1605 | + } |
|
1606 | + |
|
1607 | + |
|
1608 | + |
|
1609 | + /** |
|
1610 | + * waitlist_registration |
|
1611 | + * |
|
1612 | + * @access protected |
|
1613 | + * @param bool $notify whether or not to notify the registrant about their status change. |
|
1614 | + * @return void |
|
1615 | + */ |
|
1616 | + protected function waitlist_registration($notify = false) |
|
1617 | + { |
|
1618 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
1619 | + } |
|
1620 | + |
|
1621 | + |
|
1622 | + |
|
1623 | + /** |
|
1624 | + * generates HTML for the Registration main meta box |
|
1625 | + * |
|
1626 | + * @access public |
|
1627 | + * @return void |
|
1628 | + */ |
|
1629 | + public function _reg_details_meta_box() |
|
1630 | + { |
|
1631 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
1632 | + EEH_Autoloader::register_line_item_filter_autoloaders(); |
|
1633 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1634 | + $transaction = $this->_registration->transaction() ? $this->_registration->transaction() |
|
1635 | + : EE_Transaction::new_instance(); |
|
1636 | + $this->_session = $transaction->session_data(); |
|
1637 | + $filters = new EE_Line_Item_Filter_Collection(); |
|
1638 | + //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
1639 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
1640 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item()); |
|
1641 | + $filtered_line_item_tree = $line_item_filter_processor->process(); |
|
1642 | + $line_item_display = new EE_Line_Item_Display('reg_admin_table', |
|
1643 | + 'EE_Admin_Table_Registration_Line_Item_Display_Strategy'); |
|
1644 | + $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, |
|
1645 | + array('EE_Registration' => $this->_registration)); |
|
1646 | + $attendee = $this->_registration->attendee(); |
|
1647 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
1648 | + 'espresso_transactions_view_transaction') |
|
1649 | + ) { |
|
1650 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
1651 | + 'action' => 'view_transaction', |
|
1652 | + 'TXN_ID' => $transaction->ID(), |
|
1653 | + ), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right', |
|
1654 | + 'dashicons dashicons-cart'); |
|
1655 | + } else { |
|
1656 | + $this->_template_args['view_transaction_button'] = ''; |
|
1657 | + } |
|
1658 | + if ($attendee instanceof EE_Attendee |
|
1659 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
1660 | + 'espresso_registrations_resend_registration') |
|
1661 | + ) { |
|
1662 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array( |
|
1663 | + 'action' => 'resend_registration', |
|
1664 | + '_REG_ID' => $this->_registration->ID(), |
|
1665 | + 'redirect_to' => 'view_registration', |
|
1666 | + ), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right', |
|
1667 | + 'dashicons dashicons-email-alt'); |
|
1668 | + } else { |
|
1669 | + $this->_template_args['resend_registration_button'] = ''; |
|
1670 | + } |
|
1671 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
1672 | + $payment = $transaction->get_first_related('Payment'); |
|
1673 | + $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
|
1674 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
1675 | + $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() |
|
1676 | + : $payment_method; |
|
1677 | + $reg_details = array( |
|
1678 | + 'payment_method' => $payment_method->name(), |
|
1679 | + 'response_msg' => $payment->gateway_response(), |
|
1680 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
1681 | + 'registration_session' => $this->_registration->session_ID(), |
|
1682 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
1683 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
1684 | + ); |
|
1685 | + if (isset($reg_details['registration_id'])) { |
|
1686 | + $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
|
1687 | + $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
1688 | + $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
|
1689 | + } |
|
1690 | + if (isset($reg_details['payment_method'])) { |
|
1691 | + $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
|
1692 | + $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', |
|
1693 | + 'event_espresso'); |
|
1694 | + $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
|
1695 | + $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
|
1696 | + $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', |
|
1697 | + 'event_espresso'); |
|
1698 | + $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
|
1699 | + } |
|
1700 | + $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
|
1701 | + $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', |
|
1702 | + 'event_espresso'); |
|
1703 | + $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
|
1704 | + $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
|
1705 | + $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', |
|
1706 | + 'event_espresso'); |
|
1707 | + $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
|
1708 | + $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
|
1709 | + $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso'); |
|
1710 | + $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
|
1711 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
1712 | + 'action' => 'default', |
|
1713 | + 'event_id' => $this->_registration->event_ID(), |
|
1714 | + ), REG_ADMIN_URL); |
|
1715 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
1716 | + $this->_template_args['event_id'] = $this->_registration->event_ID(); |
|
1717 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1718 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1719 | + } |
|
1720 | + |
|
1721 | + |
|
1722 | + |
|
1723 | + /** |
|
1724 | + * generates HTML for the Registration Questions meta box. |
|
1725 | + * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters), |
|
1726 | + * otherwise uses new forms system |
|
1727 | + * |
|
1728 | + * @access public |
|
1729 | + * @return void |
|
1730 | + */ |
|
1731 | + public function _reg_questions_meta_box() |
|
1732 | + { |
|
1733 | + //allow someone to override this method entirely |
|
1734 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, |
|
1735 | + $this->_registration)) { |
|
1736 | + $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
1737 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
1738 | + $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
|
1739 | + $this->_template_args['REG_ID'] = $this->_registration->ID(); |
|
1740 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1741 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1742 | + } |
|
1743 | + } |
|
1744 | + |
|
1745 | + |
|
1746 | + |
|
1747 | + /** |
|
1748 | + * form_before_question_group |
|
1749 | + * |
|
1750 | + * @deprecated as of 4.8.32.rc.000 |
|
1751 | + * @access public |
|
1752 | + * @param string $output |
|
1753 | + * @return string |
|
1754 | + */ |
|
1755 | + public function form_before_question_group($output) |
|
1756 | + { |
|
1757 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1758 | + __('This method would have been protected but was used on a filter callback' |
|
1759 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
1760 | + '4.8.32.rc.000'); |
|
1761 | + return ' |
|
1762 | 1762 | <table class="form-table ee-width-100"> |
1763 | 1763 | <tbody> |
1764 | 1764 | '; |
1765 | - } |
|
1766 | - |
|
1767 | - |
|
1768 | - |
|
1769 | - /** |
|
1770 | - * form_after_question_group |
|
1771 | - * |
|
1772 | - * @deprecated as of 4.8.32.rc.000 |
|
1773 | - * @access public |
|
1774 | - * @param string $output |
|
1775 | - * @return string |
|
1776 | - */ |
|
1777 | - public function form_after_question_group($output) |
|
1778 | - { |
|
1779 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1780 | - __('This method would have been protected but was used on a filter callback' |
|
1781 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
1782 | - '4.8.32.rc.000'); |
|
1783 | - return ' |
|
1765 | + } |
|
1766 | + |
|
1767 | + |
|
1768 | + |
|
1769 | + /** |
|
1770 | + * form_after_question_group |
|
1771 | + * |
|
1772 | + * @deprecated as of 4.8.32.rc.000 |
|
1773 | + * @access public |
|
1774 | + * @param string $output |
|
1775 | + * @return string |
|
1776 | + */ |
|
1777 | + public function form_after_question_group($output) |
|
1778 | + { |
|
1779 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1780 | + __('This method would have been protected but was used on a filter callback' |
|
1781 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
1782 | + '4.8.32.rc.000'); |
|
1783 | + return ' |
|
1784 | 1784 | <tr class="hide-if-no-js"> |
1785 | 1785 | <th> </th> |
1786 | 1786 | <td class="reg-admin-edit-attendee-question-td"> |
1787 | 1787 | <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' |
1788 | - . esc_attr__('click to edit question', 'event_espresso') |
|
1789 | - . '"> |
|
1788 | + . esc_attr__('click to edit question', 'event_espresso') |
|
1789 | + . '"> |
|
1790 | 1790 | <span class="reg-admin-edit-question-group-spn lt-grey-txt">' |
1791 | - . __('edit the above question group', 'event_espresso') |
|
1792 | - . '</span> |
|
1791 | + . __('edit the above question group', 'event_espresso') |
|
1792 | + . '</span> |
|
1793 | 1793 | <div class="dashicons dashicons-edit"></div> |
1794 | 1794 | </a> |
1795 | 1795 | </td> |
@@ -1797,506 +1797,506 @@ discard block |
||
1797 | 1797 | </tbody> |
1798 | 1798 | </table> |
1799 | 1799 | '; |
1800 | - } |
|
1801 | - |
|
1802 | - |
|
1803 | - |
|
1804 | - /** |
|
1805 | - * form_form_field_label_wrap |
|
1806 | - * |
|
1807 | - * @deprecated as of 4.8.32.rc.000 |
|
1808 | - * @access public |
|
1809 | - * @param string $label |
|
1810 | - * @return string |
|
1811 | - */ |
|
1812 | - public function form_form_field_label_wrap($label) |
|
1813 | - { |
|
1814 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1815 | - __('This method would have been protected but was used on a filter callback' |
|
1816 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
1817 | - '4.8.32.rc.000'); |
|
1818 | - return ' |
|
1800 | + } |
|
1801 | + |
|
1802 | + |
|
1803 | + |
|
1804 | + /** |
|
1805 | + * form_form_field_label_wrap |
|
1806 | + * |
|
1807 | + * @deprecated as of 4.8.32.rc.000 |
|
1808 | + * @access public |
|
1809 | + * @param string $label |
|
1810 | + * @return string |
|
1811 | + */ |
|
1812 | + public function form_form_field_label_wrap($label) |
|
1813 | + { |
|
1814 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1815 | + __('This method would have been protected but was used on a filter callback' |
|
1816 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
1817 | + '4.8.32.rc.000'); |
|
1818 | + return ' |
|
1819 | 1819 | <tr> |
1820 | 1820 | <th> |
1821 | 1821 | ' . $label . ' |
1822 | 1822 | </th>'; |
1823 | - } |
|
1824 | - |
|
1825 | - |
|
1826 | - |
|
1827 | - /** |
|
1828 | - * form_form_field_input__wrap |
|
1829 | - * |
|
1830 | - * @deprecated as of 4.8.32.rc.000 |
|
1831 | - * @access public |
|
1832 | - * @param string $input |
|
1833 | - * @return string |
|
1834 | - */ |
|
1835 | - public function form_form_field_input__wrap($input) |
|
1836 | - { |
|
1837 | - EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1838 | - __('This method would have been protected but was used on a filter callback' |
|
1839 | - . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
1840 | - '4.8.32.rc.000'); |
|
1841 | - return ' |
|
1823 | + } |
|
1824 | + |
|
1825 | + |
|
1826 | + |
|
1827 | + /** |
|
1828 | + * form_form_field_input__wrap |
|
1829 | + * |
|
1830 | + * @deprecated as of 4.8.32.rc.000 |
|
1831 | + * @access public |
|
1832 | + * @param string $input |
|
1833 | + * @return string |
|
1834 | + */ |
|
1835 | + public function form_form_field_input__wrap($input) |
|
1836 | + { |
|
1837 | + EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, |
|
1838 | + __('This method would have been protected but was used on a filter callback' |
|
1839 | + . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'), |
|
1840 | + '4.8.32.rc.000'); |
|
1841 | + return ' |
|
1842 | 1842 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
1843 | 1843 | ' . $input . ' |
1844 | 1844 | </td> |
1845 | 1845 | </tr>'; |
1846 | - } |
|
1847 | - |
|
1848 | - |
|
1849 | - |
|
1850 | - /** |
|
1851 | - * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
1852 | - * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
1853 | - * to display the page |
|
1854 | - * |
|
1855 | - * @access protected |
|
1856 | - * @return void |
|
1857 | - */ |
|
1858 | - protected function _update_attendee_registration_form() |
|
1859 | - { |
|
1860 | - do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
1861 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
1862 | - $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
1863 | - $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
1864 | - if ($success) { |
|
1865 | - $what = __('Registration Form', 'event_espresso'); |
|
1866 | - $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
1867 | - : array('action' => 'default'); |
|
1868 | - $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
1869 | - } |
|
1870 | - } |
|
1871 | - } |
|
1872 | - |
|
1873 | - |
|
1874 | - |
|
1875 | - /** |
|
1876 | - * Gets the form for saving registrations custom questions (if done |
|
1877 | - * previously retrieves the cached form object, which may have validation errors in it) |
|
1878 | - * |
|
1879 | - * @param int $REG_ID |
|
1880 | - * @return EE_Registration_Custom_Questions_Form |
|
1881 | - */ |
|
1882 | - protected function _get_reg_custom_questions_form($REG_ID) |
|
1883 | - { |
|
1884 | - if ( ! $this->_reg_custom_questions_form) { |
|
1885 | - require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
1886 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance() |
|
1887 | - ->get_one_by_ID($REG_ID)); |
|
1888 | - $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
1889 | - } |
|
1890 | - return $this->_reg_custom_questions_form; |
|
1891 | - } |
|
1892 | - |
|
1893 | - |
|
1894 | - |
|
1895 | - /** |
|
1896 | - * Saves |
|
1897 | - * |
|
1898 | - * @access private |
|
1899 | - * @param bool $REG_ID |
|
1900 | - * @return bool |
|
1901 | - */ |
|
1902 | - private function _save_reg_custom_questions_form($REG_ID = false) |
|
1903 | - { |
|
1904 | - if ( ! $REG_ID) { |
|
1905 | - EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, |
|
1906 | - __FUNCTION__, __LINE__); |
|
1907 | - } |
|
1908 | - $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
1909 | - $form->receive_form_submission($this->_req_data); |
|
1910 | - $success = false; |
|
1911 | - if ($form->is_valid()) { |
|
1912 | - foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
1913 | - foreach ($question_group_form->inputs() as $question_id => $input) { |
|
1914 | - $where_conditions = array( |
|
1915 | - 'QST_ID' => $question_id, |
|
1916 | - 'REG_ID' => $REG_ID, |
|
1917 | - ); |
|
1918 | - $possibly_new_values = array( |
|
1919 | - 'ANS_value' => $input->normalized_value(), |
|
1920 | - ); |
|
1921 | - $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
1922 | - if ($answer instanceof EE_Answer) { |
|
1923 | - $success = $answer->save($possibly_new_values); |
|
1924 | - } else { |
|
1925 | - //insert it then |
|
1926 | - $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
1927 | - $answer = EE_Answer::new_instance($cols_n_vals); |
|
1928 | - $success = $answer->save(); |
|
1929 | - } |
|
1930 | - } |
|
1931 | - } |
|
1932 | - } else { |
|
1933 | - EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
1934 | - } |
|
1935 | - return $success; |
|
1936 | - } |
|
1937 | - |
|
1938 | - |
|
1939 | - |
|
1940 | - /** |
|
1941 | - * generates HTML for the Registration main meta box |
|
1942 | - * |
|
1943 | - * @access public |
|
1944 | - * @return void |
|
1945 | - */ |
|
1946 | - public function _reg_attendees_meta_box() |
|
1947 | - { |
|
1948 | - $REG = EEM_Registration::instance(); |
|
1949 | - //get all other registrations on this transaction, and cache |
|
1950 | - //the attendees for them so we don't have to run another query using force_join |
|
1951 | - $registrations = $REG->get_all(array( |
|
1952 | - array( |
|
1953 | - 'TXN_ID' => $this->_registration->transaction_ID(), |
|
1954 | - 'REG_ID' => array('!=', $this->_registration->ID()), |
|
1955 | - ), |
|
1956 | - 'force_join' => array('Attendee'), |
|
1957 | - )); |
|
1958 | - $this->_template_args['attendees'] = array(); |
|
1959 | - $this->_template_args['attendee_notice'] = ''; |
|
1960 | - if (empty($registrations) |
|
1961 | - || (is_array($registrations) |
|
1962 | - && ! EEH_Array::get_one_item_from_array($registrations)) |
|
1963 | - ) { |
|
1964 | - EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', |
|
1965 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1966 | - $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
1967 | - } else { |
|
1968 | - $att_nmbr = 1; |
|
1969 | - foreach ($registrations as $registration) { |
|
1970 | - /* @var $registration EE_Registration */ |
|
1971 | - $attendee = $registration->attendee() |
|
1972 | - ? $registration->attendee() |
|
1973 | - : EEM_Attendee::instance() |
|
1974 | - ->create_default_object(); |
|
1975 | - $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
1976 | - $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1977 | - $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1978 | - $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1979 | - $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1980 | - $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
|
1981 | - $attendee->full_address_as_array()); |
|
1982 | - $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
|
1983 | - 'action' => 'edit_attendee', |
|
1984 | - 'post' => $attendee->ID(), |
|
1985 | - ), REG_ADMIN_URL); |
|
1986 | - $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
1987 | - $att_nmbr++; |
|
1988 | - } |
|
1989 | - //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
|
1990 | - $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
1991 | - // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
|
1992 | - } |
|
1993 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
1994 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1995 | - } |
|
1996 | - |
|
1997 | - |
|
1998 | - |
|
1999 | - /** |
|
2000 | - * generates HTML for the Edit Registration side meta box |
|
2001 | - * |
|
2002 | - * @access public |
|
2003 | - * @return void |
|
2004 | - */ |
|
2005 | - public function _reg_registrant_side_meta_box() |
|
2006 | - { |
|
2007 | - /*@var $attendee EE_Attendee */ |
|
2008 | - $att_check = $this->_registration->attendee(); |
|
2009 | - $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
2010 | - //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
|
2011 | - if ( ! $this->_registration->is_primary_registrant()) { |
|
2012 | - $primary_registration = $this->_registration->get_primary_registration(); |
|
2013 | - $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
2014 | - : null; |
|
2015 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
2016 | - //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
|
2017 | - $primary_registration = null; |
|
2018 | - } |
|
2019 | - } else { |
|
2020 | - $primary_registration = null; |
|
2021 | - } |
|
2022 | - $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
2023 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
2024 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
2025 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
2026 | - $this->_template_args['phone'] = $attendee->phone(); |
|
2027 | - $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
2028 | - //edit link |
|
2029 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
2030 | - 'action' => 'edit_attendee', |
|
2031 | - 'post' => $attendee->ID(), |
|
2032 | - ), REG_ADMIN_URL); |
|
2033 | - $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
|
2034 | - //create link |
|
2035 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
2036 | - ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
2037 | - 'action' => 'duplicate_attendee', |
|
2038 | - '_REG_ID' => $this->_registration->ID(), |
|
2039 | - ), REG_ADMIN_URL) : ''; |
|
2040 | - $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
|
2041 | - $this->_template_args['att_check'] = $att_check; |
|
2042 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
2043 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
2044 | - } |
|
2045 | - |
|
2046 | - |
|
2047 | - |
|
2048 | - /** |
|
2049 | - * trash or restore registrations |
|
2050 | - * |
|
2051 | - * @param boolean $trash whether to archive or restore |
|
2052 | - * @access protected |
|
2053 | - * @return void |
|
2054 | - */ |
|
2055 | - protected function _trash_or_restore_registrations($trash = true) |
|
2056 | - { |
|
2057 | - $REGM = EEM_Registration::instance(); |
|
2058 | - $success = 1; |
|
2059 | - $error = 0; |
|
2060 | - $tickets = array(); |
|
2061 | - $dtts = array(); |
|
2062 | - //if empty _REG_ID then get out because there's nothing to do |
|
2063 | - if (empty($this->_req_data['_REG_ID'])) { |
|
2064 | - $msg = $trash |
|
2065 | - ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', |
|
2066 | - 'event_espresso') |
|
2067 | - : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', |
|
2068 | - 'event_espresso'); |
|
2069 | - EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__); |
|
2070 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
2071 | - } |
|
2072 | - //Checkboxes |
|
2073 | - if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2074 | - // if array has more than one element than success message should be plural |
|
2075 | - $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2076 | - // cycle thru checkboxes |
|
2077 | - while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2078 | - /** @var EE_Registration $REG */ |
|
2079 | - $REG = $REGM->get_one_by_ID($REG_ID); |
|
2080 | - $payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
|
2081 | - if ($payment_count > 0) { |
|
2082 | - $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() |
|
2083 | - : __('Unknown Attendee', 'event_espresso'); |
|
2084 | - $error = 1; |
|
2085 | - $success = 0; |
|
2086 | - EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
2087 | - 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__); |
|
2088 | - continue; //can't trash this registration because it has payments. |
|
2089 | - } |
|
2090 | - $ticket = $REG->get_first_related('Ticket'); |
|
2091 | - $tickets[$ticket->ID()] = $ticket; |
|
2092 | - $dtt = $ticket->get_many_related('Datetime'); |
|
2093 | - $dtts = array_merge($dtts, $dtt); |
|
2094 | - $updated = $trash ? $REG->delete() : $REG->restore(); |
|
2095 | - if ( ! $updated) { |
|
2096 | - $success = 0; |
|
2097 | - } else { |
|
2098 | - $success = 2; |
|
2099 | - }/**/ |
|
2100 | - } |
|
2101 | - } else { |
|
2102 | - // grab single id and delete |
|
2103 | - $REG_ID = absint($this->_req_data['_REG_ID']); |
|
2104 | - $REG = $REGM->get_one_by_ID($REG_ID); |
|
2105 | - $ticket = $REG->get_first_related('Ticket'); |
|
2106 | - $tickets[$ticket->ID()] = $ticket; |
|
2107 | - $dtts = $ticket->get_many_related('Datetime'); |
|
2108 | - $updated = $trash ? $REG->delete() : $REG->restore(); |
|
2109 | - if ( ! $updated) { |
|
2110 | - $success = 0; |
|
2111 | - } |
|
2112 | - } |
|
2113 | - //now let's update counts |
|
2114 | - EEM_Ticket::instance()->update_tickets_sold($tickets); |
|
2115 | - EEM_Datetime::instance()->update_sold($dtts); |
|
2116 | - $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2117 | - $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2118 | - $overwrite_msgs = $error ? true : false; |
|
2119 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs); |
|
2120 | - } |
|
2121 | - |
|
2122 | - |
|
2123 | - |
|
2124 | - /** |
|
2125 | - * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
2126 | - * registration but also. |
|
2127 | - * 1. Removing relations to EE_Attendee |
|
2128 | - * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
2129 | - * ALSO trashed. |
|
2130 | - * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
2131 | - * 4. Removing relationships between all tickets and the related registrations |
|
2132 | - * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
2133 | - * 6. Deleting permanently any related Checkins. |
|
2134 | - * |
|
2135 | - * @return void |
|
2136 | - */ |
|
2137 | - protected function _delete_registrations() |
|
2138 | - { |
|
2139 | - $REG_MDL = EEM_Registration::instance(); |
|
2140 | - $success = 1; |
|
2141 | - //Checkboxes |
|
2142 | - if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2143 | - // if array has more than one element than success message should be plural |
|
2144 | - $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2145 | - // cycle thru checkboxes |
|
2146 | - while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2147 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
2148 | - if ( ! $REG instanceof EE_Registration) { |
|
2149 | - continue; |
|
2150 | - } |
|
2151 | - $deleted = $this->_delete_registration($REG); |
|
2152 | - if ( ! $deleted) { |
|
2153 | - $success = 0; |
|
2154 | - } |
|
2155 | - } |
|
2156 | - } else { |
|
2157 | - // grab single id and delete |
|
2158 | - $REG_ID = $this->_req_data['_REG_ID']; |
|
2159 | - $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
2160 | - $deleted = $this->_delete_registration($REG); |
|
2161 | - if ( ! $deleted) { |
|
2162 | - $success = 0; |
|
2163 | - } |
|
2164 | - } |
|
2165 | - $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2166 | - $action_desc = __('permanently deleted.', 'event_espresso'); |
|
2167 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true); |
|
2168 | - } |
|
2169 | - |
|
2170 | - |
|
2171 | - |
|
2172 | - /** |
|
2173 | - * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
2174 | - * models get affected. |
|
2175 | - * |
|
2176 | - * @param EE_Registration $REG registration to be deleted permenantly |
|
2177 | - * @return boolean true = successful deletion, false = fail. |
|
2178 | - */ |
|
2179 | - protected function _delete_registration(EE_Registration $REG) |
|
2180 | - { |
|
2181 | - //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
|
2182 | - $TXN = $REG->get_first_related('Transaction'); |
|
2183 | - $REGS = $TXN->get_many_related('Registration'); |
|
2184 | - $all_trashed = true; |
|
2185 | - foreach ($REGS as $registration) { |
|
2186 | - if ( ! $registration->get('REG_deleted')) { |
|
2187 | - $all_trashed = false; |
|
2188 | - } |
|
2189 | - } |
|
2190 | - if ( ! $all_trashed) { |
|
2191 | - EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
2192 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2193 | - return false; |
|
2194 | - } |
|
2195 | - //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
|
2196 | - foreach ($REGS as $registration) { |
|
2197 | - //delete related answers |
|
2198 | - $registration->delete_related_permanently('Answer'); |
|
2199 | - //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
2200 | - $attendee = $registration->get_first_related('Attendee'); |
|
2201 | - if ($attendee instanceof EE_Attendee) { |
|
2202 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
2203 | - } |
|
2204 | - //now remove relationships to tickets on this registration. |
|
2205 | - $registration->_remove_relations('Ticket'); |
|
2206 | - //now delete permanently the checkins related to this registration. |
|
2207 | - $registration->delete_related_permanently('Checkin'); |
|
2208 | - if ($registration->ID() === $REG->ID()) { |
|
2209 | - continue; |
|
2210 | - } //we don't want to delete permanently the existing registration just yet. |
|
2211 | - //remove relation to transaction for these registrations if NOT the existing registrations |
|
2212 | - $registration->_remove_relations('Transaction'); |
|
2213 | - //delete permanently any related messages. |
|
2214 | - $registration->delete_related_permanently('Message'); |
|
2215 | - //now delete this registration permanently |
|
2216 | - $registration->delete_permanently(); |
|
2217 | - } |
|
2218 | - //now all related registrations on the transaction are handled. So let's just handle this registration itself (the transaction and line items should be all that's left). |
|
2219 | - //delete the line items related to the transaction for this registration. |
|
2220 | - $TXN->delete_related_permanently('Line_Item'); |
|
2221 | - //we need to remove all the relationships on the transaction |
|
2222 | - $TXN->delete_related_permanently('Payment'); |
|
2223 | - $TXN->delete_related_permanently('Extra_Meta'); |
|
2224 | - $TXN->delete_related_permanently('Message'); |
|
2225 | - //now we can delete this REG permanently (and the transaction of course) |
|
2226 | - $REG->delete_related_permanently('Transaction'); |
|
2227 | - return $REG->delete_permanently(); |
|
2228 | - } |
|
2229 | - |
|
2230 | - |
|
2231 | - |
|
2232 | - /** |
|
2233 | - * generates HTML for the Register New Attendee Admin page |
|
2234 | - * |
|
2235 | - * @access private |
|
2236 | - * @throws \EE_Error |
|
2237 | - * @return void |
|
2238 | - */ |
|
2239 | - public function new_registration() |
|
2240 | - { |
|
2241 | - if ( ! $this->_set_reg_event()) { |
|
2242 | - throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', |
|
2243 | - 'event_espresso')); |
|
2244 | - } |
|
2245 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
2246 | - // gotta start with a clean slate if we're not coming here via ajax |
|
2247 | - if ( ! defined('DOING_AJAX') |
|
2248 | - && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
2249 | - ) { |
|
2250 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2251 | - } |
|
2252 | - $this->_template_args['event_name'] = ''; |
|
2253 | - // event name |
|
2254 | - if ($this->_reg_event) { |
|
2255 | - $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
2256 | - $edit_event_url = self::add_query_args_and_nonce(array( |
|
2257 | - 'action' => 'edit', |
|
2258 | - 'post' => $this->_reg_event->ID(), |
|
2259 | - ), EVENTS_ADMIN_URL); |
|
2260 | - $edit_event_lnk = '<a href="' |
|
2261 | - . $edit_event_url |
|
2262 | - . '" title="' |
|
2263 | - . esc_attr__('Edit ', 'event_espresso') |
|
2264 | - . $this->_reg_event->name() |
|
2265 | - . '">' |
|
2266 | - . __('Edit Event', 'event_espresso') |
|
2267 | - . '</a>'; |
|
2268 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
2269 | - . $edit_event_lnk |
|
2270 | - . '</span>'; |
|
2271 | - } |
|
2272 | - $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
2273 | - if (defined('DOING_AJAX')) { |
|
2274 | - $this->_return_json(); |
|
2275 | - } |
|
2276 | - // grab header |
|
2277 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
2278 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
2279 | - $this->_template_args, true); |
|
2280 | - //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
2281 | - // the details template wrapper |
|
2282 | - $this->display_admin_page_with_sidebar(); |
|
2283 | - } |
|
2284 | - |
|
2285 | - |
|
2286 | - |
|
2287 | - /** |
|
2288 | - * This returns the content for a registration step |
|
2289 | - * |
|
2290 | - * @access protected |
|
2291 | - * @return string html |
|
2292 | - */ |
|
2293 | - protected function _get_registration_step_content() |
|
2294 | - { |
|
2295 | - if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
2296 | - $warning_msg = sprintf(__('%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
2297 | - 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
|
2298 | - '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
|
2299 | - return ' |
|
1846 | + } |
|
1847 | + |
|
1848 | + |
|
1849 | + |
|
1850 | + /** |
|
1851 | + * Updates the registration's custom questions according to the form info, if the form is submitted. |
|
1852 | + * If it's not a post, the "view_registrations" route will be called next on the SAME request |
|
1853 | + * to display the page |
|
1854 | + * |
|
1855 | + * @access protected |
|
1856 | + * @return void |
|
1857 | + */ |
|
1858 | + protected function _update_attendee_registration_form() |
|
1859 | + { |
|
1860 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
1861 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
1862 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false; |
|
1863 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
1864 | + if ($success) { |
|
1865 | + $what = __('Registration Form', 'event_espresso'); |
|
1866 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) |
|
1867 | + : array('action' => 'default'); |
|
1868 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
1869 | + } |
|
1870 | + } |
|
1871 | + } |
|
1872 | + |
|
1873 | + |
|
1874 | + |
|
1875 | + /** |
|
1876 | + * Gets the form for saving registrations custom questions (if done |
|
1877 | + * previously retrieves the cached form object, which may have validation errors in it) |
|
1878 | + * |
|
1879 | + * @param int $REG_ID |
|
1880 | + * @return EE_Registration_Custom_Questions_Form |
|
1881 | + */ |
|
1882 | + protected function _get_reg_custom_questions_form($REG_ID) |
|
1883 | + { |
|
1884 | + if ( ! $this->_reg_custom_questions_form) { |
|
1885 | + require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php'); |
|
1886 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance() |
|
1887 | + ->get_one_by_ID($REG_ID)); |
|
1888 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
1889 | + } |
|
1890 | + return $this->_reg_custom_questions_form; |
|
1891 | + } |
|
1892 | + |
|
1893 | + |
|
1894 | + |
|
1895 | + /** |
|
1896 | + * Saves |
|
1897 | + * |
|
1898 | + * @access private |
|
1899 | + * @param bool $REG_ID |
|
1900 | + * @return bool |
|
1901 | + */ |
|
1902 | + private function _save_reg_custom_questions_form($REG_ID = false) |
|
1903 | + { |
|
1904 | + if ( ! $REG_ID) { |
|
1905 | + EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, |
|
1906 | + __FUNCTION__, __LINE__); |
|
1907 | + } |
|
1908 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
1909 | + $form->receive_form_submission($this->_req_data); |
|
1910 | + $success = false; |
|
1911 | + if ($form->is_valid()) { |
|
1912 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
1913 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
1914 | + $where_conditions = array( |
|
1915 | + 'QST_ID' => $question_id, |
|
1916 | + 'REG_ID' => $REG_ID, |
|
1917 | + ); |
|
1918 | + $possibly_new_values = array( |
|
1919 | + 'ANS_value' => $input->normalized_value(), |
|
1920 | + ); |
|
1921 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
1922 | + if ($answer instanceof EE_Answer) { |
|
1923 | + $success = $answer->save($possibly_new_values); |
|
1924 | + } else { |
|
1925 | + //insert it then |
|
1926 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
1927 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
1928 | + $success = $answer->save(); |
|
1929 | + } |
|
1930 | + } |
|
1931 | + } |
|
1932 | + } else { |
|
1933 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
1934 | + } |
|
1935 | + return $success; |
|
1936 | + } |
|
1937 | + |
|
1938 | + |
|
1939 | + |
|
1940 | + /** |
|
1941 | + * generates HTML for the Registration main meta box |
|
1942 | + * |
|
1943 | + * @access public |
|
1944 | + * @return void |
|
1945 | + */ |
|
1946 | + public function _reg_attendees_meta_box() |
|
1947 | + { |
|
1948 | + $REG = EEM_Registration::instance(); |
|
1949 | + //get all other registrations on this transaction, and cache |
|
1950 | + //the attendees for them so we don't have to run another query using force_join |
|
1951 | + $registrations = $REG->get_all(array( |
|
1952 | + array( |
|
1953 | + 'TXN_ID' => $this->_registration->transaction_ID(), |
|
1954 | + 'REG_ID' => array('!=', $this->_registration->ID()), |
|
1955 | + ), |
|
1956 | + 'force_join' => array('Attendee'), |
|
1957 | + )); |
|
1958 | + $this->_template_args['attendees'] = array(); |
|
1959 | + $this->_template_args['attendee_notice'] = ''; |
|
1960 | + if (empty($registrations) |
|
1961 | + || (is_array($registrations) |
|
1962 | + && ! EEH_Array::get_one_item_from_array($registrations)) |
|
1963 | + ) { |
|
1964 | + EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', |
|
1965 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1966 | + $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
|
1967 | + } else { |
|
1968 | + $att_nmbr = 1; |
|
1969 | + foreach ($registrations as $registration) { |
|
1970 | + /* @var $registration EE_Registration */ |
|
1971 | + $attendee = $registration->attendee() |
|
1972 | + ? $registration->attendee() |
|
1973 | + : EEM_Attendee::instance() |
|
1974 | + ->create_default_object(); |
|
1975 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
1976 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1977 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1978 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1979 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1980 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', |
|
1981 | + $attendee->full_address_as_array()); |
|
1982 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array( |
|
1983 | + 'action' => 'edit_attendee', |
|
1984 | + 'post' => $attendee->ID(), |
|
1985 | + ), REG_ADMIN_URL); |
|
1986 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
1987 | + $att_nmbr++; |
|
1988 | + } |
|
1989 | + //EEH_Debug_Tools::printr( $attendees, '$attendees <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' ); |
|
1990 | + $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
|
1991 | + // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
|
1992 | + } |
|
1993 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
1994 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
1995 | + } |
|
1996 | + |
|
1997 | + |
|
1998 | + |
|
1999 | + /** |
|
2000 | + * generates HTML for the Edit Registration side meta box |
|
2001 | + * |
|
2002 | + * @access public |
|
2003 | + * @return void |
|
2004 | + */ |
|
2005 | + public function _reg_registrant_side_meta_box() |
|
2006 | + { |
|
2007 | + /*@var $attendee EE_Attendee */ |
|
2008 | + $att_check = $this->_registration->attendee(); |
|
2009 | + $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
|
2010 | + //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
|
2011 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
2012 | + $primary_registration = $this->_registration->get_primary_registration(); |
|
2013 | + $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() |
|
2014 | + : null; |
|
2015 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
2016 | + //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
|
2017 | + $primary_registration = null; |
|
2018 | + } |
|
2019 | + } else { |
|
2020 | + $primary_registration = null; |
|
2021 | + } |
|
2022 | + $this->_template_args['ATT_ID'] = $attendee->ID(); |
|
2023 | + $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
2024 | + $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
2025 | + $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
2026 | + $this->_template_args['phone'] = $attendee->phone(); |
|
2027 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
2028 | + //edit link |
|
2029 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array( |
|
2030 | + 'action' => 'edit_attendee', |
|
2031 | + 'post' => $attendee->ID(), |
|
2032 | + ), REG_ADMIN_URL); |
|
2033 | + $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
|
2034 | + //create link |
|
2035 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration |
|
2036 | + ? EE_Admin_Page::add_query_args_and_nonce(array( |
|
2037 | + 'action' => 'duplicate_attendee', |
|
2038 | + '_REG_ID' => $this->_registration->ID(), |
|
2039 | + ), REG_ADMIN_URL) : ''; |
|
2040 | + $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
|
2041 | + $this->_template_args['att_check'] = $att_check; |
|
2042 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
2043 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
2044 | + } |
|
2045 | + |
|
2046 | + |
|
2047 | + |
|
2048 | + /** |
|
2049 | + * trash or restore registrations |
|
2050 | + * |
|
2051 | + * @param boolean $trash whether to archive or restore |
|
2052 | + * @access protected |
|
2053 | + * @return void |
|
2054 | + */ |
|
2055 | + protected function _trash_or_restore_registrations($trash = true) |
|
2056 | + { |
|
2057 | + $REGM = EEM_Registration::instance(); |
|
2058 | + $success = 1; |
|
2059 | + $error = 0; |
|
2060 | + $tickets = array(); |
|
2061 | + $dtts = array(); |
|
2062 | + //if empty _REG_ID then get out because there's nothing to do |
|
2063 | + if (empty($this->_req_data['_REG_ID'])) { |
|
2064 | + $msg = $trash |
|
2065 | + ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', |
|
2066 | + 'event_espresso') |
|
2067 | + : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', |
|
2068 | + 'event_espresso'); |
|
2069 | + EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__); |
|
2070 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
2071 | + } |
|
2072 | + //Checkboxes |
|
2073 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2074 | + // if array has more than one element than success message should be plural |
|
2075 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2076 | + // cycle thru checkboxes |
|
2077 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2078 | + /** @var EE_Registration $REG */ |
|
2079 | + $REG = $REGM->get_one_by_ID($REG_ID); |
|
2080 | + $payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
|
2081 | + if ($payment_count > 0) { |
|
2082 | + $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() |
|
2083 | + : __('Unknown Attendee', 'event_espresso'); |
|
2084 | + $error = 1; |
|
2085 | + $success = 0; |
|
2086 | + EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', |
|
2087 | + 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__); |
|
2088 | + continue; //can't trash this registration because it has payments. |
|
2089 | + } |
|
2090 | + $ticket = $REG->get_first_related('Ticket'); |
|
2091 | + $tickets[$ticket->ID()] = $ticket; |
|
2092 | + $dtt = $ticket->get_many_related('Datetime'); |
|
2093 | + $dtts = array_merge($dtts, $dtt); |
|
2094 | + $updated = $trash ? $REG->delete() : $REG->restore(); |
|
2095 | + if ( ! $updated) { |
|
2096 | + $success = 0; |
|
2097 | + } else { |
|
2098 | + $success = 2; |
|
2099 | + }/**/ |
|
2100 | + } |
|
2101 | + } else { |
|
2102 | + // grab single id and delete |
|
2103 | + $REG_ID = absint($this->_req_data['_REG_ID']); |
|
2104 | + $REG = $REGM->get_one_by_ID($REG_ID); |
|
2105 | + $ticket = $REG->get_first_related('Ticket'); |
|
2106 | + $tickets[$ticket->ID()] = $ticket; |
|
2107 | + $dtts = $ticket->get_many_related('Datetime'); |
|
2108 | + $updated = $trash ? $REG->delete() : $REG->restore(); |
|
2109 | + if ( ! $updated) { |
|
2110 | + $success = 0; |
|
2111 | + } |
|
2112 | + } |
|
2113 | + //now let's update counts |
|
2114 | + EEM_Ticket::instance()->update_tickets_sold($tickets); |
|
2115 | + EEM_Datetime::instance()->update_sold($dtts); |
|
2116 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2117 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2118 | + $overwrite_msgs = $error ? true : false; |
|
2119 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs); |
|
2120 | + } |
|
2121 | + |
|
2122 | + |
|
2123 | + |
|
2124 | + /** |
|
2125 | + * This is used to permanently delete registrations. Note, this will handle not only deleting permanently the |
|
2126 | + * registration but also. |
|
2127 | + * 1. Removing relations to EE_Attendee |
|
2128 | + * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are |
|
2129 | + * ALSO trashed. |
|
2130 | + * 3. Deleting permanently any related Line items but only if the above conditions are met. |
|
2131 | + * 4. Removing relationships between all tickets and the related registrations |
|
2132 | + * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.) |
|
2133 | + * 6. Deleting permanently any related Checkins. |
|
2134 | + * |
|
2135 | + * @return void |
|
2136 | + */ |
|
2137 | + protected function _delete_registrations() |
|
2138 | + { |
|
2139 | + $REG_MDL = EEM_Registration::instance(); |
|
2140 | + $success = 1; |
|
2141 | + //Checkboxes |
|
2142 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2143 | + // if array has more than one element than success message should be plural |
|
2144 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2145 | + // cycle thru checkboxes |
|
2146 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2147 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
2148 | + if ( ! $REG instanceof EE_Registration) { |
|
2149 | + continue; |
|
2150 | + } |
|
2151 | + $deleted = $this->_delete_registration($REG); |
|
2152 | + if ( ! $deleted) { |
|
2153 | + $success = 0; |
|
2154 | + } |
|
2155 | + } |
|
2156 | + } else { |
|
2157 | + // grab single id and delete |
|
2158 | + $REG_ID = $this->_req_data['_REG_ID']; |
|
2159 | + $REG = $REG_MDL->get_one_by_ID($REG_ID); |
|
2160 | + $deleted = $this->_delete_registration($REG); |
|
2161 | + if ( ! $deleted) { |
|
2162 | + $success = 0; |
|
2163 | + } |
|
2164 | + } |
|
2165 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2166 | + $action_desc = __('permanently deleted.', 'event_espresso'); |
|
2167 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true); |
|
2168 | + } |
|
2169 | + |
|
2170 | + |
|
2171 | + |
|
2172 | + /** |
|
2173 | + * handles the permanent deletion of a registration. See comments with _delete_registrations() for details on what |
|
2174 | + * models get affected. |
|
2175 | + * |
|
2176 | + * @param EE_Registration $REG registration to be deleted permenantly |
|
2177 | + * @return boolean true = successful deletion, false = fail. |
|
2178 | + */ |
|
2179 | + protected function _delete_registration(EE_Registration $REG) |
|
2180 | + { |
|
2181 | + //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
|
2182 | + $TXN = $REG->get_first_related('Transaction'); |
|
2183 | + $REGS = $TXN->get_many_related('Registration'); |
|
2184 | + $all_trashed = true; |
|
2185 | + foreach ($REGS as $registration) { |
|
2186 | + if ( ! $registration->get('REG_deleted')) { |
|
2187 | + $all_trashed = false; |
|
2188 | + } |
|
2189 | + } |
|
2190 | + if ( ! $all_trashed) { |
|
2191 | + EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', |
|
2192 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2193 | + return false; |
|
2194 | + } |
|
2195 | + //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
|
2196 | + foreach ($REGS as $registration) { |
|
2197 | + //delete related answers |
|
2198 | + $registration->delete_related_permanently('Answer'); |
|
2199 | + //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
|
2200 | + $attendee = $registration->get_first_related('Attendee'); |
|
2201 | + if ($attendee instanceof EE_Attendee) { |
|
2202 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
2203 | + } |
|
2204 | + //now remove relationships to tickets on this registration. |
|
2205 | + $registration->_remove_relations('Ticket'); |
|
2206 | + //now delete permanently the checkins related to this registration. |
|
2207 | + $registration->delete_related_permanently('Checkin'); |
|
2208 | + if ($registration->ID() === $REG->ID()) { |
|
2209 | + continue; |
|
2210 | + } //we don't want to delete permanently the existing registration just yet. |
|
2211 | + //remove relation to transaction for these registrations if NOT the existing registrations |
|
2212 | + $registration->_remove_relations('Transaction'); |
|
2213 | + //delete permanently any related messages. |
|
2214 | + $registration->delete_related_permanently('Message'); |
|
2215 | + //now delete this registration permanently |
|
2216 | + $registration->delete_permanently(); |
|
2217 | + } |
|
2218 | + //now all related registrations on the transaction are handled. So let's just handle this registration itself (the transaction and line items should be all that's left). |
|
2219 | + //delete the line items related to the transaction for this registration. |
|
2220 | + $TXN->delete_related_permanently('Line_Item'); |
|
2221 | + //we need to remove all the relationships on the transaction |
|
2222 | + $TXN->delete_related_permanently('Payment'); |
|
2223 | + $TXN->delete_related_permanently('Extra_Meta'); |
|
2224 | + $TXN->delete_related_permanently('Message'); |
|
2225 | + //now we can delete this REG permanently (and the transaction of course) |
|
2226 | + $REG->delete_related_permanently('Transaction'); |
|
2227 | + return $REG->delete_permanently(); |
|
2228 | + } |
|
2229 | + |
|
2230 | + |
|
2231 | + |
|
2232 | + /** |
|
2233 | + * generates HTML for the Register New Attendee Admin page |
|
2234 | + * |
|
2235 | + * @access private |
|
2236 | + * @throws \EE_Error |
|
2237 | + * @return void |
|
2238 | + */ |
|
2239 | + public function new_registration() |
|
2240 | + { |
|
2241 | + if ( ! $this->_set_reg_event()) { |
|
2242 | + throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', |
|
2243 | + 'event_espresso')); |
|
2244 | + } |
|
2245 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
2246 | + // gotta start with a clean slate if we're not coming here via ajax |
|
2247 | + if ( ! defined('DOING_AJAX') |
|
2248 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
2249 | + ) { |
|
2250 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2251 | + } |
|
2252 | + $this->_template_args['event_name'] = ''; |
|
2253 | + // event name |
|
2254 | + if ($this->_reg_event) { |
|
2255 | + $this->_template_args['event_name'] = $this->_reg_event->name(); |
|
2256 | + $edit_event_url = self::add_query_args_and_nonce(array( |
|
2257 | + 'action' => 'edit', |
|
2258 | + 'post' => $this->_reg_event->ID(), |
|
2259 | + ), EVENTS_ADMIN_URL); |
|
2260 | + $edit_event_lnk = '<a href="' |
|
2261 | + . $edit_event_url |
|
2262 | + . '" title="' |
|
2263 | + . esc_attr__('Edit ', 'event_espresso') |
|
2264 | + . $this->_reg_event->name() |
|
2265 | + . '">' |
|
2266 | + . __('Edit Event', 'event_espresso') |
|
2267 | + . '</a>'; |
|
2268 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' |
|
2269 | + . $edit_event_lnk |
|
2270 | + . '</span>'; |
|
2271 | + } |
|
2272 | + $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
|
2273 | + if (defined('DOING_AJAX')) { |
|
2274 | + $this->_return_json(); |
|
2275 | + } |
|
2276 | + // grab header |
|
2277 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
2278 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, |
|
2279 | + $this->_template_args, true); |
|
2280 | + //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
2281 | + // the details template wrapper |
|
2282 | + $this->display_admin_page_with_sidebar(); |
|
2283 | + } |
|
2284 | + |
|
2285 | + |
|
2286 | + |
|
2287 | + /** |
|
2288 | + * This returns the content for a registration step |
|
2289 | + * |
|
2290 | + * @access protected |
|
2291 | + * @return string html |
|
2292 | + */ |
|
2293 | + protected function _get_registration_step_content() |
|
2294 | + { |
|
2295 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
2296 | + $warning_msg = sprintf(__('%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
|
2297 | + 'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">', |
|
2298 | + '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>'); |
|
2299 | + return ' |
|
2300 | 2300 | <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
2301 | 2301 | <script > |
2302 | 2302 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
@@ -2309,646 +2309,646 @@ discard block |
||
2309 | 2309 | } |
2310 | 2310 | }, 800 ); |
2311 | 2311 | </script >'; |
2312 | - } |
|
2313 | - $template_args = array( |
|
2314 | - 'title' => '', |
|
2315 | - 'content' => '', |
|
2316 | - 'step_button_text' => '', |
|
2317 | - 'show_notification_toggle' => false, |
|
2318 | - ); |
|
2319 | - //to indicate we're processing a new registration |
|
2320 | - $hidden_fields = array( |
|
2321 | - 'processing_registration' => array( |
|
2322 | - 'type' => 'hidden', |
|
2323 | - 'value' => 0, |
|
2324 | - ), |
|
2325 | - 'event_id' => array( |
|
2326 | - 'type' => 'hidden', |
|
2327 | - 'value' => $this->_reg_event->ID(), |
|
2328 | - ), |
|
2329 | - ); |
|
2330 | - //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
2331 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
2332 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
2333 | - switch ($step) { |
|
2334 | - case 'ticket' : |
|
2335 | - $hidden_fields['processing_registration']['value'] = 1; |
|
2336 | - $template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso'); |
|
2337 | - $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
2338 | - $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', |
|
2339 | - 'event_espresso'); |
|
2340 | - $template_args['show_notification_toggle'] = false; |
|
2341 | - break; |
|
2342 | - case 'questions' : |
|
2343 | - $hidden_fields['processing_registration']['value'] = 2; |
|
2344 | - $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', |
|
2345 | - 'event_espresso'); |
|
2346 | - //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
|
2347 | - $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
2348 | - $template_args['step_button_text'] = __('Save Registration and Continue to Details', 'event_espresso'); |
|
2349 | - $template_args['show_notification_toggle'] = true; |
|
2350 | - break; |
|
2351 | - } |
|
2352 | - $this->_set_add_edit_form_tags('process_reg_step', |
|
2353 | - $hidden_fields); //we come back to the process_registration_step route. |
|
2354 | - return EEH_Template::display_template(REG_TEMPLATE_PATH |
|
2355 | - . 'reg_admin_register_new_attendee_step_content.template.php', |
|
2356 | - $template_args, true); |
|
2357 | - } |
|
2358 | - |
|
2359 | - |
|
2360 | - |
|
2361 | - /** |
|
2362 | - * set_reg_event |
|
2363 | - * |
|
2364 | - * @access private |
|
2365 | - * @return boolean |
|
2366 | - */ |
|
2367 | - private function _set_reg_event() |
|
2368 | - { |
|
2369 | - if (is_object($this->_reg_event)) { |
|
2370 | - return true; |
|
2371 | - } |
|
2372 | - $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
2373 | - if ( ! $EVT_ID) { |
|
2374 | - return false; |
|
2375 | - } |
|
2376 | - $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2377 | - return true; |
|
2378 | - } |
|
2379 | - |
|
2380 | - |
|
2381 | - |
|
2382 | - /** |
|
2383 | - * process_reg_step |
|
2384 | - * |
|
2385 | - * @access public |
|
2386 | - * @return string |
|
2387 | - * @throws \RuntimeException |
|
2388 | - * @throws \EE_Error |
|
2389 | - */ |
|
2390 | - public function process_reg_step() |
|
2391 | - { |
|
2392 | - EE_System::do_not_cache(); |
|
2393 | - $this->_set_reg_event(); |
|
2394 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
2395 | - EE_Registry::instance()->REQ->set('uts', time()); |
|
2396 | - //what step are we on? |
|
2397 | - $cart = EE_Registry::instance()->SSN->cart(); |
|
2398 | - $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
2399 | - //if doing ajax then we need to verify the nonce |
|
2400 | - if (defined('DOING_AJAX')) { |
|
2401 | - $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
2402 | - ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
2403 | - $this->_verify_nonce($nonce, $this->_req_nonce); |
|
2404 | - } |
|
2405 | - switch ($step) { |
|
2406 | - case 'ticket' : |
|
2407 | - //process ticket selection |
|
2408 | - $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
2409 | - if ($success) { |
|
2410 | - EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', |
|
2411 | - 'event_espresso')); |
|
2412 | - } else { |
|
2413 | - $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
2414 | - } |
|
2415 | - if (defined('DOING_AJAX')) { |
|
2416 | - $this->new_registration(); //display next step |
|
2417 | - } else { |
|
2418 | - $query_args = array( |
|
2419 | - 'action' => 'new_registration', |
|
2420 | - 'processing_registration' => 1, |
|
2421 | - 'event_id' => $this->_reg_event->ID(), |
|
2422 | - 'uts' => time(), |
|
2423 | - ); |
|
2424 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2425 | - } |
|
2426 | - break; |
|
2427 | - case 'questions' : |
|
2428 | - if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
2429 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
2430 | - } |
|
2431 | - //process registration |
|
2432 | - $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
2433 | - if ($cart instanceof EE_Cart) { |
|
2434 | - $grand_total = $cart->get_cart_grand_total(); |
|
2435 | - if ($grand_total instanceof EE_Line_Item) { |
|
2436 | - $grand_total->save_this_and_descendants_to_txn(); |
|
2437 | - } |
|
2438 | - } |
|
2439 | - if ( ! $transaction instanceof EE_Transaction) { |
|
2440 | - $query_args = array( |
|
2441 | - 'action' => 'new_registration', |
|
2442 | - 'processing_registration' => 2, |
|
2443 | - 'event_id' => $this->_reg_event->ID(), |
|
2444 | - 'uts' => time(), |
|
2445 | - ); |
|
2446 | - if (defined('DOING_AJAX')) { |
|
2447 | - //display registration form again because there are errors (maybe validation?) |
|
2448 | - $this->new_registration(); |
|
2449 | - return; |
|
2450 | - } else { |
|
2451 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2452 | - return; |
|
2453 | - } |
|
2454 | - } |
|
2455 | - // maybe update status, and make sure to save transaction if not done already |
|
2456 | - if ( ! $transaction->update_status_based_on_total_paid()) { |
|
2457 | - $transaction->save(); |
|
2458 | - } |
|
2459 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2460 | - $this->_req_data = array(); |
|
2461 | - $query_args = array( |
|
2462 | - 'action' => 'redirect_to_txn', |
|
2463 | - 'TXN_ID' => $transaction->ID(), |
|
2464 | - 'EVT_ID' => $this->_reg_event->ID(), |
|
2465 | - 'event_name' => urlencode($this->_reg_event->name()), |
|
2466 | - 'redirect_from' => 'new_registration', |
|
2467 | - ); |
|
2468 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2469 | - break; |
|
2470 | - } |
|
2471 | - //what are you looking here for? Should be nothing to do at this point. |
|
2472 | - } |
|
2473 | - |
|
2474 | - |
|
2475 | - |
|
2476 | - /** |
|
2477 | - * redirect_to_txn |
|
2478 | - * |
|
2479 | - * @access public |
|
2480 | - * @return void |
|
2481 | - */ |
|
2482 | - public function redirect_to_txn() |
|
2483 | - { |
|
2484 | - EE_System::do_not_cache(); |
|
2485 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2486 | - $query_args = array( |
|
2487 | - 'action' => 'view_transaction', |
|
2488 | - 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
2489 | - 'page' => 'espresso_transactions', |
|
2490 | - ); |
|
2491 | - if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
2492 | - $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
2493 | - $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
2494 | - $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
2495 | - } |
|
2496 | - EE_Error::add_success(__('Registration Created. Please review the transaction and add any payments as necessary', |
|
2497 | - 'event_espresso')); |
|
2498 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2499 | - } |
|
2500 | - |
|
2501 | - |
|
2502 | - |
|
2503 | - /** |
|
2504 | - * generates HTML for the Attendee Contact List |
|
2505 | - * |
|
2506 | - * @access protected |
|
2507 | - * @return void |
|
2508 | - */ |
|
2509 | - protected function _attendee_contact_list_table() |
|
2510 | - { |
|
2511 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2512 | - $this->_search_btn_label = __('Contacts', 'event_espresso'); |
|
2513 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
2514 | - } |
|
2515 | - |
|
2516 | - |
|
2517 | - |
|
2518 | - /** |
|
2519 | - * get_attendees |
|
2520 | - * |
|
2521 | - * @param bool $count whether to return count or data. |
|
2522 | - * @access public |
|
2523 | - * @return array |
|
2524 | - */ |
|
2525 | - public function get_attendees($per_page, $count = false, $trash = false) |
|
2526 | - { |
|
2527 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2528 | - require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
2529 | - $ATT_MDL = EEM_Attendee::instance(); |
|
2530 | - $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
2531 | - switch ($this->_req_data['orderby']) { |
|
2532 | - case 'ATT_ID': |
|
2533 | - $orderby = 'ATT_ID'; |
|
2534 | - break; |
|
2535 | - case 'ATT_fname': |
|
2536 | - $orderby = 'ATT_fname'; |
|
2537 | - break; |
|
2538 | - case 'ATT_email': |
|
2539 | - $orderby = 'ATT_email'; |
|
2540 | - break; |
|
2541 | - case 'ATT_city': |
|
2542 | - $orderby = 'ATT_city'; |
|
2543 | - break; |
|
2544 | - case 'STA_ID': |
|
2545 | - $orderby = 'STA_ID'; |
|
2546 | - break; |
|
2547 | - case 'CNT_ID': |
|
2548 | - $orderby = 'CNT_ID'; |
|
2549 | - break; |
|
2550 | - default: |
|
2551 | - $orderby = 'ATT_lname'; |
|
2552 | - } |
|
2553 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
2554 | - : 'ASC'; |
|
2555 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
2556 | - ? $this->_req_data['paged'] : 1; |
|
2557 | - $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
2558 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
2559 | - ? $this->_req_data['perpage'] : $per_page; |
|
2560 | - $_where = array(); |
|
2561 | - if ( ! empty($this->_req_data['s'])) { |
|
2562 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2563 | - $_where['OR'] = array( |
|
2564 | - 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
2565 | - 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
2566 | - 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
2567 | - 'ATT_fname' => array('LIKE', $sstr), |
|
2568 | - 'ATT_lname' => array('LIKE', $sstr), |
|
2569 | - 'ATT_short_bio' => array('LIKE', $sstr), |
|
2570 | - 'ATT_email' => array('LIKE', $sstr), |
|
2571 | - 'ATT_address' => array('LIKE', $sstr), |
|
2572 | - 'ATT_address2' => array('LIKE', $sstr), |
|
2573 | - 'ATT_city' => array('LIKE', $sstr), |
|
2574 | - 'Country.CNT_name' => array('LIKE', $sstr), |
|
2575 | - 'State.STA_name' => array('LIKE', $sstr), |
|
2576 | - 'ATT_phone' => array('LIKE', $sstr), |
|
2577 | - 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
2578 | - 'Registration.REG_code' => array('LIKE', $sstr), |
|
2579 | - 'Registration.REG_count' => array('LIKE', $sstr), |
|
2580 | - 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
2581 | - ); |
|
2582 | - } |
|
2583 | - $offset = ($current_page - 1) * $per_page; |
|
2584 | - $limit = $count ? null : array($offset, $per_page); |
|
2585 | - if ($trash) { |
|
2586 | - $_where['status'] = array('!=', 'publish'); |
|
2587 | - $all_attendees = $count |
|
2588 | - ? $ATT_MDL->count(array( |
|
2589 | - $_where, |
|
2590 | - 'order_by' => array($orderby => $sort), |
|
2591 | - 'limit' => $limit, |
|
2592 | - ), 'ATT_ID', true) |
|
2593 | - : $ATT_MDL->get_all(array( |
|
2594 | - $_where, |
|
2595 | - 'order_by' => array($orderby => $sort), |
|
2596 | - 'limit' => $limit, |
|
2597 | - )); |
|
2598 | - } else { |
|
2599 | - $_where['status'] = array('IN', array('publish')); |
|
2600 | - $all_attendees = $count |
|
2601 | - ? $ATT_MDL->count(array( |
|
2602 | - $_where, |
|
2603 | - 'order_by' => array($orderby => $sort), |
|
2604 | - 'limit' => $limit, |
|
2605 | - ), 'ATT_ID', true) |
|
2606 | - : $ATT_MDL->get_all(array( |
|
2607 | - $_where, |
|
2608 | - 'order_by' => array($orderby => $sort), |
|
2609 | - 'limit' => $limit, |
|
2610 | - )); |
|
2611 | - } |
|
2612 | - return $all_attendees; |
|
2613 | - } |
|
2614 | - |
|
2615 | - |
|
2616 | - |
|
2617 | - /** |
|
2618 | - * This is just taking care of resending the registration confirmation |
|
2619 | - * |
|
2620 | - * @access protected |
|
2621 | - * @return void |
|
2622 | - */ |
|
2623 | - protected function _resend_registration() |
|
2624 | - { |
|
2625 | - $this->_process_resend_registration(); |
|
2626 | - $query_args = isset($this->_req_data['redirect_to']) |
|
2627 | - ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
2628 | - : array( |
|
2629 | - 'action' => 'default', |
|
2630 | - ); |
|
2631 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2632 | - } |
|
2633 | - |
|
2634 | - |
|
2635 | - |
|
2636 | - public function _registrations_report() |
|
2637 | - { |
|
2638 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2639 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
2640 | - 'page' => 'espresso_batch', |
|
2641 | - 'batch' => 'file', |
|
2642 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
2643 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
2644 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
2645 | - ))); |
|
2646 | - } else { |
|
2647 | - $new_request_args = array( |
|
2648 | - 'export' => 'report', |
|
2649 | - 'action' => 'registrations_report_for_event', |
|
2650 | - 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
2651 | - ); |
|
2652 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
2653 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2654 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2655 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
2656 | - $EE_Export->export(); |
|
2657 | - } |
|
2658 | - } |
|
2659 | - } |
|
2660 | - |
|
2661 | - |
|
2662 | - |
|
2663 | - public function _contact_list_export() |
|
2664 | - { |
|
2665 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2666 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2667 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
2668 | - $EE_Export->export_attendees(); |
|
2669 | - } |
|
2670 | - } |
|
2671 | - |
|
2672 | - |
|
2673 | - |
|
2674 | - public function _contact_list_report() |
|
2675 | - { |
|
2676 | - if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2677 | - wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
2678 | - 'page' => 'espresso_batch', |
|
2679 | - 'batch' => 'file', |
|
2680 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
2681 | - 'return_url' => urlencode($this->_req_data['return_url']), |
|
2682 | - ))); |
|
2683 | - } else { |
|
2684 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2685 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2686 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
2687 | - $EE_Export->report_attendees(); |
|
2688 | - } |
|
2689 | - } |
|
2690 | - } |
|
2691 | - |
|
2692 | - |
|
2693 | - |
|
2694 | - |
|
2695 | - |
|
2696 | - /*************************************** ATTENDEE DETAILS ***************************************/ |
|
2697 | - /** |
|
2698 | - * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
2699 | - * |
|
2700 | - * @return void |
|
2701 | - */ |
|
2702 | - protected function _duplicate_attendee() |
|
2703 | - { |
|
2704 | - $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
2705 | - //verify we have necessary info |
|
2706 | - if (empty($this->_req_data['_REG_ID'])) { |
|
2707 | - EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
2708 | - 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
2709 | - $query_args = array('action' => $action); |
|
2710 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
2711 | - } |
|
2712 | - //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
2713 | - $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
2714 | - $attendee = $registration->attendee(); |
|
2715 | - //remove relation of existing attendee on registration |
|
2716 | - $registration->_remove_relation_to($attendee, 'Attendee'); |
|
2717 | - //new attendee |
|
2718 | - $new_attendee = clone $attendee; |
|
2719 | - $new_attendee->set('ATT_ID', 0); |
|
2720 | - $new_attendee->save(); |
|
2721 | - //add new attendee to reg |
|
2722 | - $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
2723 | - EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', |
|
2724 | - 'event_espresso')); |
|
2725 | - //redirect to edit page for attendee |
|
2726 | - $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
2727 | - $this->_redirect_after_action('', '', '', $query_args, true); |
|
2728 | - } |
|
2729 | - |
|
2730 | - |
|
2731 | - |
|
2732 | - //related to cpt routes |
|
2733 | - protected function _insert_update_cpt_item($post_id, $post) |
|
2734 | - { |
|
2735 | - $success = true; |
|
2736 | - $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
2737 | - //for attendee updates |
|
2738 | - if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
2739 | - //note we should only be UPDATING attendees at this point. |
|
2740 | - $updated_fields = array( |
|
2741 | - 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
2742 | - 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
2743 | - 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
2744 | - 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
2745 | - 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
2746 | - 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
2747 | - 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
2748 | - 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
2749 | - 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
2750 | - 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
2751 | - 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
2752 | - ); |
|
2753 | - foreach ($updated_fields as $field => $value) { |
|
2754 | - $attendee->set($field, $value); |
|
2755 | - } |
|
2756 | - $success = $attendee->save(); |
|
2757 | - $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
2758 | - array()); |
|
2759 | - foreach ($attendee_update_callbacks as $a_callback) { |
|
2760 | - if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
2761 | - throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
2762 | - 'event_espresso'), $a_callback)); |
|
2763 | - } |
|
2764 | - } |
|
2765 | - } |
|
2766 | - if ($success === false) { |
|
2767 | - EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', |
|
2768 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2769 | - } |
|
2770 | - } |
|
2771 | - |
|
2772 | - |
|
2773 | - |
|
2774 | - public function trash_cpt_item($post_id) |
|
2775 | - { |
|
2776 | - } |
|
2777 | - |
|
2778 | - |
|
2779 | - |
|
2780 | - public function delete_cpt_item($post_id) |
|
2781 | - { |
|
2782 | - } |
|
2783 | - |
|
2784 | - |
|
2785 | - |
|
2786 | - public function restore_cpt_item($post_id) |
|
2787 | - { |
|
2788 | - } |
|
2789 | - |
|
2790 | - |
|
2791 | - |
|
2792 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
2793 | - { |
|
2794 | - } |
|
2795 | - |
|
2796 | - |
|
2797 | - |
|
2798 | - public function attendee_editor_metaboxes() |
|
2799 | - { |
|
2800 | - $this->verify_cpt_object(); |
|
2801 | - remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], |
|
2802 | - 'normal', 'core'); |
|
2803 | - remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2804 | - if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
2805 | - add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', |
|
2806 | - $this->_cpt_routes[$this->_req_action], 'normal'); |
|
2807 | - } |
|
2808 | - if (post_type_supports('espresso_attendees', 'comments')) { |
|
2809 | - add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', |
|
2810 | - $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2811 | - } |
|
2812 | - add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), |
|
2813 | - array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
2814 | - add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), |
|
2815 | - array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2816 | - add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), |
|
2817 | - array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
2818 | - } |
|
2819 | - |
|
2820 | - |
|
2821 | - |
|
2822 | - /** |
|
2823 | - * Metabox for attendee contact info |
|
2824 | - * |
|
2825 | - * @param WP_Post $post wp post object |
|
2826 | - * @return string attendee contact info ( and form ) |
|
2827 | - */ |
|
2828 | - public function attendee_contact_info($post) |
|
2829 | - { |
|
2830 | - //get attendee object ( should already have it ) |
|
2831 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
2832 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
2833 | - EEH_Template::display_template($template, $this->_template_args); |
|
2834 | - } |
|
2835 | - |
|
2836 | - |
|
2837 | - |
|
2838 | - /** |
|
2839 | - * Metabox for attendee details |
|
2840 | - * |
|
2841 | - * @param WP_Post $post wp post object |
|
2842 | - * @return string attendee address details (and form) |
|
2843 | - */ |
|
2844 | - public function attendee_address_details($post) |
|
2845 | - { |
|
2846 | - //get attendee object (should already have it) |
|
2847 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
2848 | - $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
2849 | - 'QST_ID' => 0, |
|
2850 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
2851 | - 'QST_system' => 'admin-state', |
|
2852 | - )), EE_Answer::new_instance(array( |
|
2853 | - 'ANS_ID' => 0, |
|
2854 | - 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
2855 | - )), array( |
|
2856 | - 'input_id' => 'STA_ID', |
|
2857 | - 'input_name' => 'STA_ID', |
|
2858 | - 'input_prefix' => '', |
|
2859 | - 'append_qstn_id' => false, |
|
2860 | - ))); |
|
2861 | - $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
2862 | - 'QST_ID' => 0, |
|
2863 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
2864 | - 'QST_system' => 'admin-country', |
|
2865 | - )), EE_Answer::new_instance(array( |
|
2866 | - 'ANS_ID' => 0, |
|
2867 | - 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
2868 | - )), array( |
|
2869 | - 'input_id' => 'CNT_ISO', |
|
2870 | - 'input_name' => 'CNT_ISO', |
|
2871 | - 'input_prefix' => '', |
|
2872 | - 'append_qstn_id' => false, |
|
2873 | - ))); |
|
2874 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
2875 | - EEH_Template::display_template($template, $this->_template_args); |
|
2876 | - } |
|
2877 | - |
|
2878 | - |
|
2879 | - |
|
2880 | - /** |
|
2881 | - * _attendee_details |
|
2882 | - * |
|
2883 | - * @access protected |
|
2884 | - * @return void |
|
2885 | - */ |
|
2886 | - public function attendee_registrations_meta_box($post) |
|
2887 | - { |
|
2888 | - $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
2889 | - $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
2890 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
2891 | - EEH_Template::display_template($template, $this->_template_args); |
|
2892 | - } |
|
2893 | - |
|
2894 | - |
|
2895 | - |
|
2896 | - /** |
|
2897 | - * add in the form fields for the attendee edit |
|
2898 | - * |
|
2899 | - * @param WP_Post $post wp post object |
|
2900 | - * @return string html for new form. |
|
2901 | - */ |
|
2902 | - public function after_title_form_fields($post) |
|
2903 | - { |
|
2904 | - if ($post->post_type == 'espresso_attendees') { |
|
2905 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
2906 | - $template_args['attendee'] = $this->_cpt_model_obj; |
|
2907 | - EEH_Template::display_template($template, $template_args); |
|
2908 | - } |
|
2909 | - } |
|
2910 | - |
|
2911 | - |
|
2912 | - |
|
2913 | - /** |
|
2914 | - * _trash_or_restore_attendee |
|
2915 | - * |
|
2916 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
2917 | - * @access protected |
|
2918 | - * @return void |
|
2919 | - */ |
|
2920 | - protected function _trash_or_restore_attendees($trash = true) |
|
2921 | - { |
|
2922 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2923 | - $ATT_MDL = EEM_Attendee::instance(); |
|
2924 | - $success = 1; |
|
2925 | - //Checkboxes |
|
2926 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2927 | - // if array has more than one element than success message should be plural |
|
2928 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2929 | - // cycle thru checkboxes |
|
2930 | - while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2931 | - $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
2932 | - : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
2933 | - if ( ! $updated) { |
|
2934 | - $success = 0; |
|
2935 | - } |
|
2936 | - } |
|
2937 | - } else { |
|
2938 | - // grab single id and delete |
|
2939 | - $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
2940 | - //get attendee |
|
2941 | - $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
2942 | - $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
2943 | - $updated = $att->save(); |
|
2944 | - if ( ! $updated) { |
|
2945 | - $success = 0; |
|
2946 | - } |
|
2947 | - } |
|
2948 | - $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
2949 | - $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2950 | - $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
2951 | - } |
|
2312 | + } |
|
2313 | + $template_args = array( |
|
2314 | + 'title' => '', |
|
2315 | + 'content' => '', |
|
2316 | + 'step_button_text' => '', |
|
2317 | + 'show_notification_toggle' => false, |
|
2318 | + ); |
|
2319 | + //to indicate we're processing a new registration |
|
2320 | + $hidden_fields = array( |
|
2321 | + 'processing_registration' => array( |
|
2322 | + 'type' => 'hidden', |
|
2323 | + 'value' => 0, |
|
2324 | + ), |
|
2325 | + 'event_id' => array( |
|
2326 | + 'type' => 'hidden', |
|
2327 | + 'value' => $this->_reg_event->ID(), |
|
2328 | + ), |
|
2329 | + ); |
|
2330 | + //if the cart is empty then we know we're at step one so we'll display ticket selector |
|
2331 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
2332 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
2333 | + switch ($step) { |
|
2334 | + case 'ticket' : |
|
2335 | + $hidden_fields['processing_registration']['value'] = 1; |
|
2336 | + $template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso'); |
|
2337 | + $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
2338 | + $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', |
|
2339 | + 'event_espresso'); |
|
2340 | + $template_args['show_notification_toggle'] = false; |
|
2341 | + break; |
|
2342 | + case 'questions' : |
|
2343 | + $hidden_fields['processing_registration']['value'] = 2; |
|
2344 | + $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', |
|
2345 | + 'event_espresso'); |
|
2346 | + //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
|
2347 | + $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
|
2348 | + $template_args['step_button_text'] = __('Save Registration and Continue to Details', 'event_espresso'); |
|
2349 | + $template_args['show_notification_toggle'] = true; |
|
2350 | + break; |
|
2351 | + } |
|
2352 | + $this->_set_add_edit_form_tags('process_reg_step', |
|
2353 | + $hidden_fields); //we come back to the process_registration_step route. |
|
2354 | + return EEH_Template::display_template(REG_TEMPLATE_PATH |
|
2355 | + . 'reg_admin_register_new_attendee_step_content.template.php', |
|
2356 | + $template_args, true); |
|
2357 | + } |
|
2358 | + |
|
2359 | + |
|
2360 | + |
|
2361 | + /** |
|
2362 | + * set_reg_event |
|
2363 | + * |
|
2364 | + * @access private |
|
2365 | + * @return boolean |
|
2366 | + */ |
|
2367 | + private function _set_reg_event() |
|
2368 | + { |
|
2369 | + if (is_object($this->_reg_event)) { |
|
2370 | + return true; |
|
2371 | + } |
|
2372 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false; |
|
2373 | + if ( ! $EVT_ID) { |
|
2374 | + return false; |
|
2375 | + } |
|
2376 | + $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2377 | + return true; |
|
2378 | + } |
|
2379 | + |
|
2380 | + |
|
2381 | + |
|
2382 | + /** |
|
2383 | + * process_reg_step |
|
2384 | + * |
|
2385 | + * @access public |
|
2386 | + * @return string |
|
2387 | + * @throws \RuntimeException |
|
2388 | + * @throws \EE_Error |
|
2389 | + */ |
|
2390 | + public function process_reg_step() |
|
2391 | + { |
|
2392 | + EE_System::do_not_cache(); |
|
2393 | + $this->_set_reg_event(); |
|
2394 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
2395 | + EE_Registry::instance()->REQ->set('uts', time()); |
|
2396 | + //what step are we on? |
|
2397 | + $cart = EE_Registry::instance()->SSN->cart(); |
|
2398 | + $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
|
2399 | + //if doing ajax then we need to verify the nonce |
|
2400 | + if (defined('DOING_AJAX')) { |
|
2401 | + $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
2402 | + ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
2403 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
2404 | + } |
|
2405 | + switch ($step) { |
|
2406 | + case 'ticket' : |
|
2407 | + //process ticket selection |
|
2408 | + $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
|
2409 | + if ($success) { |
|
2410 | + EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', |
|
2411 | + 'event_espresso')); |
|
2412 | + } else { |
|
2413 | + $query_args['step_error'] = $this->_req_data['step_error'] = true; |
|
2414 | + } |
|
2415 | + if (defined('DOING_AJAX')) { |
|
2416 | + $this->new_registration(); //display next step |
|
2417 | + } else { |
|
2418 | + $query_args = array( |
|
2419 | + 'action' => 'new_registration', |
|
2420 | + 'processing_registration' => 1, |
|
2421 | + 'event_id' => $this->_reg_event->ID(), |
|
2422 | + 'uts' => time(), |
|
2423 | + ); |
|
2424 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2425 | + } |
|
2426 | + break; |
|
2427 | + case 'questions' : |
|
2428 | + if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
2429 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
2430 | + } |
|
2431 | + //process registration |
|
2432 | + $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
|
2433 | + if ($cart instanceof EE_Cart) { |
|
2434 | + $grand_total = $cart->get_cart_grand_total(); |
|
2435 | + if ($grand_total instanceof EE_Line_Item) { |
|
2436 | + $grand_total->save_this_and_descendants_to_txn(); |
|
2437 | + } |
|
2438 | + } |
|
2439 | + if ( ! $transaction instanceof EE_Transaction) { |
|
2440 | + $query_args = array( |
|
2441 | + 'action' => 'new_registration', |
|
2442 | + 'processing_registration' => 2, |
|
2443 | + 'event_id' => $this->_reg_event->ID(), |
|
2444 | + 'uts' => time(), |
|
2445 | + ); |
|
2446 | + if (defined('DOING_AJAX')) { |
|
2447 | + //display registration form again because there are errors (maybe validation?) |
|
2448 | + $this->new_registration(); |
|
2449 | + return; |
|
2450 | + } else { |
|
2451 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2452 | + return; |
|
2453 | + } |
|
2454 | + } |
|
2455 | + // maybe update status, and make sure to save transaction if not done already |
|
2456 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
2457 | + $transaction->save(); |
|
2458 | + } |
|
2459 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2460 | + $this->_req_data = array(); |
|
2461 | + $query_args = array( |
|
2462 | + 'action' => 'redirect_to_txn', |
|
2463 | + 'TXN_ID' => $transaction->ID(), |
|
2464 | + 'EVT_ID' => $this->_reg_event->ID(), |
|
2465 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
2466 | + 'redirect_from' => 'new_registration', |
|
2467 | + ); |
|
2468 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2469 | + break; |
|
2470 | + } |
|
2471 | + //what are you looking here for? Should be nothing to do at this point. |
|
2472 | + } |
|
2473 | + |
|
2474 | + |
|
2475 | + |
|
2476 | + /** |
|
2477 | + * redirect_to_txn |
|
2478 | + * |
|
2479 | + * @access public |
|
2480 | + * @return void |
|
2481 | + */ |
|
2482 | + public function redirect_to_txn() |
|
2483 | + { |
|
2484 | + EE_System::do_not_cache(); |
|
2485 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2486 | + $query_args = array( |
|
2487 | + 'action' => 'view_transaction', |
|
2488 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
2489 | + 'page' => 'espresso_transactions', |
|
2490 | + ); |
|
2491 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
2492 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
2493 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
2494 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
2495 | + } |
|
2496 | + EE_Error::add_success(__('Registration Created. Please review the transaction and add any payments as necessary', |
|
2497 | + 'event_espresso')); |
|
2498 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2499 | + } |
|
2500 | + |
|
2501 | + |
|
2502 | + |
|
2503 | + /** |
|
2504 | + * generates HTML for the Attendee Contact List |
|
2505 | + * |
|
2506 | + * @access protected |
|
2507 | + * @return void |
|
2508 | + */ |
|
2509 | + protected function _attendee_contact_list_table() |
|
2510 | + { |
|
2511 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2512 | + $this->_search_btn_label = __('Contacts', 'event_espresso'); |
|
2513 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
2514 | + } |
|
2515 | + |
|
2516 | + |
|
2517 | + |
|
2518 | + /** |
|
2519 | + * get_attendees |
|
2520 | + * |
|
2521 | + * @param bool $count whether to return count or data. |
|
2522 | + * @access public |
|
2523 | + * @return array |
|
2524 | + */ |
|
2525 | + public function get_attendees($per_page, $count = false, $trash = false) |
|
2526 | + { |
|
2527 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2528 | + require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php'); |
|
2529 | + $ATT_MDL = EEM_Attendee::instance(); |
|
2530 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
2531 | + switch ($this->_req_data['orderby']) { |
|
2532 | + case 'ATT_ID': |
|
2533 | + $orderby = 'ATT_ID'; |
|
2534 | + break; |
|
2535 | + case 'ATT_fname': |
|
2536 | + $orderby = 'ATT_fname'; |
|
2537 | + break; |
|
2538 | + case 'ATT_email': |
|
2539 | + $orderby = 'ATT_email'; |
|
2540 | + break; |
|
2541 | + case 'ATT_city': |
|
2542 | + $orderby = 'ATT_city'; |
|
2543 | + break; |
|
2544 | + case 'STA_ID': |
|
2545 | + $orderby = 'STA_ID'; |
|
2546 | + break; |
|
2547 | + case 'CNT_ID': |
|
2548 | + $orderby = 'CNT_ID'; |
|
2549 | + break; |
|
2550 | + default: |
|
2551 | + $orderby = 'ATT_lname'; |
|
2552 | + } |
|
2553 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] |
|
2554 | + : 'ASC'; |
|
2555 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
2556 | + ? $this->_req_data['paged'] : 1; |
|
2557 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
2558 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
2559 | + ? $this->_req_data['perpage'] : $per_page; |
|
2560 | + $_where = array(); |
|
2561 | + if ( ! empty($this->_req_data['s'])) { |
|
2562 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2563 | + $_where['OR'] = array( |
|
2564 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
2565 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
2566 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
2567 | + 'ATT_fname' => array('LIKE', $sstr), |
|
2568 | + 'ATT_lname' => array('LIKE', $sstr), |
|
2569 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
2570 | + 'ATT_email' => array('LIKE', $sstr), |
|
2571 | + 'ATT_address' => array('LIKE', $sstr), |
|
2572 | + 'ATT_address2' => array('LIKE', $sstr), |
|
2573 | + 'ATT_city' => array('LIKE', $sstr), |
|
2574 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
2575 | + 'State.STA_name' => array('LIKE', $sstr), |
|
2576 | + 'ATT_phone' => array('LIKE', $sstr), |
|
2577 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
2578 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
2579 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
2580 | + 'Registration.REG_group_size' => array('LIKE', $sstr), |
|
2581 | + ); |
|
2582 | + } |
|
2583 | + $offset = ($current_page - 1) * $per_page; |
|
2584 | + $limit = $count ? null : array($offset, $per_page); |
|
2585 | + if ($trash) { |
|
2586 | + $_where['status'] = array('!=', 'publish'); |
|
2587 | + $all_attendees = $count |
|
2588 | + ? $ATT_MDL->count(array( |
|
2589 | + $_where, |
|
2590 | + 'order_by' => array($orderby => $sort), |
|
2591 | + 'limit' => $limit, |
|
2592 | + ), 'ATT_ID', true) |
|
2593 | + : $ATT_MDL->get_all(array( |
|
2594 | + $_where, |
|
2595 | + 'order_by' => array($orderby => $sort), |
|
2596 | + 'limit' => $limit, |
|
2597 | + )); |
|
2598 | + } else { |
|
2599 | + $_where['status'] = array('IN', array('publish')); |
|
2600 | + $all_attendees = $count |
|
2601 | + ? $ATT_MDL->count(array( |
|
2602 | + $_where, |
|
2603 | + 'order_by' => array($orderby => $sort), |
|
2604 | + 'limit' => $limit, |
|
2605 | + ), 'ATT_ID', true) |
|
2606 | + : $ATT_MDL->get_all(array( |
|
2607 | + $_where, |
|
2608 | + 'order_by' => array($orderby => $sort), |
|
2609 | + 'limit' => $limit, |
|
2610 | + )); |
|
2611 | + } |
|
2612 | + return $all_attendees; |
|
2613 | + } |
|
2614 | + |
|
2615 | + |
|
2616 | + |
|
2617 | + /** |
|
2618 | + * This is just taking care of resending the registration confirmation |
|
2619 | + * |
|
2620 | + * @access protected |
|
2621 | + * @return void |
|
2622 | + */ |
|
2623 | + protected function _resend_registration() |
|
2624 | + { |
|
2625 | + $this->_process_resend_registration(); |
|
2626 | + $query_args = isset($this->_req_data['redirect_to']) |
|
2627 | + ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) |
|
2628 | + : array( |
|
2629 | + 'action' => 'default', |
|
2630 | + ); |
|
2631 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2632 | + } |
|
2633 | + |
|
2634 | + |
|
2635 | + |
|
2636 | + public function _registrations_report() |
|
2637 | + { |
|
2638 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2639 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
2640 | + 'page' => 'espresso_batch', |
|
2641 | + 'batch' => 'file', |
|
2642 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
2643 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
2644 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
2645 | + ))); |
|
2646 | + } else { |
|
2647 | + $new_request_args = array( |
|
2648 | + 'export' => 'report', |
|
2649 | + 'action' => 'registrations_report_for_event', |
|
2650 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null, |
|
2651 | + ); |
|
2652 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
2653 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2654 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2655 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
2656 | + $EE_Export->export(); |
|
2657 | + } |
|
2658 | + } |
|
2659 | + } |
|
2660 | + |
|
2661 | + |
|
2662 | + |
|
2663 | + public function _contact_list_export() |
|
2664 | + { |
|
2665 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2666 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2667 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
2668 | + $EE_Export->export_attendees(); |
|
2669 | + } |
|
2670 | + } |
|
2671 | + |
|
2672 | + |
|
2673 | + |
|
2674 | + public function _contact_list_report() |
|
2675 | + { |
|
2676 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2677 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array( |
|
2678 | + 'page' => 'espresso_batch', |
|
2679 | + 'batch' => 'file', |
|
2680 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
2681 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
2682 | + ))); |
|
2683 | + } else { |
|
2684 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2685 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2686 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
2687 | + $EE_Export->report_attendees(); |
|
2688 | + } |
|
2689 | + } |
|
2690 | + } |
|
2691 | + |
|
2692 | + |
|
2693 | + |
|
2694 | + |
|
2695 | + |
|
2696 | + /*************************************** ATTENDEE DETAILS ***************************************/ |
|
2697 | + /** |
|
2698 | + * This duplicates the attendee object for the given incoming registration id and attendee_id. |
|
2699 | + * |
|
2700 | + * @return void |
|
2701 | + */ |
|
2702 | + protected function _duplicate_attendee() |
|
2703 | + { |
|
2704 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
2705 | + //verify we have necessary info |
|
2706 | + if (empty($this->_req_data['_REG_ID'])) { |
|
2707 | + EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', |
|
2708 | + 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
2709 | + $query_args = array('action' => $action); |
|
2710 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
2711 | + } |
|
2712 | + //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
|
2713 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
2714 | + $attendee = $registration->attendee(); |
|
2715 | + //remove relation of existing attendee on registration |
|
2716 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
2717 | + //new attendee |
|
2718 | + $new_attendee = clone $attendee; |
|
2719 | + $new_attendee->set('ATT_ID', 0); |
|
2720 | + $new_attendee->save(); |
|
2721 | + //add new attendee to reg |
|
2722 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
2723 | + EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', |
|
2724 | + 'event_espresso')); |
|
2725 | + //redirect to edit page for attendee |
|
2726 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
2727 | + $this->_redirect_after_action('', '', '', $query_args, true); |
|
2728 | + } |
|
2729 | + |
|
2730 | + |
|
2731 | + |
|
2732 | + //related to cpt routes |
|
2733 | + protected function _insert_update_cpt_item($post_id, $post) |
|
2734 | + { |
|
2735 | + $success = true; |
|
2736 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
2737 | + //for attendee updates |
|
2738 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
2739 | + //note we should only be UPDATING attendees at this point. |
|
2740 | + $updated_fields = array( |
|
2741 | + 'ATT_fname' => $this->_req_data['ATT_fname'], |
|
2742 | + 'ATT_lname' => $this->_req_data['ATT_lname'], |
|
2743 | + 'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
2744 | + 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
|
2745 | + 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
|
2746 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
2747 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
2748 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
2749 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
2750 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
2751 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '', |
|
2752 | + ); |
|
2753 | + foreach ($updated_fields as $field => $value) { |
|
2754 | + $attendee->set($field, $value); |
|
2755 | + } |
|
2756 | + $success = $attendee->save(); |
|
2757 | + $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', |
|
2758 | + array()); |
|
2759 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
2760 | + if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
2761 | + throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', |
|
2762 | + 'event_espresso'), $a_callback)); |
|
2763 | + } |
|
2764 | + } |
|
2765 | + } |
|
2766 | + if ($success === false) { |
|
2767 | + EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', |
|
2768 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2769 | + } |
|
2770 | + } |
|
2771 | + |
|
2772 | + |
|
2773 | + |
|
2774 | + public function trash_cpt_item($post_id) |
|
2775 | + { |
|
2776 | + } |
|
2777 | + |
|
2778 | + |
|
2779 | + |
|
2780 | + public function delete_cpt_item($post_id) |
|
2781 | + { |
|
2782 | + } |
|
2783 | + |
|
2784 | + |
|
2785 | + |
|
2786 | + public function restore_cpt_item($post_id) |
|
2787 | + { |
|
2788 | + } |
|
2789 | + |
|
2790 | + |
|
2791 | + |
|
2792 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
2793 | + { |
|
2794 | + } |
|
2795 | + |
|
2796 | + |
|
2797 | + |
|
2798 | + public function attendee_editor_metaboxes() |
|
2799 | + { |
|
2800 | + $this->verify_cpt_object(); |
|
2801 | + remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], |
|
2802 | + 'normal', 'core'); |
|
2803 | + remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2804 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
2805 | + add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', |
|
2806 | + $this->_cpt_routes[$this->_req_action], 'normal'); |
|
2807 | + } |
|
2808 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
2809 | + add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', |
|
2810 | + $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2811 | + } |
|
2812 | + add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), |
|
2813 | + array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
2814 | + add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), |
|
2815 | + array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2816 | + add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), |
|
2817 | + array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
2818 | + } |
|
2819 | + |
|
2820 | + |
|
2821 | + |
|
2822 | + /** |
|
2823 | + * Metabox for attendee contact info |
|
2824 | + * |
|
2825 | + * @param WP_Post $post wp post object |
|
2826 | + * @return string attendee contact info ( and form ) |
|
2827 | + */ |
|
2828 | + public function attendee_contact_info($post) |
|
2829 | + { |
|
2830 | + //get attendee object ( should already have it ) |
|
2831 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
2832 | + $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
2833 | + EEH_Template::display_template($template, $this->_template_args); |
|
2834 | + } |
|
2835 | + |
|
2836 | + |
|
2837 | + |
|
2838 | + /** |
|
2839 | + * Metabox for attendee details |
|
2840 | + * |
|
2841 | + * @param WP_Post $post wp post object |
|
2842 | + * @return string attendee address details (and form) |
|
2843 | + */ |
|
2844 | + public function attendee_address_details($post) |
|
2845 | + { |
|
2846 | + //get attendee object (should already have it) |
|
2847 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
2848 | + $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
2849 | + 'QST_ID' => 0, |
|
2850 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
2851 | + 'QST_system' => 'admin-state', |
|
2852 | + )), EE_Answer::new_instance(array( |
|
2853 | + 'ANS_ID' => 0, |
|
2854 | + 'ANS_value' => $this->_cpt_model_obj->state_ID(), |
|
2855 | + )), array( |
|
2856 | + 'input_id' => 'STA_ID', |
|
2857 | + 'input_name' => 'STA_ID', |
|
2858 | + 'input_prefix' => '', |
|
2859 | + 'append_qstn_id' => false, |
|
2860 | + ))); |
|
2861 | + $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array( |
|
2862 | + 'QST_ID' => 0, |
|
2863 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
2864 | + 'QST_system' => 'admin-country', |
|
2865 | + )), EE_Answer::new_instance(array( |
|
2866 | + 'ANS_ID' => 0, |
|
2867 | + 'ANS_value' => $this->_cpt_model_obj->country_ID(), |
|
2868 | + )), array( |
|
2869 | + 'input_id' => 'CNT_ISO', |
|
2870 | + 'input_name' => 'CNT_ISO', |
|
2871 | + 'input_prefix' => '', |
|
2872 | + 'append_qstn_id' => false, |
|
2873 | + ))); |
|
2874 | + $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
2875 | + EEH_Template::display_template($template, $this->_template_args); |
|
2876 | + } |
|
2877 | + |
|
2878 | + |
|
2879 | + |
|
2880 | + /** |
|
2881 | + * _attendee_details |
|
2882 | + * |
|
2883 | + * @access protected |
|
2884 | + * @return void |
|
2885 | + */ |
|
2886 | + public function attendee_registrations_meta_box($post) |
|
2887 | + { |
|
2888 | + $this->_template_args['attendee'] = $this->_cpt_model_obj; |
|
2889 | + $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
|
2890 | + $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
2891 | + EEH_Template::display_template($template, $this->_template_args); |
|
2892 | + } |
|
2893 | + |
|
2894 | + |
|
2895 | + |
|
2896 | + /** |
|
2897 | + * add in the form fields for the attendee edit |
|
2898 | + * |
|
2899 | + * @param WP_Post $post wp post object |
|
2900 | + * @return string html for new form. |
|
2901 | + */ |
|
2902 | + public function after_title_form_fields($post) |
|
2903 | + { |
|
2904 | + if ($post->post_type == 'espresso_attendees') { |
|
2905 | + $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
2906 | + $template_args['attendee'] = $this->_cpt_model_obj; |
|
2907 | + EEH_Template::display_template($template, $template_args); |
|
2908 | + } |
|
2909 | + } |
|
2910 | + |
|
2911 | + |
|
2912 | + |
|
2913 | + /** |
|
2914 | + * _trash_or_restore_attendee |
|
2915 | + * |
|
2916 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
2917 | + * @access protected |
|
2918 | + * @return void |
|
2919 | + */ |
|
2920 | + protected function _trash_or_restore_attendees($trash = true) |
|
2921 | + { |
|
2922 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2923 | + $ATT_MDL = EEM_Attendee::instance(); |
|
2924 | + $success = 1; |
|
2925 | + //Checkboxes |
|
2926 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2927 | + // if array has more than one element than success message should be plural |
|
2928 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2929 | + // cycle thru checkboxes |
|
2930 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2931 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) |
|
2932 | + : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
2933 | + if ( ! $updated) { |
|
2934 | + $success = 0; |
|
2935 | + } |
|
2936 | + } |
|
2937 | + } else { |
|
2938 | + // grab single id and delete |
|
2939 | + $ATT_ID = absint($this->_req_data['ATT_ID']); |
|
2940 | + //get attendee |
|
2941 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
2942 | + $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
|
2943 | + $updated = $att->save(); |
|
2944 | + if ( ! $updated) { |
|
2945 | + $success = 0; |
|
2946 | + } |
|
2947 | + } |
|
2948 | + $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
2949 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2950 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
2951 | + } |
|
2952 | 2952 | |
2953 | 2953 | } |
2954 | 2954 |