@@ -146,7 +146,7 @@ |
||
146 | 146 | } |
147 | 147 | } |
148 | 148 | global $wpdb; |
149 | - $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
149 | + $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete)); |
|
150 | 150 | return $tables_to_delete; |
151 | 151 | } |
152 | 152 |
@@ -17,211 +17,211 @@ |
||
17 | 17 | class TableManager extends \EE_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var TableAnalysis $table_analysis |
|
22 | - */ |
|
23 | - private $table_analysis; |
|
24 | - |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * TableManager constructor. |
|
29 | - * |
|
30 | - * @param TableAnalysis $TableAnalysis |
|
31 | - */ |
|
32 | - public function __construct(TableAnalysis $TableAnalysis) |
|
33 | - { |
|
34 | - $this->table_analysis = $TableAnalysis; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Gets the injected table analyzer, or throws an exception |
|
41 | - * |
|
42 | - * @return TableAnalysis |
|
43 | - * @throws \EE_Error |
|
44 | - */ |
|
45 | - protected function getTableAnalysis() |
|
46 | - { |
|
47 | - if ($this->table_analysis instanceof TableAnalysis) { |
|
48 | - return $this->table_analysis; |
|
49 | - } else { |
|
50 | - throw new \EE_Error( |
|
51 | - sprintf( |
|
52 | - __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
53 | - get_class($this) |
|
54 | - ) |
|
55 | - ); |
|
56 | - } |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
63 | - * @param string $column_name |
|
64 | - * @param string $column_info |
|
65 | - * @return bool|false|int |
|
66 | - */ |
|
67 | - public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
68 | - { |
|
69 | - if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) { |
|
70 | - return false; |
|
71 | - } |
|
72 | - global $wpdb; |
|
73 | - $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
74 | - $columns = $this->getTableColumns($table_name); |
|
75 | - if ( ! in_array($column_name, $columns)) { |
|
76 | - $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
77 | - return $wpdb->query($alter_query); |
|
78 | - } |
|
79 | - return true; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Gets the name of all columns on the table. $table_name can |
|
86 | - * optionally start with $wpdb->prefix or not |
|
87 | - * |
|
88 | - * @global \wpdb $wpdb |
|
89 | - * @param string $table_name |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function getTableColumns($table_name) |
|
93 | - { |
|
94 | - global $wpdb; |
|
95 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
96 | - $fieldArray = array(); |
|
97 | - if ( ! empty($table_name)) { |
|
98 | - $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
|
99 | - if ($columns !== false) { |
|
100 | - foreach ($columns as $column) { |
|
101 | - $fieldArray[] = $column->Field; |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - return $fieldArray; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Drops the specified table from the database. $table_name can |
|
112 | - * optionally start with $wpdb->prefix or not |
|
113 | - * |
|
114 | - * @global \wpdb $wpdb |
|
115 | - * @param string $table_name |
|
116 | - * @return int |
|
117 | - */ |
|
118 | - public function dropTable($table_name) |
|
119 | - { |
|
120 | - global $wpdb; |
|
121 | - if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
122 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
123 | - return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
124 | - } |
|
125 | - return 0; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
132 | - * each table name provided has a wpdb prefix attached, and that it exists. |
|
133 | - * Returns the list actually deleted |
|
134 | - * |
|
135 | - * @global WPDB $wpdb |
|
136 | - * @param array $table_names |
|
137 | - * @return array of table names which we deleted |
|
138 | - */ |
|
139 | - public function dropTables($table_names) |
|
140 | - { |
|
141 | - $tables_to_delete = array(); |
|
142 | - foreach ($table_names as $table_name) { |
|
143 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
144 | - if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
145 | - $tables_to_delete[] = $table_name; |
|
146 | - } |
|
147 | - } |
|
148 | - global $wpdb; |
|
149 | - $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
150 | - return $tables_to_delete; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * Drops the specified index from the specified table. $table_name can |
|
157 | - * optionally start with $wpdb->prefix or not |
|
158 | - * |
|
159 | - * @global \wpdb $wpdb |
|
160 | - * @param string $table_name |
|
161 | - * @param string $indexName |
|
162 | - * @return int |
|
163 | - */ |
|
164 | - public function dropIndex($table_name, $indexName) |
|
165 | - { |
|
166 | - if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) { |
|
167 | - return false; |
|
168 | - } |
|
169 | - global $wpdb; |
|
170 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
171 | - $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$indexName'"; |
|
172 | - if ( |
|
173 | - $this->getTableAnalysis()->tableExists($table_name) |
|
174 | - && $wpdb->get_var($index_exists_query) |
|
175 | - === $table_name //using get_var with the $index_exists_query returns the table's name |
|
176 | - ) { |
|
177 | - return $wpdb->query("ALTER TABLE $table_name DROP INDEX $indexName"); |
|
178 | - } |
|
179 | - return 0; |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * Just creates the requested table. $table_name can |
|
186 | - * optionally start with $wpdb->prefix or not |
|
187 | - * |
|
188 | - * @param string $table_name |
|
189 | - * @param string $createSql defining the table's columns and indexes |
|
190 | - * @param string $engine (no need to specify "ENGINE=", that's implied) |
|
191 | - * @return void |
|
192 | - * @throws \EE_Error |
|
193 | - */ |
|
194 | - public function createTable($table_name, $createSql, $engine = 'MyISAM') |
|
195 | - { |
|
196 | - // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
|
197 | - if (preg_match('((((.*?))(,\s))+)', $createSql, $valid_column_data)) { |
|
198 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
199 | - $SQL = "CREATE TABLE $table_name ( $createSql ) ENGINE=$engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
|
200 | - /** @var \wpdb $wpdb */ |
|
201 | - global $wpdb; |
|
202 | - //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
|
203 | - //happened. And then we can choose to tell the end user |
|
204 | - $old_show_errors_policy = $wpdb->show_errors(true); |
|
205 | - $old_error_suppression_policy = $wpdb->suppress_errors(false); |
|
206 | - ob_start(); |
|
207 | - dbDelta($SQL); |
|
208 | - $output = ob_get_contents(); |
|
209 | - ob_end_clean(); |
|
210 | - $wpdb->show_errors($old_show_errors_policy); |
|
211 | - $wpdb->suppress_errors($old_error_suppression_policy); |
|
212 | - if ( ! empty($output)) { |
|
213 | - throw new \EE_Error($output); |
|
214 | - } |
|
215 | - } else { |
|
216 | - throw new \EE_Error( |
|
217 | - sprintf( |
|
218 | - __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', |
|
219 | - 'event_espresso'), |
|
220 | - '<br />', |
|
221 | - $createSql |
|
222 | - ) |
|
223 | - ); |
|
224 | - } |
|
225 | - } |
|
20 | + /** |
|
21 | + * @var TableAnalysis $table_analysis |
|
22 | + */ |
|
23 | + private $table_analysis; |
|
24 | + |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * TableManager constructor. |
|
29 | + * |
|
30 | + * @param TableAnalysis $TableAnalysis |
|
31 | + */ |
|
32 | + public function __construct(TableAnalysis $TableAnalysis) |
|
33 | + { |
|
34 | + $this->table_analysis = $TableAnalysis; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Gets the injected table analyzer, or throws an exception |
|
41 | + * |
|
42 | + * @return TableAnalysis |
|
43 | + * @throws \EE_Error |
|
44 | + */ |
|
45 | + protected function getTableAnalysis() |
|
46 | + { |
|
47 | + if ($this->table_analysis instanceof TableAnalysis) { |
|
48 | + return $this->table_analysis; |
|
49 | + } else { |
|
50 | + throw new \EE_Error( |
|
51 | + sprintf( |
|
52 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
53 | + get_class($this) |
|
54 | + ) |
|
55 | + ); |
|
56 | + } |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
63 | + * @param string $column_name |
|
64 | + * @param string $column_info |
|
65 | + * @return bool|false|int |
|
66 | + */ |
|
67 | + public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
68 | + { |
|
69 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) { |
|
70 | + return false; |
|
71 | + } |
|
72 | + global $wpdb; |
|
73 | + $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
74 | + $columns = $this->getTableColumns($table_name); |
|
75 | + if ( ! in_array($column_name, $columns)) { |
|
76 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
77 | + return $wpdb->query($alter_query); |
|
78 | + } |
|
79 | + return true; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Gets the name of all columns on the table. $table_name can |
|
86 | + * optionally start with $wpdb->prefix or not |
|
87 | + * |
|
88 | + * @global \wpdb $wpdb |
|
89 | + * @param string $table_name |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function getTableColumns($table_name) |
|
93 | + { |
|
94 | + global $wpdb; |
|
95 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
96 | + $fieldArray = array(); |
|
97 | + if ( ! empty($table_name)) { |
|
98 | + $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
|
99 | + if ($columns !== false) { |
|
100 | + foreach ($columns as $column) { |
|
101 | + $fieldArray[] = $column->Field; |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + return $fieldArray; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Drops the specified table from the database. $table_name can |
|
112 | + * optionally start with $wpdb->prefix or not |
|
113 | + * |
|
114 | + * @global \wpdb $wpdb |
|
115 | + * @param string $table_name |
|
116 | + * @return int |
|
117 | + */ |
|
118 | + public function dropTable($table_name) |
|
119 | + { |
|
120 | + global $wpdb; |
|
121 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
122 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
123 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
124 | + } |
|
125 | + return 0; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
132 | + * each table name provided has a wpdb prefix attached, and that it exists. |
|
133 | + * Returns the list actually deleted |
|
134 | + * |
|
135 | + * @global WPDB $wpdb |
|
136 | + * @param array $table_names |
|
137 | + * @return array of table names which we deleted |
|
138 | + */ |
|
139 | + public function dropTables($table_names) |
|
140 | + { |
|
141 | + $tables_to_delete = array(); |
|
142 | + foreach ($table_names as $table_name) { |
|
143 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
144 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
145 | + $tables_to_delete[] = $table_name; |
|
146 | + } |
|
147 | + } |
|
148 | + global $wpdb; |
|
149 | + $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
150 | + return $tables_to_delete; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * Drops the specified index from the specified table. $table_name can |
|
157 | + * optionally start with $wpdb->prefix or not |
|
158 | + * |
|
159 | + * @global \wpdb $wpdb |
|
160 | + * @param string $table_name |
|
161 | + * @param string $indexName |
|
162 | + * @return int |
|
163 | + */ |
|
164 | + public function dropIndex($table_name, $indexName) |
|
165 | + { |
|
166 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) { |
|
167 | + return false; |
|
168 | + } |
|
169 | + global $wpdb; |
|
170 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
171 | + $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$indexName'"; |
|
172 | + if ( |
|
173 | + $this->getTableAnalysis()->tableExists($table_name) |
|
174 | + && $wpdb->get_var($index_exists_query) |
|
175 | + === $table_name //using get_var with the $index_exists_query returns the table's name |
|
176 | + ) { |
|
177 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $indexName"); |
|
178 | + } |
|
179 | + return 0; |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * Just creates the requested table. $table_name can |
|
186 | + * optionally start with $wpdb->prefix or not |
|
187 | + * |
|
188 | + * @param string $table_name |
|
189 | + * @param string $createSql defining the table's columns and indexes |
|
190 | + * @param string $engine (no need to specify "ENGINE=", that's implied) |
|
191 | + * @return void |
|
192 | + * @throws \EE_Error |
|
193 | + */ |
|
194 | + public function createTable($table_name, $createSql, $engine = 'MyISAM') |
|
195 | + { |
|
196 | + // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
|
197 | + if (preg_match('((((.*?))(,\s))+)', $createSql, $valid_column_data)) { |
|
198 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
199 | + $SQL = "CREATE TABLE $table_name ( $createSql ) ENGINE=$engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
|
200 | + /** @var \wpdb $wpdb */ |
|
201 | + global $wpdb; |
|
202 | + //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
|
203 | + //happened. And then we can choose to tell the end user |
|
204 | + $old_show_errors_policy = $wpdb->show_errors(true); |
|
205 | + $old_error_suppression_policy = $wpdb->suppress_errors(false); |
|
206 | + ob_start(); |
|
207 | + dbDelta($SQL); |
|
208 | + $output = ob_get_contents(); |
|
209 | + ob_end_clean(); |
|
210 | + $wpdb->show_errors($old_show_errors_policy); |
|
211 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
212 | + if ( ! empty($output)) { |
|
213 | + throw new \EE_Error($output); |
|
214 | + } |
|
215 | + } else { |
|
216 | + throw new \EE_Error( |
|
217 | + sprintf( |
|
218 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', |
|
219 | + 'event_espresso'), |
|
220 | + '<br />', |
|
221 | + $createSql |
|
222 | + ) |
|
223 | + ); |
|
224 | + } |
|
225 | + } |
|
226 | 226 | |
227 | 227 | } |
@@ -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> |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param bool $routing |
57 | 57 | * @return Transactions_Admin_Page |
58 | 58 | */ |
59 | - public function __construct( $routing = TRUE ) { |
|
60 | - parent::__construct( $routing ); |
|
59 | + public function __construct($routing = TRUE) { |
|
60 | + parent::__construct($routing); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | protected function _ajax_hooks() { |
83 | - add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds')); |
|
84 | - add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds')); |
|
85 | - add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment')); |
|
83 | + add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds')); |
|
84 | + add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds')); |
|
85 | + add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | 'buttons' => array( |
98 | 98 | 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
99 | 99 | 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
100 | - 'delete' => esc_html__('Delete Transaction','event_espresso'), |
|
100 | + 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | $this->_set_transaction_status_array(); |
115 | 115 | |
116 | - $txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0; |
|
116 | + $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0; |
|
117 | 117 | |
118 | 118 | $this->_page_routes = array( |
119 | 119 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'filename' => 'transactions_overview_views_filters_search' |
186 | 186 | ), |
187 | 187 | ), |
188 | - 'help_tour' => array( 'Transactions_Overview_Help_Tour' ), |
|
188 | + 'help_tour' => array('Transactions_Overview_Help_Tour'), |
|
189 | 189 | /** |
190 | 190 | * commented out because currently we are not displaying tips for transaction list table status but this |
191 | 191 | * may change in a later iteration so want to keep the code for then. |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | 'nav' => array( |
198 | 198 | 'label' => esc_html__('View Transaction', 'event_espresso'), |
199 | 199 | 'order' => 5, |
200 | - 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url, |
|
200 | + 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url, |
|
201 | 201 | 'persistent' => FALSE |
202 | 202 | ), |
203 | 203 | 'help_tabs' => array( |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | 'filename' => 'transactions_view_transaction_primary_registrant_billing_information' |
219 | 219 | ), |
220 | 220 | ), |
221 | - 'qtips' => array( 'Transaction_Details_Tips' ), |
|
222 | - 'help_tour' => array( 'Transaction_Details_Help_Tour' ), |
|
221 | + 'qtips' => array('Transaction_Details_Tips'), |
|
222 | + 'help_tour' => array('Transaction_Details_Help_Tour'), |
|
223 | 223 | 'metaboxes' => array('_transaction_details_metaboxes'), |
224 | 224 | |
225 | 225 | 'require_nonce' => FALSE |
@@ -237,23 +237,23 @@ discard block |
||
237 | 237 | // IF a registration was JUST added via the admin... |
238 | 238 | if ( |
239 | 239 | isset( |
240 | - $this->_req_data[ 'redirect_from' ], |
|
241 | - $this->_req_data[ 'EVT_ID' ], |
|
242 | - $this->_req_data[ 'event_name' ] |
|
240 | + $this->_req_data['redirect_from'], |
|
241 | + $this->_req_data['EVT_ID'], |
|
242 | + $this->_req_data['event_name'] |
|
243 | 243 | ) |
244 | 244 | ) { |
245 | 245 | // then set a cookie so that we can block any attempts to use |
246 | 246 | // the back button as a way to enter another registration. |
247 | - setcookie( 'ee_registration_added', $this->_req_data[ 'EVT_ID' ], time() + WEEK_IN_SECONDS, '/' ); |
|
247 | + setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/'); |
|
248 | 248 | // and update the global |
249 | - $_COOKIE[ 'ee_registration_added' ] = $this->_req_data[ 'EVT_ID' ]; |
|
249 | + $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID']; |
|
250 | 250 | } |
251 | - EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = esc_html__( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' ); |
|
252 | - EE_Registry::$i18n_js_strings[ 'error_occurred' ] = esc_html__( 'An error occurred! Please refresh the page and try again.', 'event_espresso' ); |
|
253 | - EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status; |
|
254 | - EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status; |
|
255 | - EE_Registry::$i18n_js_strings[ 'payments_total' ] = esc_html__( 'Payments Total', 'event_espresso' ); |
|
256 | - EE_Registry::$i18n_js_strings[ 'transaction_overpaid' ] = esc_html__( 'This transaction has been overpaid ! Payments Total', 'event_espresso' ); |
|
251 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso'); |
|
252 | + EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', 'event_espresso'); |
|
253 | + EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
254 | + EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
255 | + EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
256 | + EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', 'event_espresso'); |
|
257 | 257 | } |
258 | 258 | public function admin_notices() {} |
259 | 259 | public function admin_footer_scripts() {} |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function load_scripts_styles() { |
322 | 322 | //enqueue style |
323 | - wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
323 | + wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
324 | 324 | wp_enqueue_style('espresso_txn'); |
325 | 325 | |
326 | 326 | //scripts |
327 | 327 | add_filter('FHEE_load_accounting_js', '__return_true'); |
328 | 328 | |
329 | 329 | //scripts |
330 | - wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE); |
|
330 | + wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE); |
|
331 | 331 | wp_enqueue_script('espresso_txn'); |
332 | 332 | |
333 | 333 | } |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @return void |
368 | 368 | */ |
369 | 369 | protected function _set_list_table_views_default() { |
370 | - $this->_views = array ( |
|
371 | - 'all' => array ( |
|
370 | + $this->_views = array( |
|
371 | + 'all' => array( |
|
372 | 372 | 'slug' => 'all', |
373 | 373 | 'label' => esc_html__('View All Transactions', 'event_espresso'), |
374 | 374 | 'count' => 0 |
@@ -396,21 +396,21 @@ discard block |
||
396 | 396 | * @return void |
397 | 397 | */ |
398 | 398 | private function _set_transaction_object() { |
399 | - if ( is_object( $this->_transaction) ) |
|
399 | + if (is_object($this->_transaction)) |
|
400 | 400 | return; //get out we've already set the object |
401 | 401 | |
402 | 402 | $TXN = EEM_Transaction::instance(); |
403 | 403 | |
404 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
404 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE; |
|
405 | 405 | |
406 | 406 | //get transaction object |
407 | 407 | $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
408 | - $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
408 | + $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
409 | 409 | $this->_transaction->verify_abandoned_transaction_status(); |
410 | 410 | |
411 | - if ( empty( $this->_transaction ) ) { |
|
412 | - $error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
413 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
411 | + if (empty($this->_transaction)) { |
|
412 | + $error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.esc_html__(' could not be retrieved.', 'event_espresso'); |
|
413 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | * @return array |
424 | 424 | */ |
425 | 425 | protected function _transaction_legend_items() { |
426 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
426 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
427 | 427 | $items = array(); |
428 | 428 | |
429 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
430 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
431 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
429 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
430 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
431 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
432 | 432 | $items['view_related_messages'] = array( |
433 | 433 | 'class' => $related_for_icon['css_class'], |
434 | 434 | 'desc' => $related_for_icon['label'], |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | |
439 | 439 | $items = apply_filters( |
440 | 440 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
441 | - array_merge( $items, |
|
441 | + array_merge($items, |
|
442 | 442 | array( |
443 | 443 | 'view_details' => array( |
444 | 444 | 'class' => 'dashicons dashicons-cart', |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | ), |
451 | 451 | 'view_receipt' => array( |
452 | 452 | 'class' => 'dashicons dashicons-media-default', |
453 | - 'desc' => esc_html__('View Transaction Receipt', 'event_espresso' ) |
|
453 | + 'desc' => esc_html__('View Transaction Receipt', 'event_espresso') |
|
454 | 454 | ), |
455 | 455 | 'view_registration' => array( |
456 | 456 | 'class' => 'dashicons dashicons-clipboard', |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | ) |
461 | 461 | ); |
462 | 462 | |
463 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) { |
|
464 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
463 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) { |
|
464 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
465 | 465 | $items['send_payment_reminder'] = array( |
466 | 466 | 'class' => 'dashicons dashicons-email-alt', |
467 | 467 | 'desc' => esc_html__('Send Payment Reminder', 'event_espresso') |
@@ -482,29 +482,29 @@ discard block |
||
482 | 482 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
483 | 483 | array( |
484 | 484 | 'overpaid' => array( |
485 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
486 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' ) |
|
485 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code, |
|
486 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence') |
|
487 | 487 | ), |
488 | 488 | 'complete' => array( |
489 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
490 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' ) |
|
489 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code, |
|
490 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence') |
|
491 | 491 | ), |
492 | 492 | 'incomplete' => array( |
493 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
494 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' ) |
|
493 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code, |
|
494 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence') |
|
495 | 495 | ), |
496 | 496 | 'abandoned' => array( |
497 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
498 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' ) |
|
497 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code, |
|
498 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence') |
|
499 | 499 | ), |
500 | 500 | 'failed' => array( |
501 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
502 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' ) |
|
501 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code, |
|
502 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence') |
|
503 | 503 | ) |
504 | 504 | ) |
505 | 505 | ); |
506 | 506 | |
507 | - return array_merge( $items, $more_items); |
|
507 | + return array_merge($items, $more_items); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | */ |
518 | 518 | protected function _transactions_overview_list_table() { |
519 | 519 | $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
520 | - $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL; |
|
521 | - $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : ''; |
|
522 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() ); |
|
520 | + $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL; |
|
521 | + $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : ''; |
|
522 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
523 | 523 | $this->display_admin_list_table_page_with_no_sidebar(); |
524 | 524 | } |
525 | 525 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @return void |
534 | 534 | */ |
535 | 535 | protected function _transaction_details() { |
536 | - do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction ); |
|
536 | + do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
537 | 537 | |
538 | 538 | $this->_set_transaction_status_array(); |
539 | 539 | |
@@ -546,14 +546,14 @@ discard block |
||
546 | 546 | $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL; |
547 | 547 | |
548 | 548 | $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
549 | - $this->_template_args['txn_nmbr']['label'] = esc_html__( 'Transaction Number', 'event_espresso' ); |
|
549 | + $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
550 | 550 | |
551 | 551 | $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
552 | - $this->_template_args['txn_datetime']['label'] = esc_html__( 'Date', 'event_espresso' ); |
|
552 | + $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
553 | 553 | |
554 | - $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ]; |
|
555 | - $this->_template_args['txn_status']['label'] = esc_html__( 'Transaction Status', 'event_espresso' ); |
|
556 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
554 | + $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
|
555 | + $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
556 | + $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID'); |
|
557 | 557 | |
558 | 558 | $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
559 | 559 | $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | ) |
567 | 567 | ) { |
568 | 568 | $this->_template_args['send_payment_reminder_button'] = |
569 | - EEH_MSG_Template::is_mt_active( 'payment_reminder' ) |
|
569 | + EEH_MSG_Template::is_mt_active('payment_reminder') |
|
570 | 570 | && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code |
571 | 571 | && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code |
572 | 572 | ? EEH_Template::get_button_or_link( |
@@ -588,40 +588,40 @@ discard block |
||
588 | 588 | } |
589 | 589 | |
590 | 590 | $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
591 | - $this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE ); |
|
592 | - if ( EE_Registry::instance()->CFG->currency->sign_b4 ) { |
|
593 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
591 | + $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE); |
|
592 | + if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
593 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due']; |
|
594 | 594 | } else { |
595 | - $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
595 | + $this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign; |
|
596 | 596 | } |
597 | - $this->_template_args['amount_due_class'] = ''; |
|
597 | + $this->_template_args['amount_due_class'] = ''; |
|
598 | 598 | |
599 | - if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) { |
|
599 | + if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) { |
|
600 | 600 | // paid in full |
601 | - $this->_template_args['amount_due'] = FALSE; |
|
602 | - } elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) { |
|
601 | + $this->_template_args['amount_due'] = FALSE; |
|
602 | + } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) { |
|
603 | 603 | // overpaid |
604 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
605 | - } elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) { |
|
604 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
605 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) { |
|
606 | 606 | // monies owing |
607 | - $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
608 | - } elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) { |
|
607 | + $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
608 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) { |
|
609 | 609 | // no payments made yet |
610 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
611 | - } elseif ( $this->_transaction->get('TXN_total') == 0 ) { |
|
610 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
611 | + } elseif ($this->_transaction->get('TXN_total') == 0) { |
|
612 | 612 | // free event |
613 | - $this->_template_args['amount_due'] = FALSE; |
|
613 | + $this->_template_args['amount_due'] = FALSE; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | $payment_method = $this->_transaction->payment_method(); |
617 | 617 | |
618 | 618 | $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
619 | 619 | ? $payment_method->admin_name() |
620 | - : esc_html__( 'Unknown', 'event_espresso' ); |
|
620 | + : esc_html__('Unknown', 'event_espresso'); |
|
621 | 621 | |
622 | 622 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
623 | 623 | // link back to overview |
624 | - $this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] ) |
|
624 | + $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) |
|
625 | 625 | ? $_SERVER['HTTP_REFERER'] |
626 | 626 | : TXN_ADMIN_URL; |
627 | 627 | |
@@ -629,13 +629,13 @@ discard block |
||
629 | 629 | // next link |
630 | 630 | $next_txn = $this->_transaction->next( |
631 | 631 | null, |
632 | - array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), |
|
632 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
633 | 633 | 'TXN_ID' |
634 | 634 | ); |
635 | 635 | $this->_template_args['next_transaction'] = $next_txn |
636 | 636 | ? $this->_next_link( |
637 | 637 | EE_Admin_Page::add_query_args_and_nonce( |
638 | - array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ), |
|
638 | + array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), |
|
639 | 639 | TXN_ADMIN_URL |
640 | 640 | ), |
641 | 641 | 'dashicons dashicons-arrow-right ee-icon-size-22' |
@@ -644,13 +644,13 @@ discard block |
||
644 | 644 | // previous link |
645 | 645 | $previous_txn = $this->_transaction->previous( |
646 | 646 | null, |
647 | - array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), |
|
647 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
648 | 648 | 'TXN_ID' |
649 | 649 | ); |
650 | 650 | $this->_template_args['previous_transaction'] = $previous_txn |
651 | 651 | ? $this->_previous_link( |
652 | 652 | EE_Admin_Page::add_query_args_and_nonce( |
653 | - array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ), |
|
653 | + array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), |
|
654 | 654 | TXN_ADMIN_URL |
655 | 655 | ), |
656 | 656 | 'dashicons dashicons-arrow-left ee-icon-size-22' |
@@ -660,16 +660,16 @@ discard block |
||
660 | 660 | // were we just redirected here after adding a new registration ??? |
661 | 661 | if ( |
662 | 662 | isset( |
663 | - $this->_req_data[ 'redirect_from' ], |
|
664 | - $this->_req_data[ 'EVT_ID' ], |
|
665 | - $this->_req_data[ 'event_name' ] |
|
663 | + $this->_req_data['redirect_from'], |
|
664 | + $this->_req_data['EVT_ID'], |
|
665 | + $this->_req_data['event_name'] |
|
666 | 666 | ) |
667 | 667 | ) { |
668 | 668 | if ( |
669 | 669 | EE_Registry::instance()->CAP->current_user_can( |
670 | 670 | 'ee_edit_registrations', |
671 | 671 | 'espresso_registrations_new_registration', |
672 | - $this->_req_data[ 'EVT_ID' ] |
|
672 | + $this->_req_data['EVT_ID'] |
|
673 | 673 | ) |
674 | 674 | ) { |
675 | 675 | $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
@@ -679,25 +679,25 @@ discard block |
||
679 | 679 | 'action' => 'new_registration', |
680 | 680 | 'return' => 'default', |
681 | 681 | 'TXN_ID' => $this->_transaction->ID(), |
682 | - 'event_id' => $this->_req_data[ 'EVT_ID' ], |
|
682 | + 'event_id' => $this->_req_data['EVT_ID'], |
|
683 | 683 | ), |
684 | 684 | REG_ADMIN_URL |
685 | 685 | ); |
686 | 686 | $this->_admin_page_title .= '">'; |
687 | 687 | |
688 | 688 | $this->_admin_page_title .= sprintf( |
689 | - esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso' ), |
|
690 | - htmlentities( urldecode( $this->_req_data[ 'event_name' ] ), ENT_QUOTES, 'UTF-8' ) |
|
689 | + esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
690 | + htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8') |
|
691 | 691 | ); |
692 | 692 | $this->_admin_page_title .= '</a>'; |
693 | 693 | } |
694 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
694 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
695 | 695 | } |
696 | 696 | // grab messages at the last second |
697 | 697 | $this->_template_args['notices'] = EE_Error::get_notices(); |
698 | 698 | // path to template |
699 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
700 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
699 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php'; |
|
700 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
701 | 701 | |
702 | 702 | // the details template wrapper |
703 | 703 | $this->display_admin_page_with_sidebar(); |
@@ -716,18 +716,18 @@ discard block |
||
716 | 716 | |
717 | 717 | $this->_set_transaction_object(); |
718 | 718 | |
719 | - add_meta_box( 'edit-txn-details-mbox', esc_html__( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' ); |
|
719 | + add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high'); |
|
720 | 720 | add_meta_box( |
721 | 721 | 'edit-txn-attendees-mbox', |
722 | - esc_html__( 'Attendees Registered in this Transaction', 'event_espresso' ), |
|
723 | - array( $this, 'txn_attendees_meta_box' ), |
|
722 | + esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
723 | + array($this, 'txn_attendees_meta_box'), |
|
724 | 724 | $this->_wp_page_slug, |
725 | 725 | 'normal', |
726 | 726 | 'high', |
727 | - array( 'TXN_ID' => $this->_transaction->ID() ) |
|
727 | + array('TXN_ID' => $this->_transaction->ID()) |
|
728 | 728 | ); |
729 | - add_meta_box( 'edit-txn-registrant-mbox', esc_html__( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' ); |
|
730 | - add_meta_box( 'edit-txn-billing-info-mbox', esc_html__( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' ); |
|
729 | + add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
730 | + add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
731 | 731 | |
732 | 732 | } |
733 | 733 | |
@@ -748,15 +748,15 @@ discard block |
||
748 | 748 | |
749 | 749 | //get line table |
750 | 750 | EEH_Autoloader::register_line_item_display_autoloaders(); |
751 | - $Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' ); |
|
752 | - $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() ); |
|
751 | + $Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy'); |
|
752 | + $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item()); |
|
753 | 753 | $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code'); |
754 | 754 | |
755 | 755 | // process taxes |
756 | - $taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax ))); |
|
757 | - $this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE; |
|
756 | + $taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
757 | + $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE; |
|
758 | 758 | |
759 | - $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE ); |
|
759 | + $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE); |
|
760 | 760 | $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total'); |
761 | 761 | $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID'); |
762 | 762 | |
@@ -764,63 +764,63 @@ discard block |
||
764 | 764 | |
765 | 765 | // process payment details |
766 | 766 | $payments = $this->_transaction->get_many_related('Payment'); |
767 | - if( ! empty( $payments ) ) { |
|
768 | - $this->_template_args[ 'payments' ] = $payments; |
|
769 | - $this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments ); |
|
767 | + if ( ! empty($payments)) { |
|
768 | + $this->_template_args['payments'] = $payments; |
|
769 | + $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
770 | 770 | } else { |
771 | - $this->_template_args[ 'payments' ] = false; |
|
772 | - $this->_template_args[ 'existing_reg_payments' ] = array(); |
|
771 | + $this->_template_args['payments'] = false; |
|
772 | + $this->_template_args['existing_reg_payments'] = array(); |
|
773 | 773 | } |
774 | 774 | |
775 | - $this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment' ), TXN_ADMIN_URL ); |
|
776 | - $this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL ); |
|
775 | + $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL); |
|
776 | + $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL); |
|
777 | 777 | |
778 | - if ( isset( $txn_details['invoice_number'] )) { |
|
778 | + if (isset($txn_details['invoice_number'])) { |
|
779 | 779 | $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
780 | - $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__( 'Invoice Number', 'event_espresso' ); |
|
780 | + $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', 'event_espresso'); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session'); |
784 | - $this->_template_args['txn_details']['registration_session']['label'] = esc_html__( 'Registration Session', 'event_espresso' ); |
|
784 | + $this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', 'event_espresso'); |
|
785 | 785 | |
786 | - $this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : ''; |
|
787 | - $this->_template_args['txn_details']['ip_address']['label'] = esc_html__( 'Transaction placed from IP', 'event_espresso' ); |
|
786 | + $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : ''; |
|
787 | + $this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', 'event_espresso'); |
|
788 | 788 | |
789 | - $this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : ''; |
|
790 | - $this->_template_args['txn_details']['user_agent']['label'] = esc_html__( 'Registrant User Agent', 'event_espresso' ); |
|
789 | + $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : ''; |
|
790 | + $this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', 'event_espresso'); |
|
791 | 791 | |
792 | 792 | $reg_steps = '<ul>'; |
793 | - foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) { |
|
794 | - if ( $reg_step_status === true ) { |
|
795 | - $reg_steps .= '<li style="color:#70cc50">' . sprintf( esc_html__( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>'; |
|
796 | - } else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) { |
|
797 | - $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
798 | - esc_html__( '%1$s : Initiated %2$s', 'event_espresso' ), |
|
799 | - ucwords( str_replace( '_', ' ', $reg_step ) ), |
|
800 | - date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) ) |
|
801 | - ) . '</li>'; |
|
793 | + foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
794 | + if ($reg_step_status === true) { |
|
795 | + $reg_steps .= '<li style="color:#70cc50">'.sprintf(esc_html__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
796 | + } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
|
797 | + $reg_steps .= '<li style="color:#2EA2CC">'.sprintf( |
|
798 | + esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
799 | + ucwords(str_replace('_', ' ', $reg_step)), |
|
800 | + date(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
|
801 | + ).'</li>'; |
|
802 | 802 | } else { |
803 | - $reg_steps .= '<li style="color:#E76700">' . sprintf( esc_html__( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>'; |
|
803 | + $reg_steps .= '<li style="color:#E76700">'.sprintf(esc_html__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
804 | 804 | } |
805 | 805 | } |
806 | 806 | $reg_steps .= '</ul>'; |
807 | 807 | $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
808 | - $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__( 'Registration Step Progress', 'event_espresso' ); |
|
808 | + $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', 'event_espresso'); |
|
809 | 809 | |
810 | 810 | |
811 | 811 | $this->_get_registrations_to_apply_payment_to(); |
812 | - $this->_get_payment_methods( $payments ); |
|
812 | + $this->_get_payment_methods($payments); |
|
813 | 813 | $this->_get_payment_status_array(); |
814 | 814 | $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
815 | 815 | |
816 | - $this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction' ), TXN_ADMIN_URL ); |
|
817 | - $this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL ); |
|
818 | - $this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL ); |
|
816 | + $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL); |
|
817 | + $this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL); |
|
818 | + $this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL); |
|
819 | 819 | |
820 | 820 | // 'espresso_delete_payment_nonce' |
821 | 821 | |
822 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
823 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
822 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
823 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
824 | 824 | |
825 | 825 | } |
826 | 826 | |
@@ -835,27 +835,27 @@ discard block |
||
835 | 835 | * @param EE_Payment[] $payments |
836 | 836 | * @return array |
837 | 837 | */ |
838 | - protected function _get_registration_payment_IDs( $payments = array() ) { |
|
838 | + protected function _get_registration_payment_IDs($payments = array()) { |
|
839 | 839 | $existing_reg_payments = array(); |
840 | 840 | // get all reg payments for these payments |
841 | - $reg_payments = EEM_Registration_Payment::instance()->get_all( array( |
|
841 | + $reg_payments = EEM_Registration_Payment::instance()->get_all(array( |
|
842 | 842 | array( |
843 | 843 | 'PAY_ID' => array( |
844 | 844 | 'IN', |
845 | - array_keys( $payments ) |
|
845 | + array_keys($payments) |
|
846 | 846 | ) |
847 | 847 | ) |
848 | - ) ); |
|
849 | - if ( ! empty( $reg_payments ) ) { |
|
850 | - foreach ( $payments as $payment ) { |
|
851 | - if ( ! $payment instanceof EE_Payment ) { |
|
848 | + )); |
|
849 | + if ( ! empty($reg_payments)) { |
|
850 | + foreach ($payments as $payment) { |
|
851 | + if ( ! $payment instanceof EE_Payment) { |
|
852 | 852 | continue; |
853 | - } else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) { |
|
854 | - $existing_reg_payments[ $payment->ID() ] = array(); |
|
853 | + } else if ( ! isset($existing_reg_payments[$payment->ID()])) { |
|
854 | + $existing_reg_payments[$payment->ID()] = array(); |
|
855 | 855 | } |
856 | - foreach ( $reg_payments as $reg_payment ) { |
|
857 | - if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) { |
|
858 | - $existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID(); |
|
856 | + foreach ($reg_payments as $reg_payment) { |
|
857 | + if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) { |
|
858 | + $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID(); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | } |
@@ -888,54 +888,54 @@ discard block |
||
888 | 888 | ) |
889 | 889 | ) |
890 | 890 | ); |
891 | - $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
891 | + $registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div( |
|
892 | 892 | '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
893 | 893 | ); |
894 | - $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div( '', '', 'admin-primary-mbox-tbl-wrap' ); |
|
895 | - $registrations_to_apply_payment_to .= EEH_HTML::table( '', '', 'admin-primary-mbox-tbl' ); |
|
894 | + $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
895 | + $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
896 | 896 | $registrations_to_apply_payment_to .= EEH_HTML::thead( |
897 | 897 | EEH_HTML::tr( |
898 | - EEH_HTML::th( esc_html__( 'ID', 'event_espresso' ) ) . |
|
899 | - EEH_HTML::th( esc_html__( 'Registrant', 'event_espresso' ) ) . |
|
900 | - EEH_HTML::th( esc_html__( 'Ticket', 'event_espresso' ) ) . |
|
901 | - EEH_HTML::th( esc_html__( 'Event', 'event_espresso' ) ) . |
|
902 | - EEH_HTML::th( esc_html__( 'Paid', 'event_espresso' ), '', 'txn-admin-payment-paid-td jst-cntr' ) . |
|
903 | - EEH_HTML::th( esc_html__( 'Owing', 'event_espresso' ), '', 'txn-admin-payment-owing-td jst-cntr' ) . |
|
904 | - EEH_HTML::th( esc_html__( 'Apply', 'event_espresso' ), '', 'jst-cntr' ) |
|
898 | + EEH_HTML::th(esc_html__('ID', 'event_espresso')). |
|
899 | + EEH_HTML::th(esc_html__('Registrant', 'event_espresso')). |
|
900 | + EEH_HTML::th(esc_html__('Ticket', 'event_espresso')). |
|
901 | + EEH_HTML::th(esc_html__('Event', 'event_espresso')). |
|
902 | + EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
903 | + EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
904 | + EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
905 | 905 | ) |
906 | 906 | ); |
907 | 907 | $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
908 | 908 | // get registrations for TXN |
909 | - $registrations = $this->_transaction->registrations( $query_params ); |
|
910 | - foreach ( $registrations as $registration ) { |
|
911 | - if ( $registration instanceof EE_Registration ) { |
|
909 | + $registrations = $this->_transaction->registrations($query_params); |
|
910 | + foreach ($registrations as $registration) { |
|
911 | + if ($registration instanceof EE_Registration) { |
|
912 | 912 | $attendee_name = $registration->attendee() instanceof EE_Attendee |
913 | 913 | ? $registration->attendee()->full_name() |
914 | - : esc_html__( 'Unknown Attendee', 'event_espresso' ); |
|
914 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
915 | 915 | $owing = $registration->final_price() - $registration->paid(); |
916 | 916 | $taxable = $registration->ticket()->taxable() |
917 | - ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__( '+ tax', 'event_espresso' ) . '</span>' |
|
917 | + ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>' |
|
918 | 918 | : ''; |
919 | - $checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments ) |
|
919 | + $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) |
|
920 | 920 | ? ' checked="checked"' |
921 | 921 | : ''; |
922 | 922 | $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
923 | 923 | $registrations_to_apply_payment_to .= EEH_HTML::tr( |
924 | - EEH_HTML::td( $registration->ID() ) . |
|
925 | - EEH_HTML::td( $attendee_name ) . |
|
924 | + EEH_HTML::td($registration->ID()). |
|
925 | + EEH_HTML::td($attendee_name). |
|
926 | 926 | EEH_HTML::td( |
927 | - $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
928 | - ) . |
|
929 | - EEH_HTML::td( $registration->event_name() ) . |
|
930 | - EEH_HTML::td( $registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr' ) . |
|
931 | - EEH_HTML::td( EEH_Template::format_currency( $owing ), '', 'txn-admin-payment-owing-td jst-cntr' ) . |
|
927 | + $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable |
|
928 | + ). |
|
929 | + EEH_HTML::td($registration->event_name()). |
|
930 | + EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
931 | + EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
932 | 932 | EEH_HTML::td( |
933 | - '<input type="checkbox" value="' . $registration->ID() |
|
933 | + '<input type="checkbox" value="'.$registration->ID() |
|
934 | 934 | . '" name="txn_admin_payment[registrations]"' |
935 | - . $checked . $disabled . '>', |
|
935 | + . $checked.$disabled.'>', |
|
936 | 936 | '', 'jst-cntr' |
937 | 937 | ), |
938 | - 'apply-payment-registration-row-' . $registration->ID() |
|
938 | + 'apply-payment-registration-row-'.$registration->ID() |
|
939 | 939 | ); |
940 | 940 | } |
941 | 941 | } |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | '', 'clear description' |
951 | 951 | ); |
952 | 952 | $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
953 | - $this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to; |
|
953 | + $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | |
@@ -967,9 +967,9 @@ discard block |
||
967 | 967 | $statuses = EEM_Registration::reg_status_array(array(), TRUE); |
968 | 968 | //let's add a "don't change" option. |
969 | 969 | $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
970 | - $status_array = array_merge( $status_array, $statuses ); |
|
971 | - $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' ); |
|
972 | - $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' ); |
|
970 | + $status_array = array_merge($status_array, $statuses); |
|
971 | + $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status'); |
|
972 | + $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status'); |
|
973 | 973 | |
974 | 974 | } |
975 | 975 | |
@@ -984,21 +984,21 @@ discard block |
||
984 | 984 | * @param EE_Payment[] to show on this page |
985 | 985 | * @return void |
986 | 986 | */ |
987 | - private function _get_payment_methods( $payments = array() ) { |
|
987 | + private function _get_payment_methods($payments = array()) { |
|
988 | 988 | $payment_methods_of_payments = array(); |
989 | - foreach( $payments as $payment ){ |
|
990 | - if( $payment instanceof EE_Payment ){ |
|
991 | - $payment_methods_of_payments[] = $payment->get( 'PMD_ID' ); |
|
989 | + foreach ($payments as $payment) { |
|
990 | + if ($payment instanceof EE_Payment) { |
|
991 | + $payment_methods_of_payments[] = $payment->get('PMD_ID'); |
|
992 | 992 | } |
993 | 993 | } |
994 | - if( $payment_methods_of_payments ){ |
|
995 | - $query_args = array( array( 'OR*payment_method_for_payment' => array( |
|
996 | - 'PMD_ID' => array( 'IN', $payment_methods_of_payments ), |
|
997 | - 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) ); |
|
998 | - }else{ |
|
999 | - $query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ); |
|
994 | + if ($payment_methods_of_payments) { |
|
995 | + $query_args = array(array('OR*payment_method_for_payment' => array( |
|
996 | + 'PMD_ID' => array('IN', $payment_methods_of_payments), |
|
997 | + 'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') ))); |
|
998 | + } else { |
|
999 | + $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'))); |
|
1000 | 1000 | } |
1001 | - $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args ); |
|
1001 | + $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | |
@@ -1012,17 +1012,17 @@ discard block |
||
1012 | 1012 | * @param array $metabox |
1013 | 1013 | * @return void |
1014 | 1014 | */ |
1015 | - public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) { |
|
1015 | + public function txn_attendees_meta_box($post, $metabox = array('args' => array())) { |
|
1016 | 1016 | |
1017 | - extract( $metabox['args'] ); |
|
1017 | + extract($metabox['args']); |
|
1018 | 1018 | $this->_template_args['post'] = $post; |
1019 | 1019 | $this->_template_args['event_attendees'] = array(); |
1020 | 1020 | // process items in cart |
1021 | - $line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) ); |
|
1022 | - if ( ! empty( $line_items )) { |
|
1023 | - foreach ( $line_items as $item ) { |
|
1024 | - if ( $item instanceof EE_Line_Item ) { |
|
1025 | - switch( $item->OBJ_type() ) { |
|
1021 | + $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
|
1022 | + if ( ! empty($line_items)) { |
|
1023 | + foreach ($line_items as $item) { |
|
1024 | + if ($item instanceof EE_Line_Item) { |
|
1025 | + switch ($item->OBJ_type()) { |
|
1026 | 1026 | |
1027 | 1027 | case 'Event' : |
1028 | 1028 | break; |
@@ -1030,39 +1030,39 @@ discard block |
||
1030 | 1030 | case 'Ticket' : |
1031 | 1031 | $ticket = $item->ticket(); |
1032 | 1032 | //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
1033 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
1033 | + if ( ! $ticket instanceof EE_Ticket) { |
|
1034 | 1034 | continue; |
1035 | 1035 | } |
1036 | 1036 | try { |
1037 | 1037 | $event_name = $ticket->get_event_name(); |
1038 | - } catch ( Exception $e ) { |
|
1039 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1040 | - $event_name = esc_html__( 'Unknown Event', 'event_espresso' ); |
|
1038 | + } catch (Exception $e) { |
|
1039 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1040 | + $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
1041 | 1041 | } |
1042 | - $event_name .= ' - ' . $item->get( 'LIN_name' ); |
|
1043 | - $ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' ) ); |
|
1042 | + $event_name .= ' - '.$item->get('LIN_name'); |
|
1043 | + $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
|
1044 | 1044 | // now get all of the registrations for this transaction that use this ticket |
1045 | - $registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() ))); |
|
1046 | - foreach( $registrations as $registration ) { |
|
1047 | - if ( ! $registration instanceof EE_Registration ) { |
|
1045 | + $registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID()))); |
|
1046 | + foreach ($registrations as $registration) { |
|
1047 | + if ( ! $registration instanceof EE_Registration) { |
|
1048 | 1048 | continue; |
1049 | 1049 | } |
1050 | - $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
1051 | - $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
1052 | - $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
1053 | - $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
1050 | + $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
1051 | + $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
1052 | + $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
1053 | + $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
1054 | 1054 | // attendee info |
1055 | 1055 | $attendee = $registration->get_first_related('Attendee'); |
1056 | - if ( $attendee instanceof EE_Attendee ) { |
|
1057 | - $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
1058 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
1059 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
1060 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format( $attendee, 'inline', false, false ); |
|
1056 | + if ($attendee instanceof EE_Attendee) { |
|
1057 | + $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
1058 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
1059 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event_name.esc_html__(' Event', 'event_espresso').'">'.$attendee->email().'</a>'; |
|
1060 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, 'inline', false, false); |
|
1061 | 1061 | } else { |
1062 | 1062 | $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = ''; |
1063 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
1063 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
1064 | 1064 | $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
1065 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
1065 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | break; |
@@ -1071,12 +1071,12 @@ discard block |
||
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | |
1074 | - $this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees' ), TXN_ADMIN_URL ); |
|
1075 | - echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE ); |
|
1074 | + $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL); |
|
1075 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE); |
|
1076 | 1076 | |
1077 | 1077 | } else { |
1078 | 1078 | echo sprintf( |
1079 | - esc_html__( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ), |
|
1079 | + esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'), |
|
1080 | 1080 | '<p class="important-notice">', |
1081 | 1081 | '</p>' |
1082 | 1082 | ); |
@@ -1095,19 +1095,19 @@ discard block |
||
1095 | 1095 | */ |
1096 | 1096 | public function txn_registrant_side_meta_box() { |
1097 | 1097 | $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
1098 | - if ( ! $primary_att instanceof EE_Attendee ) { |
|
1098 | + if ( ! $primary_att instanceof EE_Attendee) { |
|
1099 | 1099 | $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', 'event_espresso'); |
1100 | 1100 | $primary_att = EEM_Attendee::instance()->create_default_object(); |
1101 | 1101 | } |
1102 | - $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1102 | + $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1103 | 1103 | $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
1104 | 1104 | $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
1105 | - $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1105 | + $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1106 | 1106 | $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
1107 | - $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID() ), REG_ADMIN_URL ); |
|
1107 | + $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL); |
|
1108 | 1108 | // get formatted address for registrant |
1109 | - $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att ); |
|
1110 | - echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE ); |
|
1109 | + $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
1110 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE); |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | |
@@ -1123,12 +1123,12 @@ discard block |
||
1123 | 1123 | |
1124 | 1124 | $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
1125 | 1125 | $this->_template_args['billing_form_url'] = add_query_arg( |
1126 | - array( 'action' => 'edit_transaction', 'process' => 'billing' ), |
|
1126 | + array('action' => 'edit_transaction', 'process' => 'billing'), |
|
1127 | 1127 | TXN_ADMIN_URL |
1128 | 1128 | ); |
1129 | 1129 | |
1130 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1131 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/ |
|
1130 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1131 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/ |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
@@ -1141,42 +1141,42 @@ discard block |
||
1141 | 1141 | * @return void |
1142 | 1142 | */ |
1143 | 1143 | public function apply_payments_or_refunds() { |
1144 | - $json_response_data = array( 'return_data' => FALSE ); |
|
1144 | + $json_response_data = array('return_data' => FALSE); |
|
1145 | 1145 | $valid_data = $this->_validate_payment_request_data(); |
1146 | - if ( ! empty( $valid_data ) ) { |
|
1147 | - $PAY_ID = $valid_data[ 'PAY_ID' ]; |
|
1146 | + if ( ! empty($valid_data)) { |
|
1147 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1148 | 1148 | //save the new payment |
1149 | - $payment = $this->_create_payment_from_request_data( $valid_data ); |
|
1149 | + $payment = $this->_create_payment_from_request_data($valid_data); |
|
1150 | 1150 | // get the TXN for this payment |
1151 | 1151 | $transaction = $payment->transaction(); |
1152 | 1152 | // verify transaction |
1153 | - if ( $transaction instanceof EE_Transaction ) { |
|
1153 | + if ($transaction instanceof EE_Transaction) { |
|
1154 | 1154 | // calculate_total_payments_and_update_status |
1155 | - $this->_process_transaction_payments( $transaction ); |
|
1156 | - $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment ); |
|
1157 | - $this->_remove_existing_registration_payments( $payment, $PAY_ID ); |
|
1155 | + $this->_process_transaction_payments($transaction); |
|
1156 | + $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
1157 | + $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
1158 | 1158 | // apply payment to registrations (if applicable) |
1159 | - if ( ! empty( $REG_IDs ) ) { |
|
1160 | - $this->_update_registration_payments( $transaction, $payment, $REG_IDs ); |
|
1159 | + if ( ! empty($REG_IDs)) { |
|
1160 | + $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
1161 | 1161 | $this->_maybe_send_notifications(); |
1162 | 1162 | // now process status changes for the same registrations |
1163 | - $this->_process_registration_status_change( $transaction, $REG_IDs ); |
|
1163 | + $this->_process_registration_status_change($transaction, $REG_IDs); |
|
1164 | 1164 | } |
1165 | - $this->_maybe_send_notifications( $payment ); |
|
1165 | + $this->_maybe_send_notifications($payment); |
|
1166 | 1166 | //prepare to render page |
1167 | - $json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs ); |
|
1168 | - do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment ); |
|
1167 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
1168 | + do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment); |
|
1169 | 1169 | } else { |
1170 | 1170 | EE_Error::add_error( |
1171 | - esc_html__( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ), |
|
1171 | + esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'), |
|
1172 | 1172 | __FILE__, __FUNCTION__, __LINE__ |
1173 | 1173 | ); |
1174 | 1174 | } |
1175 | 1175 | } else { |
1176 | - EE_Error::add_error( esc_html__( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1176 | + EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | - $notices = EE_Error::get_notices( false, false, false ); |
|
1179 | + $notices = EE_Error::get_notices(false, false, false); |
|
1180 | 1180 | $this->_template_args = array( |
1181 | 1181 | 'data' => $json_response_data, |
1182 | 1182 | 'error' => $notices['errors'], |
@@ -1193,30 +1193,30 @@ discard block |
||
1193 | 1193 | * @return array |
1194 | 1194 | */ |
1195 | 1195 | protected function _validate_payment_request_data() { |
1196 | - if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) { |
|
1196 | + if ( ! isset($this->_req_data['txn_admin_payment'])) { |
|
1197 | 1197 | return false; |
1198 | 1198 | } |
1199 | 1199 | $payment_form = $this->_generate_payment_form_section(); |
1200 | 1200 | try { |
1201 | - if ( $payment_form->was_submitted() ) { |
|
1201 | + if ($payment_form->was_submitted()) { |
|
1202 | 1202 | $payment_form->receive_form_submission(); |
1203 | - if ( ! $payment_form->is_valid() ) { |
|
1203 | + if ( ! $payment_form->is_valid()) { |
|
1204 | 1204 | $submission_error_messages = array(); |
1205 | - foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) { |
|
1206 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1205 | + foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
1206 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1207 | 1207 | $submission_error_messages[] = sprintf( |
1208 | - _x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ), |
|
1208 | + _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
1209 | 1209 | $validation_error->get_form_section()->html_label_text(), |
1210 | 1210 | $validation_error->getMessage() |
1211 | 1211 | ); |
1212 | 1212 | } |
1213 | 1213 | } |
1214 | - EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1214 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1215 | 1215 | return array(); |
1216 | 1216 | } |
1217 | 1217 | } |
1218 | - } catch ( EE_Error $e ) { |
|
1219 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1218 | + } catch (EE_Error $e) { |
|
1219 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1220 | 1220 | return array(); |
1221 | 1221 | } |
1222 | 1222 | return $payment_form->valid_data(); |
@@ -1238,63 +1238,63 @@ discard block |
||
1238 | 1238 | array( |
1239 | 1239 | 'default' => 0, |
1240 | 1240 | 'required' => false, |
1241 | - 'html_label_text' => esc_html__( 'Payment ID', 'event_espresso' ), |
|
1242 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1241 | + 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
1242 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1243 | 1243 | ) |
1244 | 1244 | ), |
1245 | 1245 | 'TXN_ID' => new EE_Text_Input( |
1246 | 1246 | array( |
1247 | 1247 | 'default' => 0, |
1248 | 1248 | 'required' => true, |
1249 | - 'html_label_text' => esc_html__( 'Transaction ID', 'event_espresso' ), |
|
1250 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1249 | + 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
1250 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1251 | 1251 | ) |
1252 | 1252 | ), |
1253 | 1253 | 'type' => new EE_Text_Input( |
1254 | 1254 | array( |
1255 | 1255 | 'default' => 1, |
1256 | 1256 | 'required' => true, |
1257 | - 'html_label_text' => esc_html__( 'Payment or Refund', 'event_espresso' ), |
|
1258 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1257 | + 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
1258 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1259 | 1259 | ) |
1260 | 1260 | ), |
1261 | 1261 | 'amount' => new EE_Text_Input( |
1262 | 1262 | array( |
1263 | 1263 | 'default' => 0, |
1264 | 1264 | 'required' => true, |
1265 | - 'html_label_text' => esc_html__( 'Payment amount', 'event_espresso' ), |
|
1266 | - 'validation_strategies' => array( new EE_Float_Normalization() ) |
|
1265 | + 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
1266 | + 'validation_strategies' => array(new EE_Float_Normalization()) |
|
1267 | 1267 | ) |
1268 | 1268 | ), |
1269 | 1269 | 'status' => new EE_Text_Input( |
1270 | 1270 | array( |
1271 | 1271 | 'default' => EEM_Payment::status_id_approved, |
1272 | 1272 | 'required' => true, |
1273 | - 'html_label_text' => esc_html__( 'Payment status', 'event_espresso' ), |
|
1273 | + 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
1274 | 1274 | ) |
1275 | 1275 | ), |
1276 | 1276 | 'PMD_ID' => new EE_Text_Input( |
1277 | 1277 | array( |
1278 | 1278 | 'default' => 2, |
1279 | 1279 | 'required' => true, |
1280 | - 'html_label_text' => esc_html__( 'Payment Method', 'event_espresso' ), |
|
1281 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1280 | + 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
1281 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1282 | 1282 | ) |
1283 | 1283 | ), |
1284 | 1284 | 'date' => new EE_Text_Input( |
1285 | 1285 | array( |
1286 | 1286 | 'default' => time(), |
1287 | 1287 | 'required' => true, |
1288 | - 'html_label_text' => esc_html__( 'Payment date', 'event_espresso' ), |
|
1288 | + 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
1289 | 1289 | ) |
1290 | 1290 | ), |
1291 | 1291 | 'txn_id_chq_nmbr' => new EE_Text_Input( |
1292 | 1292 | array( |
1293 | 1293 | 'default' => '', |
1294 | 1294 | 'required' => false, |
1295 | - 'html_label_text' => esc_html__( 'Transaction or Cheque Number', 'event_espresso' ), |
|
1295 | + 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
1296 | 1296 | 'validation_strategies' => array( |
1297 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1297 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1298 | 1298 | ) |
1299 | 1299 | ) |
1300 | 1300 | ), |
@@ -1302,9 +1302,9 @@ discard block |
||
1302 | 1302 | array( |
1303 | 1303 | 'default' => '', |
1304 | 1304 | 'required' => false, |
1305 | - 'html_label_text' => esc_html__( 'Purchase Order Number', 'event_espresso' ), |
|
1305 | + 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
1306 | 1306 | 'validation_strategies' => array( |
1307 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1307 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1308 | 1308 | ) |
1309 | 1309 | ) |
1310 | 1310 | ), |
@@ -1312,9 +1312,9 @@ discard block |
||
1312 | 1312 | array( |
1313 | 1313 | 'default' => '', |
1314 | 1314 | 'required' => false, |
1315 | - 'html_label_text' => esc_html__( 'Extra Field for Accounting', 'event_espresso' ), |
|
1315 | + 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
1316 | 1316 | 'validation_strategies' => array( |
1317 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1317 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1318 | 1318 | ) |
1319 | 1319 | ) |
1320 | 1320 | ), |
@@ -1331,37 +1331,37 @@ discard block |
||
1331 | 1331 | * @param array $valid_data |
1332 | 1332 | * @return EE_Payment |
1333 | 1333 | */ |
1334 | - protected function _create_payment_from_request_data( $valid_data ) { |
|
1335 | - $PAY_ID = $valid_data[ 'PAY_ID' ]; |
|
1334 | + protected function _create_payment_from_request_data($valid_data) { |
|
1335 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1336 | 1336 | // get payment amount |
1337 | - $amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0; |
|
1337 | + $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
1338 | 1338 | // payments have a type value of 1 and refunds have a type value of -1 |
1339 | 1339 | // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
1340 | - $amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount; |
|
1340 | + $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
1341 | 1341 | // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
1342 | - $date = $valid_data['date'] ? preg_replace( '/\s+/', ' ', $valid_data['date'] ) : date( 'Y-m-d g:i a', current_time( 'timestamp' ) ); |
|
1342 | + $date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', current_time('timestamp')); |
|
1343 | 1343 | $payment = EE_Payment::new_instance( |
1344 | 1344 | array( |
1345 | - 'TXN_ID' => $valid_data[ 'TXN_ID' ], |
|
1346 | - 'STS_ID' => $valid_data[ 'status' ], |
|
1345 | + 'TXN_ID' => $valid_data['TXN_ID'], |
|
1346 | + 'STS_ID' => $valid_data['status'], |
|
1347 | 1347 | 'PAY_timestamp' => $date, |
1348 | 1348 | 'PAY_source' => EEM_Payment_Method::scope_admin, |
1349 | - 'PMD_ID' => $valid_data[ 'PMD_ID' ], |
|
1349 | + 'PMD_ID' => $valid_data['PMD_ID'], |
|
1350 | 1350 | 'PAY_amount' => $amount, |
1351 | - 'PAY_txn_id_chq_nmbr' => $valid_data[ 'txn_id_chq_nmbr' ], |
|
1352 | - 'PAY_po_number' => $valid_data[ 'po_number' ], |
|
1353 | - 'PAY_extra_accntng' => $valid_data[ 'accounting' ], |
|
1351 | + 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
1352 | + 'PAY_po_number' => $valid_data['po_number'], |
|
1353 | + 'PAY_extra_accntng' => $valid_data['accounting'], |
|
1354 | 1354 | 'PAY_details' => $valid_data, |
1355 | 1355 | 'PAY_ID' => $PAY_ID |
1356 | 1356 | ), |
1357 | 1357 | '', |
1358 | - array( 'Y-m-d', 'g:i a' ) |
|
1358 | + array('Y-m-d', 'g:i a') |
|
1359 | 1359 | ); |
1360 | 1360 | |
1361 | - if ( ! $payment->save() ) { |
|
1361 | + if ( ! $payment->save()) { |
|
1362 | 1362 | EE_Error::add_error( |
1363 | 1363 | sprintf( |
1364 | - esc_html__( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ), |
|
1364 | + esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
1365 | 1365 | $payment->ID() |
1366 | 1366 | ), |
1367 | 1367 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1378,15 +1378,15 @@ discard block |
||
1378 | 1378 | * @param \EE_Transaction $transaction |
1379 | 1379 | * @return array |
1380 | 1380 | */ |
1381 | - protected function _process_transaction_payments( EE_Transaction $transaction ) { |
|
1381 | + protected function _process_transaction_payments(EE_Transaction $transaction) { |
|
1382 | 1382 | /** @type EE_Transaction_Payments $transaction_payments */ |
1383 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1383 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1384 | 1384 | //update the transaction with this payment |
1385 | - if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) { |
|
1386 | - EE_Error::add_success( esc_html__( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1385 | + if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
1386 | + EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1387 | 1387 | } else { |
1388 | 1388 | EE_Error::add_error( |
1389 | - esc_html__( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' ) |
|
1389 | + esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso') |
|
1390 | 1390 | , __FILE__, __FUNCTION__, __LINE__ |
1391 | 1391 | ); |
1392 | 1392 | } |
@@ -1402,19 +1402,19 @@ discard block |
||
1402 | 1402 | * @param \EE_Payment $payment |
1403 | 1403 | * @return array |
1404 | 1404 | */ |
1405 | - protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) { |
|
1405 | + protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) { |
|
1406 | 1406 | $REG_IDs = array(); |
1407 | 1407 | // grab array of IDs for specific registrations to apply changes to |
1408 | - if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) { |
|
1409 | - $REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ]; |
|
1408 | + if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
|
1409 | + $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations']; |
|
1410 | 1410 | } |
1411 | 1411 | //nothing specified ? then get all reg IDs |
1412 | - if ( empty( $REG_IDs ) ) { |
|
1412 | + if (empty($REG_IDs)) { |
|
1413 | 1413 | $registrations = $payment->transaction()->registrations(); |
1414 | - $REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1414 | + $REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1415 | 1415 | } |
1416 | 1416 | // ensure that REG_IDs are integers and NOT strings |
1417 | - return array_map( 'intval', $REG_IDs ); |
|
1417 | + return array_map('intval', $REG_IDs); |
|
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | /** |
1432 | 1432 | * @param array $existing_reg_payment_REG_IDs |
1433 | 1433 | */ |
1434 | - public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) { |
|
1434 | + public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) { |
|
1435 | 1435 | $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
1436 | 1436 | } |
1437 | 1437 | |
@@ -1446,13 +1446,13 @@ discard block |
||
1446 | 1446 | * @param \EE_Payment $payment |
1447 | 1447 | * @return array |
1448 | 1448 | */ |
1449 | - protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) { |
|
1450 | - if ( $this->existing_reg_payment_REG_IDs() === null ) { |
|
1449 | + protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) { |
|
1450 | + if ($this->existing_reg_payment_REG_IDs() === null) { |
|
1451 | 1451 | // let's get any existing reg payment records for this payment |
1452 | - $existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' ); |
|
1452 | + $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
1453 | 1453 | // but we only want the REG IDs, so grab the array keys |
1454 | - $existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array(); |
|
1455 | - $this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs ); |
|
1454 | + $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array(); |
|
1455 | + $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
1456 | 1456 | } |
1457 | 1457 | return $this->existing_reg_payment_REG_IDs(); |
1458 | 1458 | } |
@@ -1471,23 +1471,23 @@ discard block |
||
1471 | 1471 | * @param int $PAY_ID |
1472 | 1472 | * @return bool; |
1473 | 1473 | */ |
1474 | - protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) { |
|
1474 | + protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) { |
|
1475 | 1475 | // newly created payments will have nothing recorded for $PAY_ID |
1476 | - if ( $PAY_ID == 0 ) { |
|
1476 | + if ($PAY_ID == 0) { |
|
1477 | 1477 | return false; |
1478 | 1478 | } |
1479 | - $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1480 | - if ( empty( $existing_reg_payment_REG_IDs )) { |
|
1479 | + $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1480 | + if (empty($existing_reg_payment_REG_IDs)) { |
|
1481 | 1481 | return false; |
1482 | 1482 | } |
1483 | 1483 | /** @type EE_Transaction_Payments $transaction_payments */ |
1484 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1484 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1485 | 1485 | return $transaction_payments->delete_registration_payments_and_update_registrations( |
1486 | 1486 | $payment, |
1487 | 1487 | array( |
1488 | 1488 | array( |
1489 | 1489 | 'PAY_ID' => $payment->ID(), |
1490 | - 'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ), |
|
1490 | + 'REG_ID' => array('IN', $existing_reg_payment_REG_IDs), |
|
1491 | 1491 | ) |
1492 | 1492 | ) |
1493 | 1493 | ); |
@@ -1506,25 +1506,25 @@ discard block |
||
1506 | 1506 | * @param array $REG_IDs |
1507 | 1507 | * @return bool |
1508 | 1508 | */ |
1509 | - protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) { |
|
1509 | + protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) { |
|
1510 | 1510 | // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
1511 | 1511 | // so let's do that using our set of REG_IDs from the form |
1512 | 1512 | $registration_query_where_params = array( |
1513 | - 'REG_ID' => array( 'IN', $REG_IDs ) |
|
1513 | + 'REG_ID' => array('IN', $REG_IDs) |
|
1514 | 1514 | ); |
1515 | 1515 | // but add in some conditions regarding payment, |
1516 | 1516 | // so that we don't apply payments to registrations that are free or have already been paid for |
1517 | 1517 | // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
1518 | - if ( ! $payment->is_a_refund() ) { |
|
1519 | - $registration_query_where_params[ 'REG_final_price' ] = array( '!=', 0 ); |
|
1520 | - $registration_query_where_params[ 'REG_final_price*' ] = array( '!=', 'REG_paid', true ); |
|
1518 | + if ( ! $payment->is_a_refund()) { |
|
1519 | + $registration_query_where_params['REG_final_price'] = array('!=', 0); |
|
1520 | + $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
|
1521 | 1521 | } |
1522 | 1522 | //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
1523 | - $registrations = $transaction->registrations( array( $registration_query_where_params ) ); |
|
1524 | - if ( ! empty( $registrations ) ) { |
|
1523 | + $registrations = $transaction->registrations(array($registration_query_where_params)); |
|
1524 | + if ( ! empty($registrations)) { |
|
1525 | 1525 | /** @type EE_Payment_Processor $payment_processor */ |
1526 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1527 | - $payment_processor->process_registration_payments( $transaction, $payment, $registrations ); |
|
1526 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1527 | + $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
1528 | 1528 | } |
1529 | 1529 | } |
1530 | 1530 | |
@@ -1540,22 +1540,22 @@ discard block |
||
1540 | 1540 | * @param array $REG_IDs |
1541 | 1541 | * @return bool |
1542 | 1542 | */ |
1543 | - protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) { |
|
1543 | + protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) { |
|
1544 | 1544 | // first if there is no change in status then we get out. |
1545 | 1545 | if ( |
1546 | - ! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ) |
|
1546 | + ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status']) |
|
1547 | 1547 | || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN' |
1548 | 1548 | ) { |
1549 | 1549 | //no error message, no change requested, just nothing to do man. |
1550 | 1550 | return FALSE; |
1551 | 1551 | } |
1552 | 1552 | /** @type EE_Transaction_Processor $transaction_processor */ |
1553 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1553 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1554 | 1554 | // made it here dude? Oh WOW. K, let's take care of changing the statuses |
1555 | 1555 | return $transaction_processor->manually_update_registration_statuses( |
1556 | 1556 | $transaction, |
1557 | - sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ), |
|
1558 | - array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) |
|
1557 | + sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']), |
|
1558 | + array(array('REG_ID' => array('IN', $REG_IDs))) |
|
1559 | 1559 | ); |
1560 | 1560 | } |
1561 | 1561 | |
@@ -1570,16 +1570,16 @@ discard block |
||
1570 | 1570 | * @param bool | null $delete_txn_reg_status_change |
1571 | 1571 | * @return array |
1572 | 1572 | */ |
1573 | - protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) { |
|
1573 | + protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) { |
|
1574 | 1574 | // was the payment deleted ? |
1575 | - if ( is_bool( $delete_txn_reg_status_change )) { |
|
1575 | + if (is_bool($delete_txn_reg_status_change)) { |
|
1576 | 1576 | return array( |
1577 | 1577 | 'PAY_ID' => $payment->ID(), |
1578 | 1578 | 'amount' => $payment->amount(), |
1579 | 1579 | 'total_paid' => $payment->transaction()->paid(), |
1580 | 1580 | 'txn_status' => $payment->transaction()->status_ID(), |
1581 | 1581 | 'pay_status' => $payment->STS_ID(), |
1582 | - 'registrations' => $this->_registration_payment_data_array( $REG_IDs ), |
|
1582 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1583 | 1583 | 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
1584 | 1584 | ); |
1585 | 1585 | } else { |
@@ -1591,16 +1591,16 @@ discard block |
||
1591 | 1591 | 'pay_status' => $payment->STS_ID(), |
1592 | 1592 | 'PAY_ID' => $payment->ID(), |
1593 | 1593 | 'STS_ID' => $payment->STS_ID(), |
1594 | - 'status' => self::$_pay_status[ $payment->STS_ID() ], |
|
1595 | - 'date' => $payment->timestamp( 'Y-m-d', 'h:i a' ), |
|
1596 | - 'method' => strtoupper( $payment->source() ), |
|
1594 | + 'status' => self::$_pay_status[$payment->STS_ID()], |
|
1595 | + 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
1596 | + 'method' => strtoupper($payment->source()), |
|
1597 | 1597 | 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
1598 | - 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__( "Unknown", 'event_espresso' ), |
|
1598 | + 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", 'event_espresso'), |
|
1599 | 1599 | 'gateway_response' => $payment->gateway_response(), |
1600 | 1600 | 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
1601 | 1601 | 'po_number' => $payment->po_number(), |
1602 | 1602 | 'extra_accntng' => $payment->extra_accntng(), |
1603 | - 'registrations' => $this->_registration_payment_data_array( $REG_IDs ), |
|
1603 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1604 | 1604 | ); |
1605 | 1605 | } |
1606 | 1606 | } |
@@ -1615,39 +1615,39 @@ discard block |
||
1615 | 1615 | * @return void |
1616 | 1616 | */ |
1617 | 1617 | public function delete_payment() { |
1618 | - $json_response_data = array( 'return_data' => FALSE ); |
|
1619 | - $PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0; |
|
1620 | - if ( $PAY_ID ) { |
|
1621 | - $delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false; |
|
1622 | - $payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID ); |
|
1623 | - if ( $payment instanceof EE_Payment ) { |
|
1624 | - $REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1618 | + $json_response_data = array('return_data' => FALSE); |
|
1619 | + $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0; |
|
1620 | + if ($PAY_ID) { |
|
1621 | + $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false; |
|
1622 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
1623 | + if ($payment instanceof EE_Payment) { |
|
1624 | + $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1625 | 1625 | /** @type EE_Transaction_Payments $transaction_payments */ |
1626 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1627 | - if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) { |
|
1628 | - $json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change ); |
|
1629 | - if ( $delete_txn_reg_status_change ) { |
|
1626 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1627 | + if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
1628 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change); |
|
1629 | + if ($delete_txn_reg_status_change) { |
|
1630 | 1630 | $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change; |
1631 | 1631 | //MAKE sure we also add the delete_txn_req_status_change to the |
1632 | 1632 | //$_REQUEST global because that's how messages will be looking for it. |
1633 | 1633 | $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change; |
1634 | 1634 | $this->_maybe_send_notifications(); |
1635 | - $this->_process_registration_status_change( $payment->transaction(), $REG_IDs ); |
|
1635 | + $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
1636 | 1636 | } |
1637 | 1637 | } |
1638 | 1638 | } else { |
1639 | 1639 | EE_Error::add_error( |
1640 | - esc_html__( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ), |
|
1640 | + esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
1641 | 1641 | __FILE__, __FUNCTION__, __LINE__ |
1642 | 1642 | ); |
1643 | 1643 | } |
1644 | 1644 | } else { |
1645 | 1645 | EE_Error::add_error( |
1646 | - esc_html__( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ), |
|
1646 | + esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'), |
|
1647 | 1647 | __FILE__, __FUNCTION__, __LINE__ |
1648 | 1648 | ); |
1649 | 1649 | } |
1650 | - $notices = EE_Error::get_notices( false, false, false); |
|
1650 | + $notices = EE_Error::get_notices(false, false, false); |
|
1651 | 1651 | $this->_template_args = array( |
1652 | 1652 | 'data' => $json_response_data, |
1653 | 1653 | 'success' => $notices['success'], |
@@ -1667,16 +1667,16 @@ discard block |
||
1667 | 1667 | * @param array $REG_IDs |
1668 | 1668 | * @return array |
1669 | 1669 | */ |
1670 | - protected function _registration_payment_data_array( $REG_IDs ) { |
|
1670 | + protected function _registration_payment_data_array($REG_IDs) { |
|
1671 | 1671 | $registration_payment_data = array(); |
1672 | 1672 | //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
1673 | - if ( ! empty( $REG_IDs ) ) { |
|
1674 | - $registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) ); |
|
1675 | - foreach ( $registrations as $registration ) { |
|
1676 | - if ( $registration instanceof EE_Registration ) { |
|
1677 | - $registration_payment_data[ $registration->ID() ] = array( |
|
1673 | + if ( ! empty($REG_IDs)) { |
|
1674 | + $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
|
1675 | + foreach ($registrations as $registration) { |
|
1676 | + if ($registration instanceof EE_Registration) { |
|
1677 | + $registration_payment_data[$registration->ID()] = array( |
|
1678 | 1678 | 'paid' => $registration->pretty_paid(), |
1679 | - 'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ), |
|
1679 | + 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
1680 | 1680 | ); |
1681 | 1681 | } |
1682 | 1682 | } |
@@ -1696,30 +1696,30 @@ discard block |
||
1696 | 1696 | * @access protected |
1697 | 1697 | * @param \EE_Payment | null $payment |
1698 | 1698 | */ |
1699 | - protected function _maybe_send_notifications( $payment = null ) { |
|
1700 | - switch ( $payment instanceof EE_Payment ) { |
|
1699 | + protected function _maybe_send_notifications($payment = null) { |
|
1700 | + switch ($payment instanceof EE_Payment) { |
|
1701 | 1701 | // payment notifications |
1702 | 1702 | case true : |
1703 | 1703 | if ( |
1704 | 1704 | isset( |
1705 | - $this->_req_data[ 'txn_payments' ], |
|
1706 | - $this->_req_data[ 'txn_payments' ][ 'send_notifications' ] |
|
1705 | + $this->_req_data['txn_payments'], |
|
1706 | + $this->_req_data['txn_payments']['send_notifications'] |
|
1707 | 1707 | ) && |
1708 | - filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN ) |
|
1708 | + filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1709 | 1709 | ) { |
1710 | - $this->_process_payment_notification( $payment ); |
|
1710 | + $this->_process_payment_notification($payment); |
|
1711 | 1711 | } |
1712 | 1712 | break; |
1713 | 1713 | // registration notifications |
1714 | 1714 | case false : |
1715 | 1715 | if ( |
1716 | 1716 | isset( |
1717 | - $this->_req_data[ 'txn_reg_status_change' ], |
|
1718 | - $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] |
|
1717 | + $this->_req_data['txn_reg_status_change'], |
|
1718 | + $this->_req_data['txn_reg_status_change']['send_notifications'] |
|
1719 | 1719 | ) && |
1720 | - filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN ) |
|
1720 | + filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1721 | 1721 | ) { |
1722 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
1722 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
1723 | 1723 | } |
1724 | 1724 | break; |
1725 | 1725 | } |
@@ -1735,11 +1735,11 @@ discard block |
||
1735 | 1735 | * @return void |
1736 | 1736 | */ |
1737 | 1737 | protected function _send_payment_reminder() { |
1738 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
1739 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
1740 | - $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array(); |
|
1741 | - do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction ); |
|
1742 | - $this->_redirect_after_action( FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE ); |
|
1738 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE; |
|
1739 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1740 | + $query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array(); |
|
1741 | + do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction); |
|
1742 | + $this->_redirect_after_action(FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE); |
|
1743 | 1743 | } |
1744 | 1744 | |
1745 | 1745 | |
@@ -1753,36 +1753,36 @@ discard block |
||
1753 | 1753 | * @param string $view |
1754 | 1754 | * @return mixed int = count || array of transaction objects |
1755 | 1755 | */ |
1756 | - public function get_transactions( $perpage, $count = FALSE, $view = '' ) { |
|
1756 | + public function get_transactions($perpage, $count = FALSE, $view = '') { |
|
1757 | 1757 | |
1758 | 1758 | $TXN = EEM_Transaction::instance(); |
1759 | 1759 | |
1760 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
1761 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' ); |
|
1760 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year')); |
|
1761 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
1762 | 1762 | |
1763 | 1763 | //make sure our timestamps start and end right at the boundaries for each day |
1764 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
1765 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
1764 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
1765 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
1766 | 1766 | |
1767 | 1767 | |
1768 | 1768 | //convert to timestamps |
1769 | - $start_date = strtotime( $start_date ); |
|
1770 | - $end_date = strtotime( $end_date ); |
|
1769 | + $start_date = strtotime($start_date); |
|
1770 | + $end_date = strtotime($end_date); |
|
1771 | 1771 | |
1772 | 1772 | //makes sure start date is the lowest value and vice versa |
1773 | - $start_date = min( $start_date, $end_date ); |
|
1774 | - $end_date = max( $start_date, $end_date ); |
|
1773 | + $start_date = min($start_date, $end_date); |
|
1774 | + $end_date = max($start_date, $end_date); |
|
1775 | 1775 | |
1776 | 1776 | //convert to correct format for query |
1777 | - $start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
1778 | - $end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
1777 | + $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
1778 | + $end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
1779 | 1779 | |
1780 | 1780 | |
1781 | 1781 | |
1782 | 1782 | //set orderby |
1783 | 1783 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
1784 | 1784 | |
1785 | - switch ( $this->_req_data['orderby'] ) { |
|
1785 | + switch ($this->_req_data['orderby']) { |
|
1786 | 1786 | case 'TXN_ID': |
1787 | 1787 | $orderby = 'TXN_ID'; |
1788 | 1788 | break; |
@@ -1796,66 +1796,66 @@ discard block |
||
1796 | 1796 | $orderby = 'TXN_timestamp'; |
1797 | 1797 | } |
1798 | 1798 | |
1799 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
1800 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1801 | - $per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10; |
|
1802 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1799 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
1800 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1801 | + $per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10; |
|
1802 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1803 | 1803 | |
1804 | - $offset = ($current_page-1)*$per_page; |
|
1805 | - $limit = array( $offset, $per_page ); |
|
1804 | + $offset = ($current_page - 1) * $per_page; |
|
1805 | + $limit = array($offset, $per_page); |
|
1806 | 1806 | |
1807 | 1807 | $_where = array( |
1808 | - 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ), |
|
1808 | + 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)), |
|
1809 | 1809 | 'Registration.REG_count' => 1 |
1810 | 1810 | ); |
1811 | 1811 | |
1812 | - if ( isset( $this->_req_data['EVT_ID'] ) ) { |
|
1812 | + if (isset($this->_req_data['EVT_ID'])) { |
|
1813 | 1813 | $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID']; |
1814 | 1814 | } |
1815 | 1815 | |
1816 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1817 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1816 | + if (isset($this->_req_data['s'])) { |
|
1817 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1818 | 1818 | $_where['OR'] = array( |
1819 | - 'Registration.Event.EVT_name' => array( 'LIKE', $search_string ), |
|
1820 | - 'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ), |
|
1821 | - 'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ), |
|
1822 | - 'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ), |
|
1823 | - 'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ), |
|
1824 | - 'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ), |
|
1825 | - 'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ), |
|
1826 | - 'Registration.Attendee.ATT_email' => array('LIKE', $search_string ), |
|
1827 | - 'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ), |
|
1828 | - 'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ), |
|
1829 | - 'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ), |
|
1830 | - 'Registration.REG_final_price' => array( 'LIKE', $search_string ), |
|
1831 | - 'Registration.REG_code' => array( 'LIKE', $search_string ), |
|
1832 | - 'Registration.REG_count' => array( 'LIKE' , $search_string ), |
|
1833 | - 'Registration.REG_group_size' => array( 'LIKE' , $search_string ), |
|
1834 | - 'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ), |
|
1835 | - 'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ), |
|
1836 | - 'Payment.PAY_source' => array('LIKE', $search_string ), |
|
1837 | - 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ), |
|
1838 | - 'TXN_session_data' => array( 'LIKE', $search_string ), |
|
1839 | - 'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string ) |
|
1819 | + 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
|
1820 | + 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
|
1821 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $search_string), |
|
1822 | + 'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
1823 | + 'Registration.Attendee.ATT_fname' => array('LIKE', $search_string), |
|
1824 | + 'Registration.Attendee.ATT_lname' => array('LIKE', $search_string), |
|
1825 | + 'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
1826 | + 'Registration.Attendee.ATT_email' => array('LIKE', $search_string), |
|
1827 | + 'Registration.Attendee.ATT_address' => array('LIKE', $search_string), |
|
1828 | + 'Registration.Attendee.ATT_address2' => array('LIKE', $search_string), |
|
1829 | + 'Registration.Attendee.ATT_city' => array('LIKE', $search_string), |
|
1830 | + 'Registration.REG_final_price' => array('LIKE', $search_string), |
|
1831 | + 'Registration.REG_code' => array('LIKE', $search_string), |
|
1832 | + 'Registration.REG_count' => array('LIKE', $search_string), |
|
1833 | + 'Registration.REG_group_size' => array('LIKE', $search_string), |
|
1834 | + 'Registration.Ticket.TKT_name' => array('LIKE', $search_string), |
|
1835 | + 'Registration.Ticket.TKT_description' => array('LIKE', $search_string), |
|
1836 | + 'Payment.PAY_source' => array('LIKE', $search_string), |
|
1837 | + 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string), |
|
1838 | + 'TXN_session_data' => array('LIKE', $search_string), |
|
1839 | + 'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string) |
|
1840 | 1840 | ); |
1841 | 1841 | } |
1842 | 1842 | |
1843 | 1843 | //failed transactions |
1844 | - $failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE; |
|
1845 | - $abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE; |
|
1844 | + $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE : FALSE; |
|
1845 | + $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE : FALSE; |
|
1846 | 1846 | |
1847 | - if ( $failed ) { |
|
1848 | - $_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code; |
|
1849 | - } else if ( $abandoned ) { |
|
1847 | + if ($failed) { |
|
1848 | + $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
1849 | + } else if ($abandoned) { |
|
1850 | 1850 | $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
1851 | 1851 | } else { |
1852 | - $_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code ); |
|
1853 | - $_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code ); |
|
1852 | + $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code); |
|
1853 | + $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code); |
|
1854 | 1854 | } |
1855 | 1855 | |
1856 | - $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit ); |
|
1856 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit); |
|
1857 | 1857 | |
1858 | - $transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params); |
|
1858 | + $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params); |
|
1859 | 1859 | |
1860 | 1860 | |
1861 | 1861 | return $transactions; |
@@ -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 | 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 | |
@@ -17,716 +17,716 @@ discard block |
||
17 | 17 | class EEM_Registration extends EEM_Soft_Delete_Base |
18 | 18 | { |
19 | 19 | |
20 | - // private instance of the Registration object |
|
21 | - protected static $_instance = null; |
|
22 | - |
|
23 | - /** |
|
24 | - * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values |
|
25 | - * are status codes (eg, approved, cancelled, etc) |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - private static $_reg_status; |
|
30 | - |
|
31 | - /** |
|
32 | - * The value of REG_count for a primary registrant |
|
33 | - */ |
|
34 | - const PRIMARY_REGISTRANT_COUNT = 1; |
|
35 | - |
|
36 | - /** |
|
37 | - * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration. |
|
38 | - * Initial status for registrations when they are first created |
|
39 | - * Payments are NOT allowed. |
|
40 | - * Automatically toggled to whatever the default Event registration status is upon completion of the attendee |
|
41 | - * information reg step NO space reserved. Registration is NOT active |
|
42 | - */ |
|
43 | - const status_id_incomplete = 'RIC'; |
|
44 | - |
|
45 | - /** |
|
46 | - * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration. |
|
47 | - * Payments are NOT allowed. |
|
48 | - * Event Admin must manually toggle STS_ID for it to change |
|
49 | - * No space reserved. |
|
50 | - * Registration is active |
|
51 | - */ |
|
52 | - const status_id_not_approved = 'RNA'; |
|
53 | - |
|
54 | - /** |
|
55 | - * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT . |
|
56 | - * Payments are allowed. |
|
57 | - * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
58 | - * No space reserved. |
|
59 | - * Registration is active |
|
60 | - */ |
|
61 | - const status_id_pending_payment = 'RPP'; |
|
62 | - |
|
63 | - /** |
|
64 | - * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST . |
|
65 | - * Payments are allowed. |
|
66 | - * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
67 | - * No space reserved. |
|
68 | - * Registration is active |
|
69 | - */ |
|
70 | - const status_id_wait_list = 'RWL'; |
|
71 | - |
|
72 | - /** |
|
73 | - * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration. |
|
74 | - * the TXN may or may not be completed ( paid in full ) |
|
75 | - * Payments are allowed. |
|
76 | - * A space IS reserved. |
|
77 | - * Registration is active |
|
78 | - */ |
|
79 | - const status_id_approved = 'RAP'; |
|
80 | - |
|
81 | - /** |
|
82 | - * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee. |
|
83 | - * Payments are NOT allowed. |
|
84 | - * NO space reserved. |
|
85 | - * Registration is NOT active |
|
86 | - */ |
|
87 | - const status_id_cancelled = 'RCN'; |
|
88 | - |
|
89 | - /** |
|
90 | - * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin |
|
91 | - * Payments are NOT allowed. |
|
92 | - * No space reserved. |
|
93 | - * Registration is NOT active |
|
94 | - */ |
|
95 | - const status_id_declined = 'RDC'; |
|
96 | - |
|
97 | - /** |
|
98 | - * @var TableAnalysis $table_analysis |
|
99 | - */ |
|
100 | - protected $_table_analysis; |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * private constructor to prevent direct creation |
|
106 | - * |
|
107 | - * @Constructor |
|
108 | - * @access protected |
|
109 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
110 | - * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
111 | - * date time model field objects. Default is NULL (and will be assumed using the set |
|
112 | - * timezone in the 'timezone_string' wp option) |
|
113 | - */ |
|
114 | - protected function __construct($timezone = null) |
|
115 | - { |
|
116 | - $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
117 | - $this->singular_item = __('Registration', 'event_espresso'); |
|
118 | - $this->plural_item = __('Registrations', 'event_espresso'); |
|
119 | - $this->_tables = array( |
|
120 | - 'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'), |
|
121 | - ); |
|
122 | - $this->_fields = array( |
|
123 | - 'Registration' => array( |
|
124 | - 'REG_ID' => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
125 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
126 | - 'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event' |
|
127 | - ), |
|
128 | - 'ATT_ID' => new EE_Foreign_Key_Int_Field( |
|
129 | - 'ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee' |
|
130 | - ), |
|
131 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), |
|
132 | - false, 0, 'Transaction' |
|
133 | - ), |
|
134 | - 'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, |
|
135 | - 0, 'Ticket' |
|
136 | - ), |
|
137 | - 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
138 | - false, EEM_Registration::status_id_incomplete, 'Status' |
|
139 | - ), |
|
140 | - 'REG_date' => new EE_Datetime_Field('REG_date', |
|
141 | - __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone |
|
142 | - ), |
|
143 | - 'REG_final_price' => new EE_Money_Field('REG_final_price', |
|
144 | - __('Registration\'s share of the transaction total', 'event_espresso'), false, 0 |
|
145 | - ), |
|
146 | - 'REG_paid' => new EE_Money_Field('REG_paid', |
|
147 | - __('Amount paid to date towards registration', 'event_espresso'), false, 0 |
|
148 | - ), |
|
149 | - 'REG_session' => new EE_Plain_Text_Field('REG_session', |
|
150 | - __('Session ID of registration', 'event_espresso'), false, '' |
|
151 | - ), |
|
152 | - 'REG_code' => new EE_Plain_Text_Field('REG_code', |
|
153 | - __('Unique Code for this registration', 'event_espresso'), false, '' |
|
154 | - ), |
|
155 | - 'REG_url_link' => new EE_Plain_Text_Field('REG_url_link', |
|
156 | - __('String to be used in URL for identifying registration', 'event_espresso'), false, '' |
|
157 | - ), |
|
158 | - 'REG_count' => new EE_Integer_Field('REG_count', |
|
159 | - __('Count of this registration in the group registration ', 'event_espresso'), true, 1 |
|
160 | - ), |
|
161 | - 'REG_group_size' => new EE_Integer_Field('REG_group_size', |
|
162 | - __('Number of registrations on this group', 'event_espresso'), false, 1 |
|
163 | - ), |
|
164 | - 'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going', |
|
165 | - __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false |
|
166 | - ), |
|
167 | - 'REG_deleted' => new EE_Trashed_Flag_Field( |
|
168 | - 'REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), |
|
169 | - false, false |
|
170 | - ), |
|
171 | - ), |
|
172 | - ); |
|
173 | - $this->_model_relations = array( |
|
174 | - 'Event' => new EE_Belongs_To_Relation(), |
|
175 | - 'Attendee' => new EE_Belongs_To_Relation(), |
|
176 | - 'Transaction' => new EE_Belongs_To_Relation(), |
|
177 | - 'Ticket' => new EE_Belongs_To_Relation(), |
|
178 | - 'Status' => new EE_Belongs_To_Relation(), |
|
179 | - 'Answer' => new EE_Has_Many_Relation(), |
|
180 | - 'Checkin' => new EE_Has_Many_Relation(), |
|
181 | - 'Registration_Payment' => new EE_Has_Many_Relation(), |
|
182 | - 'Payment' => new EE_HABTM_Relation('Registration_Payment'), |
|
183 | - 'Message' => new EE_Has_Many_Any_Relation(false) |
|
184 | - //allow deletes even if there are messages in the queue related |
|
185 | - ); |
|
186 | - $this->_model_chain_to_wp_user = 'Event'; |
|
187 | - parent::__construct($timezone); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * reg_statuses_that_allow_payment |
|
194 | - * a filterable list of registration statuses that allow a registrant to make a payment |
|
195 | - * |
|
196 | - * @access public |
|
197 | - * @return array |
|
198 | - */ |
|
199 | - public static function reg_statuses_that_allow_payment() |
|
200 | - { |
|
201 | - return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
202 | - EEM_Registration::status_id_approved, |
|
203 | - EEM_Registration::status_id_pending_payment, |
|
204 | - EEM_Registration::status_id_wait_list, |
|
205 | - )); |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * inactive_reg_statuses |
|
212 | - * a filterable list of registration statuses that are considered active |
|
213 | - * |
|
214 | - * @access public |
|
215 | - * @return array |
|
216 | - */ |
|
217 | - public static function active_reg_statuses() |
|
218 | - { |
|
219 | - return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
220 | - EEM_Registration::status_id_approved, |
|
221 | - EEM_Registration::status_id_pending_payment, |
|
222 | - EEM_Registration::status_id_wait_list, |
|
223 | - EEM_Registration::status_id_not_approved, |
|
224 | - )); |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * inactive_reg_statuses |
|
231 | - * a filterable list of registration statuses that are not considered active |
|
232 | - * |
|
233 | - * @access public |
|
234 | - * @return array |
|
235 | - */ |
|
236 | - public static function inactive_reg_statuses() |
|
237 | - { |
|
238 | - return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
239 | - EEM_Registration::status_id_incomplete, |
|
240 | - EEM_Registration::status_id_cancelled, |
|
241 | - EEM_Registration::status_id_declined, |
|
242 | - )); |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * closed_reg_statuses |
|
249 | - * a filterable list of registration statuses that are considered "closed" |
|
250 | - * meaning they should not be considered in any calculations involving monies owing |
|
251 | - * |
|
252 | - * @access public |
|
253 | - * @return array |
|
254 | - */ |
|
255 | - public static function closed_reg_statuses() |
|
256 | - { |
|
257 | - return apply_filters('FHEE__EEM_Registration__closed_reg_statuses', array( |
|
258 | - EEM_Registration::status_id_cancelled, |
|
259 | - EEM_Registration::status_id_declined, |
|
260 | - )); |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * get list of registration statuses |
|
267 | - * |
|
268 | - * @access public |
|
269 | - * @param array $exclude The status ids to exclude from the returned results |
|
270 | - * @param bool $translated If true will return the values as singular localized strings |
|
271 | - * @return array |
|
272 | - */ |
|
273 | - public static function reg_status_array($exclude = array(), $translated = false) |
|
274 | - { |
|
275 | - EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
276 | - return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence') |
|
277 | - : self::$_reg_status; |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * get list of registration statuses |
|
284 | - * |
|
285 | - * @access private |
|
286 | - * @param array $exclude |
|
287 | - * @return array |
|
288 | - */ |
|
289 | - private function _get_registration_status_array($exclude = array()) |
|
290 | - { |
|
291 | - //in the very rare circumstance that we are deleting a model's table's data |
|
292 | - //and the table hasn't actually been created, this could have an error |
|
293 | - /** @type WPDB $wpdb */ |
|
294 | - global $wpdb; |
|
295 | - if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
296 | - $results = $wpdb->get_results( |
|
297 | - "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'" |
|
298 | - ); |
|
299 | - self::$_reg_status = array(); |
|
300 | - foreach ($results as $status) { |
|
301 | - if ( ! in_array($status->STS_ID, $exclude)) { |
|
302 | - self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
303 | - } |
|
304 | - } |
|
305 | - } |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * Gets the injected table analyzer, or throws an exception |
|
312 | - * |
|
313 | - * @return TableAnalysis |
|
314 | - * @throws \EE_Error |
|
315 | - */ |
|
316 | - protected function _get_table_analysis() |
|
317 | - { |
|
318 | - if ($this->_table_analysis instanceof TableAnalysis) { |
|
319 | - return $this->_table_analysis; |
|
320 | - } else { |
|
321 | - throw new \EE_Error(sprintf(__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
322 | - get_class($this))); |
|
323 | - } |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * This returns a wpdb->results array of all registration date month and years matching the incoming query params |
|
330 | - * and grouped by month and year. |
|
331 | - * |
|
332 | - * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
|
333 | - * @return array |
|
334 | - * @throws \EE_Error |
|
335 | - */ |
|
336 | - public function get_reg_months_and_years($where_params) |
|
337 | - { |
|
338 | - $query_params[0] = $where_params; |
|
339 | - $query_params['group_by'] = array('reg_year', 'reg_month'); |
|
340 | - $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
341 | - $columns_to_select = array( |
|
342 | - 'reg_year' => array('YEAR(REG_date)', '%s'), |
|
343 | - 'reg_month' => array('MONTHNAME(REG_date)', '%s'), |
|
344 | - ); |
|
345 | - return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * retrieve ALL registrations for a particular Attendee from db |
|
352 | - * |
|
353 | - * @access public |
|
354 | - * @param int $ATT_ID |
|
355 | - * @return EE_Registration[] |
|
356 | - */ |
|
357 | - public function get_all_registrations_for_attendee($ATT_ID = 0) |
|
358 | - { |
|
359 | - if ( ! $ATT_ID) { |
|
360 | - return false; |
|
361 | - } |
|
362 | - return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * Gets a registration given their REG_url_link. Yes, this should usually |
|
369 | - * be passed via a GET parameter. |
|
370 | - * |
|
371 | - * @param string $REG_url_link |
|
372 | - * @return EE_Registration |
|
373 | - */ |
|
374 | - public function get_registration_for_reg_url_link($REG_url_link) |
|
375 | - { |
|
376 | - if ( ! $REG_url_link) { |
|
377 | - return false; |
|
378 | - } |
|
379 | - return $this->get_one(array(array('REG_url_link' => $REG_url_link))); |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * retrieve registration for a specific transaction attendee from db |
|
386 | - * |
|
387 | - * @access public |
|
388 | - * @param int $TXN_ID |
|
389 | - * @param int $ATT_ID |
|
390 | - * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the |
|
391 | - * attendee number is required |
|
392 | - * @return mixed array on success, FALSE on fail |
|
393 | - */ |
|
394 | - public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) |
|
395 | - { |
|
396 | - return $this->get_one(array( |
|
397 | - array( |
|
398 | - 'TXN_ID' => $TXN_ID, |
|
399 | - 'ATT_ID' => $ATT_ID, |
|
400 | - ), |
|
401 | - 'limit' => array(min(($att_nmbr - 1), 0), 1), |
|
402 | - )); |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * get the number of registrations per day for the Registration Admin page Reports Tab. |
|
409 | - * (doesn't utilize models because it's a fairly specialized query) |
|
410 | - * |
|
411 | - * @access public |
|
412 | - * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
413 | - * @return stdClass[] with properties regDate and total |
|
414 | - */ |
|
415 | - public function get_registrations_per_day_report($period = '-1 month') |
|
416 | - { |
|
417 | - $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
418 | - 'Y-m-d H:i:s', 'UTC'); |
|
419 | - $where = array( |
|
420 | - 'REG_date' => array('>=', $sql_date), |
|
421 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
422 | - ); |
|
423 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
424 | - $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
425 | - } |
|
426 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
427 | - $results = $this->_get_all_wpdb_results(array( |
|
428 | - $where, |
|
429 | - 'group_by' => 'regDate', |
|
430 | - 'order_by' => array('REG_date' => 'ASC'), |
|
431 | - ), OBJECT, array( |
|
432 | - 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
433 | - 'total' => array('count(REG_ID)', '%d'), |
|
434 | - )); |
|
435 | - return $results; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * Get the number of registrations per day including the count of registrations for each Registration Status. |
|
442 | - * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
443 | - * |
|
444 | - * @param string $period |
|
445 | - * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
|
446 | - * (i.e. RAP) |
|
447 | - */ |
|
448 | - public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
|
449 | - { |
|
450 | - global $wpdb; |
|
451 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
452 | - $event_table = $wpdb->posts; |
|
453 | - $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
454 | - //prepare the query interval for displaying offset |
|
455 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
456 | - //inner date query |
|
457 | - $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
|
458 | - $inner_where = " WHERE"; |
|
459 | - //exclude events not authored by user if permissions in effect |
|
460 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
461 | - $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
|
462 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
463 | - } |
|
464 | - $inner_where .= " REG_date >= '$sql_date'"; |
|
465 | - $inner_date_query .= $inner_where; |
|
466 | - //start main query |
|
467 | - $select = "SELECT DATE($query_interval) as Registration_REG_date, "; |
|
468 | - $join = ''; |
|
469 | - $join_parts = array(); |
|
470 | - $select_parts = array(); |
|
471 | - //loop through registration stati to do parts for each status. |
|
472 | - foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
473 | - if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
474 | - continue; |
|
475 | - } |
|
476 | - $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
|
477 | - $join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'"; |
|
478 | - } |
|
479 | - //setup the selects |
|
480 | - $select .= implode(', ', $select_parts); |
|
481 | - $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
|
482 | - //setup the joins |
|
483 | - $join .= implode(" LEFT JOIN ", $join_parts); |
|
484 | - //now let's put it all together |
|
485 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
486 | - //and execute it |
|
487 | - $results = $wpdb->get_results($query, ARRAY_A); |
|
488 | - return $results; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - |
|
493 | - /** |
|
494 | - * get the number of registrations per event for the Registration Admin page Reports Tab |
|
495 | - * |
|
496 | - * @access public |
|
497 | - * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
498 | - * @return stdClass[] each with properties event_name, reg_limit, and total |
|
499 | - */ |
|
500 | - public function get_registrations_per_event_report($period = '-1 month') |
|
501 | - { |
|
502 | - $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
503 | - 'Y-m-d H:i:s', 'UTC'); |
|
504 | - $where = array( |
|
505 | - 'REG_date' => array('>=', $date_sql), |
|
506 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
507 | - ); |
|
508 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
509 | - $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
510 | - } |
|
511 | - $results = $this->_get_all_wpdb_results(array( |
|
512 | - $where, |
|
513 | - 'group_by' => 'Event.EVT_name', |
|
514 | - 'order_by' => 'Event.EVT_name', |
|
515 | - 'limit' => array(0, 24), |
|
516 | - ), OBJECT, array( |
|
517 | - 'event_name' => array('Event_CPT.post_title', '%s'), |
|
518 | - 'total' => array('COUNT(REG_ID)', '%s'), |
|
519 | - )); |
|
520 | - return $results; |
|
521 | - } |
|
522 | - |
|
523 | - |
|
524 | - |
|
525 | - /** |
|
526 | - * Get the number of registrations per event grouped by registration status. |
|
527 | - * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
528 | - * |
|
529 | - * @param string $period |
|
530 | - * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
|
531 | - * (i.e. RAP) |
|
532 | - */ |
|
533 | - public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
|
534 | - { |
|
535 | - global $wpdb; |
|
536 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
537 | - $event_table = $wpdb->posts; |
|
538 | - $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
539 | - //inner date query |
|
540 | - $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
|
541 | - $inner_where = " WHERE"; |
|
542 | - //exclude events not authored by user if permissions in effect |
|
543 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
544 | - $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
|
545 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
546 | - } |
|
547 | - $inner_where .= " REG_date >= '$sql_date'"; |
|
548 | - $inner_date_query .= $inner_where; |
|
549 | - //build main query |
|
550 | - $select = "SELECT Event.post_title as Registration_Event, "; |
|
551 | - $join = ''; |
|
552 | - $join_parts = array(); |
|
553 | - $select_parts = array(); |
|
554 | - //loop through registration stati to do parts for each status. |
|
555 | - foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
556 | - if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
557 | - continue; |
|
558 | - } |
|
559 | - $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
|
560 | - $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"; |
|
561 | - } |
|
562 | - //setup the selects |
|
563 | - $select .= implode(', ', $select_parts); |
|
564 | - $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
|
565 | - //setup remaining joins |
|
566 | - $join .= implode(" LEFT JOIN ", $join_parts); |
|
567 | - //now put it all together |
|
568 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
569 | - //and execute |
|
570 | - $results = $wpdb->get_results($query, ARRAY_A); |
|
571 | - return $results; |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - |
|
576 | - /** |
|
577 | - * Returns the EE_Registration of the primary attendee on the transaction id provided |
|
578 | - * |
|
579 | - * @param int $TXN_ID |
|
580 | - * @return EE_Registration |
|
581 | - */ |
|
582 | - public function get_primary_registration_for_transaction_ID($TXN_ID = 0) |
|
583 | - { |
|
584 | - if ( ! $TXN_ID) { |
|
585 | - return false; |
|
586 | - } |
|
587 | - return $this->get_one(array( |
|
588 | - array( |
|
589 | - 'TXN_ID' => $TXN_ID, |
|
590 | - 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT, |
|
591 | - ), |
|
592 | - )); |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * get_event_registration_count |
|
599 | - * |
|
600 | - * @access public |
|
601 | - * @param int $EVT_ID |
|
602 | - * @param boolean $for_incomplete_payments |
|
603 | - * @return int |
|
604 | - */ |
|
605 | - public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false) |
|
606 | - { |
|
607 | - // we only count approved registrations towards registration limits |
|
608 | - $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
609 | - if ($for_incomplete_payments) { |
|
610 | - $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
611 | - } |
|
612 | - return $this->count($query_params); |
|
613 | - } |
|
614 | - |
|
615 | - |
|
616 | - |
|
617 | - /** |
|
618 | - * Deletes all registrations with no transactions. Note that this needs to be very efficient |
|
619 | - * and so it uses wpdb directly |
|
620 | - * |
|
621 | - * @global WPDB $wpdb |
|
622 | - * @return int number deleted |
|
623 | - */ |
|
624 | - public function delete_registrations_with_no_transaction() |
|
625 | - { |
|
626 | - /** @type WPDB $wpdb */ |
|
627 | - global $wpdb; |
|
628 | - return $wpdb->query('DELETE r FROM ' |
|
629 | - . $this->table() |
|
630 | - . ' r LEFT JOIN ' |
|
631 | - . EEM_Transaction::instance()->table() |
|
632 | - . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL'); |
|
633 | - } |
|
634 | - |
|
635 | - |
|
636 | - |
|
637 | - /** |
|
638 | - * Count registrations checked into (or out of) a datetime |
|
639 | - * |
|
640 | - * @param int $DTT_ID datetime ID |
|
641 | - * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
642 | - * @return int |
|
643 | - */ |
|
644 | - public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) |
|
645 | - { |
|
646 | - global $wpdb; |
|
647 | - //subquery to get latest checkin |
|
648 | - $query = $wpdb->prepare('SELECT ' |
|
649 | - . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
650 | - . 'FROM ' |
|
651 | - . EEM_Checkin::instance() |
|
652 | - ->table() |
|
653 | - . ' AS checkins INNER JOIN' |
|
654 | - . '( SELECT ' |
|
655 | - . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
656 | - . 'REG_ID AS REG_ID ' |
|
657 | - . 'FROM ' |
|
658 | - . EEM_Checkin::instance()->table() |
|
659 | - . ' ' |
|
660 | - . 'WHERE DTT_ID=%d ' |
|
661 | - . 'GROUP BY REG_ID' |
|
662 | - . ') AS most_recent_checkin_per_reg ' |
|
663 | - . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
664 | - . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
665 | - . 'WHERE ' |
|
666 | - . 'checkins.CHK_in=%d', $DTT_ID, $checked_in); |
|
667 | - return (int)$wpdb->get_var($query); |
|
668 | - } |
|
669 | - |
|
670 | - |
|
671 | - |
|
672 | - /** |
|
673 | - * Count registrations checked into (or out of) an event. |
|
674 | - * |
|
675 | - * @param int $EVT_ID event ID |
|
676 | - * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
677 | - * @return int |
|
678 | - */ |
|
679 | - public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) |
|
680 | - { |
|
681 | - global $wpdb; |
|
682 | - //subquery to get latest checkin |
|
683 | - $query = $wpdb->prepare('SELECT ' |
|
684 | - . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
685 | - . 'FROM ' |
|
686 | - . EEM_Checkin::instance() |
|
687 | - ->table() |
|
688 | - . ' AS checkins INNER JOIN' |
|
689 | - . '( SELECT ' |
|
690 | - . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
691 | - . 'REG_ID AS REG_ID ' |
|
692 | - . 'FROM ' |
|
693 | - . EEM_Checkin::instance()->table() |
|
694 | - . ' AS c ' |
|
695 | - . 'INNER JOIN ' |
|
696 | - . EEM_Datetime::instance()->table() |
|
697 | - . ' AS d ' |
|
698 | - . 'ON c.DTT_ID=d.DTT_ID ' |
|
699 | - . 'WHERE d.EVT_ID=%d ' |
|
700 | - . 'GROUP BY REG_ID' |
|
701 | - . ') AS most_recent_checkin_per_reg ' |
|
702 | - . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
703 | - . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
704 | - . 'WHERE ' |
|
705 | - . 'checkins.CHK_in=%d', $EVT_ID, $checked_in); |
|
706 | - return (int)$wpdb->get_var($query); |
|
707 | - } |
|
708 | - |
|
709 | - |
|
710 | - |
|
711 | - /** |
|
712 | - * The purpose of this method is to retrieve an array of |
|
713 | - * EE_Registration objects that represent the latest registration |
|
714 | - * for each ATT_ID given in the function argument. |
|
715 | - * |
|
716 | - * @param array $attendee_ids |
|
717 | - * @return EE_Registration[] |
|
718 | - */ |
|
719 | - public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) |
|
720 | - { |
|
721 | - //first do a native wp_query to get the latest REG_ID's matching these attendees. |
|
722 | - global $wpdb; |
|
723 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
724 | - $attendee_table = $wpdb->posts; |
|
725 | - $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids); |
|
726 | - $attendee_ids = implode(',', $attendee_ids); |
|
727 | - //first we do a query to get the registration ids |
|
728 | - // (because a group by before order by causes the order by to be ignored.) |
|
729 | - $registration_id_query = " |
|
20 | + // private instance of the Registration object |
|
21 | + protected static $_instance = null; |
|
22 | + |
|
23 | + /** |
|
24 | + * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values |
|
25 | + * are status codes (eg, approved, cancelled, etc) |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + private static $_reg_status; |
|
30 | + |
|
31 | + /** |
|
32 | + * The value of REG_count for a primary registrant |
|
33 | + */ |
|
34 | + const PRIMARY_REGISTRANT_COUNT = 1; |
|
35 | + |
|
36 | + /** |
|
37 | + * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration. |
|
38 | + * Initial status for registrations when they are first created |
|
39 | + * Payments are NOT allowed. |
|
40 | + * Automatically toggled to whatever the default Event registration status is upon completion of the attendee |
|
41 | + * information reg step NO space reserved. Registration is NOT active |
|
42 | + */ |
|
43 | + const status_id_incomplete = 'RIC'; |
|
44 | + |
|
45 | + /** |
|
46 | + * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration. |
|
47 | + * Payments are NOT allowed. |
|
48 | + * Event Admin must manually toggle STS_ID for it to change |
|
49 | + * No space reserved. |
|
50 | + * Registration is active |
|
51 | + */ |
|
52 | + const status_id_not_approved = 'RNA'; |
|
53 | + |
|
54 | + /** |
|
55 | + * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT . |
|
56 | + * Payments are allowed. |
|
57 | + * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
58 | + * No space reserved. |
|
59 | + * Registration is active |
|
60 | + */ |
|
61 | + const status_id_pending_payment = 'RPP'; |
|
62 | + |
|
63 | + /** |
|
64 | + * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST . |
|
65 | + * Payments are allowed. |
|
66 | + * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
67 | + * No space reserved. |
|
68 | + * Registration is active |
|
69 | + */ |
|
70 | + const status_id_wait_list = 'RWL'; |
|
71 | + |
|
72 | + /** |
|
73 | + * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration. |
|
74 | + * the TXN may or may not be completed ( paid in full ) |
|
75 | + * Payments are allowed. |
|
76 | + * A space IS reserved. |
|
77 | + * Registration is active |
|
78 | + */ |
|
79 | + const status_id_approved = 'RAP'; |
|
80 | + |
|
81 | + /** |
|
82 | + * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee. |
|
83 | + * Payments are NOT allowed. |
|
84 | + * NO space reserved. |
|
85 | + * Registration is NOT active |
|
86 | + */ |
|
87 | + const status_id_cancelled = 'RCN'; |
|
88 | + |
|
89 | + /** |
|
90 | + * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin |
|
91 | + * Payments are NOT allowed. |
|
92 | + * No space reserved. |
|
93 | + * Registration is NOT active |
|
94 | + */ |
|
95 | + const status_id_declined = 'RDC'; |
|
96 | + |
|
97 | + /** |
|
98 | + * @var TableAnalysis $table_analysis |
|
99 | + */ |
|
100 | + protected $_table_analysis; |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * private constructor to prevent direct creation |
|
106 | + * |
|
107 | + * @Constructor |
|
108 | + * @access protected |
|
109 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
110 | + * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
111 | + * date time model field objects. Default is NULL (and will be assumed using the set |
|
112 | + * timezone in the 'timezone_string' wp option) |
|
113 | + */ |
|
114 | + protected function __construct($timezone = null) |
|
115 | + { |
|
116 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
117 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
118 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
119 | + $this->_tables = array( |
|
120 | + 'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'), |
|
121 | + ); |
|
122 | + $this->_fields = array( |
|
123 | + 'Registration' => array( |
|
124 | + 'REG_ID' => new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
125 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
126 | + 'EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event' |
|
127 | + ), |
|
128 | + 'ATT_ID' => new EE_Foreign_Key_Int_Field( |
|
129 | + 'ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee' |
|
130 | + ), |
|
131 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), |
|
132 | + false, 0, 'Transaction' |
|
133 | + ), |
|
134 | + 'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, |
|
135 | + 0, 'Ticket' |
|
136 | + ), |
|
137 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
138 | + false, EEM_Registration::status_id_incomplete, 'Status' |
|
139 | + ), |
|
140 | + 'REG_date' => new EE_Datetime_Field('REG_date', |
|
141 | + __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone |
|
142 | + ), |
|
143 | + 'REG_final_price' => new EE_Money_Field('REG_final_price', |
|
144 | + __('Registration\'s share of the transaction total', 'event_espresso'), false, 0 |
|
145 | + ), |
|
146 | + 'REG_paid' => new EE_Money_Field('REG_paid', |
|
147 | + __('Amount paid to date towards registration', 'event_espresso'), false, 0 |
|
148 | + ), |
|
149 | + 'REG_session' => new EE_Plain_Text_Field('REG_session', |
|
150 | + __('Session ID of registration', 'event_espresso'), false, '' |
|
151 | + ), |
|
152 | + 'REG_code' => new EE_Plain_Text_Field('REG_code', |
|
153 | + __('Unique Code for this registration', 'event_espresso'), false, '' |
|
154 | + ), |
|
155 | + 'REG_url_link' => new EE_Plain_Text_Field('REG_url_link', |
|
156 | + __('String to be used in URL for identifying registration', 'event_espresso'), false, '' |
|
157 | + ), |
|
158 | + 'REG_count' => new EE_Integer_Field('REG_count', |
|
159 | + __('Count of this registration in the group registration ', 'event_espresso'), true, 1 |
|
160 | + ), |
|
161 | + 'REG_group_size' => new EE_Integer_Field('REG_group_size', |
|
162 | + __('Number of registrations on this group', 'event_espresso'), false, 1 |
|
163 | + ), |
|
164 | + 'REG_att_is_going' => new EE_Boolean_Field('REG_att_is_going', |
|
165 | + __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false |
|
166 | + ), |
|
167 | + 'REG_deleted' => new EE_Trashed_Flag_Field( |
|
168 | + 'REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), |
|
169 | + false, false |
|
170 | + ), |
|
171 | + ), |
|
172 | + ); |
|
173 | + $this->_model_relations = array( |
|
174 | + 'Event' => new EE_Belongs_To_Relation(), |
|
175 | + 'Attendee' => new EE_Belongs_To_Relation(), |
|
176 | + 'Transaction' => new EE_Belongs_To_Relation(), |
|
177 | + 'Ticket' => new EE_Belongs_To_Relation(), |
|
178 | + 'Status' => new EE_Belongs_To_Relation(), |
|
179 | + 'Answer' => new EE_Has_Many_Relation(), |
|
180 | + 'Checkin' => new EE_Has_Many_Relation(), |
|
181 | + 'Registration_Payment' => new EE_Has_Many_Relation(), |
|
182 | + 'Payment' => new EE_HABTM_Relation('Registration_Payment'), |
|
183 | + 'Message' => new EE_Has_Many_Any_Relation(false) |
|
184 | + //allow deletes even if there are messages in the queue related |
|
185 | + ); |
|
186 | + $this->_model_chain_to_wp_user = 'Event'; |
|
187 | + parent::__construct($timezone); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * reg_statuses_that_allow_payment |
|
194 | + * a filterable list of registration statuses that allow a registrant to make a payment |
|
195 | + * |
|
196 | + * @access public |
|
197 | + * @return array |
|
198 | + */ |
|
199 | + public static function reg_statuses_that_allow_payment() |
|
200 | + { |
|
201 | + return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
202 | + EEM_Registration::status_id_approved, |
|
203 | + EEM_Registration::status_id_pending_payment, |
|
204 | + EEM_Registration::status_id_wait_list, |
|
205 | + )); |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * inactive_reg_statuses |
|
212 | + * a filterable list of registration statuses that are considered active |
|
213 | + * |
|
214 | + * @access public |
|
215 | + * @return array |
|
216 | + */ |
|
217 | + public static function active_reg_statuses() |
|
218 | + { |
|
219 | + return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
220 | + EEM_Registration::status_id_approved, |
|
221 | + EEM_Registration::status_id_pending_payment, |
|
222 | + EEM_Registration::status_id_wait_list, |
|
223 | + EEM_Registration::status_id_not_approved, |
|
224 | + )); |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * inactive_reg_statuses |
|
231 | + * a filterable list of registration statuses that are not considered active |
|
232 | + * |
|
233 | + * @access public |
|
234 | + * @return array |
|
235 | + */ |
|
236 | + public static function inactive_reg_statuses() |
|
237 | + { |
|
238 | + return apply_filters('FHEE__EEM_Registration__reg_statuses_that_allow_payment', array( |
|
239 | + EEM_Registration::status_id_incomplete, |
|
240 | + EEM_Registration::status_id_cancelled, |
|
241 | + EEM_Registration::status_id_declined, |
|
242 | + )); |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * closed_reg_statuses |
|
249 | + * a filterable list of registration statuses that are considered "closed" |
|
250 | + * meaning they should not be considered in any calculations involving monies owing |
|
251 | + * |
|
252 | + * @access public |
|
253 | + * @return array |
|
254 | + */ |
|
255 | + public static function closed_reg_statuses() |
|
256 | + { |
|
257 | + return apply_filters('FHEE__EEM_Registration__closed_reg_statuses', array( |
|
258 | + EEM_Registration::status_id_cancelled, |
|
259 | + EEM_Registration::status_id_declined, |
|
260 | + )); |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * get list of registration statuses |
|
267 | + * |
|
268 | + * @access public |
|
269 | + * @param array $exclude The status ids to exclude from the returned results |
|
270 | + * @param bool $translated If true will return the values as singular localized strings |
|
271 | + * @return array |
|
272 | + */ |
|
273 | + public static function reg_status_array($exclude = array(), $translated = false) |
|
274 | + { |
|
275 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
276 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence') |
|
277 | + : self::$_reg_status; |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * get list of registration statuses |
|
284 | + * |
|
285 | + * @access private |
|
286 | + * @param array $exclude |
|
287 | + * @return array |
|
288 | + */ |
|
289 | + private function _get_registration_status_array($exclude = array()) |
|
290 | + { |
|
291 | + //in the very rare circumstance that we are deleting a model's table's data |
|
292 | + //and the table hasn't actually been created, this could have an error |
|
293 | + /** @type WPDB $wpdb */ |
|
294 | + global $wpdb; |
|
295 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
296 | + $results = $wpdb->get_results( |
|
297 | + "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'" |
|
298 | + ); |
|
299 | + self::$_reg_status = array(); |
|
300 | + foreach ($results as $status) { |
|
301 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
302 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
303 | + } |
|
304 | + } |
|
305 | + } |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * Gets the injected table analyzer, or throws an exception |
|
312 | + * |
|
313 | + * @return TableAnalysis |
|
314 | + * @throws \EE_Error |
|
315 | + */ |
|
316 | + protected function _get_table_analysis() |
|
317 | + { |
|
318 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
319 | + return $this->_table_analysis; |
|
320 | + } else { |
|
321 | + throw new \EE_Error(sprintf(__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
322 | + get_class($this))); |
|
323 | + } |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * This returns a wpdb->results array of all registration date month and years matching the incoming query params |
|
330 | + * and grouped by month and year. |
|
331 | + * |
|
332 | + * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
|
333 | + * @return array |
|
334 | + * @throws \EE_Error |
|
335 | + */ |
|
336 | + public function get_reg_months_and_years($where_params) |
|
337 | + { |
|
338 | + $query_params[0] = $where_params; |
|
339 | + $query_params['group_by'] = array('reg_year', 'reg_month'); |
|
340 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
341 | + $columns_to_select = array( |
|
342 | + 'reg_year' => array('YEAR(REG_date)', '%s'), |
|
343 | + 'reg_month' => array('MONTHNAME(REG_date)', '%s'), |
|
344 | + ); |
|
345 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * retrieve ALL registrations for a particular Attendee from db |
|
352 | + * |
|
353 | + * @access public |
|
354 | + * @param int $ATT_ID |
|
355 | + * @return EE_Registration[] |
|
356 | + */ |
|
357 | + public function get_all_registrations_for_attendee($ATT_ID = 0) |
|
358 | + { |
|
359 | + if ( ! $ATT_ID) { |
|
360 | + return false; |
|
361 | + } |
|
362 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * Gets a registration given their REG_url_link. Yes, this should usually |
|
369 | + * be passed via a GET parameter. |
|
370 | + * |
|
371 | + * @param string $REG_url_link |
|
372 | + * @return EE_Registration |
|
373 | + */ |
|
374 | + public function get_registration_for_reg_url_link($REG_url_link) |
|
375 | + { |
|
376 | + if ( ! $REG_url_link) { |
|
377 | + return false; |
|
378 | + } |
|
379 | + return $this->get_one(array(array('REG_url_link' => $REG_url_link))); |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * retrieve registration for a specific transaction attendee from db |
|
386 | + * |
|
387 | + * @access public |
|
388 | + * @param int $TXN_ID |
|
389 | + * @param int $ATT_ID |
|
390 | + * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the |
|
391 | + * attendee number is required |
|
392 | + * @return mixed array on success, FALSE on fail |
|
393 | + */ |
|
394 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) |
|
395 | + { |
|
396 | + return $this->get_one(array( |
|
397 | + array( |
|
398 | + 'TXN_ID' => $TXN_ID, |
|
399 | + 'ATT_ID' => $ATT_ID, |
|
400 | + ), |
|
401 | + 'limit' => array(min(($att_nmbr - 1), 0), 1), |
|
402 | + )); |
|
403 | + } |
|
404 | + |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * get the number of registrations per day for the Registration Admin page Reports Tab. |
|
409 | + * (doesn't utilize models because it's a fairly specialized query) |
|
410 | + * |
|
411 | + * @access public |
|
412 | + * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
413 | + * @return stdClass[] with properties regDate and total |
|
414 | + */ |
|
415 | + public function get_registrations_per_day_report($period = '-1 month') |
|
416 | + { |
|
417 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
418 | + 'Y-m-d H:i:s', 'UTC'); |
|
419 | + $where = array( |
|
420 | + 'REG_date' => array('>=', $sql_date), |
|
421 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
422 | + ); |
|
423 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
424 | + $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
425 | + } |
|
426 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
427 | + $results = $this->_get_all_wpdb_results(array( |
|
428 | + $where, |
|
429 | + 'group_by' => 'regDate', |
|
430 | + 'order_by' => array('REG_date' => 'ASC'), |
|
431 | + ), OBJECT, array( |
|
432 | + 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
433 | + 'total' => array('count(REG_ID)', '%d'), |
|
434 | + )); |
|
435 | + return $results; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * Get the number of registrations per day including the count of registrations for each Registration Status. |
|
442 | + * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
443 | + * |
|
444 | + * @param string $period |
|
445 | + * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
|
446 | + * (i.e. RAP) |
|
447 | + */ |
|
448 | + public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
|
449 | + { |
|
450 | + global $wpdb; |
|
451 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
452 | + $event_table = $wpdb->posts; |
|
453 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
454 | + //prepare the query interval for displaying offset |
|
455 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
456 | + //inner date query |
|
457 | + $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
|
458 | + $inner_where = " WHERE"; |
|
459 | + //exclude events not authored by user if permissions in effect |
|
460 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
461 | + $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
|
462 | + $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
463 | + } |
|
464 | + $inner_where .= " REG_date >= '$sql_date'"; |
|
465 | + $inner_date_query .= $inner_where; |
|
466 | + //start main query |
|
467 | + $select = "SELECT DATE($query_interval) as Registration_REG_date, "; |
|
468 | + $join = ''; |
|
469 | + $join_parts = array(); |
|
470 | + $select_parts = array(); |
|
471 | + //loop through registration stati to do parts for each status. |
|
472 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
473 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
474 | + continue; |
|
475 | + } |
|
476 | + $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
|
477 | + $join_parts[] = "$registration_table AS $STS_code ON $STS_code.REG_date = dates.REG_date AND $STS_code.STS_ID = '$STS_ID'"; |
|
478 | + } |
|
479 | + //setup the selects |
|
480 | + $select .= implode(', ', $select_parts); |
|
481 | + $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
|
482 | + //setup the joins |
|
483 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
484 | + //now let's put it all together |
|
485 | + $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
486 | + //and execute it |
|
487 | + $results = $wpdb->get_results($query, ARRAY_A); |
|
488 | + return $results; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + |
|
493 | + /** |
|
494 | + * get the number of registrations per event for the Registration Admin page Reports Tab |
|
495 | + * |
|
496 | + * @access public |
|
497 | + * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
498 | + * @return stdClass[] each with properties event_name, reg_limit, and total |
|
499 | + */ |
|
500 | + public function get_registrations_per_event_report($period = '-1 month') |
|
501 | + { |
|
502 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), |
|
503 | + 'Y-m-d H:i:s', 'UTC'); |
|
504 | + $where = array( |
|
505 | + 'REG_date' => array('>=', $date_sql), |
|
506 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
507 | + ); |
|
508 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
509 | + $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
510 | + } |
|
511 | + $results = $this->_get_all_wpdb_results(array( |
|
512 | + $where, |
|
513 | + 'group_by' => 'Event.EVT_name', |
|
514 | + 'order_by' => 'Event.EVT_name', |
|
515 | + 'limit' => array(0, 24), |
|
516 | + ), OBJECT, array( |
|
517 | + 'event_name' => array('Event_CPT.post_title', '%s'), |
|
518 | + 'total' => array('COUNT(REG_ID)', '%s'), |
|
519 | + )); |
|
520 | + return $results; |
|
521 | + } |
|
522 | + |
|
523 | + |
|
524 | + |
|
525 | + /** |
|
526 | + * Get the number of registrations per event grouped by registration status. |
|
527 | + * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
528 | + * |
|
529 | + * @param string $period |
|
530 | + * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
|
531 | + * (i.e. RAP) |
|
532 | + */ |
|
533 | + public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
|
534 | + { |
|
535 | + global $wpdb; |
|
536 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
537 | + $event_table = $wpdb->posts; |
|
538 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
539 | + //inner date query |
|
540 | + $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
|
541 | + $inner_where = " WHERE"; |
|
542 | + //exclude events not authored by user if permissions in effect |
|
543 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
544 | + $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
|
545 | + $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
546 | + } |
|
547 | + $inner_where .= " REG_date >= '$sql_date'"; |
|
548 | + $inner_date_query .= $inner_where; |
|
549 | + //build main query |
|
550 | + $select = "SELECT Event.post_title as Registration_Event, "; |
|
551 | + $join = ''; |
|
552 | + $join_parts = array(); |
|
553 | + $select_parts = array(); |
|
554 | + //loop through registration stati to do parts for each status. |
|
555 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
556 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
557 | + continue; |
|
558 | + } |
|
559 | + $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
|
560 | + $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"; |
|
561 | + } |
|
562 | + //setup the selects |
|
563 | + $select .= implode(', ', $select_parts); |
|
564 | + $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
|
565 | + //setup remaining joins |
|
566 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
567 | + //now put it all together |
|
568 | + $query = $select . $join . ' GROUP BY Registration_Event'; |
|
569 | + //and execute |
|
570 | + $results = $wpdb->get_results($query, ARRAY_A); |
|
571 | + return $results; |
|
572 | + } |
|
573 | + |
|
574 | + |
|
575 | + |
|
576 | + /** |
|
577 | + * Returns the EE_Registration of the primary attendee on the transaction id provided |
|
578 | + * |
|
579 | + * @param int $TXN_ID |
|
580 | + * @return EE_Registration |
|
581 | + */ |
|
582 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) |
|
583 | + { |
|
584 | + if ( ! $TXN_ID) { |
|
585 | + return false; |
|
586 | + } |
|
587 | + return $this->get_one(array( |
|
588 | + array( |
|
589 | + 'TXN_ID' => $TXN_ID, |
|
590 | + 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT, |
|
591 | + ), |
|
592 | + )); |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * get_event_registration_count |
|
599 | + * |
|
600 | + * @access public |
|
601 | + * @param int $EVT_ID |
|
602 | + * @param boolean $for_incomplete_payments |
|
603 | + * @return int |
|
604 | + */ |
|
605 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false) |
|
606 | + { |
|
607 | + // we only count approved registrations towards registration limits |
|
608 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
609 | + if ($for_incomplete_payments) { |
|
610 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
611 | + } |
|
612 | + return $this->count($query_params); |
|
613 | + } |
|
614 | + |
|
615 | + |
|
616 | + |
|
617 | + /** |
|
618 | + * Deletes all registrations with no transactions. Note that this needs to be very efficient |
|
619 | + * and so it uses wpdb directly |
|
620 | + * |
|
621 | + * @global WPDB $wpdb |
|
622 | + * @return int number deleted |
|
623 | + */ |
|
624 | + public function delete_registrations_with_no_transaction() |
|
625 | + { |
|
626 | + /** @type WPDB $wpdb */ |
|
627 | + global $wpdb; |
|
628 | + return $wpdb->query('DELETE r FROM ' |
|
629 | + . $this->table() |
|
630 | + . ' r LEFT JOIN ' |
|
631 | + . EEM_Transaction::instance()->table() |
|
632 | + . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL'); |
|
633 | + } |
|
634 | + |
|
635 | + |
|
636 | + |
|
637 | + /** |
|
638 | + * Count registrations checked into (or out of) a datetime |
|
639 | + * |
|
640 | + * @param int $DTT_ID datetime ID |
|
641 | + * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
642 | + * @return int |
|
643 | + */ |
|
644 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) |
|
645 | + { |
|
646 | + global $wpdb; |
|
647 | + //subquery to get latest checkin |
|
648 | + $query = $wpdb->prepare('SELECT ' |
|
649 | + . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
650 | + . 'FROM ' |
|
651 | + . EEM_Checkin::instance() |
|
652 | + ->table() |
|
653 | + . ' AS checkins INNER JOIN' |
|
654 | + . '( SELECT ' |
|
655 | + . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
656 | + . 'REG_ID AS REG_ID ' |
|
657 | + . 'FROM ' |
|
658 | + . EEM_Checkin::instance()->table() |
|
659 | + . ' ' |
|
660 | + . 'WHERE DTT_ID=%d ' |
|
661 | + . 'GROUP BY REG_ID' |
|
662 | + . ') AS most_recent_checkin_per_reg ' |
|
663 | + . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
664 | + . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
665 | + . 'WHERE ' |
|
666 | + . 'checkins.CHK_in=%d', $DTT_ID, $checked_in); |
|
667 | + return (int)$wpdb->get_var($query); |
|
668 | + } |
|
669 | + |
|
670 | + |
|
671 | + |
|
672 | + /** |
|
673 | + * Count registrations checked into (or out of) an event. |
|
674 | + * |
|
675 | + * @param int $EVT_ID event ID |
|
676 | + * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
677 | + * @return int |
|
678 | + */ |
|
679 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) |
|
680 | + { |
|
681 | + global $wpdb; |
|
682 | + //subquery to get latest checkin |
|
683 | + $query = $wpdb->prepare('SELECT ' |
|
684 | + . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
685 | + . 'FROM ' |
|
686 | + . EEM_Checkin::instance() |
|
687 | + ->table() |
|
688 | + . ' AS checkins INNER JOIN' |
|
689 | + . '( SELECT ' |
|
690 | + . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
691 | + . 'REG_ID AS REG_ID ' |
|
692 | + . 'FROM ' |
|
693 | + . EEM_Checkin::instance()->table() |
|
694 | + . ' AS c ' |
|
695 | + . 'INNER JOIN ' |
|
696 | + . EEM_Datetime::instance()->table() |
|
697 | + . ' AS d ' |
|
698 | + . 'ON c.DTT_ID=d.DTT_ID ' |
|
699 | + . 'WHERE d.EVT_ID=%d ' |
|
700 | + . 'GROUP BY REG_ID' |
|
701 | + . ') AS most_recent_checkin_per_reg ' |
|
702 | + . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
703 | + . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
704 | + . 'WHERE ' |
|
705 | + . 'checkins.CHK_in=%d', $EVT_ID, $checked_in); |
|
706 | + return (int)$wpdb->get_var($query); |
|
707 | + } |
|
708 | + |
|
709 | + |
|
710 | + |
|
711 | + /** |
|
712 | + * The purpose of this method is to retrieve an array of |
|
713 | + * EE_Registration objects that represent the latest registration |
|
714 | + * for each ATT_ID given in the function argument. |
|
715 | + * |
|
716 | + * @param array $attendee_ids |
|
717 | + * @return EE_Registration[] |
|
718 | + */ |
|
719 | + public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) |
|
720 | + { |
|
721 | + //first do a native wp_query to get the latest REG_ID's matching these attendees. |
|
722 | + global $wpdb; |
|
723 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
724 | + $attendee_table = $wpdb->posts; |
|
725 | + $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids); |
|
726 | + $attendee_ids = implode(',', $attendee_ids); |
|
727 | + //first we do a query to get the registration ids |
|
728 | + // (because a group by before order by causes the order by to be ignored.) |
|
729 | + $registration_id_query = " |
|
730 | 730 | SELECT registrations.registration_ids as registration_id |
731 | 731 | FROM ( |
732 | 732 | SELECT |
@@ -740,23 +740,23 @@ discard block |
||
740 | 740 | ) AS registrations |
741 | 741 | GROUP BY registrations.attendee_ids |
742 | 742 | "; |
743 | - $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A); |
|
744 | - if (empty($registration_ids)) { |
|
745 | - return array(); |
|
746 | - } |
|
747 | - $ids_for_model_query = array(); |
|
748 | - //let's flatten the ids so they can be used in the model query. |
|
749 | - foreach ($registration_ids as $registration_id) { |
|
750 | - if (isset($registration_id['registration_id'])) { |
|
751 | - $ids_for_model_query[] = $registration_id['registration_id']; |
|
752 | - } |
|
753 | - } |
|
754 | - //construct query |
|
755 | - $_where = array( |
|
756 | - 'REG_ID' => array('IN', $ids_for_model_query), |
|
757 | - ); |
|
758 | - return $this->get_all(array($_where)); |
|
759 | - } |
|
743 | + $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A); |
|
744 | + if (empty($registration_ids)) { |
|
745 | + return array(); |
|
746 | + } |
|
747 | + $ids_for_model_query = array(); |
|
748 | + //let's flatten the ids so they can be used in the model query. |
|
749 | + foreach ($registration_ids as $registration_id) { |
|
750 | + if (isset($registration_id['registration_id'])) { |
|
751 | + $ids_for_model_query[] = $registration_id['registration_id']; |
|
752 | + } |
|
753 | + } |
|
754 | + //construct query |
|
755 | + $_where = array( |
|
756 | + 'REG_ID' => array('IN', $ids_for_model_query), |
|
757 | + ); |
|
758 | + return $this->get_all(array($_where)); |
|
759 | + } |
|
760 | 760 | |
761 | 761 | |
762 | 762 |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | //and the table hasn't actually been created, this could have an error |
293 | 293 | /** @type WPDB $wpdb */ |
294 | 294 | global $wpdb; |
295 | - if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
295 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) { |
|
296 | 296 | $results = $wpdb->get_results( |
297 | 297 | "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'" |
298 | 298 | ); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | 'group_by' => 'regDate', |
430 | 430 | 'order_by' => array('REG_date' => 'ASC'), |
431 | 431 | ), OBJECT, array( |
432 | - 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
432 | + 'regDate' => array('DATE('.$query_interval.')', '%s'), |
|
433 | 433 | 'total' => array('count(REG_ID)', '%d'), |
434 | 434 | )); |
435 | 435 | return $results; |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
449 | 449 | { |
450 | 450 | global $wpdb; |
451 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
451 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
452 | 452 | $event_table = $wpdb->posts; |
453 | 453 | $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
454 | 454 | //prepare the query interval for displaying offset |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | //exclude events not authored by user if permissions in effect |
460 | 460 | if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
461 | 461 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
462 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
462 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
463 | 463 | } |
464 | 464 | $inner_where .= " REG_date >= '$sql_date'"; |
465 | 465 | $inner_date_query .= $inner_where; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | //setup the joins |
483 | 483 | $join .= implode(" LEFT JOIN ", $join_parts); |
484 | 484 | //now let's put it all together |
485 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
485 | + $query = $select.$join.' GROUP BY Registration_REG_date'; |
|
486 | 486 | //and execute it |
487 | 487 | $results = $wpdb->get_results($query, ARRAY_A); |
488 | 488 | return $results; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
534 | 534 | { |
535 | 535 | global $wpdb; |
536 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
536 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
537 | 537 | $event_table = $wpdb->posts; |
538 | 538 | $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
539 | 539 | //inner date query |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | //exclude events not authored by user if permissions in effect |
543 | 543 | if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
544 | 544 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
545 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
545 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
546 | 546 | } |
547 | 547 | $inner_where .= " REG_date >= '$sql_date'"; |
548 | 548 | $inner_date_query .= $inner_where; |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | //setup remaining joins |
566 | 566 | $join .= implode(" LEFT JOIN ", $join_parts); |
567 | 567 | //now put it all together |
568 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
568 | + $query = $select.$join.' GROUP BY Registration_Event'; |
|
569 | 569 | //and execute |
570 | 570 | $results = $wpdb->get_results($query, ARRAY_A); |
571 | 571 | return $results; |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
665 | 665 | . 'WHERE ' |
666 | 666 | . 'checkins.CHK_in=%d', $DTT_ID, $checked_in); |
667 | - return (int)$wpdb->get_var($query); |
|
667 | + return (int) $wpdb->get_var($query); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
704 | 704 | . 'WHERE ' |
705 | 705 | . 'checkins.CHK_in=%d', $EVT_ID, $checked_in); |
706 | - return (int)$wpdb->get_var($query); |
|
706 | + return (int) $wpdb->get_var($query); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -720,9 +720,9 @@ discard block |
||
720 | 720 | { |
721 | 721 | //first do a native wp_query to get the latest REG_ID's matching these attendees. |
722 | 722 | global $wpdb; |
723 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
723 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
724 | 724 | $attendee_table = $wpdb->posts; |
725 | - $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int)$attendee_ids); |
|
725 | + $attendee_ids = is_array($attendee_ids) ? array_map('absint', $attendee_ids) : array((int) $attendee_ids); |
|
726 | 726 | $attendee_ids = implode(',', $attendee_ids); |
727 | 727 | //first we do a query to get the registration ids |
728 | 728 | // (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 |