Completed
Branch FET-8385-datetime-ticket-selec... (e7a63b)
by
unknown
56:53 queued 37:10
created
admin_pages/maintenance/templates/ee_migration_page.template.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  * @type string $reset_db_page_link
17 17
  */
18 18
 
19
-if ( $show_backup_db_text ) { ?>
20
-<h1><span class="dashicons dashicons-migrate"></span><?php _e("Database Migration Manager", "event_espresso");?></h1>
19
+if ($show_backup_db_text) { ?>
20
+<h1><span class="dashicons dashicons-migrate"></span><?php _e("Database Migration Manager", "event_espresso"); ?></h1>
21 21
 <?php } ?>
22 22
 <div class="padding">
23 23
 	<div id="migration-prep">
24 24
 
25
- 		<?php if ( $script_names ) { ?>
25
+ 		<?php if ($script_names) { ?>
26 26
  			<h3 class="espresso-header">
27 27
  				<span class="dashicons dashicons-flag ee-icon-size-22"></span>
28 28
  				<?php
@@ -39,34 +39,34 @@  discard block
 block discarded – undo
39 39
 				?>
40 40
  			</h3>
41 41
  			<p>
42
- 			<?php echo apply_filters('FHEE__ee_migration_page__p_after_header',sprintf(__("Since you have already been using Event Espresso and have previous event and registration data in your database, you have the option to migrate, or copy over, this existing data into a format that is compatible with %s.", "event_espresso"),$next_db_state),$next_db_state);?>
42
+ 			<?php echo apply_filters('FHEE__ee_migration_page__p_after_header', sprintf(__("Since you have already been using Event Espresso and have previous event and registration data in your database, you have the option to migrate, or copy over, this existing data into a format that is compatible with %s.", "event_espresso"), $next_db_state), $next_db_state); ?>
43 43
  			</p>
44
- 		<?php } elseif ( $show_most_recent_migration ) { ?>
44
+ 		<?php } elseif ($show_most_recent_migration) { ?>
45 45
  			 <h3 class="espresso-header">
46 46
  			 	<span class="dashicons dashicons-awards ee-icon-size-22"></span>
47
- 				 <?php echo apply_filters('FHEE__ee_migration_page__done_migration_header',sprintf(__('Congratulations! Your database is "up-to-date" and you are ready to begin using %s', "event_espresso"),$ultimate_db_state));?>
47
+ 				 <?php echo apply_filters('FHEE__ee_migration_page__done_migration_header', sprintf(__('Congratulations! Your database is "up-to-date" and you are ready to begin using %s', "event_espresso"), $ultimate_db_state)); ?>
48 48
  			 </h3>
49 49
  			 <p>
50
- 			 	<?php echo apply_filters('FHEE__ee_migration_page__p_after_done_migration_header',sprintf(__("Time to find out about all the great new features %s has to offer.", "event_espresso"),$ultimate_db_state));?> &nbsp;
51
- 			 	<b><a id="get-started-after-migrate" class="button-primary" href="<?php echo add_query_arg( array( 'page' => 'espresso_about' ), admin_url( 'admin.php' )); ?>">
52
- 			 		<?php _e("Let's Get Started", "event_espresso");?>&nbsp;<span class="dashicons dashicons-arrow-right ee-icon-size-22" style="margin:0;"></span>
50
+ 			 	<?php echo apply_filters('FHEE__ee_migration_page__p_after_done_migration_header', sprintf(__("Time to find out about all the great new features %s has to offer.", "event_espresso"), $ultimate_db_state)); ?> &nbsp;
51
+ 			 	<b><a id="get-started-after-migrate" class="button-primary" href="<?php echo add_query_arg(array('page' => 'espresso_about'), admin_url('admin.php')); ?>">
52
+ 			 		<?php _e("Let's Get Started", "event_espresso"); ?>&nbsp;<span class="dashicons dashicons-arrow-right ee-icon-size-22" style="margin:0;"></span>
53 53
  			 	</a></b>
54 54
  			 </p>
55 55
  		<?php } ?>
56 56
 
57 57
 
58
-		<?php if ($show_backup_db_text){ ?>
58
+		<?php if ($show_backup_db_text) { ?>
59 59
 		<div id="migration-options-dv">
60 60
 			<h2>
61 61
 				<span class="dashicons dashicons-admin-tools"></span>
62
-				<?php _e("Migration Options", "event_espresso");?>
63
-				<span class="tiny-text lt-grey-text"> &nbsp; <?php _e(' to migrate or not to migrate?', "event_espresso");?></span>
62
+				<?php _e("Migration Options", "event_espresso"); ?>
63
+				<span class="tiny-text lt-grey-text"> &nbsp; <?php _e(' to migrate or not to migrate?', "event_espresso"); ?></span>
64 64
 			</h2>
65 65
 			<div class="ee-table-wrap">
66 66
 				<table>
67 67
 					<tbody>
68 68
 						<tr>
69
-							<td><h3><?php _e('1', 'event_espresso');?></h3></td>
69
+							<td><h3><?php _e('1', 'event_espresso'); ?></h3></td>
70 70
 							<td>
71 71
 								<?php
72 72
 								echo apply_filters(
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 									__('%1$sYes. I have backed up my database%2$s, %3$sunderstand the risks involved%4$s, and am ready to migrate my existing %5$s data to %6$s.', "event_espresso"),
76 76
 									'<strong>',
77 77
 									'</strong>',
78
-									'<a id="migration-risks" class="" title="' . esc_attr__('click for more details', "event_espresso") . '">',
78
+									'<a id="migration-risks" class="" title="'.esc_attr__('click for more details', "event_espresso").'">',
79 79
 									'</a>',
80 80
 										$current_db_state,
81 81
 										$next_db_state
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 									$next_db_state
85 85
 								);
86 86
 								?>
87
-								<a id="display-migration-details" class="display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="migration-details" ><?php _e('click for more details', "event_espresso");?>&nbsp;+</a>
88
-								<a  id="hide-migration-details" class="hide-the-displayed lt-grey-text smaller-text hide-if-no-js"  rel="migration-details" style="display:none;" ><?php echo sprintf( __( 'hide%1$sdetails%1$s-', 'event_espresso' ), '&nbsp;' ); ?></a>
87
+								<a id="display-migration-details" class="display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="migration-details" ><?php _e('click for more details', "event_espresso"); ?>&nbsp;+</a>
88
+								<a  id="hide-migration-details" class="hide-the-displayed lt-grey-text smaller-text hide-if-no-js"  rel="migration-details" style="display:none;" ><?php echo sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'); ?></a>
89 89
 							</td>
90 90
 							<td>
91
-								<a id="db-backed-up" class="toggle-migration-monitor button-primary"><?php echo apply_filters('FHEE__ee_migration_page__option_1_button_text',sprintf(__("Migrate My %s Data to %s", "event_espresso"),$current_db_state,$next_db_state),$current_db_state,$next_db_state);?></a>
91
+								<a id="db-backed-up" class="toggle-migration-monitor button-primary"><?php echo apply_filters('FHEE__ee_migration_page__option_1_button_text', sprintf(__("Migrate My %s Data to %s", "event_espresso"), $current_db_state, $next_db_state), $current_db_state, $next_db_state); ?></a>
92 92
 							</td>
93 93
 						</tr>
94 94
 						<tr>
95 95
 							<td colspan="3" style="padding: 0">
96 96
 								<div id="migration-details-dv" style="display: none; padding: 1em;">
97 97
 
98
-									<span class="reminder-spn"><?php printf(__("%s Important: %s Before migrating, please back up your database and files.", "event_espresso"),"<b>","</b>");?></span>
98
+									<span class="reminder-spn"><?php printf(__("%s Important: %s Before migrating, please back up your database and files.", "event_espresso"), "<b>", "</b>"); ?></span>
99 99
 									<p>
100 100
 									<?php
101 101
 										printf(
@@ -111,27 +111,27 @@  discard block
 block discarded – undo
111 111
 										);
112 112
 									?>
113 113
 									</p>
114
-									<?php do_action('AHEE__ee_migration_page__option_1_extra_details');?>
114
+									<?php do_action('AHEE__ee_migration_page__option_1_extra_details'); ?>
115 115
 								</div>
116 116
 							</td>
117 117
 						</tr>
118 118
 						<tr>
119
-							<td><h3><?php _e('2', 'event_espresso');?></h3></td>
119
+							<td><h3><?php _e('2', 'event_espresso'); ?></h3></td>
120 120
 							<td>
121
-								<?php echo apply_filters( 'FHEE__ee_migration_page__option_2_main',sprintf(__('I do NOT want to migrate my %1$s data to %2$s at this time and just want to use %3$s without migrating data.', "event_espresso"),$current_db_state,$next_db_state,$ultimate_db_state),$current_db_state,$next_db_state,$ultimate_db_state);?><br />
122
-								<span class="reminder-spn"><?php _e( 'Please Note: In order to avoid errors, any existing Event Espresso data (events, ticket, registrations, etc) in your db will be erased! Regular WP data will NOT be affected.', 'event_espresso' );?></span>
123
-								<a id="display-no-migration-details" class="display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="no-migration-details"><?php _e('click for more details', "event_espresso");?>&nbsp;+</a>
124
-								<a  id="hide-no-migration-details" class="hide-the-displayed lt-grey-text smaller-text hide-if-no-js"  rel="no-migration-details" style="display:none;" ><?php echo sprintf( __( 'hide%1$sdetails%1$s-', 'event_espresso' ), '&nbsp;' ); ?></a>
121
+								<?php echo apply_filters('FHEE__ee_migration_page__option_2_main', sprintf(__('I do NOT want to migrate my %1$s data to %2$s at this time and just want to use %3$s without migrating data.', "event_espresso"), $current_db_state, $next_db_state, $ultimate_db_state), $current_db_state, $next_db_state, $ultimate_db_state); ?><br />
122
+								<span class="reminder-spn"><?php _e('Please Note: In order to avoid errors, any existing Event Espresso data (events, ticket, registrations, etc) in your db will be erased! Regular WP data will NOT be affected.', 'event_espresso'); ?></span>
123
+								<a id="display-no-migration-details" class="display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="no-migration-details"><?php _e('click for more details', "event_espresso"); ?>&nbsp;+</a>
124
+								<a  id="hide-no-migration-details" class="hide-the-displayed lt-grey-text smaller-text hide-if-no-js"  rel="no-migration-details" style="display:none;" ><?php echo sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'); ?></a>
125 125
 							</td>
126 126
 							<td>
127
-								<a id="do-not-migrate" class="do-not-migrate button-primary" href="<?php echo $reset_db_page_link;?>"><?php echo apply_filters('FHEE__ee_migration_page__option_2_button_text',sprintf(__("Just Start %s and Delete Existing Data", "event_espresso"),$ultimate_db_state),$ultimate_db_state);?></a>
127
+								<a id="do-not-migrate" class="do-not-migrate button-primary" href="<?php echo $reset_db_page_link; ?>"><?php echo apply_filters('FHEE__ee_migration_page__option_2_button_text', sprintf(__("Just Start %s and Delete Existing Data", "event_espresso"), $ultimate_db_state), $ultimate_db_state); ?></a>
128 128
 							</td>
129 129
 						</tr>
130 130
 						<tr>
131 131
 							<td colspan="3" style="padding: 0">
132 132
 								<div id="no-migration-details-dv" style="display: none; padding: 1em;">
133 133
 									<p>
134
-									<?php echo apply_filters('FHEE__ee_migration_page__option_2_details',sprintf(__("If your existing Event and Registration Data is no longer relevant nor required, you can just start up %s without performing a data migration.", "event_espresso"),$ultimate_db_state),$ultimate_db_state);?>
134
+									<?php echo apply_filters('FHEE__ee_migration_page__option_2_details', sprintf(__("If your existing Event and Registration Data is no longer relevant nor required, you can just start up %s without performing a data migration.", "event_espresso"), $ultimate_db_state), $ultimate_db_state); ?>
135 135
 									</p>
136 136
 								</div>
137 137
 							</td>
@@ -139,20 +139,20 @@  discard block
 block discarded – undo
139 139
 					</tbody>
140 140
 				</table>
141 141
 			</div>
142
-			<?php do_action('AHEE__ee_migration_page__after_migration_options_table');?>
142
+			<?php do_action('AHEE__ee_migration_page__after_migration_options_table'); ?>
143 143
 		</div>
144 144
 	<?php } ?>
145 145
 
146 146
 	<?php
147
-		if ( $show_most_recent_migration ) {
148
-			if( $most_recent_migration && $most_recent_migration instanceof EE_Data_Migration_Script_Base ) {
149
-				if( $most_recent_migration->can_continue() ) {
147
+		if ($show_most_recent_migration) {
148
+			if ($most_recent_migration && $most_recent_migration instanceof EE_Data_Migration_Script_Base) {
149
+				if ($most_recent_migration->can_continue()) {
150 150
 					//tell the user they should continue their migration because it appears to be unfinished... well, assuming there were no errors ?>
151 151
 					<h3 class="espresso-header">
152 152
 						<span class="dashicons dashicons-star-half ee-icon-size-22"></span>
153
-						<?php printf(__("It appears that your previous Data Migration Task (%s) is incomplete, and should be resumed", "event_espresso"),$most_recent_migration->pretty_name());?>
153
+						<?php printf(__("It appears that your previous Data Migration Task (%s) is incomplete, and should be resumed", "event_espresso"), $most_recent_migration->pretty_name()); ?>
154 154
 					</h3>
155
-			<?php } elseif ( $most_recent_migration->is_broken() ) {
155
+			<?php } elseif ($most_recent_migration->is_broken()) {
156 156
 					//tell the user the migration failed and they should notify EE?>
157 157
 					<h3 class="espresso-header">
158 158
 						<span class="dashicons dashicons-no ee-icon-size-22"></span>
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
 			<?php }
162 162
 
163 163
 				//display errors or not of the most recent migration ran
164
-				if ( $most_recent_migration->get_errors() ){ ?>
164
+				if ($most_recent_migration->get_errors()) { ?>
165 165
 					<div class="ee-attention">
166
-						<strong><?php printf(__("Warnings occurred during your last migration (%s):",'event_espresso'),$most_recent_migration->pretty_name()) ?></strong>
167
-						<a id="show-hide-migration-warnings" class="display-the-hidden"><?php _e("Show Warnings", 'event_espresso');?></a>
166
+						<strong><?php printf(__("Warnings occurred during your last migration (%s):", 'event_espresso'), $most_recent_migration->pretty_name()) ?></strong>
167
+						<a id="show-hide-migration-warnings" class="display-the-hidden"><?php _e("Show Warnings", 'event_espresso'); ?></a>
168 168
 						<ul class="migration-warnings" style="display:none">
169
-						<?php foreach($most_recent_migration->get_errors() as $error){ ?>
170
-							<li><?php echo htmlentities( $error ) ?></li>
169
+						<?php foreach ($most_recent_migration->get_errors() as $error) { ?>
170
+							<li><?php echo htmlentities($error) ?></li>
171 171
 						<?php }?>
172 172
 						</ul>
173 173
 					</div>
174 174
 				<?php } else {
175 175
 					//there were no errors during the last migration, just say so?>
176
-					<h2><?php printf(__("The last data migration task (%s) ran successfully without errors.", "event_espresso"),$most_recent_migration->pretty_name())?></h2>
176
+					<h2><?php printf(__("The last data migration task (%s) ran successfully without errors.", "event_espresso"), $most_recent_migration->pretty_name())?></h2>
177 177
 				<?php }
178 178
 				} else {
179 179
 			}
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 	</div>
185 185
 	<!--end of #migration-prep-->
186 186
 
187
-	<?php if ($show_migration_progress){?>
187
+	<?php if ($show_migration_progress) {?>
188 188
 	<div id='migration-monitor' <?php echo $show_backup_db_text ? "style='display:none'" : ''?>>
189
-		<?php if( $show_backup_db_text){?>
189
+		<?php if ($show_backup_db_text) {?>
190 190
 		<p>
191 191
 			<a class="toggle-migration-monitor small-text" style="cursor: pointer;">
192
-				<span class="dashicons dashicons-arrow-left-alt2" style="top:0;"></span><?php _e("return to previous screen", "event_espresso");?>
192
+				<span class="dashicons dashicons-arrow-left-alt2" style="top:0;"></span><?php _e("return to previous screen", "event_espresso"); ?>
193 193
 			</a>
194 194
 			<br/>
195 195
 
@@ -198,33 +198,33 @@  discard block
 block discarded – undo
198 198
 		<div id='progress-area'>
199 199
 			<h3 class="espresso-header">
200 200
 				<?php
201
-				echo  sprintf( _n(
201
+				echo  sprintf(_n(
202 202
 					"In order to import all of your existing Event Espresso data, the following upgrade task needs to be performed:",
203 203
 					"In order to import all of your existing Event Espresso data, the following %s upgrade tasks need to be performed:",
204 204
 					count($script_names),
205 205
 					"event_espresso"
206
-				), count( $script_names ) );?>
206
+				), count($script_names)); ?>
207 207
 			</h3>
208 208
 			<ul style="list-style: inside;">
209
-				<?php foreach($script_names as $script_name){?>
209
+				<?php foreach ($script_names as $script_name) {?>
210 210
 				<li style="margin: 0 0 1em 1em; line-height: 1.1em;"><?php echo $script_name?></li>
211 211
 				<?php }?>
212 212
 			</ul>
213 213
 			<br/>
214 214
 			<?php if (count($script_names) > 1) {?>
215
-			<p><?php _e("Please note: after each task is completed you will need to continue the data migration, or report an error to Event Espresso.", "event_espresso");?></p>
215
+			<p><?php _e("Please note: after each task is completed you will need to continue the data migration, or report an error to Event Espresso.", "event_espresso"); ?></p>
216 216
 			<?php }?>
217 217
 
218 218
 			<div class="ee-attention">
219 219
 				<p>
220 220
 					<span class="reminder-spn">
221
-						<strong><?php _e("Please Note:", "event_espresso");?></strong>
221
+						<strong><?php _e("Please Note:", "event_espresso"); ?></strong>
222 222
 					</span>
223 223
 					<br/>
224
-					<?php _e("Depending on the number of events and the complexity of the information in your database, this could take a few minutes.", "event_espresso");?>
224
+					<?php _e("Depending on the number of events and the complexity of the information in your database, this could take a few minutes.", "event_espresso"); ?>
225 225
 				</p>
226 226
 				<p>
227
-					<?php printf(__("%sPlease be patient and do NOT navigate away from this page once the migration has begun%s. If any issues arise due to existing malformed data, an itemized report will be made available to you after the migration has completed.", "event_espresso"),'<strong>', '</strong>' );?>
227
+					<?php printf(__("%sPlease be patient and do NOT navigate away from this page once the migration has begun%s. If any issues arise due to existing malformed data, an itemized report will be made available to you after the migration has completed.", "event_espresso"), '<strong>', '</strong>'); ?>
228 228
 				</p>
229 229
 				<p>
230 230
 					<?php _e("Click the button below to begin the migration process.", "event_espresso") ?>
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 			<!-- #progress-responsive -->
240 240
 
241 241
 			<button id='start-migration' class='button-primary'>
242
-				<?php echo $show_continue_current_migration_script ? __("Continue Migration", "event_espresso") : __("Begin Migration", "event_espresso");?>
242
+				<?php echo $show_continue_current_migration_script ? __("Continue Migration", "event_espresso") : __("Begin Migration", "event_espresso"); ?>
243 243
 			</button>
244 244
 			<br class="clear"/>
245 245
 
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 	</div>
256 256
 
257 257
 <?php }
258
-	   if ( $show_maintenance_switch ) {
258
+	   if ($show_maintenance_switch) {
259 259
  ?>
260
-	<h2><span class="dashicons dashicons-admin-tools"></span><?php  _e('Set Event Espresso Maintenance Mode', 'event_espresso');?></h2>
260
+	<h2><span class="dashicons dashicons-admin-tools"></span><?php  _e('Set Event Espresso Maintenance Mode', 'event_espresso'); ?></h2>
261 261
    	<form method='post' action='<?php echo $update_migration_script_page_link?>'>
262 262
 		<div class="ee-table-wrap">
263 263
 			<table>
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 						<input type="radio" id="maintenance_mode_level_off" name="maintenance_mode_level" value="0" <?php echo EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_0_not_in_maintenance ? 'checked="checked"' : ''?>>
267 267
 					</td>
268 268
 					<th align="left">
269
-						<label for="maintenance_mode_level_off"><?php  _e('Maintenance Mode OFF', 'event_espresso');?></label>
269
+						<label for="maintenance_mode_level_off"><?php  _e('Maintenance Mode OFF', 'event_espresso'); ?></label>
270 270
 				   		<p class='description' style="font-weight: normal;">
271
-					   		<?php _e("This is the normal operating mode for Event Espresso and allows all functionality to be viewed by all site visitors.", "event_espresso");?>
271
+					   		<?php _e("This is the normal operating mode for Event Espresso and allows all functionality to be viewed by all site visitors.", "event_espresso"); ?>
272 272
 				   		</p>
273 273
 					</th>
274 274
 				</tr>
@@ -281,14 +281,14 @@  discard block
 block discarded – undo
281 281
 							<?php  _e('Maintenance Mode ON', 'event_espresso')?>
282 282
 						</label>
283 283
 				   		<p class='description' style="font-weight: normal;">
284
-					   		<?php _e("This disables Event Espresso frontend functionality for all site visitors that are not administrators, and allows you to configure and/or test things on the frontend of your website before others can see.", "event_espresso");?>
284
+					   		<?php _e("This disables Event Espresso frontend functionality for all site visitors that are not administrators, and allows you to configure and/or test things on the frontend of your website before others can see.", "event_espresso"); ?>
285 285
 				   		</p>
286 286
 					</th>
287 287
 				</tr>
288 288
 			</table>
289 289
 		</div>
290 290
 		<p>
291
-   			<input type='submit' class="button-primary" value='<?php _e("Update Maintenance Mode", "event_espresso");?>'>
291
+   			<input type='submit' class="button-primary" value='<?php _e("Update Maintenance Mode", "event_espresso"); ?>'>
292 292
    		</p>
293 293
    	</form>
294 294
 	   	<?php
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 //(all other times it gets resurrected from a wordpress option)
17 17
 $stages = glob(EE_CORE.'data_migration_scripts/4_8_0_stages/*');
18 18
 $class_to_filepath = array();
19
-foreach($stages as $filepath){
19
+foreach ($stages as $filepath) {
20 20
 	$matches = array();
21
-	preg_match('~4_8_0_stages/(.*).dmsstage.php~',$filepath,$matches);
21
+	preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22 22
 	$class_to_filepath[$matches[1]] = $filepath;
23 23
 }
24 24
 //give addons a chance to autoload their stages too
25
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages',$class_to_filepath);
25
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath);
26 26
 EEH_Autoloader::register_autoloader($class_to_filepath);
27 27
 
28 28
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @since                4.6.0
39 39
  *
40 40
  */
41
-class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base{
41
+class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base {
42 42
 
43 43
 	/**
44 44
 	 * return EE_DMS_Core_4_8_0
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 	 * @param TableManager  $table_manager
47 47
 	 * @param TableAnalysis $table_analysis
48 48
 	 */
49
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
49
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
50 50
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.8.0.P (for promotions)", "event_espresso");
51 51
 		$this->_priority = 10;
52 52
 		$this->_migration_stages = array(
53 53
 			new EE_DMS_4_8_0_pretax_totals(),
54 54
 			new EE_DMS_4_8_0_event_subtotals(),
55 55
 		);
56
-		parent::__construct( $table_manager, $table_analysis );
56
+		parent::__construct($table_manager, $table_analysis);
57 57
 	}
58 58
 
59 59
 
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function can_migrate_from_version($version_array) {
70 70
 		$version_string = $version_array['Core'];
71
-		if ( version_compare( $version_string, '4.8.0', '<=' ) && version_compare( $version_string, '4.7.0', '>=' ) ) {
71
+		if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) {
72 72
 //			echo "$version_string can be migrated from";
73 73
 			return true;
74
-		}elseif( ! $version_string ){
74
+		}elseif ( ! $version_string) {
75 75
 //			echo "no version string provided: $version_string";
76 76
 			//no version string provided... this must be pre 4.3
77
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
78
-		}else{
77
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
78
+		} else {
79 79
 //			echo "$version_string doesnt apply";
80 80
 			return false;
81 81
 		}
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
 	 * @return bool
97 97
 	 */
98 98
 	public function schema_changes_before_migration() {
99
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
100
-		$now_in_mysql = current_time( 'mysql', true );
99
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
100
+		$now_in_mysql = current_time('mysql', true);
101 101
 
102
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
103
-		$table_name='esp_answer';
104
-		$sql=" ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
102
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
103
+		$table_name = 'esp_answer';
104
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
105 105
 					REG_ID int(10) unsigned NOT NULL,
106 106
 					QST_ID int(10) unsigned NOT NULL,
107 107
 					ANS_value text NOT NULL,
108 108
 					PRIMARY KEY  (ANS_ID),
109 109
 					KEY REG_ID (REG_ID),
110 110
 					KEY QST_ID (QST_ID)";
111
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
111
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
112 112
 
113 113
 		$table_name = 'esp_attendee_meta';
114 114
 		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
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' );
151
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152 152
 
153 153
 		$table_name = 'esp_currency';
154 154
 		$sql = "CUR_code varchar(6) collate utf8_bin NOT NULL,
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 				CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2',
159 159
 				CUR_active tinyint(1) DEFAULT '0',
160 160
 				PRIMARY KEY  (CUR_code)";
161
-		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB' );
161
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
162 162
 
163 163
 
164 164
 		$table_name = 'esp_currency_payment_method';
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 						KEY EVT_ID (EVT_ID),
189 189
 						KEY DTT_is_primary (DTT_is_primary)";
190 190
 
191
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
191
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
192 192
 
193 193
 		$table_name = 'esp_event_meta';
194 194
 		$sql = "
@@ -207,41 +207,41 @@  discard block
 block discarded – undo
207 207
 			EVT_donations tinyint(1) NULL,
208 208
 			PRIMARY KEY  (EVTM_ID),
209 209
 			KEY EVT_ID (EVT_ID)";
210
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
210
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
211 211
 
212 212
 
213 213
 
214
-		$table_name='esp_event_question_group';
215
-		$sql="EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
214
+		$table_name = 'esp_event_question_group';
215
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
216 216
 					EVT_ID bigint(20) unsigned NOT NULL,
217 217
 					QSG_ID int(10) unsigned NOT NULL,
218 218
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
219 219
 					PRIMARY KEY  (EQG_ID),
220 220
 					KEY EVT_ID (EVT_ID),
221 221
 					KEY QSG_ID (QSG_ID)";
222
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
222
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
223 223
 
224 224
 
225 225
 
226
-		$table_name='esp_event_venue';
227
-		$sql="EVV_ID int(11) NOT NULL AUTO_INCREMENT,
226
+		$table_name = 'esp_event_venue';
227
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
228 228
 				EVT_ID bigint(20) unsigned NOT NULL,
229 229
 				VNU_ID bigint(20) unsigned NOT NULL,
230 230
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
231 231
 				PRIMARY KEY  (EVV_ID)";
232
-		$this->_table_has_not_changed_since_previous($table_name,$sql, 'ENGINE=InnoDB');
232
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
233 233
 
234 234
 
235 235
 
236
-		$table_name='esp_extra_meta';
237
-		$sql="EXM_ID int(11) NOT NULL AUTO_INCREMENT,
236
+		$table_name = 'esp_extra_meta';
237
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
238 238
 				OBJ_ID int(11) DEFAULT NULL,
239 239
 				EXM_type varchar(45) DEFAULT NULL,
240 240
 				EXM_key varchar(45) DEFAULT NULL,
241 241
 				EXM_value text,
242 242
 				PRIMARY KEY  (EXM_ID),
243 243
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
244
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
244
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
245 245
 
246 246
 		$table_name = 'esp_extra_join';
247 247
 		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
255 255
 		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
256 256
 
257
-		$table_name='esp_line_item';
258
-		$sql="LIN_ID int(11) NOT NULL AUTO_INCREMENT,
257
+		$table_name = 'esp_line_item';
258
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
259 259
 				LIN_code varchar(245) NOT NULL DEFAULT '',
260 260
 				TXN_ID int(11) DEFAULT NULL,
261 261
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 				PRIMARY KEY  (LIN_ID),
275 275
 				KEY LIN_code (LIN_code(191)),
276 276
 				KEY TXN_ID (TXN_ID)";
277
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
277
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
278 278
 
279 279
 		$table_name = 'esp_log';
280 280
 		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
314 314
 					PRIMARY KEY  (GRP_ID),
315 315
 					KEY MTP_user_id (MTP_user_id)";
316
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
316
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
317 317
 
318 318
 		$table_name = 'esp_event_message_template';
319 319
 		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 					PRIMARY KEY  (EMT_ID),
323 323
 					KEY EVT_ID (EVT_ID),
324 324
 					KEY GRP_ID (GRP_ID)";
325
-		$this->_table_has_not_changed_since_previous( $table_name, $sql, 'ENGINE=InnoDB');
325
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
326 326
 
327 327
 
328 328
 		$table_name = 'esp_payment';
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 					  PRIMARY KEY  (TTM_ID)";
396 396
 		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
397 397
 
398
-		$table_name='esp_question';
399
-		$sql='QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
398
+		$table_name = 'esp_question';
399
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
400 400
 					QST_display_text text NOT NULL,
401 401
 					QST_admin_label varchar(255) NOT NULL,
402 402
 					QST_system varchar(25) NOT NULL DEFAULT "",
@@ -410,22 +410,22 @@  discard block
 block discarded – undo
410 410
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
411 411
 					PRIMARY KEY  (QST_ID),
412 412
 					KEY QST_order (QST_order)';
413
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
413
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
414 414
 
415
-		$table_name='esp_question_group_question';
416
-		$sql="QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
415
+		$table_name = 'esp_question_group_question';
416
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
417 417
 					QSG_ID int(10) unsigned NOT NULL,
418 418
 					QST_ID int(10) unsigned NOT NULL,
419 419
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
420 420
 					PRIMARY KEY  (QGQ_ID),
421 421
 					KEY QST_ID (QST_ID),
422 422
 					KEY QSG_ID_order (QSG_ID,QGQ_order)";
423
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
423
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
424 424
 
425 425
 
426 426
 
427
-		$table_name='esp_question_option';
428
-		$sql="QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
427
+		$table_name = 'esp_question_option';
428
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
429 429
 					QSO_value varchar(255) NOT NULL,
430 430
 					QSO_desc text NOT NULL,
431 431
 					QST_ID int(10) unsigned NOT NULL,
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 					PRIMARY KEY  (QSO_ID),
436 436
 					KEY QST_ID (QST_ID),
437 437
 					KEY QSO_order (QSO_order)";
438
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
438
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
439 439
 
440 440
 
441 441
 
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 
482 482
 
483 483
 
484
-		$table_name='esp_checkin';
485
-		$sql="CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
484
+		$table_name = 'esp_checkin';
485
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
486 486
 					REG_ID int(10) unsigned NOT NULL,
487 487
 					DTT_ID int(10) unsigned NOT NULL,
488 488
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 					  PRC_parent int(10) unsigned DEFAULT 0,
578 578
 					  PRIMARY KEY  (PRC_ID),
579 579
 					  KEY PRT_ID (PRT_ID)";
580
-		$this->_table_is_changed_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
580
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
581 581
 
582 582
 		$table_name = "esp_price_type";
583 583
 		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
616 616
 					  PRIMARY KEY  (TKT_ID),
617 617
 					  KEY TKT_start_date (TKT_start_date)";
618
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
618
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
619 619
 
620 620
 		$table_name = 'esp_question_group';
621
-		$sql='QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
621
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
622 622
 					QSG_name varchar(255) NOT NULL,
623 623
 					QSG_identifier varchar(100) NOT NULL,
624 624
 					QSG_desc text NULL,
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 					PRIMARY KEY  (QSG_ID),
632 632
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
633 633
 					KEY QSG_order (QSG_order)';
634
-		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
634
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
635 635
 
636 636
 		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
637 637
 		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 		return $script_4_7_defaults->schema_changes_after_migration();
668 668
 	}
669 669
 
670
-	public function migration_page_hooks(){
670
+	public function migration_page_hooks() {
671 671
 
672 672
 	}
673 673
 
@@ -681,31 +681,31 @@  discard block
 block discarded – undo
681 681
 		//CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active
682 682
 		//('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
683 683
 		$newer_countries = array(
684
-			array( 'AX', 'ALA', 0, '&#197;land Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0 ),
685
-			array( 'BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0 ),
686
-			array( 'CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0 ),
687
-			array( 'GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0 ),
688
-			array( 'IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2,  '+44', 0, 0  ),
689
-			array( 'JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0 ),
690
-			array( 'MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0 ),
691
-			array( 'ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1,  2, '+382', 0, 0 ),
692
-			array( 'RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0 ),
693
-			array( 'SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0 ),
694
-			array( 'SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0 ),
695
-			array( 'XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0 ),
696
-			array( 'YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0 ),
697
-			array( 'BQ', 'BES', 0, 'Bonaire, Saint Eustatius and Saba', 'USD', 'Dollar', 'Dollars', '$', 1,  2, '+599', 0, 0 ),
698
-			array( 'BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1,  2, '+47', 0, 0 ),
699
-			array( 'IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1,  2, '+246', 0, 0 ),
700
-			array( 'CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1,  2, '+61', 0, 0 ),
701
-			array( 'CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1,  2, '+891', 0, 0 ),
702
-			array( 'HM', 'HMD', 0, 'Heard Island and McDonald Islands', 'AUD', 'Dollar', 'Dollars', '$', 1,  2, '+891', 0, 0 ),
703
-			array( 'PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1,  2, '+970', 0, 0 ),
704
-			array( 'GS', 'SGS', 0, 'South Georgia and the South Sandwich Islands', 'GBP', 'Pound', 'Pounds', '£', 1,  2, '+500', 0, 0 ),
705
-			array( 'TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1,  2, '+670', 0, 0 ),
706
-			array( 'TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1,  2, '+262', 0, 0 ),
707
-
708
-			array( 'UM', 'UMI', 0, 'United States Minor Outlying Islands', 'USD', 'Dollar', 'Dollars', '$', 1,  2, '+1', 0, 0 ),
684
+			array('AX', 'ALA', 0, '&#197;land Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0),
685
+			array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
686
+			array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0),
687
+			array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0),
688
+			array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
689
+			array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0),
690
+			array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0),
691
+			array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0),
692
+			array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0),
693
+			array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0),
694
+			array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0),
695
+			array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0),
696
+			array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0),
697
+			array('BQ', 'BES', 0, 'Bonaire, Saint Eustatius and Saba', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+599', 0, 0),
698
+			array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0),
699
+			array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0),
700
+			array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0),
701
+			array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
702
+			array('HM', 'HMD', 0, 'Heard Island and McDonald Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0),
703
+			array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0),
704
+			array('GS', 'SGS', 0, 'South Georgia and the South Sandwich Islands', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+500', 0, 0),
705
+			array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0),
706
+			array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0),
707
+
708
+			array('UM', 'UMI', 0, 'United States Minor Outlying Islands', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+1', 0, 0),
709 709
 		);
710 710
 		global $wpdb;
711 711
 		$country_table = $wpdb->prefix."esp_country";
@@ -724,14 +724,14 @@  discard block
 block discarded – undo
724 724
 							"CNT_is_EU" => '%d',
725 725
 							"CNT_active" => '%d',
726 726
 						);
727
-		if ( $this->_get_table_analysis()->tableExists( $country_table ) ) {
728
-			foreach( $newer_countries as $country ) {
729
-				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1" ;
727
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
728
+			foreach ($newer_countries as $country) {
729
+				$SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1";
730 730
 				$countries = $wpdb->get_var($SQL);
731
-				if ( ! $countries ) {
731
+				if ( ! $countries) {
732 732
 
733
-					$wpdb->insert( $country_table,
734
-							array_combine( array_keys( $country_format), $country ),
733
+					$wpdb->insert($country_table,
734
+							array_combine(array_keys($country_format), $country),
735 735
 							$country_format
736 736
 							);
737 737
 				}
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 		// CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active
750 750
 		//( 'EUR',  'Euro',  'Euros',  '€',  2,1),
751 751
 		$newer_currencies = array(
752
-			array( 'RSD', 'Dinar', 'Dinars', '', 3, 1 ),
752
+			array('RSD', 'Dinar', 'Dinars', '', 3, 1),
753 753
 		);
754 754
 		global $wpdb;
755 755
 		$currency_table = $wpdb->prefix."esp_currency";
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 							"CUR_dec_plc" => '%d',
762 762
 							"CUR_active" => '%d',
763 763
 						);
764
-		if ( $this->_get_table_analysis()->tableExists( $currency_table ) ) {
765
-			foreach( $newer_currencies as $currency ) {
766
-				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1" ;
764
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
765
+			foreach ($newer_currencies as $currency) {
766
+				$SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1";
767 767
 				$countries = $wpdb->get_var($SQL);
768
-				if ( ! $countries ) {
768
+				if ( ! $countries) {
769 769
 
770
-					$wpdb->insert( $currency_table,
771
-							array_combine( array_keys( $currency_format), $currency ),
770
+					$wpdb->insert($currency_table,
771
+							array_combine(array_keys($currency_format), $currency),
772 772
 							$currency_format
773 773
 							);
774 774
 				}
@@ -780,9 +780,9 @@  discard block
 block discarded – undo
780 780
 	 * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
781 781
 	 * we should be able to stop doing this in 4.9
782 782
 	 */
783
-	public function fix_non_default_taxes(){
783
+	public function fix_non_default_taxes() {
784 784
 		global $wpdb;
785
-		$query = $wpdb->prepare( "UPDATE
785
+		$query = $wpdb->prepare("UPDATE
786 786
 				{$wpdb->prefix}esp_price p INNER JOIN
787 787
 				{$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID
788 788
 			SET
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 			WHERE
791 791
 				p.PRC_is_default = 0 AND
792 792
 				pt.PBT_ID = %d
793
-					", EEM_Price_Type::base_type_tax );
794
-		$wpdb->query( $query );
793
+					", EEM_Price_Type::base_type_tax);
794
+		$wpdb->query($query);
795 795
 	}
796 796
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 1 patch
Spacing   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 //(all other times it gets resurrected from a wordpress option)
12 12
 $stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14
-if ( ! empty( $stages ) ) {
15
-	foreach($stages as $filepath){
14
+if ( ! empty($stages)) {
15
+	foreach ($stages as $filepath) {
16 16
 		$matches = array();
17
-		preg_match('~4_1_0_stages/(.*).dmsstage.php~',$filepath,$matches);
17
+		preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18 18
 		$class_to_filepath[$matches[1]] = $filepath;
19 19
 	}
20 20
 }
21 21
 //give addons a chance to autoload their stages too
22
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages',$class_to_filepath);
22
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath);
23 23
 EEH_Autoloader::register_autoloader($class_to_filepath);
24 24
 
25 25
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
  * --a function named update_espresso_config() which saves the EE_Config object to the database
38 38
  * --...and all its subclasses... really, you're best off copying the whole thing when 4.1 is released into this file and wrapping its declaration in if( ! class_exists()){...}
39 39
  */
40
-class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base{
40
+class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base {
41 41
 
42 42
 
43 43
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param TableManager  $table_manager
48 48
 	 * @param TableAnalysis $table_analysis
49 49
 	 */
50
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
50
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
51 51
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso");
52 52
 		$this->_priority = 10;
53 53
 		$this->_migration_stages = array(
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			new EE_DMS_4_1_0_answers(),
70 70
 			new EE_DMS_4_1_0_checkins(),
71 71
 		);
72
-		parent::__construct( $table_manager, $table_analysis );
72
+		parent::__construct($table_manager, $table_analysis);
73 73
 	}
74 74
 	/**
75 75
 	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
 	 * @global wpdb $wpdb
78 78
 	 * @return boolean
79 79
 	 */
80
-	private function _checkin_table_exists(){
80
+	private function _checkin_table_exists() {
81 81
 		global $wpdb;
82 82
 		$results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
83
-		if($results){
83
+		if ($results) {
84 84
 			return true;
85
-		}else{
85
+		} else {
86 86
 			return false;
87 87
 		}
88 88
 	}
89 89
 
90 90
 	public function can_migrate_from_version($version_array) {
91 91
 		$version_string = $version_array['Core'];
92
-		if ( version_compare( $version_string, '4.0.0', '<=' ) && version_compare( $version_string, '3.1.26', '>=' ) ) {
92
+		if (version_compare($version_string, '4.0.0', '<=') && version_compare($version_string, '3.1.26', '>=')) {
93 93
 //			echo "$version_string can be migrated fro";
94 94
 			return true;
95
-		}elseif( ! $version_string ){
95
+		}elseif ( ! $version_string) {
96 96
 //			echo "no version string provided: $version_string";
97 97
 			//no version string provided... this must be pre 4.1
98 98
 			//because since 4.1 we're
99
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
100
-		}else{
99
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
100
+		} else {
101 101
 //			echo "$version_string doesnt apply";
102 102
 			return false;
103 103
 		}
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 	}
108 108
 	public function schema_changes_before_migration() {
109 109
 		//relies on 4.1's EEH_Activation::create_table
110
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
110
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
111 111
 
112
-		$table_name='esp_answer';
113
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
112
+		$table_name = 'esp_answer';
113
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
114 114
 					REG_ID INT UNSIGNED NOT NULL,
115 115
 					QST_ID INT UNSIGNED NOT NULL,
116 116
 					ANS_value TEXT NOT NULL,
117 117
 					PRIMARY KEY  (ANS_ID)";
118
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
118
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
119 119
 
120 120
 		$table_name = 'esp_attendee_meta';
121 121
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
156 156
 					  CNT_active TINYINT(1) DEFAULT '0',
157 157
 					  PRIMARY KEY  (CNT_ISO)";
158
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
158
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
159 159
 
160 160
 
161 161
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 
178 178
 
179
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
179
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
180 180
 		$table_name = 'esp_event_meta';
181 181
 		$sql = "
182 182
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
@@ -193,41 +193,41 @@  discard block
 block discarded – undo
193 193
 			EVT_external_URL VARCHAR(200) NULL,
194 194
 			EVT_donations TINYINT(1) NULL,
195 195
 			PRIMARY KEY  (EVTM_ID)";
196
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
196
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
197 197
 
198 198
 
199 199
 
200
-		$table_name='esp_event_question_group';
201
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
200
+		$table_name = 'esp_event_question_group';
201
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
202 202
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
203 203
 					QSG_ID INT UNSIGNED NOT NULL,
204 204
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
205 205
 					PRIMARY KEY  (EQG_ID)";
206
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
206
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
207 207
 
208 208
 
209 209
 
210
-		$table_name='esp_event_venue';
211
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
210
+		$table_name = 'esp_event_venue';
211
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
212 212
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
213 213
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
214 214
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
215 215
 				PRIMARY KEY  (EVV_ID)";
216
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
216
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
217 217
 
218 218
 
219 219
 
220
-		$table_name='esp_extra_meta';
221
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
220
+		$table_name = 'esp_extra_meta';
221
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
222 222
 				OBJ_ID INT(11) DEFAULT NULL,
223 223
 				EXM_type VARCHAR(45) DEFAULT NULL,
224 224
 				EXM_key VARCHAR(45) DEFAULT NULL,
225 225
 				EXM_value TEXT,
226 226
 				PRIMARY KEY  (EXM_ID)";
227
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
227
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
228 228
 
229
-		$table_name='esp_line_item';
230
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
229
+		$table_name = 'esp_line_item';
230
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
231 231
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
232 232
 				TXN_ID INT(11) DEFAULT NULL,
233 233
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 				OBJ_ID INT(11) DEFAULT NULL,
244 244
 				OBJ_type VARCHAR(45)DEFAULT NULL,
245 245
 				PRIMARY KEY  (LIN_ID)";
246
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
246
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247 247
 
248 248
 		$table_name = 'esp_message_template';
249 249
 		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 					PRIMARY KEY  (GRP_ID),
271 271
 					KEY EVT_ID (EVT_ID),
272 272
 					KEY MTP_user_id (MTP_user_id)";
273
-		$this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB');
273
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
274 274
 
275 275
 
276 276
 
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 
379 379
 
380 380
 
381
-		$table_name='esp_question';
382
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
381
+		$table_name = 'esp_question';
382
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
383 383
 					QST_display_text TEXT NOT NULL,
384 384
 					QST_admin_label VARCHAR(255) NOT NULL,
385 385
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -391,12 +391,12 @@  discard block
 block discarded – undo
391 391
 					QST_wp_user BIGINT UNSIGNED NULL,
392 392
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
393 393
 					PRIMARY KEY  (QST_ID)';
394
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
394
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
395 395
 
396
-		$this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' );
396
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
397 397
 
398 398
 		$table_name = 'esp_question_group';
399
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
399
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
400 400
 					QSG_name VARCHAR(255) NOT NULL,
401 401
 					QSG_identifier VARCHAR(100) NOT NULL,
402 402
 					QSG_desc TEXT NULL,
@@ -407,27 +407,27 @@  discard block
 block discarded – undo
407 407
 					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
408 408
 					PRIMARY KEY  (QSG_ID),
409 409
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
410
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
410
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
411 411
 
412 412
 
413 413
 
414
-		$table_name='esp_question_group_question';
415
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
414
+		$table_name = 'esp_question_group_question';
415
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
416 416
 					QSG_ID INT UNSIGNED NOT NULL,
417 417
 					QST_ID INT UNSIGNED NOT NULL,
418 418
 					PRIMARY KEY  (QGQ_ID) ";
419
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
419
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
420 420
 
421 421
 
422 422
 
423
-		$table_name='esp_question_option';
424
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
423
+		$table_name = 'esp_question_option';
424
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
425 425
 					QSO_value VARCHAR(255) NOT NULL,
426 426
 					QSO_desc TEXT NOT NULL,
427 427
 					QST_ID INT UNSIGNED NOT NULL,
428 428
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
429 429
 					PRIMARY KEY  (QSO_ID)";
430
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
430
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
431 431
 
432 432
 
433 433
 
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 
461 461
 
462 462
 
463
-		$table_name='esp_checkin';
464
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
463
+		$table_name = 'esp_checkin';
464
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
465 465
 					REG_ID INT(10) UNSIGNED NOT NULL,
466 466
 					DTT_ID INT(10) UNSIGNED NOT NULL,
467 467
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
 
569 569
 		global $wpdb;
570 570
 		$state_table = $wpdb->prefix."esp_state";
571
-		if ( $this->_get_table_analysis()->tableExists( $state_table ) ) {
571
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
572 572
 
573
-			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
573
+			$SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
574 574
 			$states = $wpdb->get_var($SQL);
575
-			if ( ! $states ) {
576
-				$SQL = "INSERT INTO " . $state_table . "
575
+			if ( ! $states) {
576
+				$SQL = "INSERT INTO ".$state_table."
577 577
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
578 578
 				(1, 'US', 'AK', 'Alaska', 1),
579 579
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -660,12 +660,12 @@  discard block
 block discarded – undo
660 660
 
661 661
 		global $wpdb;
662 662
 		$country_table = $wpdb->prefix."esp_country";
663
-		if ( $this->_get_table_analysis()->tableExists( $country_table ) ) {
663
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
664 664
 
665
-			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
665
+			$SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
666 666
 			$countries = $wpdb->get_var($SQL);
667
-			if ( ! $countries ) {
668
-				$SQL = "INSERT INTO " . $country_table . "
667
+			if ( ! $countries) {
668
+				$SQL = "INSERT INTO ".$country_table."
669 669
 				(CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES
670 670
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
671 671
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -912,20 +912,20 @@  discard block
 block discarded – undo
912 912
 		global $wpdb;
913 913
 		$price_type_table = $wpdb->prefix."esp_price_type";
914 914
 
915
-		if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) {
915
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
916 916
 
917
-			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
918
-			$price_types_exist = $wpdb->get_var( $SQL );
917
+			$SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
918
+			$price_types_exist = $wpdb->get_var($SQL);
919 919
 
920
-			if ( ! $price_types_exist ) {
920
+			if ( ! $price_types_exist) {
921 921
 				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
922
-							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
923
-							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
924
-							(3, '" . __('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
925
-							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
926
-							(5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
927
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL );
928
-				$wpdb->query( $SQL );
922
+							(1, '".__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
923
+							(2, '" . __('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
924
+							(3, '" . __('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
925
+							(4, '" . __('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
926
+							(5, '" . __('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
927
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
928
+				$wpdb->query($SQL);
929 929
 			}
930 930
 		}
931 931
 	}
@@ -945,16 +945,16 @@  discard block
 block discarded – undo
945 945
 		global $wpdb;
946 946
 		$price_table = $wpdb->prefix."esp_price";
947 947
 
948
-		if ( $this->_get_table_analysis()->tableExists(  $price_table ) ) {
948
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
949 949
 
950
-			$SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table;
951
-			$prices_exist = $wpdb->get_var( $SQL );
950
+			$SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
951
+			$prices_exist = $wpdb->get_var($SQL);
952 952
 
953
-			if ( ! $prices_exist ) {
953
+			if ( ! $prices_exist) {
954 954
 				$SQL = "INSERT INTO $price_table
955 955
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
956 956
 							(1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);";
957
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL );
957
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
958 958
 				$wpdb->query($SQL);
959 959
 			}
960 960
 		}
@@ -971,34 +971,34 @@  discard block
 block discarded – undo
971 971
 
972 972
 		global $wpdb;
973 973
 		$ticket_table = $wpdb->prefix."esp_ticket";
974
-		if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) {
974
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
975 975
 
976
-			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
976
+			$SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
977 977
 			$tickets_exist = $wpdb->get_var($SQL);
978 978
 
979
-			if ( ! $tickets_exist ) {
979
+			if ( ! $tickets_exist) {
980 980
 				$SQL = "INSERT INTO $ticket_table
981 981
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
982
-					( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
983
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL );
982
+					( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
983
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
984 984
 				$wpdb->query($SQL);
985 985
 			}
986 986
 		}
987 987
 		$ticket_price_table = $wpdb->prefix."esp_ticket_price";
988 988
 
989
-		if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) {
989
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
990 990
 
991
-			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
991
+			$SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
992 992
 			$ticket_prc_exist = $wpdb->get_var($SQL);
993 993
 
994
-			if ( ! $ticket_prc_exist ) {
994
+			if ( ! $ticket_prc_exist) {
995 995
 
996 996
 				$SQL = "INSERT INTO $ticket_price_table
997 997
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
998 998
 				( 1, 1, 1 )
999 999
 				";
1000 1000
 
1001
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL );
1001
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
1002 1002
 				$wpdb->query($SQL);
1003 1003
 			}
1004 1004
 		}
@@ -1011,20 +1011,20 @@  discard block
 block discarded – undo
1011 1011
 	 * @param string $country_name
1012 1012
 	 * @return array where keys are columns, values are column values
1013 1013
 	 */
1014
-	public function get_or_create_country($country_name){
1015
-		if( ! $country_name ){
1014
+	public function get_or_create_country($country_name) {
1015
+		if ( ! $country_name) {
1016 1016
 			throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso"));
1017 1017
 		}
1018 1018
 		global $wpdb;
1019 1019
 		$country_table = $wpdb->prefix."esp_country";
1020
-		if(is_int($country_name)){
1020
+		if (is_int($country_name)) {
1021 1021
 			$country_name = $this->get_iso_from_3_1_country_id($country_name);
1022 1022
 		}
1023 1023
 		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
1024 1024
 			CNT_ISO LIKE %s OR
1025 1025
 			CNT_ISO3 LIKE %s OR
1026
-			CNT_name LIKE %s LIMIT 1",$country_name,$country_name,$country_name),ARRAY_A);
1027
-		if( ! $country ){
1026
+			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
1027
+		if ( ! $country) {
1028 1028
 			//insert a new one then
1029 1029
 			$cols_n_values = array(
1030 1030
 				'CNT_ISO'=> $this->_find_available_country_iso(2),
@@ -1044,26 +1044,26 @@  discard block
 block discarded – undo
1044 1044
 				'CNT_active'=>true
1045 1045
 			);
1046 1046
 			$data_types = array(
1047
-				'%s',//CNT_ISO
1048
-				'%s',//CNT_ISO3
1049
-				'%d',//RGN_ID
1050
-				'%s',//CNT_name
1051
-				'%s',//CNT_cur_code
1052
-				'%s',//CNT_cur_single
1053
-				'%s',//CNT_cur_plural
1054
-				'%s',//CNT_cur_sign
1055
-				'%d',//CNT_cur_sign_b4
1056
-				'%d',//CNT_cur_dec_plc
1057
-				'%s',//CNT_cur_dec_mrk
1058
-				'%s',//CNT_cur_thsnds
1059
-				'%s',//CNT_tel_code
1060
-				'%d',//CNT_is_EU
1061
-				'%d',//CNT_active
1047
+				'%s', //CNT_ISO
1048
+				'%s', //CNT_ISO3
1049
+				'%d', //RGN_ID
1050
+				'%s', //CNT_name
1051
+				'%s', //CNT_cur_code
1052
+				'%s', //CNT_cur_single
1053
+				'%s', //CNT_cur_plural
1054
+				'%s', //CNT_cur_sign
1055
+				'%d', //CNT_cur_sign_b4
1056
+				'%d', //CNT_cur_dec_plc
1057
+				'%s', //CNT_cur_dec_mrk
1058
+				'%s', //CNT_cur_thsnds
1059
+				'%s', //CNT_tel_code
1060
+				'%d', //CNT_is_EU
1061
+				'%d', //CNT_active
1062 1062
 			);
1063 1063
 			$success = $wpdb->insert($country_table,
1064 1064
 					$cols_n_values,
1065 1065
 					$data_types);
1066
-			if( ! $success){
1066
+			if ( ! $success) {
1067 1067
 				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('country_id'=>$country_name), $country_table, $cols_n_values, $data_types));
1068 1068
 			}
1069 1069
 			$country = $cols_n_values;
@@ -1075,18 +1075,18 @@  discard block
 block discarded – undo
1075 1075
 	 * @global type $wpdb
1076 1076
 	 * @return string
1077 1077
 	 */
1078
-	private function _find_available_country_iso($num_letters = 2){
1078
+	private function _find_available_country_iso($num_letters = 2) {
1079 1079
 		global $wpdb;
1080 1080
 		$country_table = $wpdb->prefix."esp_country";
1081 1081
 		$attempts = 0;
1082
-		do{
1082
+		do {
1083 1083
 			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1084
-			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s",$current_iso));
1084
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s", $current_iso));
1085 1085
 			$attempts++;
1086 1086
 		//keep going until we find an available country code, or we arbitrarily
1087 1087
 		//decide we've tried this enough. Somehow they have way too many countries
1088 1088
 		//(probably because they're mis-using the EE3 country_id like a custom question)
1089
-		}while( intval($country_with_that_iso) && $attempts < 200 );
1089
+		}while (intval($country_with_that_iso) && $attempts < 200);
1090 1090
 		return $current_iso;
1091 1091
 	}
1092 1092
 
@@ -1097,14 +1097,14 @@  discard block
 block discarded – undo
1097 1097
 	 * @param string $state_name
1098 1098
 	 * @return array where keys are columns, values are column values
1099 1099
 	 */
1100
-	public function get_or_create_state($state_name,$country_name = ''){
1101
-		if( ! $state_name ){
1100
+	public function get_or_create_state($state_name, $country_name = '') {
1101
+		if ( ! $state_name) {
1102 1102
 			throw new EE_Error(__("Could not get-or-create state because no state name was provided", "event_espresso"));
1103 1103
 		}
1104
-		try{
1104
+		try {
1105 1105
 			$country = $this->get_or_create_country($country_name);
1106 1106
 			$country_iso = $country['CNT_ISO'];
1107
-		}catch(EE_Error $e){
1107
+		} catch (EE_Error $e) {
1108 1108
 			$country_iso = $this->get_default_country_iso();
1109 1109
 		}
1110 1110
 		global $wpdb;
@@ -1112,24 +1112,24 @@  discard block
 block discarded – undo
1112 1112
 		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1113 1113
 			(STA_abbrev LIKE %s OR
1114 1114
 			STA_name LIKE %s) AND
1115
-			CNT_ISO LIKE %s LIMIT 1",$state_name,$state_name,$country_iso),ARRAY_A);
1116
-		if ( ! $state){
1115
+			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1116
+		if ( ! $state) {
1117 1117
 			//insert a new one then
1118 1118
 			$cols_n_values = array(
1119 1119
 				'CNT_ISO'=>$country_iso,
1120
-				'STA_abbrev'=>substr($state_name,0,6),
1120
+				'STA_abbrev'=>substr($state_name, 0, 6),
1121 1121
 				'STA_name'=>$state_name,
1122 1122
 				'STA_active'=>true
1123 1123
 			);
1124 1124
 			$data_types = array(
1125
-				'%s',//CNT_ISO
1126
-				'%s',//STA_abbrev
1127
-				'%s',//STA_name
1128
-				'%d',//STA_active
1125
+				'%s', //CNT_ISO
1126
+				'%s', //STA_abbrev
1127
+				'%s', //STA_name
1128
+				'%d', //STA_active
1129 1129
 			);
1130
-			$success = $wpdb->insert($state_table,$cols_n_values,$data_types);
1131
-			if ( ! $success ){
1132
-				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name,'country_id'=>$country_name), $state_table, $cols_n_values, $data_types));
1130
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1131
+			if ( ! $success) {
1132
+				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name, 'country_id'=>$country_name), $state_table, $cols_n_values, $data_types));
1133 1133
 			}
1134 1134
 			$state = $cols_n_values;
1135 1135
 			$state['STA_ID'] = $wpdb->insert_id;
@@ -1142,21 +1142,21 @@  discard block
 block discarded – undo
1142 1142
 	 * @param type $timeString
1143 1143
 	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes with leading zeros)
1144 1144
 	 */
1145
-	public function convertTimeFromAMPM($timeString){
1145
+	public function convertTimeFromAMPM($timeString) {
1146 1146
 		$matches = array();
1147
-		preg_match("~(\\d*):(\\d*)~",$timeString,$matches);
1148
-		if( ! $matches || count($matches)<3){
1147
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1148
+		if ( ! $matches || count($matches) < 3) {
1149 1149
 			$hour = '00';
1150 1150
 			$minutes = '00';
1151
-		}else{
1151
+		} else {
1152 1152
 			$hour = intval($matches[1]);
1153 1153
 			$minutes = $matches[2];
1154 1154
 		}
1155
-		if(strpos($timeString, 'PM') || strpos($timeString, 'pm')){
1155
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1156 1156
 			$hour = intval($hour) + 12;
1157 1157
 		}
1158
-		$hour = str_pad( "$hour", 2, '0',STR_PAD_LEFT);
1159
-		$minutes = str_pad( "$minutes", 2, '0',STR_PAD_LEFT);
1158
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1159
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1160 1160
 		return "$hour:$minutes";
1161 1161
 	}
1162 1162
 
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 	 * @param int $country_id
1166 1166
 	 * @return string the country's ISO3 code
1167 1167
 	 */
1168
-	public function get_iso_from_3_1_country_id($country_id){
1168
+	public function get_iso_from_3_1_country_id($country_id) {
1169 1169
 		$old_countries = array(
1170 1170
 			array(64, 'United States', 'US', 'USA', 1),
1171 1171
 			array(15, 'Australia', 'AU', 'AUS', 1),
@@ -1391,9 +1391,9 @@  discard block
 block discarded – undo
1391 1391
 			array(226, 'Zimbabwe', 'ZW', 'ZWE', 1));
1392 1392
 
1393 1393
 		$country_iso = 'US';
1394
-		foreach($old_countries as $country_array){
1394
+		foreach ($old_countries as $country_array) {
1395 1395
 			//note: index 0 is the 3.1 country ID
1396
-			if($country_array[0] == $country_id){
1396
+			if ($country_array[0] == $country_id) {
1397 1397
 				//note: index 2 is the ISO
1398 1398
 				$country_iso = $country_array[2];
1399 1399
 				break;
@@ -1406,8 +1406,8 @@  discard block
 block discarded – undo
1406 1406
 	 * Gets the ISO3 for the
1407 1407
 	 * @return string
1408 1408
 	 */
1409
-	public function get_default_country_iso(){
1410
-		$old_org_options= get_option('events_organization_settings');
1409
+	public function get_default_country_iso() {
1410
+		$old_org_options = get_option('events_organization_settings');
1411 1411
 		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1412 1412
 		return $iso;
1413 1413
 	}
@@ -1419,13 +1419,13 @@  discard block
 block discarded – undo
1419 1419
 	 * the event's DEFAULT payment status, or the attendee's payment status) required pre-approval.
1420 1420
 	 * @return string STS_ID for use in 4.1
1421 1421
 	 */
1422
-	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false){
1422
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) {
1423 1423
 
1424 1424
 		//EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1425
-		if($this_thing_required_pre_approval){
1425
+		if ($this_thing_required_pre_approval) {
1426 1426
 				return 'RNA';
1427
-		}else{
1428
-				$mapping = $default_reg_stati_conversions=array(
1427
+		} else {
1428
+				$mapping = $default_reg_stati_conversions = array(
1429 1429
 			'Completed'=>'RAP',
1430 1430
 			''=>'RPP',
1431 1431
 			'Incomplete'=>'RPP',
@@ -1455,22 +1455,22 @@  discard block
 block discarded – undo
1455 1455
 	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1456 1456
 	 * @return boolean whether or not we had to do the big job of creating an image attachment
1457 1457
 	 */
1458
-	public function convert_image_url_to_attachment_and_attach_to_post($guid,$new_cpt_id,  EE_Data_Migration_Script_Stage $migration_stage){
1458
+	public function convert_image_url_to_attachment_and_attach_to_post($guid, $new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage) {
1459 1459
 		$created_attachment_post = false;
1460 1460
 		$guid = $this->_get_original_guid($guid);
1461
-		if($guid){
1461
+		if ($guid) {
1462 1462
 			//check for an existing attachment post with this guid
1463 1463
 			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1464
-			if( ! $attachment_post_id){
1464
+			if ( ! $attachment_post_id) {
1465 1465
 				//post thumbnail with that GUID doesn't exist, we should create one
1466 1466
 				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1467 1467
 				$created_attachment_post = true;
1468 1468
 			}
1469 1469
 			//double-check we actually have an attachment post
1470
-			if( $attachment_post_id){
1471
-				update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id);
1472
-			}else{
1473
-				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"),$guid,$new_cpt_id,$attachment_post_id));
1470
+			if ($attachment_post_id) {
1471
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1472
+			} else {
1473
+				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"), $guid, $new_cpt_id, $attachment_post_id));
1474 1474
 			}
1475 1475
 		}
1476 1476
 		return $created_attachment_post;
@@ -1484,13 +1484,13 @@  discard block
 block discarded – undo
1484 1484
 	 * @param string $guid_in_old_event
1485 1485
 	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1486 1486
 	 */
1487
-	private function _get_original_guid($guid_in_old_event){
1488
-		$original_guid = preg_replace('~-\d*x\d*\.~','.',$guid_in_old_event,1);
1487
+	private function _get_original_guid($guid_in_old_event) {
1488
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1489 1489
 		//do a head request to verify the file exists
1490 1490
 		$head_response = wp_remote_head($original_guid);
1491
-		if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){
1491
+		if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1492 1492
 			return $original_guid;
1493
-		}else{
1493
+		} else {
1494 1494
 			return $guid_in_old_event;
1495 1495
 		}
1496 1496
 	}
@@ -1502,32 +1502,32 @@  discard block
 block discarded – undo
1502 1502
 	 * @param EE_Data_Migration_Script_Stage $migration_stage
1503 1503
 	 * @return int
1504 1504
 	 */
1505
-	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage){
1506
-		if ( ! $guid){
1505
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) {
1506
+		if ( ! $guid) {
1507 1507
 			$migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!", "event_espresso")));
1508 1508
 			return 0;
1509 1509
 		}
1510
-		$wp_filetype = wp_check_filetype(basename($guid), null );
1510
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1511 1511
 		$wp_upload_dir = wp_upload_dir();
1512 1512
 		//if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1513
-		if(strpos($guid,$wp_upload_dir['url']) === FALSE){
1513
+		if (strpos($guid, $wp_upload_dir['url']) === FALSE) {
1514 1514
 			//image is located remotely. download it and place it in the uploads directory
1515
-			if( ! is_readable($guid)){
1516
-				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"),$guid));
1515
+			if ( ! is_readable($guid)) {
1516
+				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"), $guid));
1517 1517
 				return 0;
1518 1518
 			}
1519
-			$contents= file_get_contents($guid);
1520
-			if($contents === FALSE){
1521
-				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"),$guid));
1519
+			$contents = file_get_contents($guid);
1520
+			if ($contents === FALSE) {
1521
+				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"), $guid));
1522 1522
 				return false;
1523 1523
 			}
1524
-			$local_filepath  = $wp_upload_dir['path'].DS.basename($guid);
1524
+			$local_filepath = $wp_upload_dir['path'].DS.basename($guid);
1525 1525
 			$savefile = fopen($local_filepath, 'w');
1526 1526
 			fwrite($savefile, $contents);
1527 1527
 			fclose($savefile);
1528
-			$guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath);
1529
-		}else{
1530
-			$local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid);
1528
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1529
+		} else {
1530
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1531 1531
 		}
1532 1532
 
1533 1533
 		$attachment = array(
@@ -1537,24 +1537,24 @@  discard block
 block discarded – undo
1537 1537
 		   'post_content' => '',
1538 1538
 		   'post_status' => 'inherit'
1539 1539
 		);
1540
-		$attach_id = wp_insert_attachment( $attachment, $guid );
1541
-		if( ! $attach_id ){
1542
-			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"),$guid,$this->_json_encode($attachment)));
1540
+		$attach_id = wp_insert_attachment($attachment, $guid);
1541
+		if ( ! $attach_id) {
1542
+			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"), $guid, $this->_json_encode($attachment)));
1543 1543
 			return $attach_id;
1544 1544
 		}
1545 1545
 
1546 1546
 		// you must first include the image.php file
1547 1547
 		// for the function wp_generate_attachment_metadata() to work
1548
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
1548
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1549 1549
 
1550
-		$attach_data = wp_generate_attachment_metadata( $attach_id, $local_filepath );
1551
-		if( ! $attach_data){
1552
-			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"),$attach_id,$local_filepath,$guid));
1550
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1551
+		if ( ! $attach_data) {
1552
+			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"), $attach_id, $local_filepath, $guid));
1553 1553
 			return $attach_id;
1554 1554
 		}
1555
-		$metadata_save_result = wp_update_attachment_metadata( $attach_id, $attach_data );
1556
-		if( ! $metadata_save_result ){
1557
-			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"),$attach_id,$this->_json_encode($attach_data)));
1555
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1556
+		if ( ! $metadata_save_result) {
1557
+			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"), $attach_id, $this->_json_encode($attach_data)));
1558 1558
 		}
1559 1559
 		return $attach_id;
1560 1560
 	}
@@ -1566,9 +1566,9 @@  discard block
 block discarded – undo
1566 1566
 	 * @param string $guid
1567 1567
 	 * @return int
1568 1568
 	 */
1569
-	private function _get_image_attachment_id_by_GUID($guid){
1569
+	private function _get_image_attachment_id_by_GUID($guid) {
1570 1570
 		global $wpdb;
1571
-		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1",$guid));
1571
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1572 1572
 		return $attachment_id;
1573 1573
 	}
1574 1574
 	/**
@@ -1580,20 +1580,20 @@  discard block
 block discarded – undo
1580 1580
 	 * @param string $timezone
1581 1581
 	 * @return string
1582 1582
 	 */
1583
-	public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string,$timezone = null){
1583
+	public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string, $timezone = null) {
1584 1584
 		$original_tz = $timezone;
1585
-		if( ! $timezone){
1585
+		if ( ! $timezone) {
1586 1586
 			$timezone = $this->_get_wp_timezone();
1587 1587
 		}
1588
-		if( ! $timezone){
1589
-			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"),$original_tz,$row_of_data));
1588
+		if ( ! $timezone) {
1589
+			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz, $row_of_data));
1590 1590
 			$timezone = 'UTC';
1591 1591
 		}
1592
-		try{
1593
-			$date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) );
1592
+		try {
1593
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1594 1594
 			$date_obj->setTimezone(new DateTimeZone('UTC'));
1595
-		}catch(Exception $e){
1596
-			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"),$DATETIME_string,$timezone));
1595
+		} catch (Exception $e) {
1596
+			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"), $DATETIME_string, $timezone));
1597 1597
 			$date_obj = new DateTime();
1598 1598
 		}
1599 1599
 
@@ -1604,14 +1604,14 @@  discard block
 block discarded – undo
1604 1604
 	 * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset)
1605 1605
 	 * @return string
1606 1606
 	 */
1607
-	private function _get_wp_timezone(){
1608
-		$timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone;
1607
+	private function _get_wp_timezone() {
1608
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1609 1609
 
1610 1610
 		//if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1611
-		if ( empty( $timezone ) ) {
1611
+		if (empty($timezone)) {
1612 1612
 			//let's get a the WordPress UTC offset
1613 1613
 			$offset = get_option('gmt_offset');
1614
-			$timezone = $this->timezone_convert_to_string_from_offset( $offset );
1614
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1615 1615
 		}
1616 1616
 		return $timezone;
1617 1617
 	}
@@ -1620,11 +1620,11 @@  discard block
 block discarded – undo
1620 1620
 	 * @param int $offset
1621 1621
 	 * @return boolean
1622 1622
 	 */
1623
-	private function timezone_convert_to_string_from_offset($offset){
1623
+	private function timezone_convert_to_string_from_offset($offset) {
1624 1624
 		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1625 1625
 		$offset *= 3600; // convert hour offset to seconds
1626 1626
         $abbrarray = timezone_abbreviations_list();
1627
-        foreach ($abbrarray as $abbr){
1627
+        foreach ($abbrarray as $abbr) {
1628 1628
                 foreach ($abbr as $city)
1629 1629
                 {
1630 1630
                         if ($city['offset'] == $offset)
@@ -1638,32 +1638,32 @@  discard block
 block discarded – undo
1638 1638
         return FALSE;
1639 1639
 	}
1640 1640
 
1641
-	public function migration_page_hooks(){
1642
-		add_filter('FHEE__ee_migration_page__header',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1643
-		add_filter('FHEE__ee_migration_page__p_after_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1644
-		add_filter('FHEE__ee_migration_page__option_1_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1645
-		add_filter('FHEE__ee_migration_page__option_1_button_text',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1646
-		add_action('AHEE__ee_migration_page__option_1_extra_details',array($this,'_migration_page_hook_option_1_extra_details'),10,3);
1647
-		add_filter('FHEE__ee_migration_page__option_2_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,4);
1648
-		add_filter('FHEE__ee_migration_page__option_2_button_text',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1649
-		add_filter('FHEE__ee_migration_page__option_2_details',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1650
-		add_action('AHEE__ee_migration_page__after_migration_options_table',array($this,'_migration_page_hook_after_migration_options_table'));
1651
-		add_filter('FHEE__ee_migration_page__done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1652
-		add_filter('FHEE__ee_migration_page__p_after_done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1641
+	public function migration_page_hooks() {
1642
+		add_filter('FHEE__ee_migration_page__header', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1643
+		add_filter('FHEE__ee_migration_page__p_after_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1644
+		add_filter('FHEE__ee_migration_page__option_1_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1645
+		add_filter('FHEE__ee_migration_page__option_1_button_text', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1646
+		add_action('AHEE__ee_migration_page__option_1_extra_details', array($this, '_migration_page_hook_option_1_extra_details'), 10, 3);
1647
+		add_filter('FHEE__ee_migration_page__option_2_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 4);
1648
+		add_filter('FHEE__ee_migration_page__option_2_button_text', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1649
+		add_filter('FHEE__ee_migration_page__option_2_details', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1650
+		add_action('AHEE__ee_migration_page__after_migration_options_table', array($this, '_migration_page_hook_after_migration_options_table'));
1651
+		add_filter('FHEE__ee_migration_page__done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1652
+		add_filter('FHEE__ee_migration_page__p_after_done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1653 1653
 	}
1654 1654
 
1655
-	public function _migrate_page_hook_simplify_version_strings($old_content,$current_db_state,$next_db_state,$ultimate_db_state = NULL){
1656
-		return str_replace(array($current_db_state,$next_db_state,$ultimate_db_state),array(__('EE3','event_espresso'),__('EE4','event_espresso'),  __("EE4", 'event_espresso')),$old_content);
1655
+	public function _migrate_page_hook_simplify_version_strings($old_content, $current_db_state, $next_db_state, $ultimate_db_state = NULL) {
1656
+		return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state), array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')), $old_content);
1657 1657
 	}
1658
-	public function _migration_page_hook_simplify_next_db_state($old_content,$next_db_state){
1659
-		return str_replace($next_db_state,  __("EE4", 'event_espresso'),$old_content);
1658
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) {
1659
+		return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content);
1660 1660
 	}
1661
-	public function _migration_page_hook_option_1_extra_details(){
1662
-		?><p><?php	printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso"));?></p><?php
1661
+	public function _migration_page_hook_option_1_extra_details() {
1662
+		?><p><?php	printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso")); ?></p><?php
1663 1663
 	}
1664
-	public function _migration_page_hook_after_migration_options_table(){
1664
+	public function _migration_page_hook_after_migration_options_table() {
1665 1665
 		?><p class="ee-attention">
1666
-				<strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso");?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso");	?>
1666
+				<strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso"); ?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?>
1667 1667
 			</p><?php
1668 1668
 	}
1669 1669
 }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Indentation   +2885 added lines, -2885 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -24,1772 +24,1772 @@  discard block
 block discarded – undo
24 24
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
25 25
 {
26 26
 
27
-    /**
28
-     * @var EE_Registration
29
-     */
30
-    private $_registration;
31
-
32
-    /**
33
-     * @var EE_Event
34
-     */
35
-    private $_reg_event;
36
-
37
-    /**
38
-     * @var EE_Session
39
-     */
40
-    private        $_session;
41
-
42
-    private static $_reg_status;
43
-
44
-    /**
45
-     * Form for displaying the custom questions for this registration.
46
-     * This gets used a few times throughout the request so its best to cache it
47
-     *
48
-     * @var EE_Registration_Custom_Questions_Form
49
-     */
50
-    protected $_reg_custom_questions_form = null;
51
-
52
-
53
-
54
-    /**
55
-     *        constructor
56
-     *
57
-     * @Constructor
58
-     * @access public
59
-     * @param bool $routing
60
-     * @return Registrations_Admin_Page
61
-     */
62
-    public function __construct($routing = true)
63
-    {
64
-        parent::__construct($routing);
65
-        add_action('wp_loaded', array($this, 'wp_loaded'));
66
-    }
67
-
68
-
69
-
70
-    public function wp_loaded()
71
-    {
72
-        // when adding a new registration...
73
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
74
-            EE_System::do_not_cache();
75
-            if ( ! isset($this->_req_data['processing_registration'])
76
-                 || absint($this->_req_data['processing_registration']) !== 1
77
-            ) {
78
-                // and it's NOT the attendee information reg step
79
-                // force cookie expiration by setting time to last week
80
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
81
-                // and update the global
82
-                $_COOKIE['ee_registration_added'] = 0;
83
-            }
84
-        }
85
-    }
86
-
87
-
88
-
89
-    protected function _init_page_props()
90
-    {
91
-        $this->page_slug = REG_PG_SLUG;
92
-        $this->_admin_base_url = REG_ADMIN_URL;
93
-        $this->_admin_base_path = REG_ADMIN;
94
-        $this->page_label = __('Registrations', 'event_espresso');
95
-        $this->_cpt_routes = array(
96
-            'add_new_attendee' => 'espresso_attendees',
97
-            'edit_attendee'    => 'espresso_attendees',
98
-            'insert_attendee'  => 'espresso_attendees',
99
-            'update_attendee'  => 'espresso_attendees',
100
-        );
101
-        $this->_cpt_model_names = array(
102
-            'add_new_attendee' => 'EEM_Attendee',
103
-            'edit_attendee'    => 'EEM_Attendee',
104
-        );
105
-        $this->_cpt_edit_routes = array(
106
-            'espresso_attendees' => 'edit_attendee',
107
-        );
108
-        $this->_pagenow_map = array(
109
-            'add_new_attendee' => 'post-new.php',
110
-            'edit_attendee'    => 'post.php',
111
-            'trash'            => 'post.php',
112
-        );
113
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
114
-        //add filters so that the comment urls don't take users to a confusing 404 page
115
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
116
-    }
117
-
118
-
119
-
120
-    public function clear_comment_link($link, $comment, $args)
121
-    {
122
-        //gotta make sure this only happens on this route
123
-        $post_type = get_post_type($comment->comment_post_ID);
124
-        if ($post_type === 'espresso_attendees') {
125
-            return '#commentsdiv';
126
-        }
127
-        return $link;
128
-    }
129
-
130
-
131
-
132
-    protected function _ajax_hooks()
133
-    {
134
-        //todo: all hooks for registrations ajax goes in here
135
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
136
-    }
137
-
138
-
139
-
140
-    protected function _define_page_props()
141
-    {
142
-        $this->_admin_page_title = $this->page_label;
143
-        $this->_labels = array(
144
-            'buttons'                      => array(
145
-                'add-registrant'      => __('Add New Registration', 'event_espresso'),
146
-                'add-attendee'        => __('Add Contact', 'event_espresso'),
147
-                'edit'                => __('Edit Contact', 'event_espresso'),
148
-                'report'              => __("Event Registrations CSV Report", "event_espresso"),
149
-                'report_all'          => __('All Registrations CSV Report', 'event_espresso'),
150
-                'contact_list_report' => __('Contact List Report', 'event_espresso'),
151
-                'contact_list_export' => __("Export Data", "event_espresso"),
152
-            ),
153
-            'publishbox'                   => array(
154
-                'add_new_attendee' => __("Add Contact Record", 'event_espresso'),
155
-                'edit_attendee'    => __("Update Contact Record", 'event_espresso'),
156
-            ),
157
-            'hide_add_button_on_cpt_route' => array(
158
-                'edit_attendee' => true,
159
-            ),
160
-        );
161
-    }
162
-
163
-
164
-
165
-    /**
166
-     *        grab url requests and route them
167
-     *
168
-     * @access private
169
-     * @return void
170
-     */
171
-    public function _set_page_routes()
172
-    {
173
-        $this->_get_registration_status_array();
174
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
175
-            ? $this->_req_data['_REG_ID'] : 0;
176
-        $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
177
-            ? $this->_req_data['ATT_ID'] : 0;
178
-        $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post']
179
-            : $att_id;
180
-        $this->_page_routes = array(
181
-            'default' => array(
182
-                'func'       => '_registrations_overview_list_table',
183
-                'capability' => 'ee_read_registrations',
184
-            ),
185
-            'view_registration' => array(
186
-                'func'       => '_registration_details',
187
-                'capability' => 'ee_read_registration',
188
-                'obj_id'     => $reg_id,
189
-            ),
190
-            'edit_registration' => array(
191
-                'func'               => '_update_attendee_registration_form',
192
-                'noheader'           => true,
193
-                'headers_sent_route' => 'view_registration',
194
-                'capability'         => 'ee_edit_registration',
195
-                'obj_id'             => $reg_id,
196
-                '_REG_ID'            => $reg_id,
197
-            ),
198
-            'trash_registrations' => array(
199
-                'func'       => '_trash_or_restore_registrations',
200
-                'args'       => array('trash' => true),
201
-                'noheader'   => true,
202
-                'capability' => 'ee_delete_registrations',
203
-            ),
204
-            'restore_registrations' => array(
205
-                'func'       => '_trash_or_restore_registrations',
206
-                'args'       => array('trash' => false),
207
-                'noheader'   => true,
208
-                'capability' => 'ee_delete_registrations',
209
-            ),
210
-            'delete_registrations' => array(
211
-                'func'       => '_delete_registrations',
212
-                'noheader'   => true,
213
-                'capability' => 'ee_delete_registrations',
214
-            ),
215
-            'new_registration' => array(
216
-                'func'       => 'new_registration',
217
-                'capability' => 'ee_edit_registrations',
218
-            ),
219
-            'process_reg_step' => array(
220
-                'func'       => 'process_reg_step',
221
-                'noheader'   => true,
222
-                'capability' => 'ee_edit_registrations',
223
-            ),
224
-            'redirect_to_txn' => array(
225
-                'func'       => 'redirect_to_txn',
226
-                'noheader'   => true,
227
-                'capability' => 'ee_edit_registrations',
228
-            ),
229
-            'change_reg_status' => array(
230
-                'func'       => '_change_reg_status',
231
-                'noheader'   => true,
232
-                'capability' => 'ee_edit_registration',
233
-                'obj_id'     => $reg_id,
234
-            ),
235
-            'approve_registration' => array(
236
-                'func'       => 'approve_registration',
237
-                'noheader'   => true,
238
-                'capability' => 'ee_edit_registration',
239
-                'obj_id'     => $reg_id,
240
-            ),
241
-            'approve_and_notify_registration' => array(
242
-                'func'       => 'approve_registration',
243
-                'noheader'   => true,
244
-                'args'       => array(true),
245
-                'capability' => 'ee_edit_registration',
246
-                'obj_id'     => $reg_id,
247
-            ),
248
-            'decline_registration' => array(
249
-                'func'       => 'decline_registration',
250
-                'noheader'   => true,
251
-                'capability' => 'ee_edit_registration',
252
-                'obj_id'     => $reg_id,
253
-            ),
254
-            'decline_and_notify_registration' => array(
255
-                'func'       => 'decline_registration',
256
-                'noheader'   => true,
257
-                'args'       => array(true),
258
-                'capability' => 'ee_edit_registration',
259
-                'obj_id'     => $reg_id,
260
-            ),
261
-            'pending_registration' => array(
262
-                'func'       => 'pending_registration',
263
-                'noheader'   => true,
264
-                'capability' => 'ee_edit_registration',
265
-                'obj_id'     => $reg_id,
266
-            ),
267
-            'pending_and_notify_registration' => array(
268
-                'func'       => 'pending_registration',
269
-                'noheader'   => true,
270
-                'args'       => array(true),
271
-                'capability' => 'ee_edit_registration',
272
-                'obj_id'     => $reg_id,
273
-            ),
274
-            'no_approve_registration' => array(
275
-                'func'       => 'not_approve_registration',
276
-                'noheader'   => true,
277
-                'capability' => 'ee_edit_registration',
278
-                'obj_id'     => $reg_id,
279
-            ),
280
-            'no_approve_and_notify_registration' => array(
281
-                'func'       => 'not_approve_registration',
282
-                'noheader'   => true,
283
-                'args'       => array(true),
284
-                'capability' => 'ee_edit_registration',
285
-                'obj_id'     => $reg_id,
286
-            ),
287
-            'cancel_registration' => array(
288
-                'func'       => 'cancel_registration',
289
-                'noheader'   => true,
290
-                'capability' => 'ee_edit_registration',
291
-                'obj_id'     => $reg_id,
292
-            ),
293
-            'cancel_and_notify_registration' => array(
294
-                'func'       => 'cancel_registration',
295
-                'noheader'   => true,
296
-                'args'       => array(true),
297
-                'capability' => 'ee_edit_registration',
298
-                'obj_id'     => $reg_id,
299
-            ),
300
-            'contact_list' => array(
301
-                'func'       => '_attendee_contact_list_table',
302
-                'capability' => 'ee_read_contacts',
303
-            ),
304
-            'add_new_attendee' => array(
305
-                'func' => '_create_new_cpt_item',
306
-                'args' => array(
307
-                    'new_attendee' => true,
308
-                    'capability'   => 'ee_edit_contacts',
309
-                ),
310
-            ),
311
-            'edit_attendee' => array(
312
-                'func'       => '_edit_cpt_item',
313
-                'capability' => 'ee_edit_contacts',
314
-                'obj_id'     => $att_id,
315
-            ),
316
-            'duplicate_attendee' => array(
317
-                'func'       => '_duplicate_attendee',
318
-                'noheader'   => true,
319
-                'capability' => 'ee_edit_contacts',
320
-                'obj_id'     => $att_id,
321
-            ),
322
-            'insert_attendee' => array(
323
-                'func'       => '_insert_or_update_attendee',
324
-                'args'       => array(
325
-                    'new_attendee' => true,
326
-                ),
327
-                'noheader'   => true,
328
-                'capability' => 'ee_edit_contacts',
329
-            ),
330
-            'update_attendee' => array(
331
-                'func'       => '_insert_or_update_attendee',
332
-                'args'       => array(
333
-                    'new_attendee' => false,
334
-                ),
335
-                'noheader'   => true,
336
-                'capability' => 'ee_edit_contacts',
337
-                'obj_id'     => $att_id,
338
-            ),
339
-            'trash_attendees' => array(
340
-                'func'       => '_trash_or_restore_attendees',
341
-                'args'       => array(
342
-                    'trash' => true,
343
-                ),
344
-                'noheader'   => true,
345
-                'capability' => 'ee_delete_contacts',
346
-                'obj_id'     => $att_id,
347
-            ),
348
-            'restore_attendees'    => array(
349
-                'func'       => '_trash_or_restore_attendees',
350
-                'args'       => array(
351
-                    'trash' => false,
352
-                ),
353
-                'noheader'   => true,
354
-                'capability' => 'ee_delete_contacts',
355
-                'obj_id'     => $att_id,
356
-            ),
357
-            'resend_registration'  => array(
358
-                'func'       => '_resend_registration',
359
-                'noheader'   => true,
360
-                'capability' => 'ee_send_message',
361
-            ),
362
-            'registrations_report' => array(
363
-                'func'       => '_registrations_report',
364
-                'noheader'   => true,
365
-                'capability' => 'ee_read_registrations',
366
-            ),
367
-            'contact_list_export'  => array(
368
-                'func'       => '_contact_list_export',
369
-                'noheader'   => true,
370
-                'capability' => 'export',
371
-            ),
372
-            'contact_list_report'  => array(
373
-                'func'       => '_contact_list_report',
374
-                'noheader'   => true,
375
-                'capability' => 'ee_read_contacts',
376
-            ),
377
-        );
378
-    }
379
-
380
-
381
-
382
-    protected function _set_page_config()
383
-    {
384
-        $this->_page_config = array(
385
-            'default' => array(
386
-                'nav'           => array(
387
-                    'label' => __('Overview', 'event_espresso'),
388
-                    'order' => 5,
389
-                ),
390
-                'help_tabs'     => array(
391
-                    'registrations_overview_help_tab'                       => array(
392
-                        'title'    => __('Registrations Overview', 'event_espresso'),
393
-                        'filename' => 'registrations_overview',
394
-                    ),
395
-                    'registrations_overview_table_column_headings_help_tab' => array(
396
-                        'title'    => __('Registrations Table Column Headings', 'event_espresso'),
397
-                        'filename' => 'registrations_overview_table_column_headings',
398
-                    ),
399
-                    'registrations_overview_filters_help_tab'               => array(
400
-                        'title'    => __('Registration Filters', 'event_espresso'),
401
-                        'filename' => 'registrations_overview_filters',
402
-                    ),
403
-                    'registrations_overview_views_help_tab'                 => array(
404
-                        'title'    => __('Registration Views', 'event_espresso'),
405
-                        'filename' => 'registrations_overview_views',
406
-                    ),
407
-                    'registrations_regoverview_other_help_tab'              => array(
408
-                        'title'    => __('Registrations Other', 'event_espresso'),
409
-                        'filename' => 'registrations_overview_other',
410
-                    ),
411
-                ),
412
-                'help_tour'     => array('Registration_Overview_Help_Tour'),
413
-                'qtips'         => array('Registration_List_Table_Tips'),
414
-                'list_table'    => 'EE_Registrations_List_Table',
415
-                'require_nonce' => false,
416
-            ),
417
-            'view_registration' => array(
418
-                'nav'           => array(
419
-                    'label'      => __('REG Details', 'event_espresso'),
420
-                    'order'      => 15,
421
-                    'url'        => isset($this->_req_data['_REG_ID'])
422
-                        ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
423
-                        : $this->_admin_base_url,
424
-                    'persistent' => false,
425
-                ),
426
-                'help_tabs'     => array(
427
-                    'registrations_details_help_tab'                    => array(
428
-                        'title'    => __('Registration Details', 'event_espresso'),
429
-                        'filename' => 'registrations_details',
430
-                    ),
431
-                    'registrations_details_table_help_tab'              => array(
432
-                        'title'    => __('Registration Details Table', 'event_espresso'),
433
-                        'filename' => 'registrations_details_table',
434
-                    ),
435
-                    'registrations_details_form_answers_help_tab'       => array(
436
-                        'title'    => __('Registration Form Answers', 'event_espresso'),
437
-                        'filename' => 'registrations_details_form_answers',
438
-                    ),
439
-                    'registrations_details_registrant_details_help_tab' => array(
440
-                        'title'    => __('Contact Details', 'event_espresso'),
441
-                        'filename' => 'registrations_details_registrant_details',
442
-                    ),
443
-                ),
444
-                'help_tour'     => array('Registration_Details_Help_Tour'),
445
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes,
446
-                    array('_registration_details_metaboxes')),
447
-                'require_nonce' => false,
448
-            ),
449
-            'new_registration' => array(
450
-                'nav'           => array(
451
-                    'label'      => __('Add New Registration', 'event_espresso'),
452
-                    'url'        => '#',
453
-                    'order'      => 15,
454
-                    'persistent' => false,
455
-                ),
456
-                'metaboxes'     => $this->_default_espresso_metaboxes,
457
-                'labels'        => array(
458
-                    'publishbox' => __('Save Registration', 'event_espresso'),
459
-                ),
460
-                'require_nonce' => false,
461
-            ),
462
-            'add_new_attendee' => array(
463
-                'nav'           => array(
464
-                    'label'      => __('Add Contact', 'event_espresso'),
465
-                    'order'      => 15,
466
-                    'persistent' => false,
467
-                ),
468
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes,
469
-                    array('_publish_post_box', 'attendee_editor_metaboxes')),
470
-                'require_nonce' => false,
471
-            ),
472
-            'edit_attendee' => array(
473
-                'nav'           => array(
474
-                    'label'      => __('Edit Contact', 'event_espresso'),
475
-                    'order'      => 15,
476
-                    'persistent' => false,
477
-                    'url'        => isset($this->_req_data['ATT_ID'])
478
-                        ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
479
-                        : $this->_admin_base_url,
480
-                ),
481
-                'metaboxes'     => array('attendee_editor_metaboxes'),
482
-                'require_nonce' => false,
483
-            ),
484
-            'contact_list' => array(
485
-                'nav'           => array(
486
-                    'label' => __('Contact List', 'event_espresso'),
487
-                    'order' => 20,
488
-                ),
489
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
490
-                'help_tabs'     => array(
491
-                    'registrations_contact_list_help_tab'                       => array(
492
-                        'title'    => __('Registrations Contact List', 'event_espresso'),
493
-                        'filename' => 'registrations_contact_list',
494
-                    ),
495
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
496
-                        'title'    => __('Contact List Table Column Headings', 'event_espresso'),
497
-                        'filename' => 'registrations_contact_list_table_column_headings',
498
-                    ),
499
-                    'registrations_contact_list_views_help_tab'                 => array(
500
-                        'title'    => __('Contact List Views', 'event_espresso'),
501
-                        'filename' => 'registrations_contact_list_views',
502
-                    ),
503
-                    'registrations_contact_list_other_help_tab'                 => array(
504
-                        'title'    => __('Contact List Other', 'event_espresso'),
505
-                        'filename' => 'registrations_contact_list_other',
506
-                    ),
507
-                ),
508
-                'help_tour'     => array('Contact_List_Help_Tour'),
509
-                'metaboxes'     => array(),
510
-                'require_nonce' => false,
511
-            ),
512
-            //override default cpt routes
513
-            'create_new'   => '',
514
-            'edit'         => '',
515
-        );
516
-    }
517
-
518
-
519
-
520
-    /**
521
-     * The below methods aren't used by this class currently
522
-     */
523
-    protected function _add_screen_options()
524
-    {
525
-    }
526
-
527
-
528
-
529
-    protected function _add_feature_pointers()
530
-    {
531
-    }
532
-
533
-
534
-
535
-    public function admin_init()
536
-    {
537
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes',
538
-            'event_espresso');
539
-    }
540
-
541
-
542
-
543
-    public function admin_notices()
544
-    {
545
-    }
546
-
547
-
548
-
549
-    public function admin_footer_scripts()
550
-    {
551
-    }
552
-
553
-
554
-
555
-    /**
556
-     *        get list of registration statuses
557
-     *
558
-     * @access private
559
-     * @return void
560
-     */
561
-    private function _get_registration_status_array()
562
-    {
563
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
564
-    }
565
-
566
-
567
-
568
-    protected function _add_screen_options_default()
569
-    {
570
-        $this->_per_page_screen_option();
571
-    }
572
-
573
-
574
-
575
-    protected function _add_screen_options_contact_list()
576
-    {
577
-        $page_title = $this->_admin_page_title;
578
-        $this->_admin_page_title = __("Contacts", 'event_espresso');
579
-        $this->_per_page_screen_option();
580
-        $this->_admin_page_title = $page_title;
581
-    }
582
-
583
-
584
-
585
-    public function load_scripts_styles()
586
-    {
587
-        //style
588
-        //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
589
-        wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'),
590
-            EVENT_ESPRESSO_VERSION);
591
-        wp_enqueue_style('espresso_reg');
592
-        //script
593
-        wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js',
594
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true);
595
-        wp_enqueue_script('espresso_reg');
596
-    }
597
-
598
-
599
-
600
-    public function load_scripts_styles_edit_attendee()
601
-    {
602
-        //stuff to only show up on our attendee edit details page.
603
-        $attendee_details_translations = array(
604
-            'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'),
605
-                $this->_cpt_model_obj->get_datetime('ATT_created')),
606
-        );
607
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
608
-        wp_enqueue_script('jquery-validate');
609
-    }
610
-
611
-
612
-
613
-    public function load_scripts_styles_view_registration()
614
-    {
615
-        //styles
616
-        wp_enqueue_style('espresso-ui-theme');
617
-        //scripts
618
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
619
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
620
-    }
621
-
622
-
623
-
624
-    public function load_scripts_styles_contact_list()
625
-    {
626
-        wp_deregister_style('espresso_reg');
627
-        wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'),
628
-            EVENT_ESPRESSO_VERSION);
629
-        wp_enqueue_style('espresso_att');
630
-    }
631
-
632
-
633
-
634
-    public function load_scripts_styles_new_registration()
635
-    {
636
-        wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'),
637
-            EVENT_ESPRESSO_VERSION, true);
638
-        wp_enqueue_script('ee-spco-for-admin');
639
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
640
-        EE_Form_Section_Proper::wp_enqueue_scripts();
641
-        EED_Ticket_Selector::load_tckt_slctr_assets();
642
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
643
-    }
644
-
645
-
646
-
647
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
648
-    {
649
-        add_filter('FHEE_load_EE_messages', '__return_true');
650
-    }
651
-
652
-
653
-
654
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
655
-    {
656
-        add_filter('FHEE_load_EE_messages', '__return_true');
657
-    }
658
-
659
-
660
-
661
-    protected function _set_list_table_views_default()
662
-    {
663
-        //for notification related bulk actions we need to make sure only active messengers have an option.
664
-        EED_Messages::set_autoloaders();
665
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
666
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
667
-        $active_mts = $message_resource_manager->list_of_active_message_types();
668
-        //key= bulk_action_slug, value= message type.
669
-        $match_array = array(
670
-            'approve_registration'    => 'registration',
671
-            'decline_registration'    => 'declined_registration',
672
-            'pending_registration'    => 'pending_approval',
673
-            'no_approve_registration' => 'not_approved_registration',
674
-            'cancel_registration'     => 'cancelled_registration',
675
-        );
676
-        /** setup reg status bulk actions **/
677
-        $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
678
-        if (in_array($match_array['approve_registration'], $active_mts)
679
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
680
-        ) {
681
-            $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations',
682
-                'event_espresso');
683
-        }
684
-        $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
685
-        if (in_array($match_array['decline_registration'], $active_mts)
686
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
687
-        ) {
688
-            $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations',
689
-                'event_espresso');
690
-        }
691
-        $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
692
-        if (in_array($match_array['pending_registration'], $active_mts)
693
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
694
-        ) {
695
-            $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify',
696
-                'event_espresso');
697
-        }
698
-        $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
699
-        if (in_array($match_array['no_approve_registration'], $active_mts)
700
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
701
-        ) {
702
-            $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify',
703
-                'event_espresso');
704
-        }
705
-        $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
706
-        if (in_array($match_array['cancel_registration'], $active_mts)
707
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
708
-        ) {
709
-            $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify',
710
-                'event_espresso');
711
-        }
712
-        $this->_views = array(
713
-            'all'   => array(
714
-                'slug'        => 'all',
715
-                'label'       => __('View All Registrations', 'event_espresso'),
716
-                'count'       => 0,
717
-                'bulk_action' => array_merge($def_reg_status_actions, array(
718
-                    'trash_registrations' => __('Trash Registrations', 'event_espresso'),
719
-                )),
720
-            ),
721
-            'month' => array(
722
-                'slug'        => 'month',
723
-                'label'       => __('This Month', 'event_espresso'),
724
-                'count'       => 0,
725
-                'bulk_action' => array_merge($def_reg_status_actions, array(
726
-                    'trash_registrations' => __('Trash Registrations', 'event_espresso'),
727
-                )),
728
-            ),
729
-            'today' => array(
730
-                'slug'        => 'today',
731
-                'label'       => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))),
732
-                'count'       => 0,
733
-                'bulk_action' => array_merge($def_reg_status_actions, array(
734
-                    'trash_registrations' => __('Trash Registrations', 'event_espresso'),
735
-                )),
736
-            ),
737
-        );
738
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
739
-            'espresso_registrations_delete_registration')
740
-        ) {
741
-            $this->_views['incomplete'] = array(
742
-                'slug'        => 'incomplete',
743
-                'label'       => __('Incomplete', 'event_espresso'),
744
-                'count'       => 0,
745
-                'bulk_action' => array(
746
-                    'trash_registrations' => __('Trash Registrations', 'event_espresso'),
747
-                ),
748
-            );
749
-            $this->_views['trash'] = array(
750
-                'slug'        => 'trash',
751
-                'label'       => __('Trash', 'event_espresso'),
752
-                'count'       => 0,
753
-                'bulk_action' => array(
754
-                    'restore_registrations' => __('Restore Registrations', 'event_espresso'),
755
-                    'delete_registrations'  => __('Delete Registrations Permanently', 'event_espresso'),
756
-                ),
757
-            );
758
-        }
759
-    }
760
-
761
-
762
-
763
-    protected function _set_list_table_views_contact_list()
764
-    {
765
-        $this->_views = array(
766
-            'in_use' => array(
767
-                'slug'        => 'in_use',
768
-                'label'       => __('In Use', 'event_espresso'),
769
-                'count'       => 0,
770
-                'bulk_action' => array(
771
-                    'trash_attendees' => __('Move to Trash', 'event_espresso'),
772
-                ),
773
-            ),
774
-        );
775
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts',
776
-            'espresso_registrations_trash_attendees')
777
-        ) {
778
-            $this->_views['trash'] = array(
779
-                'slug'        => 'trash',
780
-                'label'       => __('Trash', 'event_espresso'),
781
-                'count'       => 0,
782
-                'bulk_action' => array(
783
-                    'restore_attendees' => __('Restore from Trash', 'event_espresso'),
784
-                ),
785
-            );
786
-        }
787
-    }
788
-
789
-
790
-
791
-    protected function _registration_legend_items()
792
-    {
793
-        $fc_items = array(
794
-            'star-icon'        => array(
795
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
796
-                'desc'  => __('This is the Primary Registrant', 'event_espresso'),
797
-            ),
798
-            'view_details'     => array(
799
-                'class' => 'dashicons dashicons-clipboard',
800
-                'desc'  => __('View Registration Details', 'event_espresso'),
801
-            ),
802
-            'edit_attendee'    => array(
803
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
804
-                'desc'  => __('Edit Contact Details', 'event_espresso'),
805
-            ),
806
-            'view_transaction' => array(
807
-                'class' => 'dashicons dashicons-cart',
808
-                'desc'  => __('View Transaction Details', 'event_espresso'),
809
-            ),
810
-            'view_invoice'     => array(
811
-                'class' => 'dashicons dashicons-media-spreadsheet',
812
-                'desc'  => __('View Transaction Invoice', 'event_espresso'),
813
-            ),
814
-        );
815
-        if (EE_Registry::instance()->CAP->current_user_can('ee_send_message',
816
-            'espresso_registrations_resend_registration')
817
-        ) {
818
-            $fc_items['resend_registration'] = array(
819
-                'class' => 'dashicons dashicons-email-alt',
820
-                'desc'  => __('Resend Registration Details', 'event_espresso'),
821
-            );
822
-        } else {
823
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
824
-        }
825
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
826
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
827
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
828
-                $fc_items['view_related_messages'] = array(
829
-                    'class' => $related_for_icon['css_class'],
830
-                    'desc'  => $related_for_icon['label'],
831
-                );
832
-            }
833
-        }
834
-        $sc_items = array(
835
-            'approved_status'   => array(
836
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
837
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
838
-            ),
839
-            'pending_status'    => array(
840
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
841
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
842
-            ),
843
-            'wait_list'         => array(
844
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
845
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
846
-            ),
847
-            'incomplete_status' => array(
848
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
849
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'),
850
-            ),
851
-            'not_approved'      => array(
852
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
853
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
854
-            ),
855
-            'declined_status'   => array(
856
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
857
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
858
-            ),
859
-            'cancelled_status'  => array(
860
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
861
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
862
-            ),
863
-        );
864
-        return array_merge($fc_items, $sc_items);
865
-    }
866
-
867
-
868
-
869
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
870
-    /**
871
-     * @throws \EE_Error
872
-     */
873
-    protected function _registrations_overview_list_table()
874
-    {
875
-        $this->_template_args['admin_page_header'] = '';
876
-        $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
877
-        if ($EVT_ID) {
878
-            if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations',
879
-                'espresso_registrations_new_registration', $EVT_ID)
880
-            ) {
881
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant',
882
-                        array('event_id' => $EVT_ID), 'add-new-h2');
883
-            }
884
-            $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
885
-            if ($event instanceof EE_Event) {
886
-                $this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s',
887
-                    'event_espresso'), '<h3 style="line-height:1.5em;">',
888
-                    '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array(
889
-                        'action' => 'edit',
890
-                        'post'   => $event->ID(),
891
-                    ), EVENTS_ADMIN_URL) . '">&nbsp;' . $event->get('EVT_name') . '&nbsp;</a>&nbsp;', '</h3>');
892
-            }
893
-            $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
894
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
895
-            if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
896
-                $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5);
897
-                $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
898
-                $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
899
-                $this->_template_args['admin_page_header'] .= $datetime->name();
900
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
901
-                $this->_template_args['admin_page_header'] .= '</span></h3>';
902
-            }
903
-        }
904
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
905
-        $this->display_admin_list_table_page_with_no_sidebar();
906
-    }
907
-
908
-
909
-
910
-    /**
911
-     * This sets the _registration property for the registration details screen
912
-     *
913
-     * @access private
914
-     * @return bool
915
-     */
916
-    private function _set_registration_object()
917
-    {
918
-        //get out if we've already set the object
919
-        if (is_object($this->_registration)) {
920
-            return true;
921
-        }
922
-        $REG = EEM_Registration::instance();
923
-        $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
924
-        if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
925
-            return true;
926
-        } else {
927
-            $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.',
928
-                'event_espresso'), $REG_ID);
929
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
930
-            $this->_registration = null;
931
-            return false;
932
-        }
933
-    }
934
-
935
-
936
-
937
-    /**
938
-     * get registrations for given parameters (used by list table)
939
-     *
940
-     * @param  int     $per_page   how many registrations displayed per page
941
-     * @param  boolean $count      return the count or objects
942
-     * @param  boolean $this_month whether to return for just this month
943
-     * @param  boolean $today      whether to return results for just today
944
-     * @throws \EE_Error
945
-     * @return mixed (int|array)  int = count || array of registration objects
946
-     */
947
-    public function get_registrations($per_page = 10, $count = false, $this_month = false, $today = false)
948
-    {
949
-        $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0
950
-            ? absint($this->_req_data['event_id']) : false;
951
-        $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int)$this->_req_data['EVT_CAT'] > 0
952
-            ? absint($this->_req_data['EVT_CAT']) : false;
953
-        $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null;
954
-        $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status'])
955
-            : false;
956
-        $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range'])
957
-            : false;//should be like 2013-april
958
-        $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? true : false;
959
-        $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? true : false;
960
-        $start_date = false;
961
-        $end_date = false;
962
-        $_where = array();
963
-        $trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? true : false;
964
-        $incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? true : false;
965
-        //set orderby
966
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
967
-        switch ($this->_req_data['orderby']) {
968
-            case '_REG_ID':
969
-                $orderby = 'REG_ID';
970
-                break;
971
-            case '_Reg_status':
972
-                $orderby = 'STS_ID';
973
-                break;
974
-            case 'ATT_fname':
975
-                $orderby = 'Attendee.ATT_lname';
976
-                break;
977
-            case 'event_name':
978
-                $orderby = 'Event.EVT_name';
979
-                break;
980
-            case 'DTT_EVT_start':
981
-                $orderby = 'Event.Datetime.DTT_EVT_start';
982
-                break;
983
-            default: //'REG_date'
984
-                $orderby = 'REG_date';
985
-        }
986
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
987
-            : 'DESC';
988
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
989
-            ? $this->_req_data['paged'] : 1;
990
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
991
-            ? $this->_req_data['perpage'] : $per_page;
992
-        $offset = ($current_page - 1) * $per_page;
993
-        $limit = $count ? null : array($offset, $per_page);
994
-        if ($EVT_ID) {
995
-            $_where['EVT_ID'] = $EVT_ID;
996
-        }
997
-        if ($CAT_ID) {
998
-            $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID;
999
-        }
1000
-        //if DTT is included we filter by that datetime.
1001
-        if ($DTT_ID) {
1002
-            $_where['Ticket.Datetime.DTT_ID'] = $DTT_ID;
1003
-        }
1004
-        if ($incomplete) {
1005
-            $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
1006
-        } else if ( ! $trash) {
1007
-            $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1008
-        }
1009
-        if ($reg_status) {
1010
-            $_where['STS_ID'] = $reg_status;
1011
-        }
1012
-        $this_year_r = date('Y', current_time('timestamp'));
1013
-        $time_start = ' 00:00:00';
1014
-        $time_end = ' 23:59:59';
1015
-        if ($today_a || $today) {
1016
-            $curdate = date('Y-m-d', current_time('timestamp'));
1017
-            $_where['REG_date'] = array(
1018
-                'BETWEEN',
1019
-                array(
1020
-                    EEM_Registration::instance()
1021
-                                    ->convert_datetime_for_query('REG_date', $curdate . $time_start, 'Y-m-d H:i:s'),
1022
-                    EEM_Registration::instance()
1023
-                                    ->convert_datetime_for_query('REG_date', $curdate . $time_end, 'Y-m-d H:i:s'),
1024
-                ),
1025
-            );
1026
-        } elseif ($this_month_a || $this_month) {
1027
-            $this_month_r = date('m', current_time('timestamp'));
1028
-            $days_this_month = date('t', current_time('timestamp'));
1029
-            $_where['REG_date'] = array(
1030
-                'BETWEEN',
1031
-                array(
1032
-                    EEM_Registration::instance()
1033
-                                    ->convert_datetime_for_query('REG_date',
1034
-                                        $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s'),
1035
-                    EEM_Registration::instance()
1036
-                                    ->convert_datetime_for_query('REG_date',
1037
-                                        $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
1038
-                                        'Y-m-d H:i:s'),
1039
-                ),
1040
-            );
1041
-        } elseif ($month_range) {
1042
-            $pieces = explode(' ', $this->_req_data['month_range'], 3);
1043
-            $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : '';
1044
-            $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1045
-            $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01'));
1046
-            $_where['REG_date'] = array(
1047
-                'BETWEEN',
1048
-                array(
1049
-                    EEM_Registration::instance()
1050
-                                    ->convert_datetime_for_query('REG_date', $year_r . '-' . $month_r . '-01 00:00:00',
1051
-                                        'Y-m-d H:i:s'),
1052
-                    EEM_Registration::instance()
1053
-                                    ->convert_datetime_for_query('REG_date',
1054
-                                        $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s'),
1055
-                ),
1056
-            );
1057
-        } elseif ($start_date && $end_date) {
1058
-            throw new EE_Error("not yet supported");
1059
-        } elseif ($start_date) {
1060
-            throw new EE_Error("not yet supported");
1061
-        } elseif ($end_date) {
1062
-            throw new EE_Error("not yet supported");
1063
-        }
1064
-        if ( ! empty($this->_req_data['s'])) {
1065
-            $sstr = '%' . $this->_req_data['s'] . '%';
1066
-            $_where['OR'] = array(
1067
-                'Event.EVT_name'                          => array('LIKE', $sstr),
1068
-                'Event.EVT_desc'                          => array('LIKE', $sstr),
1069
-                'Event.EVT_short_desc'                    => array('LIKE', $sstr),
1070
-                'Attendee.ATT_full_name'                  => array('LIKE', $sstr),
1071
-                'Attendee.ATT_fname'                      => array('LIKE', $sstr),
1072
-                'Attendee.ATT_lname'                      => array('LIKE', $sstr),
1073
-                'Attendee.ATT_short_bio'                  => array('LIKE', $sstr),
1074
-                'Attendee.ATT_email'                      => array('LIKE', $sstr),
1075
-                'Attendee.ATT_address'                    => array('LIKE', $sstr),
1076
-                'Attendee.ATT_address2'                   => array('LIKE', $sstr),
1077
-                'Attendee.ATT_city'                       => array('LIKE', $sstr),
1078
-                'REG_final_price'                         => array('LIKE', $sstr),
1079
-                'REG_code'                                => array('LIKE', $sstr),
1080
-                'REG_count'                               => array('LIKE', $sstr),
1081
-                'REG_group_size'                          => array('LIKE', $sstr),
1082
-                'Ticket.TKT_name'                         => array('LIKE', $sstr),
1083
-                'Ticket.TKT_description'                  => array('LIKE', $sstr),
1084
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr),
1085
-            );
1086
-        }
1087
-        //capability checks
1088
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) {
1089
-            $_where['AND'] = array(
1090
-                'Event.EVT_wp_user' => get_current_user_id(),
1091
-            );
1092
-        }
1093
-        if ($count) {
1094
-            if ($trash) {
1095
-                return EEM_Registration::instance()->count_deleted(array($_where));
1096
-            } else if ($incomplete) {
1097
-                return EEM_Registration::instance()->count(array($_where));
1098
-            } else {
1099
-                return EEM_Registration::instance()->count(array(
1100
-                    $_where,
1101
-                    'default_where_conditions' => 'this_model_only',
1102
-                ));
1103
-            }
1104
-        } else {
1105
-            //make sure we remove default where conditions cause all registrations matching query are returned
1106
-            $query_params = array(
1107
-                $_where,
1108
-                'order_by'                 => array($orderby => $sort),
1109
-                'default_where_conditions' => 'this_model_only',
1110
-            );
1111
-            if ($per_page !== -1) {
1112
-                $query_params['limit'] = $limit;
1113
-            }
1114
-            $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params)
1115
-                : EEM_Registration::instance()->get_all($query_params);
1116
-            if ($EVT_ID
1117
-                && isset($registrations[0])
1118
-                && $registrations[0] instanceof EE_Registration
1119
-                && $registrations[0]->event_obj()
1120
-            ) {
1121
-                $first_registration = $registrations[0];
1122
-                //EEH_Debug_Tools::printr( $registrations[0], '$registrations  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1123
-                $event_name = $first_registration->event_obj()->name();
1124
-                $event_date = $first_registration->date_obj()
1125
-                                                 ->start_date_and_time('l F j, Y,',
1126
-                                                     'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1127
-                // edit event link
1128
-                if ($event_name != '') {
1129
-                    $edit_event_url = self::add_query_args_and_nonce(array(
1130
-                        'action' => 'edit_event',
1131
-                        'EVT_ID' => $EVT_ID,
1132
-                    ), EVENTS_ADMIN_URL);
1133
-                    $edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__('Edit ',
1134
-                            'event_espresso') . $event_name . '">' . __('Edit Event', 'event_espresso') . '</a>';
1135
-                    $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>';
1136
-                }
1137
-                $back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL);
1138
-                $back_2_reg_lnk = '<a href="'
1139
-                                  . $back_2_reg_url
1140
-                                  . '" title="'
1141
-                                  . esc_attr__('click to return to viewing all registrations ', 'event_espresso')
1142
-                                  . '">&laquo; '
1143
-                                  . __('Back to All Registrations', 'event_espresso')
1144
-                                  . '</a>';
1145
-                $this->_template_args['before_admin_page_content'] = '
27
+	/**
28
+	 * @var EE_Registration
29
+	 */
30
+	private $_registration;
31
+
32
+	/**
33
+	 * @var EE_Event
34
+	 */
35
+	private $_reg_event;
36
+
37
+	/**
38
+	 * @var EE_Session
39
+	 */
40
+	private        $_session;
41
+
42
+	private static $_reg_status;
43
+
44
+	/**
45
+	 * Form for displaying the custom questions for this registration.
46
+	 * This gets used a few times throughout the request so its best to cache it
47
+	 *
48
+	 * @var EE_Registration_Custom_Questions_Form
49
+	 */
50
+	protected $_reg_custom_questions_form = null;
51
+
52
+
53
+
54
+	/**
55
+	 *        constructor
56
+	 *
57
+	 * @Constructor
58
+	 * @access public
59
+	 * @param bool $routing
60
+	 * @return Registrations_Admin_Page
61
+	 */
62
+	public function __construct($routing = true)
63
+	{
64
+		parent::__construct($routing);
65
+		add_action('wp_loaded', array($this, 'wp_loaded'));
66
+	}
67
+
68
+
69
+
70
+	public function wp_loaded()
71
+	{
72
+		// when adding a new registration...
73
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
74
+			EE_System::do_not_cache();
75
+			if ( ! isset($this->_req_data['processing_registration'])
76
+				 || absint($this->_req_data['processing_registration']) !== 1
77
+			) {
78
+				// and it's NOT the attendee information reg step
79
+				// force cookie expiration by setting time to last week
80
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
81
+				// and update the global
82
+				$_COOKIE['ee_registration_added'] = 0;
83
+			}
84
+		}
85
+	}
86
+
87
+
88
+
89
+	protected function _init_page_props()
90
+	{
91
+		$this->page_slug = REG_PG_SLUG;
92
+		$this->_admin_base_url = REG_ADMIN_URL;
93
+		$this->_admin_base_path = REG_ADMIN;
94
+		$this->page_label = __('Registrations', 'event_espresso');
95
+		$this->_cpt_routes = array(
96
+			'add_new_attendee' => 'espresso_attendees',
97
+			'edit_attendee'    => 'espresso_attendees',
98
+			'insert_attendee'  => 'espresso_attendees',
99
+			'update_attendee'  => 'espresso_attendees',
100
+		);
101
+		$this->_cpt_model_names = array(
102
+			'add_new_attendee' => 'EEM_Attendee',
103
+			'edit_attendee'    => 'EEM_Attendee',
104
+		);
105
+		$this->_cpt_edit_routes = array(
106
+			'espresso_attendees' => 'edit_attendee',
107
+		);
108
+		$this->_pagenow_map = array(
109
+			'add_new_attendee' => 'post-new.php',
110
+			'edit_attendee'    => 'post.php',
111
+			'trash'            => 'post.php',
112
+		);
113
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
114
+		//add filters so that the comment urls don't take users to a confusing 404 page
115
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
116
+	}
117
+
118
+
119
+
120
+	public function clear_comment_link($link, $comment, $args)
121
+	{
122
+		//gotta make sure this only happens on this route
123
+		$post_type = get_post_type($comment->comment_post_ID);
124
+		if ($post_type === 'espresso_attendees') {
125
+			return '#commentsdiv';
126
+		}
127
+		return $link;
128
+	}
129
+
130
+
131
+
132
+	protected function _ajax_hooks()
133
+	{
134
+		//todo: all hooks for registrations ajax goes in here
135
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
136
+	}
137
+
138
+
139
+
140
+	protected function _define_page_props()
141
+	{
142
+		$this->_admin_page_title = $this->page_label;
143
+		$this->_labels = array(
144
+			'buttons'                      => array(
145
+				'add-registrant'      => __('Add New Registration', 'event_espresso'),
146
+				'add-attendee'        => __('Add Contact', 'event_espresso'),
147
+				'edit'                => __('Edit Contact', 'event_espresso'),
148
+				'report'              => __("Event Registrations CSV Report", "event_espresso"),
149
+				'report_all'          => __('All Registrations CSV Report', 'event_espresso'),
150
+				'contact_list_report' => __('Contact List Report', 'event_espresso'),
151
+				'contact_list_export' => __("Export Data", "event_espresso"),
152
+			),
153
+			'publishbox'                   => array(
154
+				'add_new_attendee' => __("Add Contact Record", 'event_espresso'),
155
+				'edit_attendee'    => __("Update Contact Record", 'event_espresso'),
156
+			),
157
+			'hide_add_button_on_cpt_route' => array(
158
+				'edit_attendee' => true,
159
+			),
160
+		);
161
+	}
162
+
163
+
164
+
165
+	/**
166
+	 *        grab url requests and route them
167
+	 *
168
+	 * @access private
169
+	 * @return void
170
+	 */
171
+	public function _set_page_routes()
172
+	{
173
+		$this->_get_registration_status_array();
174
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
175
+			? $this->_req_data['_REG_ID'] : 0;
176
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
177
+			? $this->_req_data['ATT_ID'] : 0;
178
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post']
179
+			: $att_id;
180
+		$this->_page_routes = array(
181
+			'default' => array(
182
+				'func'       => '_registrations_overview_list_table',
183
+				'capability' => 'ee_read_registrations',
184
+			),
185
+			'view_registration' => array(
186
+				'func'       => '_registration_details',
187
+				'capability' => 'ee_read_registration',
188
+				'obj_id'     => $reg_id,
189
+			),
190
+			'edit_registration' => array(
191
+				'func'               => '_update_attendee_registration_form',
192
+				'noheader'           => true,
193
+				'headers_sent_route' => 'view_registration',
194
+				'capability'         => 'ee_edit_registration',
195
+				'obj_id'             => $reg_id,
196
+				'_REG_ID'            => $reg_id,
197
+			),
198
+			'trash_registrations' => array(
199
+				'func'       => '_trash_or_restore_registrations',
200
+				'args'       => array('trash' => true),
201
+				'noheader'   => true,
202
+				'capability' => 'ee_delete_registrations',
203
+			),
204
+			'restore_registrations' => array(
205
+				'func'       => '_trash_or_restore_registrations',
206
+				'args'       => array('trash' => false),
207
+				'noheader'   => true,
208
+				'capability' => 'ee_delete_registrations',
209
+			),
210
+			'delete_registrations' => array(
211
+				'func'       => '_delete_registrations',
212
+				'noheader'   => true,
213
+				'capability' => 'ee_delete_registrations',
214
+			),
215
+			'new_registration' => array(
216
+				'func'       => 'new_registration',
217
+				'capability' => 'ee_edit_registrations',
218
+			),
219
+			'process_reg_step' => array(
220
+				'func'       => 'process_reg_step',
221
+				'noheader'   => true,
222
+				'capability' => 'ee_edit_registrations',
223
+			),
224
+			'redirect_to_txn' => array(
225
+				'func'       => 'redirect_to_txn',
226
+				'noheader'   => true,
227
+				'capability' => 'ee_edit_registrations',
228
+			),
229
+			'change_reg_status' => array(
230
+				'func'       => '_change_reg_status',
231
+				'noheader'   => true,
232
+				'capability' => 'ee_edit_registration',
233
+				'obj_id'     => $reg_id,
234
+			),
235
+			'approve_registration' => array(
236
+				'func'       => 'approve_registration',
237
+				'noheader'   => true,
238
+				'capability' => 'ee_edit_registration',
239
+				'obj_id'     => $reg_id,
240
+			),
241
+			'approve_and_notify_registration' => array(
242
+				'func'       => 'approve_registration',
243
+				'noheader'   => true,
244
+				'args'       => array(true),
245
+				'capability' => 'ee_edit_registration',
246
+				'obj_id'     => $reg_id,
247
+			),
248
+			'decline_registration' => array(
249
+				'func'       => 'decline_registration',
250
+				'noheader'   => true,
251
+				'capability' => 'ee_edit_registration',
252
+				'obj_id'     => $reg_id,
253
+			),
254
+			'decline_and_notify_registration' => array(
255
+				'func'       => 'decline_registration',
256
+				'noheader'   => true,
257
+				'args'       => array(true),
258
+				'capability' => 'ee_edit_registration',
259
+				'obj_id'     => $reg_id,
260
+			),
261
+			'pending_registration' => array(
262
+				'func'       => 'pending_registration',
263
+				'noheader'   => true,
264
+				'capability' => 'ee_edit_registration',
265
+				'obj_id'     => $reg_id,
266
+			),
267
+			'pending_and_notify_registration' => array(
268
+				'func'       => 'pending_registration',
269
+				'noheader'   => true,
270
+				'args'       => array(true),
271
+				'capability' => 'ee_edit_registration',
272
+				'obj_id'     => $reg_id,
273
+			),
274
+			'no_approve_registration' => array(
275
+				'func'       => 'not_approve_registration',
276
+				'noheader'   => true,
277
+				'capability' => 'ee_edit_registration',
278
+				'obj_id'     => $reg_id,
279
+			),
280
+			'no_approve_and_notify_registration' => array(
281
+				'func'       => 'not_approve_registration',
282
+				'noheader'   => true,
283
+				'args'       => array(true),
284
+				'capability' => 'ee_edit_registration',
285
+				'obj_id'     => $reg_id,
286
+			),
287
+			'cancel_registration' => array(
288
+				'func'       => 'cancel_registration',
289
+				'noheader'   => true,
290
+				'capability' => 'ee_edit_registration',
291
+				'obj_id'     => $reg_id,
292
+			),
293
+			'cancel_and_notify_registration' => array(
294
+				'func'       => 'cancel_registration',
295
+				'noheader'   => true,
296
+				'args'       => array(true),
297
+				'capability' => 'ee_edit_registration',
298
+				'obj_id'     => $reg_id,
299
+			),
300
+			'contact_list' => array(
301
+				'func'       => '_attendee_contact_list_table',
302
+				'capability' => 'ee_read_contacts',
303
+			),
304
+			'add_new_attendee' => array(
305
+				'func' => '_create_new_cpt_item',
306
+				'args' => array(
307
+					'new_attendee' => true,
308
+					'capability'   => 'ee_edit_contacts',
309
+				),
310
+			),
311
+			'edit_attendee' => array(
312
+				'func'       => '_edit_cpt_item',
313
+				'capability' => 'ee_edit_contacts',
314
+				'obj_id'     => $att_id,
315
+			),
316
+			'duplicate_attendee' => array(
317
+				'func'       => '_duplicate_attendee',
318
+				'noheader'   => true,
319
+				'capability' => 'ee_edit_contacts',
320
+				'obj_id'     => $att_id,
321
+			),
322
+			'insert_attendee' => array(
323
+				'func'       => '_insert_or_update_attendee',
324
+				'args'       => array(
325
+					'new_attendee' => true,
326
+				),
327
+				'noheader'   => true,
328
+				'capability' => 'ee_edit_contacts',
329
+			),
330
+			'update_attendee' => array(
331
+				'func'       => '_insert_or_update_attendee',
332
+				'args'       => array(
333
+					'new_attendee' => false,
334
+				),
335
+				'noheader'   => true,
336
+				'capability' => 'ee_edit_contacts',
337
+				'obj_id'     => $att_id,
338
+			),
339
+			'trash_attendees' => array(
340
+				'func'       => '_trash_or_restore_attendees',
341
+				'args'       => array(
342
+					'trash' => true,
343
+				),
344
+				'noheader'   => true,
345
+				'capability' => 'ee_delete_contacts',
346
+				'obj_id'     => $att_id,
347
+			),
348
+			'restore_attendees'    => array(
349
+				'func'       => '_trash_or_restore_attendees',
350
+				'args'       => array(
351
+					'trash' => false,
352
+				),
353
+				'noheader'   => true,
354
+				'capability' => 'ee_delete_contacts',
355
+				'obj_id'     => $att_id,
356
+			),
357
+			'resend_registration'  => array(
358
+				'func'       => '_resend_registration',
359
+				'noheader'   => true,
360
+				'capability' => 'ee_send_message',
361
+			),
362
+			'registrations_report' => array(
363
+				'func'       => '_registrations_report',
364
+				'noheader'   => true,
365
+				'capability' => 'ee_read_registrations',
366
+			),
367
+			'contact_list_export'  => array(
368
+				'func'       => '_contact_list_export',
369
+				'noheader'   => true,
370
+				'capability' => 'export',
371
+			),
372
+			'contact_list_report'  => array(
373
+				'func'       => '_contact_list_report',
374
+				'noheader'   => true,
375
+				'capability' => 'ee_read_contacts',
376
+			),
377
+		);
378
+	}
379
+
380
+
381
+
382
+	protected function _set_page_config()
383
+	{
384
+		$this->_page_config = array(
385
+			'default' => array(
386
+				'nav'           => array(
387
+					'label' => __('Overview', 'event_espresso'),
388
+					'order' => 5,
389
+				),
390
+				'help_tabs'     => array(
391
+					'registrations_overview_help_tab'                       => array(
392
+						'title'    => __('Registrations Overview', 'event_espresso'),
393
+						'filename' => 'registrations_overview',
394
+					),
395
+					'registrations_overview_table_column_headings_help_tab' => array(
396
+						'title'    => __('Registrations Table Column Headings', 'event_espresso'),
397
+						'filename' => 'registrations_overview_table_column_headings',
398
+					),
399
+					'registrations_overview_filters_help_tab'               => array(
400
+						'title'    => __('Registration Filters', 'event_espresso'),
401
+						'filename' => 'registrations_overview_filters',
402
+					),
403
+					'registrations_overview_views_help_tab'                 => array(
404
+						'title'    => __('Registration Views', 'event_espresso'),
405
+						'filename' => 'registrations_overview_views',
406
+					),
407
+					'registrations_regoverview_other_help_tab'              => array(
408
+						'title'    => __('Registrations Other', 'event_espresso'),
409
+						'filename' => 'registrations_overview_other',
410
+					),
411
+				),
412
+				'help_tour'     => array('Registration_Overview_Help_Tour'),
413
+				'qtips'         => array('Registration_List_Table_Tips'),
414
+				'list_table'    => 'EE_Registrations_List_Table',
415
+				'require_nonce' => false,
416
+			),
417
+			'view_registration' => array(
418
+				'nav'           => array(
419
+					'label'      => __('REG Details', 'event_espresso'),
420
+					'order'      => 15,
421
+					'url'        => isset($this->_req_data['_REG_ID'])
422
+						? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
423
+						: $this->_admin_base_url,
424
+					'persistent' => false,
425
+				),
426
+				'help_tabs'     => array(
427
+					'registrations_details_help_tab'                    => array(
428
+						'title'    => __('Registration Details', 'event_espresso'),
429
+						'filename' => 'registrations_details',
430
+					),
431
+					'registrations_details_table_help_tab'              => array(
432
+						'title'    => __('Registration Details Table', 'event_espresso'),
433
+						'filename' => 'registrations_details_table',
434
+					),
435
+					'registrations_details_form_answers_help_tab'       => array(
436
+						'title'    => __('Registration Form Answers', 'event_espresso'),
437
+						'filename' => 'registrations_details_form_answers',
438
+					),
439
+					'registrations_details_registrant_details_help_tab' => array(
440
+						'title'    => __('Contact Details', 'event_espresso'),
441
+						'filename' => 'registrations_details_registrant_details',
442
+					),
443
+				),
444
+				'help_tour'     => array('Registration_Details_Help_Tour'),
445
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes,
446
+					array('_registration_details_metaboxes')),
447
+				'require_nonce' => false,
448
+			),
449
+			'new_registration' => array(
450
+				'nav'           => array(
451
+					'label'      => __('Add New Registration', 'event_espresso'),
452
+					'url'        => '#',
453
+					'order'      => 15,
454
+					'persistent' => false,
455
+				),
456
+				'metaboxes'     => $this->_default_espresso_metaboxes,
457
+				'labels'        => array(
458
+					'publishbox' => __('Save Registration', 'event_espresso'),
459
+				),
460
+				'require_nonce' => false,
461
+			),
462
+			'add_new_attendee' => array(
463
+				'nav'           => array(
464
+					'label'      => __('Add Contact', 'event_espresso'),
465
+					'order'      => 15,
466
+					'persistent' => false,
467
+				),
468
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes,
469
+					array('_publish_post_box', 'attendee_editor_metaboxes')),
470
+				'require_nonce' => false,
471
+			),
472
+			'edit_attendee' => array(
473
+				'nav'           => array(
474
+					'label'      => __('Edit Contact', 'event_espresso'),
475
+					'order'      => 15,
476
+					'persistent' => false,
477
+					'url'        => isset($this->_req_data['ATT_ID'])
478
+						? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
479
+						: $this->_admin_base_url,
480
+				),
481
+				'metaboxes'     => array('attendee_editor_metaboxes'),
482
+				'require_nonce' => false,
483
+			),
484
+			'contact_list' => array(
485
+				'nav'           => array(
486
+					'label' => __('Contact List', 'event_espresso'),
487
+					'order' => 20,
488
+				),
489
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
490
+				'help_tabs'     => array(
491
+					'registrations_contact_list_help_tab'                       => array(
492
+						'title'    => __('Registrations Contact List', 'event_espresso'),
493
+						'filename' => 'registrations_contact_list',
494
+					),
495
+					'registrations_contact-list_table_column_headings_help_tab' => array(
496
+						'title'    => __('Contact List Table Column Headings', 'event_espresso'),
497
+						'filename' => 'registrations_contact_list_table_column_headings',
498
+					),
499
+					'registrations_contact_list_views_help_tab'                 => array(
500
+						'title'    => __('Contact List Views', 'event_espresso'),
501
+						'filename' => 'registrations_contact_list_views',
502
+					),
503
+					'registrations_contact_list_other_help_tab'                 => array(
504
+						'title'    => __('Contact List Other', 'event_espresso'),
505
+						'filename' => 'registrations_contact_list_other',
506
+					),
507
+				),
508
+				'help_tour'     => array('Contact_List_Help_Tour'),
509
+				'metaboxes'     => array(),
510
+				'require_nonce' => false,
511
+			),
512
+			//override default cpt routes
513
+			'create_new'   => '',
514
+			'edit'         => '',
515
+		);
516
+	}
517
+
518
+
519
+
520
+	/**
521
+	 * The below methods aren't used by this class currently
522
+	 */
523
+	protected function _add_screen_options()
524
+	{
525
+	}
526
+
527
+
528
+
529
+	protected function _add_feature_pointers()
530
+	{
531
+	}
532
+
533
+
534
+
535
+	public function admin_init()
536
+	{
537
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes',
538
+			'event_espresso');
539
+	}
540
+
541
+
542
+
543
+	public function admin_notices()
544
+	{
545
+	}
546
+
547
+
548
+
549
+	public function admin_footer_scripts()
550
+	{
551
+	}
552
+
553
+
554
+
555
+	/**
556
+	 *        get list of registration statuses
557
+	 *
558
+	 * @access private
559
+	 * @return void
560
+	 */
561
+	private function _get_registration_status_array()
562
+	{
563
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
564
+	}
565
+
566
+
567
+
568
+	protected function _add_screen_options_default()
569
+	{
570
+		$this->_per_page_screen_option();
571
+	}
572
+
573
+
574
+
575
+	protected function _add_screen_options_contact_list()
576
+	{
577
+		$page_title = $this->_admin_page_title;
578
+		$this->_admin_page_title = __("Contacts", 'event_espresso');
579
+		$this->_per_page_screen_option();
580
+		$this->_admin_page_title = $page_title;
581
+	}
582
+
583
+
584
+
585
+	public function load_scripts_styles()
586
+	{
587
+		//style
588
+		//wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
589
+		wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'),
590
+			EVENT_ESPRESSO_VERSION);
591
+		wp_enqueue_style('espresso_reg');
592
+		//script
593
+		wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js',
594
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, true);
595
+		wp_enqueue_script('espresso_reg');
596
+	}
597
+
598
+
599
+
600
+	public function load_scripts_styles_edit_attendee()
601
+	{
602
+		//stuff to only show up on our attendee edit details page.
603
+		$attendee_details_translations = array(
604
+			'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'),
605
+				$this->_cpt_model_obj->get_datetime('ATT_created')),
606
+		);
607
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
608
+		wp_enqueue_script('jquery-validate');
609
+	}
610
+
611
+
612
+
613
+	public function load_scripts_styles_view_registration()
614
+	{
615
+		//styles
616
+		wp_enqueue_style('espresso-ui-theme');
617
+		//scripts
618
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
619
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
620
+	}
621
+
622
+
623
+
624
+	public function load_scripts_styles_contact_list()
625
+	{
626
+		wp_deregister_style('espresso_reg');
627
+		wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'),
628
+			EVENT_ESPRESSO_VERSION);
629
+		wp_enqueue_style('espresso_att');
630
+	}
631
+
632
+
633
+
634
+	public function load_scripts_styles_new_registration()
635
+	{
636
+		wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'),
637
+			EVENT_ESPRESSO_VERSION, true);
638
+		wp_enqueue_script('ee-spco-for-admin');
639
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
640
+		EE_Form_Section_Proper::wp_enqueue_scripts();
641
+		EED_Ticket_Selector::load_tckt_slctr_assets();
642
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
643
+	}
644
+
645
+
646
+
647
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
648
+	{
649
+		add_filter('FHEE_load_EE_messages', '__return_true');
650
+	}
651
+
652
+
653
+
654
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
655
+	{
656
+		add_filter('FHEE_load_EE_messages', '__return_true');
657
+	}
658
+
659
+
660
+
661
+	protected function _set_list_table_views_default()
662
+	{
663
+		//for notification related bulk actions we need to make sure only active messengers have an option.
664
+		EED_Messages::set_autoloaders();
665
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
666
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
667
+		$active_mts = $message_resource_manager->list_of_active_message_types();
668
+		//key= bulk_action_slug, value= message type.
669
+		$match_array = array(
670
+			'approve_registration'    => 'registration',
671
+			'decline_registration'    => 'declined_registration',
672
+			'pending_registration'    => 'pending_approval',
673
+			'no_approve_registration' => 'not_approved_registration',
674
+			'cancel_registration'     => 'cancelled_registration',
675
+		);
676
+		/** setup reg status bulk actions **/
677
+		$def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
678
+		if (in_array($match_array['approve_registration'], $active_mts)
679
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
680
+		) {
681
+			$def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations',
682
+				'event_espresso');
683
+		}
684
+		$def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
685
+		if (in_array($match_array['decline_registration'], $active_mts)
686
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
687
+		) {
688
+			$def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations',
689
+				'event_espresso');
690
+		}
691
+		$def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
692
+		if (in_array($match_array['pending_registration'], $active_mts)
693
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
694
+		) {
695
+			$def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify',
696
+				'event_espresso');
697
+		}
698
+		$def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
699
+		if (in_array($match_array['no_approve_registration'], $active_mts)
700
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
701
+		) {
702
+			$def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify',
703
+				'event_espresso');
704
+		}
705
+		$def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
706
+		if (in_array($match_array['cancel_registration'], $active_mts)
707
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')
708
+		) {
709
+			$def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify',
710
+				'event_espresso');
711
+		}
712
+		$this->_views = array(
713
+			'all'   => array(
714
+				'slug'        => 'all',
715
+				'label'       => __('View All Registrations', 'event_espresso'),
716
+				'count'       => 0,
717
+				'bulk_action' => array_merge($def_reg_status_actions, array(
718
+					'trash_registrations' => __('Trash Registrations', 'event_espresso'),
719
+				)),
720
+			),
721
+			'month' => array(
722
+				'slug'        => 'month',
723
+				'label'       => __('This Month', 'event_espresso'),
724
+				'count'       => 0,
725
+				'bulk_action' => array_merge($def_reg_status_actions, array(
726
+					'trash_registrations' => __('Trash Registrations', 'event_espresso'),
727
+				)),
728
+			),
729
+			'today' => array(
730
+				'slug'        => 'today',
731
+				'label'       => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))),
732
+				'count'       => 0,
733
+				'bulk_action' => array_merge($def_reg_status_actions, array(
734
+					'trash_registrations' => __('Trash Registrations', 'event_espresso'),
735
+				)),
736
+			),
737
+		);
738
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
739
+			'espresso_registrations_delete_registration')
740
+		) {
741
+			$this->_views['incomplete'] = array(
742
+				'slug'        => 'incomplete',
743
+				'label'       => __('Incomplete', 'event_espresso'),
744
+				'count'       => 0,
745
+				'bulk_action' => array(
746
+					'trash_registrations' => __('Trash Registrations', 'event_espresso'),
747
+				),
748
+			);
749
+			$this->_views['trash'] = array(
750
+				'slug'        => 'trash',
751
+				'label'       => __('Trash', 'event_espresso'),
752
+				'count'       => 0,
753
+				'bulk_action' => array(
754
+					'restore_registrations' => __('Restore Registrations', 'event_espresso'),
755
+					'delete_registrations'  => __('Delete Registrations Permanently', 'event_espresso'),
756
+				),
757
+			);
758
+		}
759
+	}
760
+
761
+
762
+
763
+	protected function _set_list_table_views_contact_list()
764
+	{
765
+		$this->_views = array(
766
+			'in_use' => array(
767
+				'slug'        => 'in_use',
768
+				'label'       => __('In Use', 'event_espresso'),
769
+				'count'       => 0,
770
+				'bulk_action' => array(
771
+					'trash_attendees' => __('Move to Trash', 'event_espresso'),
772
+				),
773
+			),
774
+		);
775
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts',
776
+			'espresso_registrations_trash_attendees')
777
+		) {
778
+			$this->_views['trash'] = array(
779
+				'slug'        => 'trash',
780
+				'label'       => __('Trash', 'event_espresso'),
781
+				'count'       => 0,
782
+				'bulk_action' => array(
783
+					'restore_attendees' => __('Restore from Trash', 'event_espresso'),
784
+				),
785
+			);
786
+		}
787
+	}
788
+
789
+
790
+
791
+	protected function _registration_legend_items()
792
+	{
793
+		$fc_items = array(
794
+			'star-icon'        => array(
795
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
796
+				'desc'  => __('This is the Primary Registrant', 'event_espresso'),
797
+			),
798
+			'view_details'     => array(
799
+				'class' => 'dashicons dashicons-clipboard',
800
+				'desc'  => __('View Registration Details', 'event_espresso'),
801
+			),
802
+			'edit_attendee'    => array(
803
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
804
+				'desc'  => __('Edit Contact Details', 'event_espresso'),
805
+			),
806
+			'view_transaction' => array(
807
+				'class' => 'dashicons dashicons-cart',
808
+				'desc'  => __('View Transaction Details', 'event_espresso'),
809
+			),
810
+			'view_invoice'     => array(
811
+				'class' => 'dashicons dashicons-media-spreadsheet',
812
+				'desc'  => __('View Transaction Invoice', 'event_espresso'),
813
+			),
814
+		);
815
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message',
816
+			'espresso_registrations_resend_registration')
817
+		) {
818
+			$fc_items['resend_registration'] = array(
819
+				'class' => 'dashicons dashicons-email-alt',
820
+				'desc'  => __('Resend Registration Details', 'event_espresso'),
821
+			);
822
+		} else {
823
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
824
+		}
825
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
826
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
827
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
828
+				$fc_items['view_related_messages'] = array(
829
+					'class' => $related_for_icon['css_class'],
830
+					'desc'  => $related_for_icon['label'],
831
+				);
832
+			}
833
+		}
834
+		$sc_items = array(
835
+			'approved_status'   => array(
836
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
837
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
838
+			),
839
+			'pending_status'    => array(
840
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
841
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
842
+			),
843
+			'wait_list'         => array(
844
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
845
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
846
+			),
847
+			'incomplete_status' => array(
848
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
849
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, false, 'sentence'),
850
+			),
851
+			'not_approved'      => array(
852
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
853
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
854
+			),
855
+			'declined_status'   => array(
856
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
857
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
858
+			),
859
+			'cancelled_status'  => array(
860
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
861
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
862
+			),
863
+		);
864
+		return array_merge($fc_items, $sc_items);
865
+	}
866
+
867
+
868
+
869
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
870
+	/**
871
+	 * @throws \EE_Error
872
+	 */
873
+	protected function _registrations_overview_list_table()
874
+	{
875
+		$this->_template_args['admin_page_header'] = '';
876
+		$EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0;
877
+		if ($EVT_ID) {
878
+			if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations',
879
+				'espresso_registrations_new_registration', $EVT_ID)
880
+			) {
881
+				$this->_admin_page_title .= ' ' . $this->get_action_link_or_button('new_registration', 'add-registrant',
882
+						array('event_id' => $EVT_ID), 'add-new-h2');
883
+			}
884
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
885
+			if ($event instanceof EE_Event) {
886
+				$this->_template_args['admin_page_header'] = sprintf(__('%s Viewing registrations for the event: %s%s',
887
+					'event_espresso'), '<h3 style="line-height:1.5em;">',
888
+					'<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce(array(
889
+						'action' => 'edit',
890
+						'post'   => $event->ID(),
891
+					), EVENTS_ADMIN_URL) . '">&nbsp;' . $event->get('EVT_name') . '&nbsp;</a>&nbsp;', '</h3>');
892
+			}
893
+			$DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
894
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
895
+			if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
896
+				$this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5);
897
+				$this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
898
+				$this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
899
+				$this->_template_args['admin_page_header'] .= $datetime->name();
900
+				$this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
901
+				$this->_template_args['admin_page_header'] .= '</span></h3>';
902
+			}
903
+		}
904
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
905
+		$this->display_admin_list_table_page_with_no_sidebar();
906
+	}
907
+
908
+
909
+
910
+	/**
911
+	 * This sets the _registration property for the registration details screen
912
+	 *
913
+	 * @access private
914
+	 * @return bool
915
+	 */
916
+	private function _set_registration_object()
917
+	{
918
+		//get out if we've already set the object
919
+		if (is_object($this->_registration)) {
920
+			return true;
921
+		}
922
+		$REG = EEM_Registration::instance();
923
+		$REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
924
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
925
+			return true;
926
+		} else {
927
+			$error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.',
928
+				'event_espresso'), $REG_ID);
929
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
930
+			$this->_registration = null;
931
+			return false;
932
+		}
933
+	}
934
+
935
+
936
+
937
+	/**
938
+	 * get registrations for given parameters (used by list table)
939
+	 *
940
+	 * @param  int     $per_page   how many registrations displayed per page
941
+	 * @param  boolean $count      return the count or objects
942
+	 * @param  boolean $this_month whether to return for just this month
943
+	 * @param  boolean $today      whether to return results for just today
944
+	 * @throws \EE_Error
945
+	 * @return mixed (int|array)  int = count || array of registration objects
946
+	 */
947
+	public function get_registrations($per_page = 10, $count = false, $this_month = false, $today = false)
948
+	{
949
+		$EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0
950
+			? absint($this->_req_data['event_id']) : false;
951
+		$CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int)$this->_req_data['EVT_CAT'] > 0
952
+			? absint($this->_req_data['EVT_CAT']) : false;
953
+		$DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null;
954
+		$reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status'])
955
+			: false;
956
+		$month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range'])
957
+			: false;//should be like 2013-april
958
+		$today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? true : false;
959
+		$this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? true : false;
960
+		$start_date = false;
961
+		$end_date = false;
962
+		$_where = array();
963
+		$trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? true : false;
964
+		$incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? true : false;
965
+		//set orderby
966
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
967
+		switch ($this->_req_data['orderby']) {
968
+			case '_REG_ID':
969
+				$orderby = 'REG_ID';
970
+				break;
971
+			case '_Reg_status':
972
+				$orderby = 'STS_ID';
973
+				break;
974
+			case 'ATT_fname':
975
+				$orderby = 'Attendee.ATT_lname';
976
+				break;
977
+			case 'event_name':
978
+				$orderby = 'Event.EVT_name';
979
+				break;
980
+			case 'DTT_EVT_start':
981
+				$orderby = 'Event.Datetime.DTT_EVT_start';
982
+				break;
983
+			default: //'REG_date'
984
+				$orderby = 'REG_date';
985
+		}
986
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
987
+			: 'DESC';
988
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
989
+			? $this->_req_data['paged'] : 1;
990
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
991
+			? $this->_req_data['perpage'] : $per_page;
992
+		$offset = ($current_page - 1) * $per_page;
993
+		$limit = $count ? null : array($offset, $per_page);
994
+		if ($EVT_ID) {
995
+			$_where['EVT_ID'] = $EVT_ID;
996
+		}
997
+		if ($CAT_ID) {
998
+			$_where['Event.Term_Taxonomy.term_id'] = $CAT_ID;
999
+		}
1000
+		//if DTT is included we filter by that datetime.
1001
+		if ($DTT_ID) {
1002
+			$_where['Ticket.Datetime.DTT_ID'] = $DTT_ID;
1003
+		}
1004
+		if ($incomplete) {
1005
+			$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
1006
+		} else if ( ! $trash) {
1007
+			$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1008
+		}
1009
+		if ($reg_status) {
1010
+			$_where['STS_ID'] = $reg_status;
1011
+		}
1012
+		$this_year_r = date('Y', current_time('timestamp'));
1013
+		$time_start = ' 00:00:00';
1014
+		$time_end = ' 23:59:59';
1015
+		if ($today_a || $today) {
1016
+			$curdate = date('Y-m-d', current_time('timestamp'));
1017
+			$_where['REG_date'] = array(
1018
+				'BETWEEN',
1019
+				array(
1020
+					EEM_Registration::instance()
1021
+									->convert_datetime_for_query('REG_date', $curdate . $time_start, 'Y-m-d H:i:s'),
1022
+					EEM_Registration::instance()
1023
+									->convert_datetime_for_query('REG_date', $curdate . $time_end, 'Y-m-d H:i:s'),
1024
+				),
1025
+			);
1026
+		} elseif ($this_month_a || $this_month) {
1027
+			$this_month_r = date('m', current_time('timestamp'));
1028
+			$days_this_month = date('t', current_time('timestamp'));
1029
+			$_where['REG_date'] = array(
1030
+				'BETWEEN',
1031
+				array(
1032
+					EEM_Registration::instance()
1033
+									->convert_datetime_for_query('REG_date',
1034
+										$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s'),
1035
+					EEM_Registration::instance()
1036
+									->convert_datetime_for_query('REG_date',
1037
+										$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
1038
+										'Y-m-d H:i:s'),
1039
+				),
1040
+			);
1041
+		} elseif ($month_range) {
1042
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1043
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : '';
1044
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1045
+			$days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01'));
1046
+			$_where['REG_date'] = array(
1047
+				'BETWEEN',
1048
+				array(
1049
+					EEM_Registration::instance()
1050
+									->convert_datetime_for_query('REG_date', $year_r . '-' . $month_r . '-01 00:00:00',
1051
+										'Y-m-d H:i:s'),
1052
+					EEM_Registration::instance()
1053
+									->convert_datetime_for_query('REG_date',
1054
+										$year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s'),
1055
+				),
1056
+			);
1057
+		} elseif ($start_date && $end_date) {
1058
+			throw new EE_Error("not yet supported");
1059
+		} elseif ($start_date) {
1060
+			throw new EE_Error("not yet supported");
1061
+		} elseif ($end_date) {
1062
+			throw new EE_Error("not yet supported");
1063
+		}
1064
+		if ( ! empty($this->_req_data['s'])) {
1065
+			$sstr = '%' . $this->_req_data['s'] . '%';
1066
+			$_where['OR'] = array(
1067
+				'Event.EVT_name'                          => array('LIKE', $sstr),
1068
+				'Event.EVT_desc'                          => array('LIKE', $sstr),
1069
+				'Event.EVT_short_desc'                    => array('LIKE', $sstr),
1070
+				'Attendee.ATT_full_name'                  => array('LIKE', $sstr),
1071
+				'Attendee.ATT_fname'                      => array('LIKE', $sstr),
1072
+				'Attendee.ATT_lname'                      => array('LIKE', $sstr),
1073
+				'Attendee.ATT_short_bio'                  => array('LIKE', $sstr),
1074
+				'Attendee.ATT_email'                      => array('LIKE', $sstr),
1075
+				'Attendee.ATT_address'                    => array('LIKE', $sstr),
1076
+				'Attendee.ATT_address2'                   => array('LIKE', $sstr),
1077
+				'Attendee.ATT_city'                       => array('LIKE', $sstr),
1078
+				'REG_final_price'                         => array('LIKE', $sstr),
1079
+				'REG_code'                                => array('LIKE', $sstr),
1080
+				'REG_count'                               => array('LIKE', $sstr),
1081
+				'REG_group_size'                          => array('LIKE', $sstr),
1082
+				'Ticket.TKT_name'                         => array('LIKE', $sstr),
1083
+				'Ticket.TKT_description'                  => array('LIKE', $sstr),
1084
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr),
1085
+			);
1086
+		}
1087
+		//capability checks
1088
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) {
1089
+			$_where['AND'] = array(
1090
+				'Event.EVT_wp_user' => get_current_user_id(),
1091
+			);
1092
+		}
1093
+		if ($count) {
1094
+			if ($trash) {
1095
+				return EEM_Registration::instance()->count_deleted(array($_where));
1096
+			} else if ($incomplete) {
1097
+				return EEM_Registration::instance()->count(array($_where));
1098
+			} else {
1099
+				return EEM_Registration::instance()->count(array(
1100
+					$_where,
1101
+					'default_where_conditions' => 'this_model_only',
1102
+				));
1103
+			}
1104
+		} else {
1105
+			//make sure we remove default where conditions cause all registrations matching query are returned
1106
+			$query_params = array(
1107
+				$_where,
1108
+				'order_by'                 => array($orderby => $sort),
1109
+				'default_where_conditions' => 'this_model_only',
1110
+			);
1111
+			if ($per_page !== -1) {
1112
+				$query_params['limit'] = $limit;
1113
+			}
1114
+			$registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params)
1115
+				: EEM_Registration::instance()->get_all($query_params);
1116
+			if ($EVT_ID
1117
+				&& isset($registrations[0])
1118
+				&& $registrations[0] instanceof EE_Registration
1119
+				&& $registrations[0]->event_obj()
1120
+			) {
1121
+				$first_registration = $registrations[0];
1122
+				//EEH_Debug_Tools::printr( $registrations[0], '$registrations  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1123
+				$event_name = $first_registration->event_obj()->name();
1124
+				$event_date = $first_registration->date_obj()
1125
+												 ->start_date_and_time('l F j, Y,',
1126
+													 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1127
+				// edit event link
1128
+				if ($event_name != '') {
1129
+					$edit_event_url = self::add_query_args_and_nonce(array(
1130
+						'action' => 'edit_event',
1131
+						'EVT_ID' => $EVT_ID,
1132
+					), EVENTS_ADMIN_URL);
1133
+					$edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__('Edit ',
1134
+							'event_espresso') . $event_name . '">' . __('Edit Event', 'event_espresso') . '</a>';
1135
+					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>';
1136
+				}
1137
+				$back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL);
1138
+				$back_2_reg_lnk = '<a href="'
1139
+								  . $back_2_reg_url
1140
+								  . '" title="'
1141
+								  . esc_attr__('click to return to viewing all registrations ', 'event_espresso')
1142
+								  . '">&laquo; '
1143
+								  . __('Back to All Registrations', 'event_espresso')
1144
+								  . '</a>';
1145
+				$this->_template_args['before_admin_page_content'] = '
1146 1146
 			<div id="admin-page-header">
1147 1147
 				<h1><span class="small-text not-bold">' . __('Event: ', 'event_espresso') . '</span>' . $event_name . '</h1>
1148 1148
 				<h3><span class="small-text not-bold">' . __('Date: ', 'event_espresso') . '</span>' . $event_date . '</h3>
1149 1149
 				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span>
1150 1150
 			</div>
1151 1151
 			';
1152
-            }
1153
-            return $registrations;
1154
-        }
1155
-    }
1156
-
1157
-
1158
-
1159
-    public function get_registration_status_array()
1160
-    {
1161
-        return self::$_reg_status;
1162
-    }
1163
-
1164
-
1165
-
1166
-
1167
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1168
-    /**
1169
-     *        generates HTML for the View Registration Details Admin page
1170
-     *
1171
-     * @access protected
1172
-     * @return void
1173
-     */
1174
-    protected function _registration_details()
1175
-    {
1176
-        $this->_template_args = array();
1177
-        $this->_set_registration_object();
1178
-        if (is_object($this->_registration)) {
1179
-            $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
1180
-                : EE_Transaction::new_instance();
1181
-            $this->_session = $transaction->session_data();
1182
-            $event_id = $this->_registration->event_ID();
1183
-            $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1184
-            $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso');
1185
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1186
-            $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso');
1187
-            $this->_template_args['grand_total'] = $transaction->total();
1188
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1189
-            // link back to overview
1190
-            $this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1191
-            $this->_template_args['registration'] = $this->_registration;
1192
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1193
-                'action'   => 'default',
1194
-                'event_id' => $event_id,
1195
-            ), REG_ADMIN_URL);
1196
-            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1197
-                'action' => 'default',
1198
-                'EVT_ID' => $event_id,
1199
-                'page'   => 'espresso_transactions',
1200
-            ), admin_url('admin.php'));
1201
-            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1202
-                'page'   => 'espresso_events',
1203
-                'action' => 'edit',
1204
-                'post'   => $event_id,
1205
-            ), admin_url('admin.php'));
1206
-            //next and previous links
1207
-            $next_reg = $this->_registration->next(null, array(), 'REG_ID');
1208
-            $this->_template_args['next_registration'] = $next_reg
1209
-                ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array(
1210
-                    'action'  => 'view_registration',
1211
-                    '_REG_ID' => $next_reg['REG_ID'],
1212
-                ), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
1213
-            $previous_reg = $this->_registration->previous(null, array(), 'REG_ID');
1214
-            $this->_template_args['previous_registration'] = $previous_reg
1215
-                ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array(
1216
-                    'action'  => 'view_registration',
1217
-                    '_REG_ID' => $previous_reg['REG_ID'],
1218
-                ), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1219
-            // grab header
1220
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1221
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1222
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path,
1223
-                $this->_template_args, true);
1224
-        } else {
1225
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1226
-        }
1227
-        // the details template wrapper
1228
-        $this->display_admin_page_with_sidebar();
1229
-    }
1230
-
1231
-
1232
-
1233
-    protected function _registration_details_metaboxes()
1234
-    {
1235
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1236
-        $this->_set_registration_object();
1237
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1238
-        add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'),
1239
-            array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1240
-        add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'),
1241
-            array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1242
-        if ($attendee instanceof EE_Attendee
1243
-            && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')
1244
-        ) {
1245
-            add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'),
1246
-                array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high');
1247
-        }
1248
-        add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'),
1249
-            array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high');
1250
-        if ($this->_registration->group_size() > 1) {
1251
-            add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'),
1252
-                array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high');
1253
-        }
1254
-    }
1255
-
1256
-
1257
-
1258
-    /**
1259
-     * set_reg_status_buttons_metabox
1260
-     *
1261
-     * @access protected
1262
-     * @return string
1263
-     * @throws \EE_Error
1264
-     */
1265
-    public function set_reg_status_buttons_metabox()
1266
-    {
1267
-        $this->_set_registration_object();
1268
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1269
-        echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array(
1270
-            'action' => 'change_reg_status',
1271
-        ), REG_ADMIN_URL));
1272
-        echo $change_reg_status_form->get_html();
1273
-        echo $change_reg_status_form->form_close();
1274
-    }
1275
-
1276
-
1277
-
1278
-    /**
1279
-     * @return EE_Form_Section_Proper
1280
-     */
1281
-    protected function _generate_reg_status_change_form()
1282
-    {
1283
-        return new EE_Form_Section_Proper(array(
1284
-                'name'            => 'reg_status_change_form',
1285
-                'html_id'         => 'reg-status-change-form',
1286
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1287
-                'subsections'     => array(
1288
-                    'return'             => new EE_Hidden_Input(array(
1289
-                        'name'    => 'return',
1290
-                        'default' => 'view_registration',
1291
-                    )),
1292
-                    'REG_ID'             => new EE_Hidden_Input(array(
1293
-                        'name'    => 'REG_ID',
1294
-                        'default' => $this->_registration->ID(),
1295
-                    )),
1296
-                    'current_status'     => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status',
1297
-                            'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(),
1298
-                            '', 'status-' . $this->_registration->status_ID(),
1299
-                            'line-height: 1em; font-size: 1.5em; font-weight: bold;')))),
1300
-                    'reg_status'         => new EE_Select_Input($this->_get_reg_statuses(), array(
1301
-                            'html_label_text' => __('Change Registration Status to', 'event_espresso'),
1302
-                            'default'         => $this->_registration->status_ID(),
1303
-                        )),
1304
-                    'send_notifications' => new EE_Yes_No_Input(array(
1305
-                            'html_label_text' => __('Send Related Messages', 'event_espresso'),
1306
-                            'default'         => false,
1307
-                            'html_help_text'  => __('If set to "Yes", then the related messages will be sent to the registrant.',
1308
-                                'event_espresso'),
1309
-                        )),
1310
-                    'submit'             => new EE_Submit_Input(array(
1311
-                        'html_class'      => 'button-primary',
1312
-                        'html_label_text' => '&nbsp;',
1313
-                        'default'         => __('Update Registration Status', 'event_espresso'),
1314
-                    )),
1315
-                ),
1316
-            ));
1317
-    }
1318
-
1319
-
1320
-
1321
-    /**
1322
-     * Returns an array of all the buttons for the various statuses and switch status actions
1323
-     *
1324
-     * @return string
1325
-     */
1326
-    protected function _get_current_reg_status_help_text($STS_ID = '')
1327
-    {
1328
-        //$reg_status_help_text = array(
1329
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1330
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1331
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1332
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1333
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1334
-        //	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1335
-        //);
1336
-        //Approved
1337
-        //An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant .
1338
-        //Cancelled
1339
-        //	A {
1340
-        //	cancelled} registration is performed by the registrant . Payments are not allowed, the registration is inactive, and no space is reserved .
1341
-        //Declined
1342
-        //A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved .
1343
-        //Not Approved
1344
-        //A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved .
1345
-        //Pending Payment
1346
-        //A pending registration allows payments . The status will be automatically toggled to approved if the {
1347
-        //	payment} is made in full by registrant .
1348
-    }
1349
-
1350
-
1351
-
1352
-    /**
1353
-     * Returns an array of all the buttons for the various statuses and switch status actions
1354
-     *
1355
-     * @return array
1356
-     */
1357
-    protected function _get_reg_statuses()
1358
-    {
1359
-        $reg_status_array = EEM_Registration::instance()->reg_status_array();
1360
-        unset ($reg_status_array[EEM_Registration::status_id_incomplete]);
1361
-        // get current reg status
1362
-        $current_status = $this->_registration->status_ID();
1363
-        // is registration for free event? This will determine whether to display the pending payment option
1364
-        if ($current_status != EEM_Registration::status_id_pending_payment
1365
-            && $this->_registration->transaction()
1366
-                                   ->is_free()
1367
-        ) {
1368
-            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1369
-        }
1370
-        return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1371
-    }
1372
-
1373
-
1374
-
1375
-    /**
1376
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1377
-     *
1378
-     * @param bool $status REG status given for changing registrations to.
1379
-     * @param bool $notify Whether to send messages notifications or not.
1380
-     * @return array  (array with reg_id(s) updated and whether update was successful.
1381
-     */
1382
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1383
-    {
1384
-        if (isset($this->_req_data['reg_status_change_form'])) {
1385
-            $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1386
-                ? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array();
1387
-        } else {
1388
-            $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array();
1389
-        }
1390
-        $success = $this->_set_registration_status($REG_IDs, $status);
1391
-        //notify?
1392
-        if ($success
1393
-            && $notify
1394
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
1395
-                'espresso_registrations_resend_registration')
1396
-        ) {
1397
-            $this->_process_resend_registration();
1398
-        }
1399
-        return $success;
1400
-    }
1401
-
1402
-
1403
-
1404
-    /**
1405
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1406
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1407
-     *
1408
-     * @param array $REG_IDs
1409
-     * @param bool  $status
1410
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1411
-     *               the array of updated registrations).
1412
-     */
1413
-    protected function _set_registration_status($REG_IDs = array(), $status = false)
1414
-    {
1415
-        $success = false;
1416
-        // typecast $REG_IDs
1417
-        $REG_IDs = (array)$REG_IDs;
1418
-        if ( ! empty($REG_IDs)) {
1419
-            $success = true;
1420
-            // set default status if none is passed
1421
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1422
-            // sanitize $REG_IDs
1423
-            $REG_IDs = array_filter($REG_IDs, 'absint');
1424
-            //loop through REG_ID's and change status
1425
-            foreach ($REG_IDs as $REG_ID) {
1426
-                $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1427
-                if ($registration instanceof EE_Registration) {
1428
-                    $registration->set_status($status);
1429
-                    $result = $registration->save();
1430
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1431
-                    $success = $result !== false ? $success : false;
1432
-                }
1433
-            }
1434
-        }
1435
-        //reset _req_data['_REG_ID'] for any potential future messages notifications
1436
-        $this->_req_data['_REG_ID'] = $REG_IDs;
1437
-        //return $success and processed registrations
1438
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1439
-    }
1440
-
1441
-
1442
-
1443
-    /**
1444
-     * Common logic for setting up success message and redirecting to appropriate route
1445
-     *
1446
-     * @param  string $STS_ID status id for the registration changed to
1447
-     * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1448
-     * @return void
1449
-     */
1450
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1451
-    {
1452
-        $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1453
-            : array('success' => false);
1454
-        $success = isset($result['success']) && $result['success'];
1455
-        //setup success message
1456
-        if ($success) {
1457
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1458
-                $msg = sprintf(__('Registration status has been set to %s', 'event_espresso'),
1459
-                    EEH_Template::pretty_status($STS_ID, false, 'lower'));
1460
-            } else {
1461
-                $msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'),
1462
-                    EEH_Template::pretty_status($STS_ID, false, 'lower'));
1463
-            }
1464
-            EE_Error::add_success($msg);
1465
-        } else {
1466
-            EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__,
1467
-                __LINE__, __FUNCTION__);
1468
-        }
1469
-        if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
1470
-            $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1471
-        } else {
1472
-            $route = array('action' => 'default');
1473
-        }
1474
-        //unset nonces
1475
-        foreach ($this->_req_data as $ref => $value) {
1476
-            if (strpos($ref, 'nonce') !== false) {
1477
-                unset($this->_req_data[$ref]);
1478
-                continue;
1479
-            }
1480
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1481
-            $this->_req_data[$ref] = $value;
1482
-        }
1483
-        //merge request vars so that the reloaded list table contains any existing filter query params
1484
-        $route = array_merge($this->_req_data, $route);
1485
-        $this->_redirect_after_action($success, '', '', $route, true);
1486
-    }
1487
-
1488
-
1489
-
1490
-    /**
1491
-     * incoming reg status change from reg details page.
1492
-     *
1493
-     * @return void
1494
-     */
1495
-    protected function _change_reg_status()
1496
-    {
1497
-        $this->_req_data['return'] = 'view_registration';
1498
-        //set notify based on whether the send notifications toggle is set or not
1499
-        $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1500
-        //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1501
-        $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
1502
-            ? $this->_req_data['reg_status_change_form']['reg_status'] : '';
1503
-        switch ($this->_req_data['reg_status_change_form']['reg_status']) {
1504
-            case EEM_Registration::status_id_approved :
1505
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
1506
-                $this->approve_registration($notify);
1507
-                break;
1508
-            case EEM_Registration::status_id_pending_payment :
1509
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
1510
-                $this->pending_registration($notify);
1511
-                break;
1512
-            case EEM_Registration::status_id_not_approved :
1513
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
1514
-                $this->not_approve_registration($notify);
1515
-                break;
1516
-            case EEM_Registration::status_id_declined :
1517
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
1518
-                $this->decline_registration($notify);
1519
-                break;
1520
-            case EEM_Registration::status_id_cancelled :
1521
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
1522
-                $this->cancel_registration($notify);
1523
-                break;
1524
-            case EEM_Registration::status_id_wait_list :
1525
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') :
1526
-                $this->waitlist_registration($notify);
1527
-                break;
1528
-            case EEM_Registration::status_id_incomplete :
1529
-            default :
1530
-                $result['success'] = false;
1531
-                unset($this->_req_data['return']);
1532
-                $this->_reg_status_change_return('', false);
1533
-                break;
1534
-        }
1535
-    }
1536
-
1537
-
1538
-
1539
-    /**
1540
-     * approve_registration
1541
-     *
1542
-     * @access protected
1543
-     * @param bool $notify whether or not to notify the registrant about their approval.
1544
-     * @return void
1545
-     */
1546
-    protected function approve_registration($notify = false)
1547
-    {
1548
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1549
-    }
1550
-
1551
-
1552
-
1553
-    /**
1554
-     *        decline_registration
1555
-     *
1556
-     * @access protected
1557
-     * @param bool $notify whether or not to notify the registrant about their status change.
1558
-     * @return void
1559
-     */
1560
-    protected function decline_registration($notify = false)
1561
-    {
1562
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1563
-    }
1564
-
1565
-
1566
-
1567
-    /**
1568
-     *        cancel_registration
1569
-     *
1570
-     * @access protected
1571
-     * @param bool $notify whether or not to notify the registrant about their status change.
1572
-     * @return void
1573
-     */
1574
-    protected function cancel_registration($notify = false)
1575
-    {
1576
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1577
-    }
1578
-
1579
-
1580
-
1581
-    /**
1582
-     *        not_approve_registration
1583
-     *
1584
-     * @access protected
1585
-     * @param bool $notify whether or not to notify the registrant about their status change.
1586
-     * @return void
1587
-     */
1588
-    protected function not_approve_registration($notify = false)
1589
-    {
1590
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1591
-    }
1592
-
1593
-
1594
-
1595
-    /**
1596
-     *        decline_registration
1597
-     *
1598
-     * @access protected
1599
-     * @param bool $notify whether or not to notify the registrant about their status change.
1600
-     * @return void
1601
-     */
1602
-    protected function pending_registration($notify = false)
1603
-    {
1604
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1605
-    }
1606
-
1607
-
1608
-
1609
-    /**
1610
-     * waitlist_registration
1611
-     *
1612
-     * @access protected
1613
-     * @param bool $notify whether or not to notify the registrant about their status change.
1614
-     * @return void
1615
-     */
1616
-    protected function waitlist_registration($notify = false)
1617
-    {
1618
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1619
-    }
1620
-
1621
-
1622
-
1623
-    /**
1624
-     *        generates HTML for the Registration main meta box
1625
-     *
1626
-     * @access public
1627
-     * @return void
1628
-     */
1629
-    public function _reg_details_meta_box()
1630
-    {
1631
-        EEH_Autoloader::register_line_item_display_autoloaders();
1632
-        EEH_Autoloader::register_line_item_filter_autoloaders();
1633
-        EE_Registry::instance()->load_helper('Line_Item');
1634
-        $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
1635
-            : EE_Transaction::new_instance();
1636
-        $this->_session = $transaction->session_data();
1637
-        $filters = new EE_Line_Item_Filter_Collection();
1638
-        //$filters->add( new EE_Non_Zero_Line_Item_Filter() );
1639
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1640
-        $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
1641
-        $filtered_line_item_tree = $line_item_filter_processor->process();
1642
-        $line_item_display = new EE_Line_Item_Display('reg_admin_table',
1643
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
1644
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree,
1645
-            array('EE_Registration' => $this->_registration));
1646
-        $attendee = $this->_registration->attendee();
1647
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
1648
-            'espresso_transactions_view_transaction')
1649
-        ) {
1650
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array(
1651
-                'action' => 'view_transaction',
1652
-                'TXN_ID' => $transaction->ID(),
1653
-            ), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right',
1654
-                'dashicons dashicons-cart');
1655
-        } else {
1656
-            $this->_template_args['view_transaction_button'] = '';
1657
-        }
1658
-        if ($attendee instanceof EE_Attendee
1659
-            && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
1660
-                'espresso_registrations_resend_registration')
1661
-        ) {
1662
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array(
1663
-                'action'      => 'resend_registration',
1664
-                '_REG_ID'     => $this->_registration->ID(),
1665
-                'redirect_to' => 'view_registration',
1666
-            ), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right',
1667
-                'dashicons dashicons-email-alt');
1668
-        } else {
1669
-            $this->_template_args['resend_registration_button'] = '';
1670
-        }
1671
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1672
-        $payment = $transaction->get_first_related('Payment');
1673
-        $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
1674
-        $payment_method = $payment->get_first_related('Payment_Method');
1675
-        $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance()
1676
-            : $payment_method;
1677
-        $reg_details = array(
1678
-            'payment_method'       => $payment_method->name(),
1679
-            'response_msg'         => $payment->gateway_response(),
1680
-            'registration_id'      => $this->_registration->get('REG_code'),
1681
-            'registration_session' => $this->_registration->session_ID(),
1682
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
1683
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
1684
-        );
1685
-        if (isset($reg_details['registration_id'])) {
1686
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
1687
-            $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
1688
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
1689
-        }
1690
-        if (isset($reg_details['payment_method'])) {
1691
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
1692
-            $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method',
1693
-                'event_espresso');
1694
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
1695
-            $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
1696
-            $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response',
1697
-                'event_espresso');
1698
-            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
1699
-        }
1700
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
1701
-        $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session',
1702
-            'event_espresso');
1703
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
1704
-        $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
1705
-        $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP',
1706
-            'event_espresso');
1707
-        $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
1708
-        $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
1709
-        $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
1710
-        $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
1711
-        $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1712
-            'action'   => 'default',
1713
-            'event_id' => $this->_registration->event_ID(),
1714
-        ), REG_ADMIN_URL);
1715
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
1716
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
1717
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1718
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1719
-    }
1720
-
1721
-
1722
-
1723
-    /**
1724
-     * generates HTML for the Registration Questions meta box.
1725
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
1726
-     * otherwise uses new forms system
1727
-     *
1728
-     * @access public
1729
-     * @return void
1730
-     */
1731
-    public function _reg_questions_meta_box()
1732
-    {
1733
-        //allow someone to override this method entirely
1734
-        if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this,
1735
-            $this->_registration)) {
1736
-            $form = $this->_get_reg_custom_questions_form($this->_registration->ID());
1737
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : '';
1738
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
1739
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1740
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1741
-            echo EEH_Template::display_template($template_path, $this->_template_args, true);
1742
-        }
1743
-    }
1744
-
1745
-
1746
-
1747
-    /**
1748
-     * form_before_question_group
1749
-     *
1750
-     * @deprecated    as of 4.8.32.rc.000
1751
-     * @access        public
1752
-     * @param        string $output
1753
-     * @return        string
1754
-     */
1755
-    public function form_before_question_group($output)
1756
-    {
1757
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1758
-            __('This method would have been protected but was used on a filter callback'
1759
-               . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1760
-            '4.8.32.rc.000');
1761
-        return '
1152
+			}
1153
+			return $registrations;
1154
+		}
1155
+	}
1156
+
1157
+
1158
+
1159
+	public function get_registration_status_array()
1160
+	{
1161
+		return self::$_reg_status;
1162
+	}
1163
+
1164
+
1165
+
1166
+
1167
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1168
+	/**
1169
+	 *        generates HTML for the View Registration Details Admin page
1170
+	 *
1171
+	 * @access protected
1172
+	 * @return void
1173
+	 */
1174
+	protected function _registration_details()
1175
+	{
1176
+		$this->_template_args = array();
1177
+		$this->_set_registration_object();
1178
+		if (is_object($this->_registration)) {
1179
+			$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
1180
+				: EE_Transaction::new_instance();
1181
+			$this->_session = $transaction->session_data();
1182
+			$event_id = $this->_registration->event_ID();
1183
+			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1184
+			$this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso');
1185
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1186
+			$this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso');
1187
+			$this->_template_args['grand_total'] = $transaction->total();
1188
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1189
+			// link back to overview
1190
+			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1191
+			$this->_template_args['registration'] = $this->_registration;
1192
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1193
+				'action'   => 'default',
1194
+				'event_id' => $event_id,
1195
+			), REG_ADMIN_URL);
1196
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1197
+				'action' => 'default',
1198
+				'EVT_ID' => $event_id,
1199
+				'page'   => 'espresso_transactions',
1200
+			), admin_url('admin.php'));
1201
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1202
+				'page'   => 'espresso_events',
1203
+				'action' => 'edit',
1204
+				'post'   => $event_id,
1205
+			), admin_url('admin.php'));
1206
+			//next and previous links
1207
+			$next_reg = $this->_registration->next(null, array(), 'REG_ID');
1208
+			$this->_template_args['next_registration'] = $next_reg
1209
+				? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array(
1210
+					'action'  => 'view_registration',
1211
+					'_REG_ID' => $next_reg['REG_ID'],
1212
+				), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
1213
+			$previous_reg = $this->_registration->previous(null, array(), 'REG_ID');
1214
+			$this->_template_args['previous_registration'] = $previous_reg
1215
+				? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array(
1216
+					'action'  => 'view_registration',
1217
+					'_REG_ID' => $previous_reg['REG_ID'],
1218
+				), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1219
+			// grab header
1220
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1221
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1222
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path,
1223
+				$this->_template_args, true);
1224
+		} else {
1225
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1226
+		}
1227
+		// the details template wrapper
1228
+		$this->display_admin_page_with_sidebar();
1229
+	}
1230
+
1231
+
1232
+
1233
+	protected function _registration_details_metaboxes()
1234
+	{
1235
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1236
+		$this->_set_registration_object();
1237
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1238
+		add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'),
1239
+			array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1240
+		add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'),
1241
+			array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1242
+		if ($attendee instanceof EE_Attendee
1243
+			&& EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')
1244
+		) {
1245
+			add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'),
1246
+				array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high');
1247
+		}
1248
+		add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'),
1249
+			array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high');
1250
+		if ($this->_registration->group_size() > 1) {
1251
+			add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'),
1252
+				array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high');
1253
+		}
1254
+	}
1255
+
1256
+
1257
+
1258
+	/**
1259
+	 * set_reg_status_buttons_metabox
1260
+	 *
1261
+	 * @access protected
1262
+	 * @return string
1263
+	 * @throws \EE_Error
1264
+	 */
1265
+	public function set_reg_status_buttons_metabox()
1266
+	{
1267
+		$this->_set_registration_object();
1268
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1269
+		echo $change_reg_status_form->form_open(self::add_query_args_and_nonce(array(
1270
+			'action' => 'change_reg_status',
1271
+		), REG_ADMIN_URL));
1272
+		echo $change_reg_status_form->get_html();
1273
+		echo $change_reg_status_form->form_close();
1274
+	}
1275
+
1276
+
1277
+
1278
+	/**
1279
+	 * @return EE_Form_Section_Proper
1280
+	 */
1281
+	protected function _generate_reg_status_change_form()
1282
+	{
1283
+		return new EE_Form_Section_Proper(array(
1284
+				'name'            => 'reg_status_change_form',
1285
+				'html_id'         => 'reg-status-change-form',
1286
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1287
+				'subsections'     => array(
1288
+					'return'             => new EE_Hidden_Input(array(
1289
+						'name'    => 'return',
1290
+						'default' => 'view_registration',
1291
+					)),
1292
+					'REG_ID'             => new EE_Hidden_Input(array(
1293
+						'name'    => 'REG_ID',
1294
+						'default' => $this->_registration->ID(),
1295
+					)),
1296
+					'current_status'     => new EE_Form_Section_HTML(EEH_HTML::tr(EEH_HTML::th(EEH_HTML::label(EEH_HTML::strong(__('Current Registration Status',
1297
+							'event_espresso')))) . EEH_HTML::td(EEH_HTML::strong($this->_registration->pretty_status(),
1298
+							'', 'status-' . $this->_registration->status_ID(),
1299
+							'line-height: 1em; font-size: 1.5em; font-weight: bold;')))),
1300
+					'reg_status'         => new EE_Select_Input($this->_get_reg_statuses(), array(
1301
+							'html_label_text' => __('Change Registration Status to', 'event_espresso'),
1302
+							'default'         => $this->_registration->status_ID(),
1303
+						)),
1304
+					'send_notifications' => new EE_Yes_No_Input(array(
1305
+							'html_label_text' => __('Send Related Messages', 'event_espresso'),
1306
+							'default'         => false,
1307
+							'html_help_text'  => __('If set to "Yes", then the related messages will be sent to the registrant.',
1308
+								'event_espresso'),
1309
+						)),
1310
+					'submit'             => new EE_Submit_Input(array(
1311
+						'html_class'      => 'button-primary',
1312
+						'html_label_text' => '&nbsp;',
1313
+						'default'         => __('Update Registration Status', 'event_espresso'),
1314
+					)),
1315
+				),
1316
+			));
1317
+	}
1318
+
1319
+
1320
+
1321
+	/**
1322
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1323
+	 *
1324
+	 * @return string
1325
+	 */
1326
+	protected function _get_current_reg_status_help_text($STS_ID = '')
1327
+	{
1328
+		//$reg_status_help_text = array(
1329
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1330
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1331
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1332
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1333
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1334
+		//	'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ),
1335
+		//);
1336
+		//Approved
1337
+		//An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant .
1338
+		//Cancelled
1339
+		//	A {
1340
+		//	cancelled} registration is performed by the registrant . Payments are not allowed, the registration is inactive, and no space is reserved .
1341
+		//Declined
1342
+		//A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved .
1343
+		//Not Approved
1344
+		//A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved .
1345
+		//Pending Payment
1346
+		//A pending registration allows payments . The status will be automatically toggled to approved if the {
1347
+		//	payment} is made in full by registrant .
1348
+	}
1349
+
1350
+
1351
+
1352
+	/**
1353
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1354
+	 *
1355
+	 * @return array
1356
+	 */
1357
+	protected function _get_reg_statuses()
1358
+	{
1359
+		$reg_status_array = EEM_Registration::instance()->reg_status_array();
1360
+		unset ($reg_status_array[EEM_Registration::status_id_incomplete]);
1361
+		// get current reg status
1362
+		$current_status = $this->_registration->status_ID();
1363
+		// is registration for free event? This will determine whether to display the pending payment option
1364
+		if ($current_status != EEM_Registration::status_id_pending_payment
1365
+			&& $this->_registration->transaction()
1366
+								   ->is_free()
1367
+		) {
1368
+			unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1369
+		}
1370
+		return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1371
+	}
1372
+
1373
+
1374
+
1375
+	/**
1376
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1377
+	 *
1378
+	 * @param bool $status REG status given for changing registrations to.
1379
+	 * @param bool $notify Whether to send messages notifications or not.
1380
+	 * @return array  (array with reg_id(s) updated and whether update was successful.
1381
+	 */
1382
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1383
+	{
1384
+		if (isset($this->_req_data['reg_status_change_form'])) {
1385
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1386
+				? (array)$this->_req_data['reg_status_change_form']['REG_ID'] : array();
1387
+		} else {
1388
+			$REG_IDs = isset($this->_req_data['_REG_ID']) ? (array)$this->_req_data['_REG_ID'] : array();
1389
+		}
1390
+		$success = $this->_set_registration_status($REG_IDs, $status);
1391
+		//notify?
1392
+		if ($success
1393
+			&& $notify
1394
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message',
1395
+				'espresso_registrations_resend_registration')
1396
+		) {
1397
+			$this->_process_resend_registration();
1398
+		}
1399
+		return $success;
1400
+	}
1401
+
1402
+
1403
+
1404
+	/**
1405
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1406
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1407
+	 *
1408
+	 * @param array $REG_IDs
1409
+	 * @param bool  $status
1410
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1411
+	 *               the array of updated registrations).
1412
+	 */
1413
+	protected function _set_registration_status($REG_IDs = array(), $status = false)
1414
+	{
1415
+		$success = false;
1416
+		// typecast $REG_IDs
1417
+		$REG_IDs = (array)$REG_IDs;
1418
+		if ( ! empty($REG_IDs)) {
1419
+			$success = true;
1420
+			// set default status if none is passed
1421
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1422
+			// sanitize $REG_IDs
1423
+			$REG_IDs = array_filter($REG_IDs, 'absint');
1424
+			//loop through REG_ID's and change status
1425
+			foreach ($REG_IDs as $REG_ID) {
1426
+				$registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1427
+				if ($registration instanceof EE_Registration) {
1428
+					$registration->set_status($status);
1429
+					$result = $registration->save();
1430
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1431
+					$success = $result !== false ? $success : false;
1432
+				}
1433
+			}
1434
+		}
1435
+		//reset _req_data['_REG_ID'] for any potential future messages notifications
1436
+		$this->_req_data['_REG_ID'] = $REG_IDs;
1437
+		//return $success and processed registrations
1438
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1439
+	}
1440
+
1441
+
1442
+
1443
+	/**
1444
+	 * Common logic for setting up success message and redirecting to appropriate route
1445
+	 *
1446
+	 * @param  string $STS_ID status id for the registration changed to
1447
+	 * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1448
+	 * @return void
1449
+	 */
1450
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1451
+	{
1452
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1453
+			: array('success' => false);
1454
+		$success = isset($result['success']) && $result['success'];
1455
+		//setup success message
1456
+		if ($success) {
1457
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1458
+				$msg = sprintf(__('Registration status has been set to %s', 'event_espresso'),
1459
+					EEH_Template::pretty_status($STS_ID, false, 'lower'));
1460
+			} else {
1461
+				$msg = sprintf(__('Registrations have been set to %s.', 'event_espresso'),
1462
+					EEH_Template::pretty_status($STS_ID, false, 'lower'));
1463
+			}
1464
+			EE_Error::add_success($msg);
1465
+		} else {
1466
+			EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__,
1467
+				__LINE__, __FUNCTION__);
1468
+		}
1469
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
1470
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
1471
+		} else {
1472
+			$route = array('action' => 'default');
1473
+		}
1474
+		//unset nonces
1475
+		foreach ($this->_req_data as $ref => $value) {
1476
+			if (strpos($ref, 'nonce') !== false) {
1477
+				unset($this->_req_data[$ref]);
1478
+				continue;
1479
+			}
1480
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1481
+			$this->_req_data[$ref] = $value;
1482
+		}
1483
+		//merge request vars so that the reloaded list table contains any existing filter query params
1484
+		$route = array_merge($this->_req_data, $route);
1485
+		$this->_redirect_after_action($success, '', '', $route, true);
1486
+	}
1487
+
1488
+
1489
+
1490
+	/**
1491
+	 * incoming reg status change from reg details page.
1492
+	 *
1493
+	 * @return void
1494
+	 */
1495
+	protected function _change_reg_status()
1496
+	{
1497
+		$this->_req_data['return'] = 'view_registration';
1498
+		//set notify based on whether the send notifications toggle is set or not
1499
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
1500
+		//$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1501
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
1502
+			? $this->_req_data['reg_status_change_form']['reg_status'] : '';
1503
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
1504
+			case EEM_Registration::status_id_approved :
1505
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
1506
+				$this->approve_registration($notify);
1507
+				break;
1508
+			case EEM_Registration::status_id_pending_payment :
1509
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
1510
+				$this->pending_registration($notify);
1511
+				break;
1512
+			case EEM_Registration::status_id_not_approved :
1513
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
1514
+				$this->not_approve_registration($notify);
1515
+				break;
1516
+			case EEM_Registration::status_id_declined :
1517
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
1518
+				$this->decline_registration($notify);
1519
+				break;
1520
+			case EEM_Registration::status_id_cancelled :
1521
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
1522
+				$this->cancel_registration($notify);
1523
+				break;
1524
+			case EEM_Registration::status_id_wait_list :
1525
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') :
1526
+				$this->waitlist_registration($notify);
1527
+				break;
1528
+			case EEM_Registration::status_id_incomplete :
1529
+			default :
1530
+				$result['success'] = false;
1531
+				unset($this->_req_data['return']);
1532
+				$this->_reg_status_change_return('', false);
1533
+				break;
1534
+		}
1535
+	}
1536
+
1537
+
1538
+
1539
+	/**
1540
+	 * approve_registration
1541
+	 *
1542
+	 * @access protected
1543
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1544
+	 * @return void
1545
+	 */
1546
+	protected function approve_registration($notify = false)
1547
+	{
1548
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1549
+	}
1550
+
1551
+
1552
+
1553
+	/**
1554
+	 *        decline_registration
1555
+	 *
1556
+	 * @access protected
1557
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1558
+	 * @return void
1559
+	 */
1560
+	protected function decline_registration($notify = false)
1561
+	{
1562
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1563
+	}
1564
+
1565
+
1566
+
1567
+	/**
1568
+	 *        cancel_registration
1569
+	 *
1570
+	 * @access protected
1571
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1572
+	 * @return void
1573
+	 */
1574
+	protected function cancel_registration($notify = false)
1575
+	{
1576
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1577
+	}
1578
+
1579
+
1580
+
1581
+	/**
1582
+	 *        not_approve_registration
1583
+	 *
1584
+	 * @access protected
1585
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1586
+	 * @return void
1587
+	 */
1588
+	protected function not_approve_registration($notify = false)
1589
+	{
1590
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1591
+	}
1592
+
1593
+
1594
+
1595
+	/**
1596
+	 *        decline_registration
1597
+	 *
1598
+	 * @access protected
1599
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1600
+	 * @return void
1601
+	 */
1602
+	protected function pending_registration($notify = false)
1603
+	{
1604
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1605
+	}
1606
+
1607
+
1608
+
1609
+	/**
1610
+	 * waitlist_registration
1611
+	 *
1612
+	 * @access protected
1613
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1614
+	 * @return void
1615
+	 */
1616
+	protected function waitlist_registration($notify = false)
1617
+	{
1618
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1619
+	}
1620
+
1621
+
1622
+
1623
+	/**
1624
+	 *        generates HTML for the Registration main meta box
1625
+	 *
1626
+	 * @access public
1627
+	 * @return void
1628
+	 */
1629
+	public function _reg_details_meta_box()
1630
+	{
1631
+		EEH_Autoloader::register_line_item_display_autoloaders();
1632
+		EEH_Autoloader::register_line_item_filter_autoloaders();
1633
+		EE_Registry::instance()->load_helper('Line_Item');
1634
+		$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
1635
+			: EE_Transaction::new_instance();
1636
+		$this->_session = $transaction->session_data();
1637
+		$filters = new EE_Line_Item_Filter_Collection();
1638
+		//$filters->add( new EE_Non_Zero_Line_Item_Filter() );
1639
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1640
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
1641
+		$filtered_line_item_tree = $line_item_filter_processor->process();
1642
+		$line_item_display = new EE_Line_Item_Display('reg_admin_table',
1643
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
1644
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree,
1645
+			array('EE_Registration' => $this->_registration));
1646
+		$attendee = $this->_registration->attendee();
1647
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
1648
+			'espresso_transactions_view_transaction')
1649
+		) {
1650
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array(
1651
+				'action' => 'view_transaction',
1652
+				'TXN_ID' => $transaction->ID(),
1653
+			), TXN_ADMIN_URL), esc_html__(' View Transaction'), 'button secondary-button right',
1654
+				'dashicons dashicons-cart');
1655
+		} else {
1656
+			$this->_template_args['view_transaction_button'] = '';
1657
+		}
1658
+		if ($attendee instanceof EE_Attendee
1659
+			&& EE_Registry::instance()->CAP->current_user_can('ee_send_message',
1660
+				'espresso_registrations_resend_registration')
1661
+		) {
1662
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array(
1663
+				'action'      => 'resend_registration',
1664
+				'_REG_ID'     => $this->_registration->ID(),
1665
+				'redirect_to' => 'view_registration',
1666
+			), REG_ADMIN_URL), esc_html__(' Resend Registration'), 'button secondary-button right',
1667
+				'dashicons dashicons-email-alt');
1668
+		} else {
1669
+			$this->_template_args['resend_registration_button'] = '';
1670
+		}
1671
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1672
+		$payment = $transaction->get_first_related('Payment');
1673
+		$payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
1674
+		$payment_method = $payment->get_first_related('Payment_Method');
1675
+		$payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance()
1676
+			: $payment_method;
1677
+		$reg_details = array(
1678
+			'payment_method'       => $payment_method->name(),
1679
+			'response_msg'         => $payment->gateway_response(),
1680
+			'registration_id'      => $this->_registration->get('REG_code'),
1681
+			'registration_session' => $this->_registration->session_ID(),
1682
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
1683
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
1684
+		);
1685
+		if (isset($reg_details['registration_id'])) {
1686
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
1687
+			$this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
1688
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
1689
+		}
1690
+		if (isset($reg_details['payment_method'])) {
1691
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
1692
+			$this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method',
1693
+				'event_espresso');
1694
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
1695
+			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
1696
+			$this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response',
1697
+				'event_espresso');
1698
+			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
1699
+		}
1700
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
1701
+		$this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session',
1702
+			'event_espresso');
1703
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
1704
+		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
1705
+		$this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP',
1706
+			'event_espresso');
1707
+		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
1708
+		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
1709
+		$this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
1710
+		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
1711
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
1712
+			'action'   => 'default',
1713
+			'event_id' => $this->_registration->event_ID(),
1714
+		), REG_ADMIN_URL);
1715
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
1716
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
1717
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1718
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1719
+	}
1720
+
1721
+
1722
+
1723
+	/**
1724
+	 * generates HTML for the Registration Questions meta box.
1725
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
1726
+	 * otherwise uses new forms system
1727
+	 *
1728
+	 * @access public
1729
+	 * @return void
1730
+	 */
1731
+	public function _reg_questions_meta_box()
1732
+	{
1733
+		//allow someone to override this method entirely
1734
+		if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this,
1735
+			$this->_registration)) {
1736
+			$form = $this->_get_reg_custom_questions_form($this->_registration->ID());
1737
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : '';
1738
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
1739
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1740
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1741
+			echo EEH_Template::display_template($template_path, $this->_template_args, true);
1742
+		}
1743
+	}
1744
+
1745
+
1746
+
1747
+	/**
1748
+	 * form_before_question_group
1749
+	 *
1750
+	 * @deprecated    as of 4.8.32.rc.000
1751
+	 * @access        public
1752
+	 * @param        string $output
1753
+	 * @return        string
1754
+	 */
1755
+	public function form_before_question_group($output)
1756
+	{
1757
+		EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1758
+			__('This method would have been protected but was used on a filter callback'
1759
+			   . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1760
+			'4.8.32.rc.000');
1761
+		return '
1762 1762
 	<table class="form-table ee-width-100">
1763 1763
 		<tbody>
1764 1764
 			';
1765
-    }
1766
-
1767
-
1768
-
1769
-    /**
1770
-     * form_after_question_group
1771
-     *
1772
-     * @deprecated    as of 4.8.32.rc.000
1773
-     * @access        public
1774
-     * @param        string $output
1775
-     * @return        string
1776
-     */
1777
-    public function form_after_question_group($output)
1778
-    {
1779
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1780
-            __('This method would have been protected but was used on a filter callback'
1781
-               . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1782
-            '4.8.32.rc.000');
1783
-        return '
1765
+	}
1766
+
1767
+
1768
+
1769
+	/**
1770
+	 * form_after_question_group
1771
+	 *
1772
+	 * @deprecated    as of 4.8.32.rc.000
1773
+	 * @access        public
1774
+	 * @param        string $output
1775
+	 * @return        string
1776
+	 */
1777
+	public function form_after_question_group($output)
1778
+	{
1779
+		EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1780
+			__('This method would have been protected but was used on a filter callback'
1781
+			   . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1782
+			'4.8.32.rc.000');
1783
+		return '
1784 1784
 			<tr class="hide-if-no-js">
1785 1785
 				<th> </th>
1786 1786
 				<td class="reg-admin-edit-attendee-question-td">
1787 1787
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
1788
-               . esc_attr__('click to edit question', 'event_espresso')
1789
-               . '">
1788
+			   . esc_attr__('click to edit question', 'event_espresso')
1789
+			   . '">
1790 1790
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
1791
-               . __('edit the above question group', 'event_espresso')
1792
-               . '</span>
1791
+			   . __('edit the above question group', 'event_espresso')
1792
+			   . '</span>
1793 1793
 						<div class="dashicons dashicons-edit"></div>
1794 1794
 					</a>
1795 1795
 				</td>
@@ -1797,506 +1797,506 @@  discard block
 block discarded – undo
1797 1797
 		</tbody>
1798 1798
 	</table>
1799 1799
 ';
1800
-    }
1801
-
1802
-
1803
-
1804
-    /**
1805
-     * form_form_field_label_wrap
1806
-     *
1807
-     * @deprecated    as of 4.8.32.rc.000
1808
-     * @access        public
1809
-     * @param        string $label
1810
-     * @return        string
1811
-     */
1812
-    public function form_form_field_label_wrap($label)
1813
-    {
1814
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1815
-            __('This method would have been protected but was used on a filter callback'
1816
-               . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1817
-            '4.8.32.rc.000');
1818
-        return '
1800
+	}
1801
+
1802
+
1803
+
1804
+	/**
1805
+	 * form_form_field_label_wrap
1806
+	 *
1807
+	 * @deprecated    as of 4.8.32.rc.000
1808
+	 * @access        public
1809
+	 * @param        string $label
1810
+	 * @return        string
1811
+	 */
1812
+	public function form_form_field_label_wrap($label)
1813
+	{
1814
+		EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1815
+			__('This method would have been protected but was used on a filter callback'
1816
+			   . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1817
+			'4.8.32.rc.000');
1818
+		return '
1819 1819
 			<tr>
1820 1820
 				<th>
1821 1821
 					' . $label . '
1822 1822
 				</th>';
1823
-    }
1824
-
1825
-
1826
-
1827
-    /**
1828
-     * form_form_field_input__wrap
1829
-     *
1830
-     * @deprecated    as of 4.8.32.rc.000
1831
-     * @access        public
1832
-     * @param        string $input
1833
-     * @return        string
1834
-     */
1835
-    public function form_form_field_input__wrap($input)
1836
-    {
1837
-        EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1838
-            __('This method would have been protected but was used on a filter callback'
1839
-               . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1840
-            '4.8.32.rc.000');
1841
-        return '
1823
+	}
1824
+
1825
+
1826
+
1827
+	/**
1828
+	 * form_form_field_input__wrap
1829
+	 *
1830
+	 * @deprecated    as of 4.8.32.rc.000
1831
+	 * @access        public
1832
+	 * @param        string $input
1833
+	 * @return        string
1834
+	 */
1835
+	public function form_form_field_input__wrap($input)
1836
+	{
1837
+		EE_Error::doing_it_wrong(__CLASS__ . '::' . __FUNCTION__,
1838
+			__('This method would have been protected but was used on a filter callback'
1839
+			   . 'so needed to be public. Please discontinue usage as it will be removed soon.', 'event_espresso'),
1840
+			'4.8.32.rc.000');
1841
+		return '
1842 1842
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
1843 1843
 					' . $input . '
1844 1844
 				</td>
1845 1845
 			</tr>';
1846
-    }
1847
-
1848
-
1849
-
1850
-    /**
1851
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
1852
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
1853
-     * to display the page
1854
-     *
1855
-     * @access protected
1856
-     * @return void
1857
-     */
1858
-    protected function _update_attendee_registration_form()
1859
-    {
1860
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
1861
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1862
-            $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
1863
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
1864
-            if ($success) {
1865
-                $what = __('Registration Form', 'event_espresso');
1866
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
1867
-                    : array('action' => 'default');
1868
-                $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
1869
-            }
1870
-        }
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Gets the form for saving registrations custom questions (if done
1877
-     * previously retrieves the cached form object, which may have validation errors in it)
1878
-     *
1879
-     * @param int $REG_ID
1880
-     * @return EE_Registration_Custom_Questions_Form
1881
-     */
1882
-    protected function _get_reg_custom_questions_form($REG_ID)
1883
-    {
1884
-        if ( ! $this->_reg_custom_questions_form) {
1885
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
1886
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()
1887
-                                                                                                          ->get_one_by_ID($REG_ID));
1888
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
1889
-        }
1890
-        return $this->_reg_custom_questions_form;
1891
-    }
1892
-
1893
-
1894
-
1895
-    /**
1896
-     * Saves
1897
-     *
1898
-     * @access private
1899
-     * @param bool $REG_ID
1900
-     * @return bool
1901
-     */
1902
-    private function _save_reg_custom_questions_form($REG_ID = false)
1903
-    {
1904
-        if ( ! $REG_ID) {
1905
-            EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__,
1906
-                __FUNCTION__, __LINE__);
1907
-        }
1908
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
1909
-        $form->receive_form_submission($this->_req_data);
1910
-        $success = false;
1911
-        if ($form->is_valid()) {
1912
-            foreach ($form->subforms() as $question_group_id => $question_group_form) {
1913
-                foreach ($question_group_form->inputs() as $question_id => $input) {
1914
-                    $where_conditions = array(
1915
-                        'QST_ID' => $question_id,
1916
-                        'REG_ID' => $REG_ID,
1917
-                    );
1918
-                    $possibly_new_values = array(
1919
-                        'ANS_value' => $input->normalized_value(),
1920
-                    );
1921
-                    $answer = EEM_Answer::instance()->get_one(array($where_conditions));
1922
-                    if ($answer instanceof EE_Answer) {
1923
-                        $success = $answer->save($possibly_new_values);
1924
-                    } else {
1925
-                        //insert it then
1926
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
1927
-                        $answer = EE_Answer::new_instance($cols_n_vals);
1928
-                        $success = $answer->save();
1929
-                    }
1930
-                }
1931
-            }
1932
-        } else {
1933
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
1934
-        }
1935
-        return $success;
1936
-    }
1937
-
1938
-
1939
-
1940
-    /**
1941
-     *        generates HTML for the Registration main meta box
1942
-     *
1943
-     * @access public
1944
-     * @return void
1945
-     */
1946
-    public function _reg_attendees_meta_box()
1947
-    {
1948
-        $REG = EEM_Registration::instance();
1949
-        //get all other registrations on this transaction, and cache
1950
-        //the attendees for them so we don't have to run another query using force_join
1951
-        $registrations = $REG->get_all(array(
1952
-            array(
1953
-                'TXN_ID' => $this->_registration->transaction_ID(),
1954
-                'REG_ID' => array('!=', $this->_registration->ID()),
1955
-            ),
1956
-            'force_join' => array('Attendee'),
1957
-        ));
1958
-        $this->_template_args['attendees'] = array();
1959
-        $this->_template_args['attendee_notice'] = '';
1960
-        if (empty($registrations)
1961
-            || (is_array($registrations)
1962
-                && ! EEH_Array::get_one_item_from_array($registrations))
1963
-        ) {
1964
-            EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration',
1965
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1966
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
1967
-        } else {
1968
-            $att_nmbr = 1;
1969
-            foreach ($registrations as $registration) {
1970
-                /* @var $registration EE_Registration */
1971
-                $attendee = $registration->attendee()
1972
-                    ? $registration->attendee()
1973
-                    : EEM_Attendee::instance()
1974
-                                  ->create_default_object();
1975
-                $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
1976
-                $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1977
-                $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1978
-                $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1979
-                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1980
-                $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ',
1981
-                    $attendee->full_address_as_array());
1982
-                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array(
1983
-                    'action' => 'edit_attendee',
1984
-                    'post'   => $attendee->ID(),
1985
-                ), REG_ADMIN_URL);
1986
-                $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name();
1987
-                $att_nmbr++;
1988
-            }
1989
-            //EEH_Debug_Tools::printr( $attendees, '$attendees  <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' );
1990
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1991
-            //			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
1992
-        }
1993
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
1994
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1995
-    }
1996
-
1997
-
1998
-
1999
-    /**
2000
-     *        generates HTML for the Edit Registration side meta box
2001
-     *
2002
-     * @access public
2003
-     * @return void
2004
-     */
2005
-    public function _reg_registrant_side_meta_box()
2006
-    {
2007
-        /*@var $attendee EE_Attendee */
2008
-        $att_check = $this->_registration->attendee();
2009
-        $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2010
-        //now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not)
2011
-        if ( ! $this->_registration->is_primary_registrant()) {
2012
-            $primary_registration = $this->_registration->get_primary_registration();
2013
-            $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2014
-                : null;
2015
-            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2016
-                //in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
2017
-                $primary_registration = null;
2018
-            }
2019
-        } else {
2020
-            $primary_registration = null;
2021
-        }
2022
-        $this->_template_args['ATT_ID'] = $attendee->ID();
2023
-        $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
2024
-        $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
2025
-        $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
2026
-        $this->_template_args['phone'] = $attendee->phone();
2027
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2028
-        //edit link
2029
-        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
2030
-            'action' => 'edit_attendee',
2031
-            'post'   => $attendee->ID(),
2032
-        ), REG_ADMIN_URL);
2033
-        $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso');
2034
-        //create link
2035
-        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2036
-            ? EE_Admin_Page::add_query_args_and_nonce(array(
2037
-                'action'  => 'duplicate_attendee',
2038
-                '_REG_ID' => $this->_registration->ID(),
2039
-            ), REG_ADMIN_URL) : '';
2040
-        $this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
2041
-        $this->_template_args['att_check'] = $att_check;
2042
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2043
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2044
-    }
2045
-
2046
-
2047
-
2048
-    /**
2049
-     * trash or restore registrations
2050
-     *
2051
-     * @param  boolean $trash whether to archive or restore
2052
-     * @access protected
2053
-     * @return void
2054
-     */
2055
-    protected function _trash_or_restore_registrations($trash = true)
2056
-    {
2057
-        $REGM = EEM_Registration::instance();
2058
-        $success = 1;
2059
-        $error = 0;
2060
-        $tickets = array();
2061
-        $dtts = array();
2062
-        //if empty _REG_ID then get out because there's nothing to do
2063
-        if (empty($this->_req_data['_REG_ID'])) {
2064
-            $msg = $trash
2065
-                ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.',
2066
-                    'event_espresso')
2067
-                : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.',
2068
-                    'event_espresso');
2069
-            EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__);
2070
-            $this->_redirect_after_action(false, '', '', array(), true);
2071
-        }
2072
-        //Checkboxes
2073
-        if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2074
-            // if array has more than one element than success message should be plural
2075
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2076
-            // cycle thru checkboxes
2077
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2078
-                /** @var EE_Registration $REG */
2079
-                $REG = $REGM->get_one_by_ID($REG_ID);
2080
-                $payment_count = $REG->get_first_related('Transaction')->count_related('Payment');
2081
-                if ($payment_count > 0) {
2082
-                    $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name()
2083
-                        : __('Unknown Attendee', 'event_espresso');
2084
-                    $error = 1;
2085
-                    $success = 0;
2086
-                    EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2087
-                        'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__);
2088
-                    continue; //can't trash this registration because it has payments.
2089
-                }
2090
-                $ticket = $REG->get_first_related('Ticket');
2091
-                $tickets[$ticket->ID()] = $ticket;
2092
-                $dtt = $ticket->get_many_related('Datetime');
2093
-                $dtts = array_merge($dtts, $dtt);
2094
-                $updated = $trash ? $REG->delete() : $REG->restore();
2095
-                if ( ! $updated) {
2096
-                    $success = 0;
2097
-                } else {
2098
-                    $success = 2;
2099
-                }/**/
2100
-            }
2101
-        } else {
2102
-            // grab single id and delete
2103
-            $REG_ID = absint($this->_req_data['_REG_ID']);
2104
-            $REG = $REGM->get_one_by_ID($REG_ID);
2105
-            $ticket = $REG->get_first_related('Ticket');
2106
-            $tickets[$ticket->ID()] = $ticket;
2107
-            $dtts = $ticket->get_many_related('Datetime');
2108
-            $updated = $trash ? $REG->delete() : $REG->restore();
2109
-            if ( ! $updated) {
2110
-                $success = 0;
2111
-            }
2112
-        }
2113
-        //now let's update counts
2114
-        EEM_Ticket::instance()->update_tickets_sold($tickets);
2115
-        EEM_Datetime::instance()->update_sold($dtts);
2116
-        $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2117
-        $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2118
-        $overwrite_msgs = $error ? true : false;
2119
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs);
2120
-    }
2121
-
2122
-
2123
-
2124
-    /**
2125
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2126
-     * registration but also.
2127
-     * 1. Removing relations to EE_Attendee
2128
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2129
-     * ALSO trashed.
2130
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2131
-     * 4. Removing relationships between all tickets and the related registrations
2132
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2133
-     * 6. Deleting permanently any related Checkins.
2134
-     *
2135
-     * @return void
2136
-     */
2137
-    protected function _delete_registrations()
2138
-    {
2139
-        $REG_MDL = EEM_Registration::instance();
2140
-        $success = 1;
2141
-        //Checkboxes
2142
-        if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2143
-            // if array has more than one element than success message should be plural
2144
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2145
-            // cycle thru checkboxes
2146
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2147
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2148
-                if ( ! $REG instanceof EE_Registration) {
2149
-                    continue;
2150
-                }
2151
-                $deleted = $this->_delete_registration($REG);
2152
-                if ( ! $deleted) {
2153
-                    $success = 0;
2154
-                }
2155
-            }
2156
-        } else {
2157
-            // grab single id and delete
2158
-            $REG_ID = $this->_req_data['_REG_ID'];
2159
-            $REG = $REG_MDL->get_one_by_ID($REG_ID);
2160
-            $deleted = $this->_delete_registration($REG);
2161
-            if ( ! $deleted) {
2162
-                $success = 0;
2163
-            }
2164
-        }
2165
-        $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2166
-        $action_desc = __('permanently deleted.', 'event_espresso');
2167
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true);
2168
-    }
2169
-
2170
-
2171
-
2172
-    /**
2173
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2174
-     * models get affected.
2175
-     *
2176
-     * @param  EE_Registration $REG registration to be deleted permenantly
2177
-     * @return boolean              true = successful deletion, false = fail.
2178
-     */
2179
-    protected function _delete_registration(EE_Registration $REG)
2180
-    {
2181
-        //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed.
2182
-        $TXN = $REG->get_first_related('Transaction');
2183
-        $REGS = $TXN->get_many_related('Registration');
2184
-        $all_trashed = true;
2185
-        foreach ($REGS as $registration) {
2186
-            if ( ! $registration->get('REG_deleted')) {
2187
-                $all_trashed = false;
2188
-            }
2189
-        }
2190
-        if ( ! $all_trashed) {
2191
-            EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2192
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2193
-            return false;
2194
-        }
2195
-        //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one).
2196
-        foreach ($REGS as $registration) {
2197
-            //delete related answers
2198
-            $registration->delete_related_permanently('Answer');
2199
-            //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2200
-            $attendee = $registration->get_first_related('Attendee');
2201
-            if ($attendee instanceof EE_Attendee) {
2202
-                $registration->_remove_relation_to($attendee, 'Attendee');
2203
-            }
2204
-            //now remove relationships to tickets on this registration.
2205
-            $registration->_remove_relations('Ticket');
2206
-            //now delete permanently the checkins related to this registration.
2207
-            $registration->delete_related_permanently('Checkin');
2208
-            if ($registration->ID() === $REG->ID()) {
2209
-                continue;
2210
-            } //we don't want to delete permanently the existing registration just yet.
2211
-            //remove relation to transaction for these registrations if NOT the existing registrations
2212
-            $registration->_remove_relations('Transaction');
2213
-            //delete permanently any related messages.
2214
-            $registration->delete_related_permanently('Message');
2215
-            //now delete this registration permanently
2216
-            $registration->delete_permanently();
2217
-        }
2218
-        //now all related registrations on the transaction are handled.  So let's just handle this registration itself (the transaction and line items should be all that's left).
2219
-        //delete the line items related to the transaction for this registration.
2220
-        $TXN->delete_related_permanently('Line_Item');
2221
-        //we need to remove all the relationships on the transaction
2222
-        $TXN->delete_related_permanently('Payment');
2223
-        $TXN->delete_related_permanently('Extra_Meta');
2224
-        $TXN->delete_related_permanently('Message');
2225
-        //now we can delete this REG permanently (and the transaction of course)
2226
-        $REG->delete_related_permanently('Transaction');
2227
-        return $REG->delete_permanently();
2228
-    }
2229
-
2230
-
2231
-
2232
-    /**
2233
-     *    generates HTML for the Register New Attendee Admin page
2234
-     *
2235
-     * @access private
2236
-     * @throws \EE_Error
2237
-     * @return void
2238
-     */
2239
-    public function new_registration()
2240
-    {
2241
-        if ( ! $this->_set_reg_event()) {
2242
-            throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request',
2243
-                'event_espresso'));
2244
-        }
2245
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2246
-        // gotta start with a clean slate if we're not coming here via ajax
2247
-        if ( ! defined('DOING_AJAX')
2248
-             && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2249
-        ) {
2250
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2251
-        }
2252
-        $this->_template_args['event_name'] = '';
2253
-        // event name
2254
-        if ($this->_reg_event) {
2255
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2256
-            $edit_event_url = self::add_query_args_and_nonce(array(
2257
-                'action' => 'edit',
2258
-                'post'   => $this->_reg_event->ID(),
2259
-            ), EVENTS_ADMIN_URL);
2260
-            $edit_event_lnk = '<a href="'
2261
-                              . $edit_event_url
2262
-                              . '" title="'
2263
-                              . esc_attr__('Edit ', 'event_espresso')
2264
-                              . $this->_reg_event->name()
2265
-                              . '">'
2266
-                              . __('Edit Event', 'event_espresso')
2267
-                              . '</a>';
2268
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2269
-                                                   . $edit_event_lnk
2270
-                                                   . '</span>';
2271
-        }
2272
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2273
-        if (defined('DOING_AJAX')) {
2274
-            $this->_return_json();
2275
-        }
2276
-        // grab header
2277
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2278
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
2279
-            $this->_template_args, true);
2280
-        //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2281
-        // the details template wrapper
2282
-        $this->display_admin_page_with_sidebar();
2283
-    }
2284
-
2285
-
2286
-
2287
-    /**
2288
-     * This returns the content for a registration step
2289
-     *
2290
-     * @access protected
2291
-     * @return string html
2292
-     */
2293
-    protected function _get_registration_step_content()
2294
-    {
2295
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2296
-            $warning_msg = sprintf(__('%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2297
-                'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">',
2298
-                '<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>');
2299
-            return '
1846
+	}
1847
+
1848
+
1849
+
1850
+	/**
1851
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
1852
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
1853
+	 * to display the page
1854
+	 *
1855
+	 * @access protected
1856
+	 * @return void
1857
+	 */
1858
+	protected function _update_attendee_registration_form()
1859
+	{
1860
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
1861
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1862
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
1863
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
1864
+			if ($success) {
1865
+				$what = __('Registration Form', 'event_espresso');
1866
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
1867
+					: array('action' => 'default');
1868
+				$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
1869
+			}
1870
+		}
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Gets the form for saving registrations custom questions (if done
1877
+	 * previously retrieves the cached form object, which may have validation errors in it)
1878
+	 *
1879
+	 * @param int $REG_ID
1880
+	 * @return EE_Registration_Custom_Questions_Form
1881
+	 */
1882
+	protected function _get_reg_custom_questions_form($REG_ID)
1883
+	{
1884
+		if ( ! $this->_reg_custom_questions_form) {
1885
+			require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
1886
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()
1887
+																										  ->get_one_by_ID($REG_ID));
1888
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
1889
+		}
1890
+		return $this->_reg_custom_questions_form;
1891
+	}
1892
+
1893
+
1894
+
1895
+	/**
1896
+	 * Saves
1897
+	 *
1898
+	 * @access private
1899
+	 * @param bool $REG_ID
1900
+	 * @return bool
1901
+	 */
1902
+	private function _save_reg_custom_questions_form($REG_ID = false)
1903
+	{
1904
+		if ( ! $REG_ID) {
1905
+			EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__,
1906
+				__FUNCTION__, __LINE__);
1907
+		}
1908
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
1909
+		$form->receive_form_submission($this->_req_data);
1910
+		$success = false;
1911
+		if ($form->is_valid()) {
1912
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
1913
+				foreach ($question_group_form->inputs() as $question_id => $input) {
1914
+					$where_conditions = array(
1915
+						'QST_ID' => $question_id,
1916
+						'REG_ID' => $REG_ID,
1917
+					);
1918
+					$possibly_new_values = array(
1919
+						'ANS_value' => $input->normalized_value(),
1920
+					);
1921
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
1922
+					if ($answer instanceof EE_Answer) {
1923
+						$success = $answer->save($possibly_new_values);
1924
+					} else {
1925
+						//insert it then
1926
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
1927
+						$answer = EE_Answer::new_instance($cols_n_vals);
1928
+						$success = $answer->save();
1929
+					}
1930
+				}
1931
+			}
1932
+		} else {
1933
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
1934
+		}
1935
+		return $success;
1936
+	}
1937
+
1938
+
1939
+
1940
+	/**
1941
+	 *        generates HTML for the Registration main meta box
1942
+	 *
1943
+	 * @access public
1944
+	 * @return void
1945
+	 */
1946
+	public function _reg_attendees_meta_box()
1947
+	{
1948
+		$REG = EEM_Registration::instance();
1949
+		//get all other registrations on this transaction, and cache
1950
+		//the attendees for them so we don't have to run another query using force_join
1951
+		$registrations = $REG->get_all(array(
1952
+			array(
1953
+				'TXN_ID' => $this->_registration->transaction_ID(),
1954
+				'REG_ID' => array('!=', $this->_registration->ID()),
1955
+			),
1956
+			'force_join' => array('Attendee'),
1957
+		));
1958
+		$this->_template_args['attendees'] = array();
1959
+		$this->_template_args['attendee_notice'] = '';
1960
+		if (empty($registrations)
1961
+			|| (is_array($registrations)
1962
+				&& ! EEH_Array::get_one_item_from_array($registrations))
1963
+		) {
1964
+			EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration',
1965
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1966
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
1967
+		} else {
1968
+			$att_nmbr = 1;
1969
+			foreach ($registrations as $registration) {
1970
+				/* @var $registration EE_Registration */
1971
+				$attendee = $registration->attendee()
1972
+					? $registration->attendee()
1973
+					: EEM_Attendee::instance()
1974
+								  ->create_default_object();
1975
+				$this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
1976
+				$this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1977
+				$this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1978
+				$this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1979
+				$this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1980
+				$this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ',
1981
+					$attendee->full_address_as_array());
1982
+				$this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array(
1983
+					'action' => 'edit_attendee',
1984
+					'post'   => $attendee->ID(),
1985
+				), REG_ADMIN_URL);
1986
+				$this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name();
1987
+				$att_nmbr++;
1988
+			}
1989
+			//EEH_Debug_Tools::printr( $attendees, '$attendees  <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' );
1990
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1991
+			//			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
1992
+		}
1993
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
1994
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1995
+	}
1996
+
1997
+
1998
+
1999
+	/**
2000
+	 *        generates HTML for the Edit Registration side meta box
2001
+	 *
2002
+	 * @access public
2003
+	 * @return void
2004
+	 */
2005
+	public function _reg_registrant_side_meta_box()
2006
+	{
2007
+		/*@var $attendee EE_Attendee */
2008
+		$att_check = $this->_registration->attendee();
2009
+		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2010
+		//now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not)
2011
+		if ( ! $this->_registration->is_primary_registrant()) {
2012
+			$primary_registration = $this->_registration->get_primary_registration();
2013
+			$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2014
+				: null;
2015
+			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2016
+				//in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
2017
+				$primary_registration = null;
2018
+			}
2019
+		} else {
2020
+			$primary_registration = null;
2021
+		}
2022
+		$this->_template_args['ATT_ID'] = $attendee->ID();
2023
+		$this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
2024
+		$this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
2025
+		$this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
2026
+		$this->_template_args['phone'] = $attendee->phone();
2027
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2028
+		//edit link
2029
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array(
2030
+			'action' => 'edit_attendee',
2031
+			'post'   => $attendee->ID(),
2032
+		), REG_ADMIN_URL);
2033
+		$this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso');
2034
+		//create link
2035
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2036
+			? EE_Admin_Page::add_query_args_and_nonce(array(
2037
+				'action'  => 'duplicate_attendee',
2038
+				'_REG_ID' => $this->_registration->ID(),
2039
+			), REG_ADMIN_URL) : '';
2040
+		$this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
2041
+		$this->_template_args['att_check'] = $att_check;
2042
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2043
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2044
+	}
2045
+
2046
+
2047
+
2048
+	/**
2049
+	 * trash or restore registrations
2050
+	 *
2051
+	 * @param  boolean $trash whether to archive or restore
2052
+	 * @access protected
2053
+	 * @return void
2054
+	 */
2055
+	protected function _trash_or_restore_registrations($trash = true)
2056
+	{
2057
+		$REGM = EEM_Registration::instance();
2058
+		$success = 1;
2059
+		$error = 0;
2060
+		$tickets = array();
2061
+		$dtts = array();
2062
+		//if empty _REG_ID then get out because there's nothing to do
2063
+		if (empty($this->_req_data['_REG_ID'])) {
2064
+			$msg = $trash
2065
+				? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.',
2066
+					'event_espresso')
2067
+				: __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.',
2068
+					'event_espresso');
2069
+			EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__);
2070
+			$this->_redirect_after_action(false, '', '', array(), true);
2071
+		}
2072
+		//Checkboxes
2073
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2074
+			// if array has more than one element than success message should be plural
2075
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2076
+			// cycle thru checkboxes
2077
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2078
+				/** @var EE_Registration $REG */
2079
+				$REG = $REGM->get_one_by_ID($REG_ID);
2080
+				$payment_count = $REG->get_first_related('Transaction')->count_related('Payment');
2081
+				if ($payment_count > 0) {
2082
+					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name()
2083
+						: __('Unknown Attendee', 'event_espresso');
2084
+					$error = 1;
2085
+					$success = 0;
2086
+					EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2087
+						'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__);
2088
+					continue; //can't trash this registration because it has payments.
2089
+				}
2090
+				$ticket = $REG->get_first_related('Ticket');
2091
+				$tickets[$ticket->ID()] = $ticket;
2092
+				$dtt = $ticket->get_many_related('Datetime');
2093
+				$dtts = array_merge($dtts, $dtt);
2094
+				$updated = $trash ? $REG->delete() : $REG->restore();
2095
+				if ( ! $updated) {
2096
+					$success = 0;
2097
+				} else {
2098
+					$success = 2;
2099
+				}/**/
2100
+			}
2101
+		} else {
2102
+			// grab single id and delete
2103
+			$REG_ID = absint($this->_req_data['_REG_ID']);
2104
+			$REG = $REGM->get_one_by_ID($REG_ID);
2105
+			$ticket = $REG->get_first_related('Ticket');
2106
+			$tickets[$ticket->ID()] = $ticket;
2107
+			$dtts = $ticket->get_many_related('Datetime');
2108
+			$updated = $trash ? $REG->delete() : $REG->restore();
2109
+			if ( ! $updated) {
2110
+				$success = 0;
2111
+			}
2112
+		}
2113
+		//now let's update counts
2114
+		EEM_Ticket::instance()->update_tickets_sold($tickets);
2115
+		EEM_Datetime::instance()->update_sold($dtts);
2116
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2117
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2118
+		$overwrite_msgs = $error ? true : false;
2119
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs);
2120
+	}
2121
+
2122
+
2123
+
2124
+	/**
2125
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2126
+	 * registration but also.
2127
+	 * 1. Removing relations to EE_Attendee
2128
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2129
+	 * ALSO trashed.
2130
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2131
+	 * 4. Removing relationships between all tickets and the related registrations
2132
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2133
+	 * 6. Deleting permanently any related Checkins.
2134
+	 *
2135
+	 * @return void
2136
+	 */
2137
+	protected function _delete_registrations()
2138
+	{
2139
+		$REG_MDL = EEM_Registration::instance();
2140
+		$success = 1;
2141
+		//Checkboxes
2142
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2143
+			// if array has more than one element than success message should be plural
2144
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2145
+			// cycle thru checkboxes
2146
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2147
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2148
+				if ( ! $REG instanceof EE_Registration) {
2149
+					continue;
2150
+				}
2151
+				$deleted = $this->_delete_registration($REG);
2152
+				if ( ! $deleted) {
2153
+					$success = 0;
2154
+				}
2155
+			}
2156
+		} else {
2157
+			// grab single id and delete
2158
+			$REG_ID = $this->_req_data['_REG_ID'];
2159
+			$REG = $REG_MDL->get_one_by_ID($REG_ID);
2160
+			$deleted = $this->_delete_registration($REG);
2161
+			if ( ! $deleted) {
2162
+				$success = 0;
2163
+			}
2164
+		}
2165
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
2166
+		$action_desc = __('permanently deleted.', 'event_espresso');
2167
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), true);
2168
+	}
2169
+
2170
+
2171
+
2172
+	/**
2173
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2174
+	 * models get affected.
2175
+	 *
2176
+	 * @param  EE_Registration $REG registration to be deleted permenantly
2177
+	 * @return boolean              true = successful deletion, false = fail.
2178
+	 */
2179
+	protected function _delete_registration(EE_Registration $REG)
2180
+	{
2181
+		//first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed.
2182
+		$TXN = $REG->get_first_related('Transaction');
2183
+		$REGS = $TXN->get_many_related('Registration');
2184
+		$all_trashed = true;
2185
+		foreach ($REGS as $registration) {
2186
+			if ( ! $registration->get('REG_deleted')) {
2187
+				$all_trashed = false;
2188
+			}
2189
+		}
2190
+		if ( ! $all_trashed) {
2191
+			EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2192
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2193
+			return false;
2194
+		}
2195
+		//k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one).
2196
+		foreach ($REGS as $registration) {
2197
+			//delete related answers
2198
+			$registration->delete_related_permanently('Answer');
2199
+			//remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2200
+			$attendee = $registration->get_first_related('Attendee');
2201
+			if ($attendee instanceof EE_Attendee) {
2202
+				$registration->_remove_relation_to($attendee, 'Attendee');
2203
+			}
2204
+			//now remove relationships to tickets on this registration.
2205
+			$registration->_remove_relations('Ticket');
2206
+			//now delete permanently the checkins related to this registration.
2207
+			$registration->delete_related_permanently('Checkin');
2208
+			if ($registration->ID() === $REG->ID()) {
2209
+				continue;
2210
+			} //we don't want to delete permanently the existing registration just yet.
2211
+			//remove relation to transaction for these registrations if NOT the existing registrations
2212
+			$registration->_remove_relations('Transaction');
2213
+			//delete permanently any related messages.
2214
+			$registration->delete_related_permanently('Message');
2215
+			//now delete this registration permanently
2216
+			$registration->delete_permanently();
2217
+		}
2218
+		//now all related registrations on the transaction are handled.  So let's just handle this registration itself (the transaction and line items should be all that's left).
2219
+		//delete the line items related to the transaction for this registration.
2220
+		$TXN->delete_related_permanently('Line_Item');
2221
+		//we need to remove all the relationships on the transaction
2222
+		$TXN->delete_related_permanently('Payment');
2223
+		$TXN->delete_related_permanently('Extra_Meta');
2224
+		$TXN->delete_related_permanently('Message');
2225
+		//now we can delete this REG permanently (and the transaction of course)
2226
+		$REG->delete_related_permanently('Transaction');
2227
+		return $REG->delete_permanently();
2228
+	}
2229
+
2230
+
2231
+
2232
+	/**
2233
+	 *    generates HTML for the Register New Attendee Admin page
2234
+	 *
2235
+	 * @access private
2236
+	 * @throws \EE_Error
2237
+	 * @return void
2238
+	 */
2239
+	public function new_registration()
2240
+	{
2241
+		if ( ! $this->_set_reg_event()) {
2242
+			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request',
2243
+				'event_espresso'));
2244
+		}
2245
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2246
+		// gotta start with a clean slate if we're not coming here via ajax
2247
+		if ( ! defined('DOING_AJAX')
2248
+			 && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2249
+		) {
2250
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2251
+		}
2252
+		$this->_template_args['event_name'] = '';
2253
+		// event name
2254
+		if ($this->_reg_event) {
2255
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2256
+			$edit_event_url = self::add_query_args_and_nonce(array(
2257
+				'action' => 'edit',
2258
+				'post'   => $this->_reg_event->ID(),
2259
+			), EVENTS_ADMIN_URL);
2260
+			$edit_event_lnk = '<a href="'
2261
+							  . $edit_event_url
2262
+							  . '" title="'
2263
+							  . esc_attr__('Edit ', 'event_espresso')
2264
+							  . $this->_reg_event->name()
2265
+							  . '">'
2266
+							  . __('Edit Event', 'event_espresso')
2267
+							  . '</a>';
2268
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2269
+												   . $edit_event_lnk
2270
+												   . '</span>';
2271
+		}
2272
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2273
+		if (defined('DOING_AJAX')) {
2274
+			$this->_return_json();
2275
+		}
2276
+		// grab header
2277
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2278
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path,
2279
+			$this->_template_args, true);
2280
+		//$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2281
+		// the details template wrapper
2282
+		$this->display_admin_page_with_sidebar();
2283
+	}
2284
+
2285
+
2286
+
2287
+	/**
2288
+	 * This returns the content for a registration step
2289
+	 *
2290
+	 * @access protected
2291
+	 * @return string html
2292
+	 */
2293
+	protected function _get_registration_step_content()
2294
+	{
2295
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2296
+			$warning_msg = sprintf(__('%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2297
+				'event_espresso'), '<br />', '<h3 class="important-notice">', '</h3>', '<div class="float-right">',
2298
+				'<span id="redirect_timer" class="important-notice">30</span>', '</div>', '<b>', '</b>');
2299
+			return '
2300 2300
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2301 2301
 	<script >
2302 2302
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2309,646 +2309,646 @@  discard block
 block discarded – undo
2309 2309
 	        }
2310 2310
 	    }, 800 );
2311 2311
 	</script >';
2312
-        }
2313
-        $template_args = array(
2314
-            'title'                    => '',
2315
-            'content'                  => '',
2316
-            'step_button_text'         => '',
2317
-            'show_notification_toggle' => false,
2318
-        );
2319
-        //to indicate we're processing a new registration
2320
-        $hidden_fields = array(
2321
-            'processing_registration' => array(
2322
-                'type'  => 'hidden',
2323
-                'value' => 0,
2324
-            ),
2325
-            'event_id'                => array(
2326
-                'type'  => 'hidden',
2327
-                'value' => $this->_reg_event->ID(),
2328
-            ),
2329
-        );
2330
-        //if the cart is empty then we know we're at step one so we'll display ticket selector
2331
-        $cart = EE_Registry::instance()->SSN->cart();
2332
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2333
-        switch ($step) {
2334
-            case 'ticket' :
2335
-                $hidden_fields['processing_registration']['value'] = 1;
2336
-                $template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso');
2337
-                $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2338
-                $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details',
2339
-                    'event_espresso');
2340
-                $template_args['show_notification_toggle'] = false;
2341
-                break;
2342
-            case 'questions' :
2343
-                $hidden_fields['processing_registration']['value'] = 2;
2344
-                $template_args['title'] = __('Step Two: Add Registrant Details for this Registration',
2345
-                    'event_espresso');
2346
-                //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run.
2347
-                $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2348
-                $template_args['step_button_text'] = __('Save Registration and Continue to Details', 'event_espresso');
2349
-                $template_args['show_notification_toggle'] = true;
2350
-                break;
2351
-        }
2352
-        $this->_set_add_edit_form_tags('process_reg_step',
2353
-            $hidden_fields); //we come back to the process_registration_step route.
2354
-        return EEH_Template::display_template(REG_TEMPLATE_PATH
2355
-                                              . 'reg_admin_register_new_attendee_step_content.template.php',
2356
-            $template_args, true);
2357
-    }
2358
-
2359
-
2360
-
2361
-    /**
2362
-     *        set_reg_event
2363
-     *
2364
-     * @access private
2365
-     * @return boolean
2366
-     */
2367
-    private function _set_reg_event()
2368
-    {
2369
-        if (is_object($this->_reg_event)) {
2370
-            return true;
2371
-        }
2372
-        $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
2373
-        if ( ! $EVT_ID) {
2374
-            return false;
2375
-        }
2376
-        $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2377
-        return true;
2378
-    }
2379
-
2380
-
2381
-
2382
-    /**
2383
-     * process_reg_step
2384
-     *
2385
-     * @access        public
2386
-     * @return        string
2387
-     * @throws \RuntimeException
2388
-     * @throws \EE_Error
2389
-     */
2390
-    public function process_reg_step()
2391
-    {
2392
-        EE_System::do_not_cache();
2393
-        $this->_set_reg_event();
2394
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2395
-        EE_Registry::instance()->REQ->set('uts', time());
2396
-        //what step are we on?
2397
-        $cart = EE_Registry::instance()->SSN->cart();
2398
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2399
-        //if doing ajax then we need to verify the nonce
2400
-        if (defined('DOING_AJAX')) {
2401
-            $nonce = isset($this->_req_data[$this->_req_nonce])
2402
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
2403
-            $this->_verify_nonce($nonce, $this->_req_nonce);
2404
-        }
2405
-        switch ($step) {
2406
-            case 'ticket' :
2407
-                //process ticket selection
2408
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
2409
-                if ($success) {
2410
-                    EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.',
2411
-                        'event_espresso'));
2412
-                } else {
2413
-                    $query_args['step_error'] = $this->_req_data['step_error'] = true;
2414
-                }
2415
-                if (defined('DOING_AJAX')) {
2416
-                    $this->new_registration(); //display next step
2417
-                } else {
2418
-                    $query_args = array(
2419
-                        'action'                  => 'new_registration',
2420
-                        'processing_registration' => 1,
2421
-                        'event_id'                => $this->_reg_event->ID(),
2422
-                        'uts'                     => time(),
2423
-                    );
2424
-                    $this->_redirect_after_action(false, '', '', $query_args, true);
2425
-                }
2426
-                break;
2427
-            case 'questions' :
2428
-                if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) {
2429
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
2430
-                }
2431
-                //process registration
2432
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
2433
-                if ($cart instanceof EE_Cart) {
2434
-                    $grand_total = $cart->get_cart_grand_total();
2435
-                    if ($grand_total instanceof EE_Line_Item) {
2436
-                        $grand_total->save_this_and_descendants_to_txn();
2437
-                    }
2438
-                }
2439
-                if ( ! $transaction instanceof EE_Transaction) {
2440
-                    $query_args = array(
2441
-                        'action'                  => 'new_registration',
2442
-                        'processing_registration' => 2,
2443
-                        'event_id'                => $this->_reg_event->ID(),
2444
-                        'uts'                     => time(),
2445
-                    );
2446
-                    if (defined('DOING_AJAX')) {
2447
-                        //display registration form again because there are errors (maybe validation?)
2448
-                        $this->new_registration();
2449
-                        return;
2450
-                    } else {
2451
-                        $this->_redirect_after_action(false, '', '', $query_args, true);
2452
-                        return;
2453
-                    }
2454
-                }
2455
-                // maybe update status, and make sure to save transaction if not done already
2456
-                if ( ! $transaction->update_status_based_on_total_paid()) {
2457
-                    $transaction->save();
2458
-                }
2459
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2460
-                $this->_req_data = array();
2461
-                $query_args = array(
2462
-                    'action'        => 'redirect_to_txn',
2463
-                    'TXN_ID'        => $transaction->ID(),
2464
-                    'EVT_ID'        => $this->_reg_event->ID(),
2465
-                    'event_name'    => urlencode($this->_reg_event->name()),
2466
-                    'redirect_from' => 'new_registration',
2467
-                );
2468
-                $this->_redirect_after_action(false, '', '', $query_args, true);
2469
-                break;
2470
-        }
2471
-        //what are you looking here for?  Should be nothing to do at this point.
2472
-    }
2473
-
2474
-
2475
-
2476
-    /**
2477
-     * redirect_to_txn
2478
-     *
2479
-     * @access public
2480
-     * @return void
2481
-     */
2482
-    public function redirect_to_txn()
2483
-    {
2484
-        EE_System::do_not_cache();
2485
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2486
-        $query_args = array(
2487
-            'action' => 'view_transaction',
2488
-            'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
2489
-            'page'   => 'espresso_transactions',
2490
-        );
2491
-        if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
2492
-            $query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
2493
-            $query_args['event_name'] = urlencode($this->_req_data['event_name']);
2494
-            $query_args['redirect_from'] = $this->_req_data['redirect_from'];
2495
-        }
2496
-        EE_Error::add_success(__('Registration Created.  Please review the transaction and add any payments as necessary',
2497
-                'event_espresso'));
2498
-        $this->_redirect_after_action(false, '', '', $query_args, true);
2499
-    }
2500
-
2501
-
2502
-
2503
-    /**
2504
-     *        generates HTML for the Attendee Contact List
2505
-     *
2506
-     * @access protected
2507
-     * @return void
2508
-     */
2509
-    protected function _attendee_contact_list_table()
2510
-    {
2511
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2512
-        $this->_search_btn_label = __('Contacts', 'event_espresso');
2513
-        $this->display_admin_list_table_page_with_no_sidebar();
2514
-    }
2515
-
2516
-
2517
-
2518
-    /**
2519
-     *        get_attendees
2520
-     *
2521
-     * @param bool $count whether to return count or data.
2522
-     * @access public
2523
-     * @return array
2524
-     */
2525
-    public function get_attendees($per_page, $count = false, $trash = false)
2526
-    {
2527
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2528
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
2529
-        $ATT_MDL = EEM_Attendee::instance();
2530
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2531
-        switch ($this->_req_data['orderby']) {
2532
-            case 'ATT_ID':
2533
-                $orderby = 'ATT_ID';
2534
-                break;
2535
-            case 'ATT_fname':
2536
-                $orderby = 'ATT_fname';
2537
-                break;
2538
-            case 'ATT_email':
2539
-                $orderby = 'ATT_email';
2540
-                break;
2541
-            case 'ATT_city':
2542
-                $orderby = 'ATT_city';
2543
-                break;
2544
-            case 'STA_ID':
2545
-                $orderby = 'STA_ID';
2546
-                break;
2547
-            case 'CNT_ID':
2548
-                $orderby = 'CNT_ID';
2549
-                break;
2550
-            default:
2551
-                $orderby = 'ATT_lname';
2552
-        }
2553
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
2554
-            : 'ASC';
2555
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
2556
-            ? $this->_req_data['paged'] : 1;
2557
-        $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
2558
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
2559
-            ? $this->_req_data['perpage'] : $per_page;
2560
-        $_where = array();
2561
-        if ( ! empty($this->_req_data['s'])) {
2562
-            $sstr = '%' . $this->_req_data['s'] . '%';
2563
-            $_where['OR'] = array(
2564
-                'Registration.Event.EVT_name'       => array('LIKE', $sstr),
2565
-                'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
2566
-                'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
2567
-                'ATT_fname'                         => array('LIKE', $sstr),
2568
-                'ATT_lname'                         => array('LIKE', $sstr),
2569
-                'ATT_short_bio'                     => array('LIKE', $sstr),
2570
-                'ATT_email'                         => array('LIKE', $sstr),
2571
-                'ATT_address'                       => array('LIKE', $sstr),
2572
-                'ATT_address2'                      => array('LIKE', $sstr),
2573
-                'ATT_city'                          => array('LIKE', $sstr),
2574
-                'Country.CNT_name'                  => array('LIKE', $sstr),
2575
-                'State.STA_name'                    => array('LIKE', $sstr),
2576
-                'ATT_phone'                         => array('LIKE', $sstr),
2577
-                'Registration.REG_final_price'      => array('LIKE', $sstr),
2578
-                'Registration.REG_code'             => array('LIKE', $sstr),
2579
-                'Registration.REG_count'            => array('LIKE', $sstr),
2580
-                'Registration.REG_group_size'       => array('LIKE', $sstr),
2581
-            );
2582
-        }
2583
-        $offset = ($current_page - 1) * $per_page;
2584
-        $limit = $count ? null : array($offset, $per_page);
2585
-        if ($trash) {
2586
-            $_where['status'] = array('!=', 'publish');
2587
-            $all_attendees = $count
2588
-                ? $ATT_MDL->count(array(
2589
-                    $_where,
2590
-                    'order_by' => array($orderby => $sort),
2591
-                    'limit'    => $limit,
2592
-                ), 'ATT_ID', true)
2593
-                : $ATT_MDL->get_all(array(
2594
-                    $_where,
2595
-                    'order_by' => array($orderby => $sort),
2596
-                    'limit'    => $limit,
2597
-                ));
2598
-        } else {
2599
-            $_where['status'] = array('IN', array('publish'));
2600
-            $all_attendees = $count
2601
-                ? $ATT_MDL->count(array(
2602
-                    $_where,
2603
-                    'order_by' => array($orderby => $sort),
2604
-                    'limit'    => $limit,
2605
-                ), 'ATT_ID', true)
2606
-                : $ATT_MDL->get_all(array(
2607
-                    $_where,
2608
-                    'order_by' => array($orderby => $sort),
2609
-                    'limit'    => $limit,
2610
-                ));
2611
-        }
2612
-        return $all_attendees;
2613
-    }
2614
-
2615
-
2616
-
2617
-    /**
2618
-     * This is just taking care of resending the registration confirmation
2619
-     *
2620
-     * @access protected
2621
-     * @return void
2622
-     */
2623
-    protected function _resend_registration()
2624
-    {
2625
-        $this->_process_resend_registration();
2626
-        $query_args = isset($this->_req_data['redirect_to'])
2627
-            ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
2628
-            : array(
2629
-                'action' => 'default',
2630
-            );
2631
-        $this->_redirect_after_action(false, '', '', $query_args, true);
2632
-    }
2633
-
2634
-
2635
-
2636
-    public function _registrations_report()
2637
-    {
2638
-        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2639
-            wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
2640
-                'page'        => 'espresso_batch',
2641
-                'batch'       => 'file',
2642
-                'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2643
-                'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
2644
-                'return_url'  => urlencode($this->_req_data['return_url']),
2645
-            )));
2646
-        } else {
2647
-            $new_request_args = array(
2648
-                'export' => 'report',
2649
-                'action' => 'registrations_report_for_event',
2650
-                'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2651
-            );
2652
-            $this->_req_data = array_merge($this->_req_data, $new_request_args);
2653
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2654
-                require_once(EE_CLASSES . 'EE_Export.class.php');
2655
-                $EE_Export = EE_Export::instance($this->_req_data);
2656
-                $EE_Export->export();
2657
-            }
2658
-        }
2659
-    }
2660
-
2661
-
2662
-
2663
-    public function _contact_list_export()
2664
-    {
2665
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2666
-            require_once(EE_CLASSES . 'EE_Export.class.php');
2667
-            $EE_Export = EE_Export::instance($this->_req_data);
2668
-            $EE_Export->export_attendees();
2669
-        }
2670
-    }
2671
-
2672
-
2673
-
2674
-    public function _contact_list_report()
2675
-    {
2676
-        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2677
-            wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
2678
-                'page'        => 'espresso_batch',
2679
-                'batch'       => 'file',
2680
-                'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
2681
-                'return_url'  => urlencode($this->_req_data['return_url']),
2682
-            )));
2683
-        } else {
2684
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2685
-                require_once(EE_CLASSES . 'EE_Export.class.php');
2686
-                $EE_Export = EE_Export::instance($this->_req_data);
2687
-                $EE_Export->report_attendees();
2688
-            }
2689
-        }
2690
-    }
2691
-
2692
-
2693
-
2694
-
2695
-
2696
-    /***************************************        ATTENDEE DETAILS        ***************************************/
2697
-    /**
2698
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
2699
-     *
2700
-     * @return void
2701
-     */
2702
-    protected function _duplicate_attendee()
2703
-    {
2704
-        $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
2705
-        //verify we have necessary info
2706
-        if (empty($this->_req_data['_REG_ID'])) {
2707
-            EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
2708
-                'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
2709
-            $query_args = array('action' => $action);
2710
-            $this->_redirect_after_action('', '', '', $query_args, true);
2711
-        }
2712
-        //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
2713
-        $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
2714
-        $attendee = $registration->attendee();
2715
-        //remove relation of existing attendee on registration
2716
-        $registration->_remove_relation_to($attendee, 'Attendee');
2717
-        //new attendee
2718
-        $new_attendee = clone $attendee;
2719
-        $new_attendee->set('ATT_ID', 0);
2720
-        $new_attendee->save();
2721
-        //add new attendee to reg
2722
-        $registration->_add_relation_to($new_attendee, 'Attendee');
2723
-        EE_Error::add_success(__('New Contact record created.  Now make any edits you wish to make for this contact.',
2724
-            'event_espresso'));
2725
-        //redirect to edit page for attendee
2726
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
2727
-        $this->_redirect_after_action('', '', '', $query_args, true);
2728
-    }
2729
-
2730
-
2731
-
2732
-    //related to cpt routes
2733
-    protected function _insert_update_cpt_item($post_id, $post)
2734
-    {
2735
-        $success = true;
2736
-        $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
2737
-        //for attendee updates
2738
-        if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) {
2739
-            //note we should only be UPDATING attendees at this point.
2740
-            $updated_fields = array(
2741
-                'ATT_fname'     => $this->_req_data['ATT_fname'],
2742
-                'ATT_lname'     => $this->_req_data['ATT_lname'],
2743
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2744
-                'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2745
-                'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2746
-                'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
2747
-                'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
2748
-                'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
2749
-                'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
2750
-                'ATT_email'     => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '',
2751
-                'ATT_phone'     => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '',
2752
-            );
2753
-            foreach ($updated_fields as $field => $value) {
2754
-                $attendee->set($field, $value);
2755
-            }
2756
-            $success = $attendee->save();
2757
-            $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
2758
-                array());
2759
-            foreach ($attendee_update_callbacks as $a_callback) {
2760
-                if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
2761
-                    throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
2762
-                        'event_espresso'), $a_callback));
2763
-                }
2764
-            }
2765
-        }
2766
-        if ($success === false) {
2767
-            EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.',
2768
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2769
-        }
2770
-    }
2771
-
2772
-
2773
-
2774
-    public function trash_cpt_item($post_id)
2775
-    {
2776
-    }
2777
-
2778
-
2779
-
2780
-    public function delete_cpt_item($post_id)
2781
-    {
2782
-    }
2783
-
2784
-
2785
-
2786
-    public function restore_cpt_item($post_id)
2787
-    {
2788
-    }
2789
-
2790
-
2791
-
2792
-    protected function _restore_cpt_item($post_id, $revision_id)
2793
-    {
2794
-    }
2795
-
2796
-
2797
-
2798
-    public function attendee_editor_metaboxes()
2799
-    {
2800
-        $this->verify_cpt_object();
2801
-        remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action],
2802
-            'normal', 'core');
2803
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2804
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
2805
-            add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box',
2806
-                $this->_cpt_routes[$this->_req_action], 'normal');
2807
-        }
2808
-        if (post_type_supports('espresso_attendees', 'comments')) {
2809
-            add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box',
2810
-                $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2811
-        }
2812
-        add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'),
2813
-            array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core');
2814
-        add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'),
2815
-            array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2816
-        add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'),
2817
-            array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2818
-    }
2819
-
2820
-
2821
-
2822
-    /**
2823
-     * Metabox for attendee contact info
2824
-     *
2825
-     * @param  WP_Post $post wp post object
2826
-     * @return string        attendee contact info ( and form )
2827
-     */
2828
-    public function attendee_contact_info($post)
2829
-    {
2830
-        //get attendee object ( should already have it )
2831
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
2832
-        $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2833
-        EEH_Template::display_template($template, $this->_template_args);
2834
-    }
2835
-
2836
-
2837
-
2838
-    /**
2839
-     * Metabox for attendee details
2840
-     *
2841
-     * @param  WP_Post $post wp post object
2842
-     * @return string        attendee address details (and form)
2843
-     */
2844
-    public function attendee_address_details($post)
2845
-    {
2846
-        //get attendee object (should already have it)
2847
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
2848
-        $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array(
2849
-            'QST_ID'           => 0,
2850
-            'QST_display_text' => __('State/Province', 'event_espresso'),
2851
-            'QST_system'       => 'admin-state',
2852
-        )), EE_Answer::new_instance(array(
2853
-            'ANS_ID'    => 0,
2854
-            'ANS_value' => $this->_cpt_model_obj->state_ID(),
2855
-        )), array(
2856
-                'input_id'       => 'STA_ID',
2857
-                'input_name'     => 'STA_ID',
2858
-                'input_prefix'   => '',
2859
-                'append_qstn_id' => false,
2860
-            )));
2861
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array(
2862
-            'QST_ID'           => 0,
2863
-            'QST_display_text' => __('Country', 'event_espresso'),
2864
-            'QST_system'       => 'admin-country',
2865
-        )), EE_Answer::new_instance(array(
2866
-            'ANS_ID'    => 0,
2867
-            'ANS_value' => $this->_cpt_model_obj->country_ID(),
2868
-        )), array(
2869
-                'input_id'       => 'CNT_ISO',
2870
-                'input_name'     => 'CNT_ISO',
2871
-                'input_prefix'   => '',
2872
-                'append_qstn_id' => false,
2873
-            )));
2874
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2875
-        EEH_Template::display_template($template, $this->_template_args);
2876
-    }
2877
-
2878
-
2879
-
2880
-    /**
2881
-     *        _attendee_details
2882
-     *
2883
-     * @access protected
2884
-     * @return void
2885
-     */
2886
-    public function attendee_registrations_meta_box($post)
2887
-    {
2888
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
2889
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2890
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2891
-        EEH_Template::display_template($template, $this->_template_args);
2892
-    }
2893
-
2894
-
2895
-
2896
-    /**
2897
-     * add in the form fields for the attendee edit
2898
-     *
2899
-     * @param  WP_Post $post wp post object
2900
-     * @return string        html for new form.
2901
-     */
2902
-    public function after_title_form_fields($post)
2903
-    {
2904
-        if ($post->post_type == 'espresso_attendees') {
2905
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2906
-            $template_args['attendee'] = $this->_cpt_model_obj;
2907
-            EEH_Template::display_template($template, $template_args);
2908
-        }
2909
-    }
2910
-
2911
-
2912
-
2913
-    /**
2914
-     *        _trash_or_restore_attendee
2915
-     *
2916
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
2917
-     * @access protected
2918
-     * @return void
2919
-     */
2920
-    protected function _trash_or_restore_attendees($trash = true)
2921
-    {
2922
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2923
-        $ATT_MDL = EEM_Attendee::instance();
2924
-        $success = 1;
2925
-        //Checkboxes
2926
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2927
-            // if array has more than one element than success message should be plural
2928
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2929
-            // cycle thru checkboxes
2930
-            while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
2931
-                $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
2932
-                    : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
2933
-                if ( ! $updated) {
2934
-                    $success = 0;
2935
-                }
2936
-            }
2937
-        } else {
2938
-            // grab single id and delete
2939
-            $ATT_ID = absint($this->_req_data['ATT_ID']);
2940
-            //get attendee
2941
-            $att = $ATT_MDL->get_one_by_ID($ATT_ID);
2942
-            $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
2943
-            $updated = $att->save();
2944
-            if ( ! $updated) {
2945
-                $success = 0;
2946
-            }
2947
-        }
2948
-        $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso');
2949
-        $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2950
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
2951
-    }
2312
+		}
2313
+		$template_args = array(
2314
+			'title'                    => '',
2315
+			'content'                  => '',
2316
+			'step_button_text'         => '',
2317
+			'show_notification_toggle' => false,
2318
+		);
2319
+		//to indicate we're processing a new registration
2320
+		$hidden_fields = array(
2321
+			'processing_registration' => array(
2322
+				'type'  => 'hidden',
2323
+				'value' => 0,
2324
+			),
2325
+			'event_id'                => array(
2326
+				'type'  => 'hidden',
2327
+				'value' => $this->_reg_event->ID(),
2328
+			),
2329
+		);
2330
+		//if the cart is empty then we know we're at step one so we'll display ticket selector
2331
+		$cart = EE_Registry::instance()->SSN->cart();
2332
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2333
+		switch ($step) {
2334
+			case 'ticket' :
2335
+				$hidden_fields['processing_registration']['value'] = 1;
2336
+				$template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso');
2337
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2338
+				$template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details',
2339
+					'event_espresso');
2340
+				$template_args['show_notification_toggle'] = false;
2341
+				break;
2342
+			case 'questions' :
2343
+				$hidden_fields['processing_registration']['value'] = 2;
2344
+				$template_args['title'] = __('Step Two: Add Registrant Details for this Registration',
2345
+					'event_espresso');
2346
+				//in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run.
2347
+				$template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2348
+				$template_args['step_button_text'] = __('Save Registration and Continue to Details', 'event_espresso');
2349
+				$template_args['show_notification_toggle'] = true;
2350
+				break;
2351
+		}
2352
+		$this->_set_add_edit_form_tags('process_reg_step',
2353
+			$hidden_fields); //we come back to the process_registration_step route.
2354
+		return EEH_Template::display_template(REG_TEMPLATE_PATH
2355
+											  . 'reg_admin_register_new_attendee_step_content.template.php',
2356
+			$template_args, true);
2357
+	}
2358
+
2359
+
2360
+
2361
+	/**
2362
+	 *        set_reg_event
2363
+	 *
2364
+	 * @access private
2365
+	 * @return boolean
2366
+	 */
2367
+	private function _set_reg_event()
2368
+	{
2369
+		if (is_object($this->_reg_event)) {
2370
+			return true;
2371
+		}
2372
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
2373
+		if ( ! $EVT_ID) {
2374
+			return false;
2375
+		}
2376
+		$this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2377
+		return true;
2378
+	}
2379
+
2380
+
2381
+
2382
+	/**
2383
+	 * process_reg_step
2384
+	 *
2385
+	 * @access        public
2386
+	 * @return        string
2387
+	 * @throws \RuntimeException
2388
+	 * @throws \EE_Error
2389
+	 */
2390
+	public function process_reg_step()
2391
+	{
2392
+		EE_System::do_not_cache();
2393
+		$this->_set_reg_event();
2394
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2395
+		EE_Registry::instance()->REQ->set('uts', time());
2396
+		//what step are we on?
2397
+		$cart = EE_Registry::instance()->SSN->cart();
2398
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2399
+		//if doing ajax then we need to verify the nonce
2400
+		if (defined('DOING_AJAX')) {
2401
+			$nonce = isset($this->_req_data[$this->_req_nonce])
2402
+				? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
2403
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2404
+		}
2405
+		switch ($step) {
2406
+			case 'ticket' :
2407
+				//process ticket selection
2408
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2409
+				if ($success) {
2410
+					EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.',
2411
+						'event_espresso'));
2412
+				} else {
2413
+					$query_args['step_error'] = $this->_req_data['step_error'] = true;
2414
+				}
2415
+				if (defined('DOING_AJAX')) {
2416
+					$this->new_registration(); //display next step
2417
+				} else {
2418
+					$query_args = array(
2419
+						'action'                  => 'new_registration',
2420
+						'processing_registration' => 1,
2421
+						'event_id'                => $this->_reg_event->ID(),
2422
+						'uts'                     => time(),
2423
+					);
2424
+					$this->_redirect_after_action(false, '', '', $query_args, true);
2425
+				}
2426
+				break;
2427
+			case 'questions' :
2428
+				if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) {
2429
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
2430
+				}
2431
+				//process registration
2432
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
2433
+				if ($cart instanceof EE_Cart) {
2434
+					$grand_total = $cart->get_cart_grand_total();
2435
+					if ($grand_total instanceof EE_Line_Item) {
2436
+						$grand_total->save_this_and_descendants_to_txn();
2437
+					}
2438
+				}
2439
+				if ( ! $transaction instanceof EE_Transaction) {
2440
+					$query_args = array(
2441
+						'action'                  => 'new_registration',
2442
+						'processing_registration' => 2,
2443
+						'event_id'                => $this->_reg_event->ID(),
2444
+						'uts'                     => time(),
2445
+					);
2446
+					if (defined('DOING_AJAX')) {
2447
+						//display registration form again because there are errors (maybe validation?)
2448
+						$this->new_registration();
2449
+						return;
2450
+					} else {
2451
+						$this->_redirect_after_action(false, '', '', $query_args, true);
2452
+						return;
2453
+					}
2454
+				}
2455
+				// maybe update status, and make sure to save transaction if not done already
2456
+				if ( ! $transaction->update_status_based_on_total_paid()) {
2457
+					$transaction->save();
2458
+				}
2459
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2460
+				$this->_req_data = array();
2461
+				$query_args = array(
2462
+					'action'        => 'redirect_to_txn',
2463
+					'TXN_ID'        => $transaction->ID(),
2464
+					'EVT_ID'        => $this->_reg_event->ID(),
2465
+					'event_name'    => urlencode($this->_reg_event->name()),
2466
+					'redirect_from' => 'new_registration',
2467
+				);
2468
+				$this->_redirect_after_action(false, '', '', $query_args, true);
2469
+				break;
2470
+		}
2471
+		//what are you looking here for?  Should be nothing to do at this point.
2472
+	}
2473
+
2474
+
2475
+
2476
+	/**
2477
+	 * redirect_to_txn
2478
+	 *
2479
+	 * @access public
2480
+	 * @return void
2481
+	 */
2482
+	public function redirect_to_txn()
2483
+	{
2484
+		EE_System::do_not_cache();
2485
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2486
+		$query_args = array(
2487
+			'action' => 'view_transaction',
2488
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
2489
+			'page'   => 'espresso_transactions',
2490
+		);
2491
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
2492
+			$query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
2493
+			$query_args['event_name'] = urlencode($this->_req_data['event_name']);
2494
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
2495
+		}
2496
+		EE_Error::add_success(__('Registration Created.  Please review the transaction and add any payments as necessary',
2497
+				'event_espresso'));
2498
+		$this->_redirect_after_action(false, '', '', $query_args, true);
2499
+	}
2500
+
2501
+
2502
+
2503
+	/**
2504
+	 *        generates HTML for the Attendee Contact List
2505
+	 *
2506
+	 * @access protected
2507
+	 * @return void
2508
+	 */
2509
+	protected function _attendee_contact_list_table()
2510
+	{
2511
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2512
+		$this->_search_btn_label = __('Contacts', 'event_espresso');
2513
+		$this->display_admin_list_table_page_with_no_sidebar();
2514
+	}
2515
+
2516
+
2517
+
2518
+	/**
2519
+	 *        get_attendees
2520
+	 *
2521
+	 * @param bool $count whether to return count or data.
2522
+	 * @access public
2523
+	 * @return array
2524
+	 */
2525
+	public function get_attendees($per_page, $count = false, $trash = false)
2526
+	{
2527
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2528
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
2529
+		$ATT_MDL = EEM_Attendee::instance();
2530
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2531
+		switch ($this->_req_data['orderby']) {
2532
+			case 'ATT_ID':
2533
+				$orderby = 'ATT_ID';
2534
+				break;
2535
+			case 'ATT_fname':
2536
+				$orderby = 'ATT_fname';
2537
+				break;
2538
+			case 'ATT_email':
2539
+				$orderby = 'ATT_email';
2540
+				break;
2541
+			case 'ATT_city':
2542
+				$orderby = 'ATT_city';
2543
+				break;
2544
+			case 'STA_ID':
2545
+				$orderby = 'STA_ID';
2546
+				break;
2547
+			case 'CNT_ID':
2548
+				$orderby = 'CNT_ID';
2549
+				break;
2550
+			default:
2551
+				$orderby = 'ATT_lname';
2552
+		}
2553
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
2554
+			: 'ASC';
2555
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
2556
+			? $this->_req_data['paged'] : 1;
2557
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
2558
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
2559
+			? $this->_req_data['perpage'] : $per_page;
2560
+		$_where = array();
2561
+		if ( ! empty($this->_req_data['s'])) {
2562
+			$sstr = '%' . $this->_req_data['s'] . '%';
2563
+			$_where['OR'] = array(
2564
+				'Registration.Event.EVT_name'       => array('LIKE', $sstr),
2565
+				'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
2566
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
2567
+				'ATT_fname'                         => array('LIKE', $sstr),
2568
+				'ATT_lname'                         => array('LIKE', $sstr),
2569
+				'ATT_short_bio'                     => array('LIKE', $sstr),
2570
+				'ATT_email'                         => array('LIKE', $sstr),
2571
+				'ATT_address'                       => array('LIKE', $sstr),
2572
+				'ATT_address2'                      => array('LIKE', $sstr),
2573
+				'ATT_city'                          => array('LIKE', $sstr),
2574
+				'Country.CNT_name'                  => array('LIKE', $sstr),
2575
+				'State.STA_name'                    => array('LIKE', $sstr),
2576
+				'ATT_phone'                         => array('LIKE', $sstr),
2577
+				'Registration.REG_final_price'      => array('LIKE', $sstr),
2578
+				'Registration.REG_code'             => array('LIKE', $sstr),
2579
+				'Registration.REG_count'            => array('LIKE', $sstr),
2580
+				'Registration.REG_group_size'       => array('LIKE', $sstr),
2581
+			);
2582
+		}
2583
+		$offset = ($current_page - 1) * $per_page;
2584
+		$limit = $count ? null : array($offset, $per_page);
2585
+		if ($trash) {
2586
+			$_where['status'] = array('!=', 'publish');
2587
+			$all_attendees = $count
2588
+				? $ATT_MDL->count(array(
2589
+					$_where,
2590
+					'order_by' => array($orderby => $sort),
2591
+					'limit'    => $limit,
2592
+				), 'ATT_ID', true)
2593
+				: $ATT_MDL->get_all(array(
2594
+					$_where,
2595
+					'order_by' => array($orderby => $sort),
2596
+					'limit'    => $limit,
2597
+				));
2598
+		} else {
2599
+			$_where['status'] = array('IN', array('publish'));
2600
+			$all_attendees = $count
2601
+				? $ATT_MDL->count(array(
2602
+					$_where,
2603
+					'order_by' => array($orderby => $sort),
2604
+					'limit'    => $limit,
2605
+				), 'ATT_ID', true)
2606
+				: $ATT_MDL->get_all(array(
2607
+					$_where,
2608
+					'order_by' => array($orderby => $sort),
2609
+					'limit'    => $limit,
2610
+				));
2611
+		}
2612
+		return $all_attendees;
2613
+	}
2614
+
2615
+
2616
+
2617
+	/**
2618
+	 * This is just taking care of resending the registration confirmation
2619
+	 *
2620
+	 * @access protected
2621
+	 * @return void
2622
+	 */
2623
+	protected function _resend_registration()
2624
+	{
2625
+		$this->_process_resend_registration();
2626
+		$query_args = isset($this->_req_data['redirect_to'])
2627
+			? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
2628
+			: array(
2629
+				'action' => 'default',
2630
+			);
2631
+		$this->_redirect_after_action(false, '', '', $query_args, true);
2632
+	}
2633
+
2634
+
2635
+
2636
+	public function _registrations_report()
2637
+	{
2638
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2639
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
2640
+				'page'        => 'espresso_batch',
2641
+				'batch'       => 'file',
2642
+				'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2643
+				'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
2644
+				'return_url'  => urlencode($this->_req_data['return_url']),
2645
+			)));
2646
+		} else {
2647
+			$new_request_args = array(
2648
+				'export' => 'report',
2649
+				'action' => 'registrations_report_for_event',
2650
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
2651
+			);
2652
+			$this->_req_data = array_merge($this->_req_data, $new_request_args);
2653
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2654
+				require_once(EE_CLASSES . 'EE_Export.class.php');
2655
+				$EE_Export = EE_Export::instance($this->_req_data);
2656
+				$EE_Export->export();
2657
+			}
2658
+		}
2659
+	}
2660
+
2661
+
2662
+
2663
+	public function _contact_list_export()
2664
+	{
2665
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2666
+			require_once(EE_CLASSES . 'EE_Export.class.php');
2667
+			$EE_Export = EE_Export::instance($this->_req_data);
2668
+			$EE_Export->export_attendees();
2669
+		}
2670
+	}
2671
+
2672
+
2673
+
2674
+	public function _contact_list_report()
2675
+	{
2676
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2677
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(array(
2678
+				'page'        => 'espresso_batch',
2679
+				'batch'       => 'file',
2680
+				'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
2681
+				'return_url'  => urlencode($this->_req_data['return_url']),
2682
+			)));
2683
+		} else {
2684
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2685
+				require_once(EE_CLASSES . 'EE_Export.class.php');
2686
+				$EE_Export = EE_Export::instance($this->_req_data);
2687
+				$EE_Export->report_attendees();
2688
+			}
2689
+		}
2690
+	}
2691
+
2692
+
2693
+
2694
+
2695
+
2696
+	/***************************************        ATTENDEE DETAILS        ***************************************/
2697
+	/**
2698
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
2699
+	 *
2700
+	 * @return void
2701
+	 */
2702
+	protected function _duplicate_attendee()
2703
+	{
2704
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
2705
+		//verify we have necessary info
2706
+		if (empty($this->_req_data['_REG_ID'])) {
2707
+			EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
2708
+				'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
2709
+			$query_args = array('action' => $action);
2710
+			$this->_redirect_after_action('', '', '', $query_args, true);
2711
+		}
2712
+		//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
2713
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
2714
+		$attendee = $registration->attendee();
2715
+		//remove relation of existing attendee on registration
2716
+		$registration->_remove_relation_to($attendee, 'Attendee');
2717
+		//new attendee
2718
+		$new_attendee = clone $attendee;
2719
+		$new_attendee->set('ATT_ID', 0);
2720
+		$new_attendee->save();
2721
+		//add new attendee to reg
2722
+		$registration->_add_relation_to($new_attendee, 'Attendee');
2723
+		EE_Error::add_success(__('New Contact record created.  Now make any edits you wish to make for this contact.',
2724
+			'event_espresso'));
2725
+		//redirect to edit page for attendee
2726
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
2727
+		$this->_redirect_after_action('', '', '', $query_args, true);
2728
+	}
2729
+
2730
+
2731
+
2732
+	//related to cpt routes
2733
+	protected function _insert_update_cpt_item($post_id, $post)
2734
+	{
2735
+		$success = true;
2736
+		$attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
2737
+		//for attendee updates
2738
+		if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) {
2739
+			//note we should only be UPDATING attendees at this point.
2740
+			$updated_fields = array(
2741
+				'ATT_fname'     => $this->_req_data['ATT_fname'],
2742
+				'ATT_lname'     => $this->_req_data['ATT_lname'],
2743
+				'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2744
+				'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2745
+				'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2746
+				'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
2747
+				'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
2748
+				'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
2749
+				'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
2750
+				'ATT_email'     => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '',
2751
+				'ATT_phone'     => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '',
2752
+			);
2753
+			foreach ($updated_fields as $field => $value) {
2754
+				$attendee->set($field, $value);
2755
+			}
2756
+			$success = $attendee->save();
2757
+			$attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
2758
+				array());
2759
+			foreach ($attendee_update_callbacks as $a_callback) {
2760
+				if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
2761
+					throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
2762
+						'event_espresso'), $a_callback));
2763
+				}
2764
+			}
2765
+		}
2766
+		if ($success === false) {
2767
+			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.',
2768
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2769
+		}
2770
+	}
2771
+
2772
+
2773
+
2774
+	public function trash_cpt_item($post_id)
2775
+	{
2776
+	}
2777
+
2778
+
2779
+
2780
+	public function delete_cpt_item($post_id)
2781
+	{
2782
+	}
2783
+
2784
+
2785
+
2786
+	public function restore_cpt_item($post_id)
2787
+	{
2788
+	}
2789
+
2790
+
2791
+
2792
+	protected function _restore_cpt_item($post_id, $revision_id)
2793
+	{
2794
+	}
2795
+
2796
+
2797
+
2798
+	public function attendee_editor_metaboxes()
2799
+	{
2800
+		$this->verify_cpt_object();
2801
+		remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action],
2802
+			'normal', 'core');
2803
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2804
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
2805
+			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box',
2806
+				$this->_cpt_routes[$this->_req_action], 'normal');
2807
+		}
2808
+		if (post_type_supports('espresso_attendees', 'comments')) {
2809
+			add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box',
2810
+				$this->_cpt_routes[$this->_req_action], 'normal', 'core');
2811
+		}
2812
+		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'),
2813
+			array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core');
2814
+		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'),
2815
+			array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2816
+		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'),
2817
+			array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2818
+	}
2819
+
2820
+
2821
+
2822
+	/**
2823
+	 * Metabox for attendee contact info
2824
+	 *
2825
+	 * @param  WP_Post $post wp post object
2826
+	 * @return string        attendee contact info ( and form )
2827
+	 */
2828
+	public function attendee_contact_info($post)
2829
+	{
2830
+		//get attendee object ( should already have it )
2831
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2832
+		$template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2833
+		EEH_Template::display_template($template, $this->_template_args);
2834
+	}
2835
+
2836
+
2837
+
2838
+	/**
2839
+	 * Metabox for attendee details
2840
+	 *
2841
+	 * @param  WP_Post $post wp post object
2842
+	 * @return string        attendee address details (and form)
2843
+	 */
2844
+	public function attendee_address_details($post)
2845
+	{
2846
+		//get attendee object (should already have it)
2847
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2848
+		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array(
2849
+			'QST_ID'           => 0,
2850
+			'QST_display_text' => __('State/Province', 'event_espresso'),
2851
+			'QST_system'       => 'admin-state',
2852
+		)), EE_Answer::new_instance(array(
2853
+			'ANS_ID'    => 0,
2854
+			'ANS_value' => $this->_cpt_model_obj->state_ID(),
2855
+		)), array(
2856
+				'input_id'       => 'STA_ID',
2857
+				'input_name'     => 'STA_ID',
2858
+				'input_prefix'   => '',
2859
+				'append_qstn_id' => false,
2860
+			)));
2861
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(new EE_Question_Form_Input(EE_Question::new_instance(array(
2862
+			'QST_ID'           => 0,
2863
+			'QST_display_text' => __('Country', 'event_espresso'),
2864
+			'QST_system'       => 'admin-country',
2865
+		)), EE_Answer::new_instance(array(
2866
+			'ANS_ID'    => 0,
2867
+			'ANS_value' => $this->_cpt_model_obj->country_ID(),
2868
+		)), array(
2869
+				'input_id'       => 'CNT_ISO',
2870
+				'input_name'     => 'CNT_ISO',
2871
+				'input_prefix'   => '',
2872
+				'append_qstn_id' => false,
2873
+			)));
2874
+		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2875
+		EEH_Template::display_template($template, $this->_template_args);
2876
+	}
2877
+
2878
+
2879
+
2880
+	/**
2881
+	 *        _attendee_details
2882
+	 *
2883
+	 * @access protected
2884
+	 * @return void
2885
+	 */
2886
+	public function attendee_registrations_meta_box($post)
2887
+	{
2888
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2889
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2890
+		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2891
+		EEH_Template::display_template($template, $this->_template_args);
2892
+	}
2893
+
2894
+
2895
+
2896
+	/**
2897
+	 * add in the form fields for the attendee edit
2898
+	 *
2899
+	 * @param  WP_Post $post wp post object
2900
+	 * @return string        html for new form.
2901
+	 */
2902
+	public function after_title_form_fields($post)
2903
+	{
2904
+		if ($post->post_type == 'espresso_attendees') {
2905
+			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2906
+			$template_args['attendee'] = $this->_cpt_model_obj;
2907
+			EEH_Template::display_template($template, $template_args);
2908
+		}
2909
+	}
2910
+
2911
+
2912
+
2913
+	/**
2914
+	 *        _trash_or_restore_attendee
2915
+	 *
2916
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
2917
+	 * @access protected
2918
+	 * @return void
2919
+	 */
2920
+	protected function _trash_or_restore_attendees($trash = true)
2921
+	{
2922
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2923
+		$ATT_MDL = EEM_Attendee::instance();
2924
+		$success = 1;
2925
+		//Checkboxes
2926
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2927
+			// if array has more than one element than success message should be plural
2928
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2929
+			// cycle thru checkboxes
2930
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
2931
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
2932
+					: $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
2933
+				if ( ! $updated) {
2934
+					$success = 0;
2935
+				}
2936
+			}
2937
+		} else {
2938
+			// grab single id and delete
2939
+			$ATT_ID = absint($this->_req_data['ATT_ID']);
2940
+			//get attendee
2941
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
2942
+			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
2943
+			$updated = $att->save();
2944
+			if ( ! $updated) {
2945
+				$success = 0;
2946
+			}
2947
+		}
2948
+		$what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso');
2949
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2950
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
2951
+	}
2952 2952
 
2953 2953
 }
2954 2954
 
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 					'order' => 50
157 157
 					),
158 158
 				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
159
-               			'help_tabs' => array(
159
+			   			'help_tabs' => array(
160 160
 					'general_settings_critical_pages_help_tab' => array(
161 161
 						'title' => __('Critical Pages', 'event_espresso'),
162 162
 						'filename' => 'general_settings_critical_pages'
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 					'label' => __('Your Organization', 'event_espresso'),
171 171
 					'order' => 20
172 172
 				),
173
-                			'help_tabs' => array(
173
+							'help_tabs' => array(
174 174
 					'general_settings_your_organization_help_tab' => array(
175 175
 						'title' => __('Your Organization', 'event_espresso'),
176 176
 						'filename' => 'general_settings_your_organization'
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 					'order' => 60
187 187
 					),
188 188
 				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
189
-                			'help_tabs' => array(
189
+							'help_tabs' => array(
190 190
 					'general_settings_admin_options_help_tab' => array(
191 191
 						'title' => __('Admin Options', 'event_espresso'),
192 192
 						'filename' => 'general_settings_admin_options'
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 					'label' => __('Countries', 'event_espresso'),
201 201
 					'order' => 70
202 202
 					),
203
-                'help_tabs' => array(
203
+				'help_tabs' => array(
204 204
 					'general_settings_countries_help_tab' => array(
205 205
 						'title' => __('Countries', 'event_espresso'),
206 206
 						'filename' => 'general_settings_countries'
@@ -261,49 +261,49 @@  discard block
 block discarded – undo
261 261
 
262 262
 
263 263
 	/*************		Espresso Pages 		*************/
264
-    /**
265
-     * _espresso_page_settings
266
-     *
267
-     * @throws \EE_Error
268
-     */
264
+	/**
265
+	 * _espresso_page_settings
266
+	 *
267
+	 * @throws \EE_Error
268
+	 */
269 269
 	protected function _espresso_page_settings() {
270
-        // Check to make sure all of the main pages are setup properly,
271
-        // if not create the default pages and display an admin notice
272
-        EEH_Activation::verify_default_pages_exist();
273
-        $this->_transient_garbage_collection();
274
-        $this->_template_args['values'] = $this->_yes_no_values;
275
-        $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
276
-            ? EE_Registry::instance()->CFG->core->reg_page_id
277
-            : null;
278
-        $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
279
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
280
-            : false;
281
-        $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
282
-            ? EE_Registry::instance()->CFG->core->txn_page_id
283
-            : null;
284
-        $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
285
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
286
-            : false;
287
-        $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
288
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
289
-            : null;
290
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
291
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
292
-            : false;
293
-        $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
294
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
295
-            : null;
296
-        $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
297
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
298
-            : false;
299
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
300
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
301
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
302
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
303
-            $this->_template_args,
304
-            true
305
-        );
306
-        $this->display_admin_page_with_sidebar();
270
+		// Check to make sure all of the main pages are setup properly,
271
+		// if not create the default pages and display an admin notice
272
+		EEH_Activation::verify_default_pages_exist();
273
+		$this->_transient_garbage_collection();
274
+		$this->_template_args['values'] = $this->_yes_no_values;
275
+		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
276
+			? EE_Registry::instance()->CFG->core->reg_page_id
277
+			: null;
278
+		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
279
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
280
+			: false;
281
+		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
282
+			? EE_Registry::instance()->CFG->core->txn_page_id
283
+			: null;
284
+		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
285
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
286
+			: false;
287
+		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
288
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
289
+			: null;
290
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
291
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
292
+			: false;
293
+		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
294
+			? EE_Registry::instance()->CFG->core->cancel_page_id
295
+			: null;
296
+		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
297
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
298
+			: false;
299
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
300
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
301
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
302
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
303
+			$this->_template_args,
304
+			true
305
+		);
306
+		$this->display_admin_page_with_sidebar();
307 307
 
308 308
 	}
309 309
 
@@ -469,68 +469,68 @@  discard block
 block discarded – undo
469 469
 
470 470
 
471 471
 
472
-    /*************        Admin Options        *************/
473
-
474
-
475
-
476
-    /**
477
-     * _admin_option_settings
478
-     *
479
-     * @throws \EE_Error
480
-     * @throws \LogicException
481
-     */
482
-    protected function _admin_option_settings() {
483
-        $this->_template_args['admin_page_content'] = '';
484
-        try {
485
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
486
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
487
-            $this->_template_args['values'] = $this->_yes_no_values;
488
-            // also need to account for the do_action that was in the old template
489
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
490
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
491
-        } catch (Exception $e) {
492
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
493
-        }
494
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
495
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
496
-        $this->display_admin_page_with_sidebar();
497
-    }
498
-
499
-
500
-
501
-    /**
502
-     * _update_admin_option_settings
503
-     *
504
-     * @throws \EE_Error
505
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
506
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
507
-     * @throws \InvalidArgumentException
508
-     * @throws \LogicException
509
-     */
510
-    protected function _update_admin_option_settings() {
511
-        try {
512
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
513
-            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
514
-            EE_Registry::instance()->CFG->admin = apply_filters(
515
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
516
-                EE_Registry::instance()->CFG->admin
517
-            );
518
-        } catch (Exception $e) {
519
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
520
-        }
472
+	/*************        Admin Options        *************/
473
+
474
+
475
+
476
+	/**
477
+	 * _admin_option_settings
478
+	 *
479
+	 * @throws \EE_Error
480
+	 * @throws \LogicException
481
+	 */
482
+	protected function _admin_option_settings() {
483
+		$this->_template_args['admin_page_content'] = '';
484
+		try {
485
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
486
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
487
+			$this->_template_args['values'] = $this->_yes_no_values;
488
+			// also need to account for the do_action that was in the old template
489
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
490
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
491
+		} catch (Exception $e) {
492
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
493
+		}
494
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
495
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
496
+		$this->display_admin_page_with_sidebar();
497
+	}
498
+
499
+
500
+
501
+	/**
502
+	 * _update_admin_option_settings
503
+	 *
504
+	 * @throws \EE_Error
505
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
506
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
507
+	 * @throws \InvalidArgumentException
508
+	 * @throws \LogicException
509
+	 */
510
+	protected function _update_admin_option_settings() {
511
+		try {
512
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
513
+			$admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
514
+			EE_Registry::instance()->CFG->admin = apply_filters(
515
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
516
+				EE_Registry::instance()->CFG->admin
517
+			);
518
+		} catch (Exception $e) {
519
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
520
+		}
521 521
 		$this->_redirect_after_action(
522
-            apply_filters(
523
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
524
-                $this->_update_espresso_configuration(
525
-                    'Admin Options',
526
-                    EE_Registry::instance()->CFG->admin,
527
-                    __FILE__, __FUNCTION__, __LINE__
528
-                )
529
-            ),
530
-            'Admin Options',
531
-            'updated',
532
-            array( 'action' => 'admin_option_settings' )
533
-        );
522
+			apply_filters(
523
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
524
+				$this->_update_espresso_configuration(
525
+					'Admin Options',
526
+					EE_Registry::instance()->CFG->admin,
527
+					__FILE__, __FUNCTION__, __LINE__
528
+				)
529
+			),
530
+			'Admin Options',
531
+			'updated',
532
+			array( 'action' => 'admin_option_settings' )
533
+		);
534 534
 
535 535
 	}
536 536
 
Please login to merge, or discard this patch.
Spacing   +249 added lines, -250 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\admin_pages\general_settings\AdminOptionsSettings;
3 3
 
4
-if (!defined('EVENT_ESPRESSO_VERSION') )
4
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
5 5
 	exit('NO direct script access allowed');
6 6
 
7 7
 /**
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 
43 43
 
44 44
 
45
-	public function __construct( $routing = TRUE ) {
46
-		parent::__construct( $routing );
45
+	public function __construct($routing = TRUE) {
46
+		parent::__construct($routing);
47 47
 	}
48 48
 
49 49
 
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 
60 60
 
61 61
 	protected function _ajax_hooks() {
62
-		add_action('wp_ajax_espresso_display_country_settings', array( $this, 'display_country_settings'));
63
-		add_action('wp_ajax_espresso_display_country_states', array( $this, 'display_country_states'));
64
-		add_action('wp_ajax_espresso_delete_state', array( $this, 'delete_state'), 10, 3 );
65
-		add_action('wp_ajax_espresso_add_new_state', array( $this, 'add_new_state'));
62
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
63
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
64
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
65
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
66 66
 	}
67 67
 
68 68
 
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
 					'label' => __('Critical Pages', 'event_espresso'),
156 156
 					'order' => 50
157 157
 					),
158
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
158
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
159 159
                			'help_tabs' => array(
160 160
 					'general_settings_critical_pages_help_tab' => array(
161 161
 						'title' => __('Critical Pages', 'event_espresso'),
162 162
 						'filename' => 'general_settings_critical_pages'
163 163
 						)
164 164
 					),
165
-				'help_tour' => array( 'Critical_Pages_Help_Tour' ),
165
+				'help_tour' => array('Critical_Pages_Help_Tour'),
166 166
 				'require_nonce' => FALSE
167 167
 				),
168 168
 			'default' => array(
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 						'filename' => 'general_settings_your_organization'
177 177
 						)
178 178
 					),
179
-				'help_tour' => array( 'Your_Organization_Help_Tour' ),
180
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
179
+				'help_tour' => array('Your_Organization_Help_Tour'),
180
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
181 181
 				'require_nonce' => FALSE
182 182
 				),
183 183
 			'admin_option_settings' => array(
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
 					'label' => __('Admin Options', 'event_espresso'),
186 186
 					'order' => 60
187 187
 					),
188
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
188
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
189 189
                 			'help_tabs' => array(
190 190
 					'general_settings_admin_options_help_tab' => array(
191 191
 						'title' => __('Admin Options', 'event_espresso'),
192 192
 						'filename' => 'general_settings_admin_options'
193 193
 						)
194 194
 					),
195
-				'help_tour' => array( 'Admin_Options_Help_Tour' ),
195
+				'help_tour' => array('Admin_Options_Help_Tour'),
196 196
 				'require_nonce' => FALSE
197 197
 				),
198 198
 			'country_settings' => array(
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 						'filename' => 'general_settings_countries'
207 207
 						)
208 208
 					),
209
-				'help_tour' => array( 'Countries_Help_Tour' ),
209
+				'help_tour' => array('Countries_Help_Tour'),
210 210
 				'require_nonce' => FALSE
211 211
 				)
212 212
 			);
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
 	}
225 225
 
226 226
 	public function admin_init() {
227
-		EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = __( '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' );
228
-		EE_Registry::$i18n_js_strings[ 'error_occurred' ] = __( 'An error occurred! Please refresh the page and try again.', 'event_espresso' );
229
-		EE_Registry::$i18n_js_strings[ 'confirm_delete_state' ] = __( 'Are you sure you want to delete this State / Province?', 'event_espresso' );
230
-		$protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://';
231
-		EE_Registry::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php?page=espresso_general_settings', $protocol );
227
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __('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');
228
+		EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', 'event_espresso');
229
+		EE_Registry::$i18n_js_strings['confirm_delete_state'] = __('Are you sure you want to delete this State / Province?', 'event_espresso');
230
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
231
+		EE_Registry::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php?page=espresso_general_settings', $protocol);
232 232
 	}
233 233
 
234 234
 	public function admin_notices() {}
@@ -241,21 +241,21 @@  discard block
 block discarded – undo
241 241
 		//scripts
242 242
 		wp_enqueue_script('media-upload');
243 243
 		wp_enqueue_script('thickbox');
244
-		wp_register_script( 'organization_settings', GEN_SET_ASSETS_URL . 'your_organization_settings.js', array( 'jquery','media-upload','thickbox' ), EVENT_ESPRESSO_VERSION, TRUE );
245
-		wp_register_style( 'organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION );
246
-		wp_enqueue_script( 'organization_settings' );
247
-		wp_enqueue_style( 'organization-css' );
248
-		$confirm_image_delete = array( 'text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', 'event_espresso'));
249
-		wp_localize_script( 'organization_settings', 'confirm_image_delete', $confirm_image_delete );
244
+		wp_register_script('organization_settings', GEN_SET_ASSETS_URL.'your_organization_settings.js', array('jquery', 'media-upload', 'thickbox'), EVENT_ESPRESSO_VERSION, TRUE);
245
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
246
+		wp_enqueue_script('organization_settings');
247
+		wp_enqueue_style('organization-css');
248
+		$confirm_image_delete = array('text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', 'event_espresso'));
249
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
250 250
 
251 251
 	}
252 252
 
253 253
 	public function load_scripts_styles_country_settings() {
254 254
 		//scripts
255
-		wp_register_script( 'gen_settings_countries', GEN_SET_ASSETS_URL . 'gen_settings_countries.js', array( 'ee_admin_js' ), EVENT_ESPRESSO_VERSION, TRUE );
256
-		wp_register_style( 'organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION );
257
-		wp_enqueue_script( 'gen_settings_countries' );
258
-		wp_enqueue_style( 'organization-css' );
255
+		wp_register_script('gen_settings_countries', GEN_SET_ASSETS_URL.'gen_settings_countries.js', array('ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
256
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
257
+		wp_enqueue_script('gen_settings_countries');
258
+		wp_enqueue_style('organization-css');
259 259
 
260 260
 	}
261 261
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
300 300
         $this->_set_publish_post_box_vars(null, false, false, null, false);
301 301
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
302
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
302
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
303 303
             $this->_template_args,
304 304
             true
305 305
         );
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 
310 310
 	protected function _update_espresso_page_settings() {
311 311
 		// capture incoming request data
312
-		$reg_page_id = isset( $this->_req_data['reg_page_id'] ) ? absint( $this->_req_data['reg_page_id'] ) : EE_Registry::instance()->CFG->core->reg_page_id;
313
-		$txn_page_id = isset( $this->_req_data['txn_page_id'] ) ? absint( $this->_req_data['txn_page_id'] ) : EE_Registry::instance()->CFG->core->txn_page_id;
314
-		$thank_you_page_id = isset( $this->_req_data['thank_you_page_id'] ) ? absint( $this->_req_data['thank_you_page_id'] ) : EE_Registry::instance()->CFG->core->thank_you_page_id;
315
-		$cancel_page_id = isset( $this->_req_data['cancel_page_id'] ) ? absint( $this->_req_data['cancel_page_id'] ) : EE_Registry::instance()->CFG->core->cancel_page_id;
312
+		$reg_page_id = isset($this->_req_data['reg_page_id']) ? absint($this->_req_data['reg_page_id']) : EE_Registry::instance()->CFG->core->reg_page_id;
313
+		$txn_page_id = isset($this->_req_data['txn_page_id']) ? absint($this->_req_data['txn_page_id']) : EE_Registry::instance()->CFG->core->txn_page_id;
314
+		$thank_you_page_id = isset($this->_req_data['thank_you_page_id']) ? absint($this->_req_data['thank_you_page_id']) : EE_Registry::instance()->CFG->core->thank_you_page_id;
315
+		$cancel_page_id = isset($this->_req_data['cancel_page_id']) ? absint($this->_req_data['cancel_page_id']) : EE_Registry::instance()->CFG->core->cancel_page_id;
316 316
 		// pack critical_pages into an array
317 317
 		$critical_pages = array(
318 318
 			'reg_page_id' 				=> $reg_page_id,
@@ -320,17 +320,17 @@  discard block
 block discarded – undo
320 320
 			'thank_you_page_id' 	=> $thank_you_page_id,
321 321
 			'cancel_page_id' 		=> $cancel_page_id
322 322
 		);
323
-		foreach ( $critical_pages as $critical_page_name => $critical_page_id ) {
323
+		foreach ($critical_pages as $critical_page_name => $critical_page_id) {
324 324
 			// has the page changed ?
325
-			if ( EE_Registry::instance()->CFG->core->{$critical_page_name} !== $critical_page_id ) {
325
+			if (EE_Registry::instance()->CFG->core->{$critical_page_name} !== $critical_page_id) {
326 326
 				// grab post object for old page
327
-				$post = get_post( EE_Registry::instance()->CFG->core->{$critical_page_name} );
327
+				$post = get_post(EE_Registry::instance()->CFG->core->{$critical_page_name} );
328 328
 				// update post shortcodes for old page
329
-				EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save( $critical_page_id, $post );
329
+				EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($critical_page_id, $post);
330 330
 				// grab post object for new page
331
-				$post = get_post( $critical_page_id );
331
+				$post = get_post($critical_page_id);
332 332
 				// update post shortcodes for new page
333
-				EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save( $critical_page_id, $post );
333
+				EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($critical_page_id, $post);
334 334
 			}
335 335
 		}
336 336
 		// set page IDs
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 		EE_Registry::instance()->CFG->core->thank_you_page_id = $thank_you_page_id;
340 340
 		EE_Registry::instance()->CFG->core->cancel_page_id = $cancel_page_id;
341 341
 
342
-		EE_Registry::instance()->CFG->core = apply_filters( 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', EE_Registry::instance()->CFG->core, $this->_req_data );
342
+		EE_Registry::instance()->CFG->core = apply_filters('FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', EE_Registry::instance()->CFG->core, $this->_req_data);
343 343
 
344 344
 		$what = __('Critical Pages & Shortcodes', 'event_espresso');
345
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->core, __FILE__, __FUNCTION__, __LINE__ );
345
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->core, __FILE__, __FUNCTION__, __LINE__);
346 346
 		$query_args = array(
347 347
 			'action' => 'critical_pages'
348 348
 			);
349
-		$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
349
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
350 350
 
351 351
 	}
352 352
 
@@ -361,34 +361,34 @@  discard block
 block discarded – undo
361 361
 
362 362
 	protected function _your_organization_settings() {
363 363
 
364
-		$this->_template_args['site_license_key'] = isset( EE_Registry::instance()->NET_CFG->core->site_license_key ) ? EE_Registry::instance()->NET_CFG->core->get_pretty( 'site_license_key' ) : '';
365
-		$this->_template_args['organization_name'] = isset( EE_Registry::instance()->CFG->organization->name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : '';
366
-		$this->_template_args['organization_address_1'] = isset( EE_Registry::instance()->CFG->organization->address_1 ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'address_1' ) : '';
367
-		$this->_template_args['organization_address_2'] = isset( EE_Registry::instance()->CFG->organization->address_2 ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'address_2' ) : '';
368
-		$this->_template_args['organization_city'] = isset( EE_Registry::instance()->CFG->organization->city ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'city' ) : '';
369
-		$this->_template_args['organization_zip'] = isset( EE_Registry::instance()->CFG->organization->zip ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'zip' ) : '';
370
-		$this->_template_args['organization_email'] = isset( EE_Registry::instance()->CFG->organization->email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : '';
371
-		$this->_template_args['organization_phone'] = isset( EE_Registry::instance()->CFG->organization->phone ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'phone' ) : '';
372
-		$this->_template_args['organization_vat'] = isset( EE_Registry::instance()->CFG->organization->vat ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'vat' ) : '';
373
-		$this->_template_args['currency_sign'] = isset( EE_Registry::instance()->CFG->currency->sign ) ? EE_Registry::instance()->CFG->currency->get_pretty( 'sign' ) : '$';
374
-		$this->_template_args['organization_logo_url'] = isset( EE_Registry::instance()->CFG->organization->logo_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ) : FALSE;
375
-		$this->_template_args['organization_facebook'] = isset( EE_Registry::instance()->CFG->organization->facebook ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : '';
376
-		$this->_template_args['organization_twitter'] = isset( EE_Registry::instance()->CFG->organization->twitter ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : '';
377
-		$this->_template_args['organization_linkedin'] = isset( EE_Registry::instance()->CFG->organization->linkedin ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ) : '';
378
-		$this->_template_args['organization_pinterest'] = isset( EE_Registry::instance()->CFG->organization->pinterest ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ) : '';
379
-		$this->_template_args['organization_google'] = isset( EE_Registry::instance()->CFG->organization->google ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'google' ) : '';
380
-		$this->_template_args['organization_instagram'] = isset( EE_Registry::instance()->CFG->organization->instagram ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ) : '';
364
+		$this->_template_args['site_license_key'] = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') : '';
365
+		$this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : '';
366
+		$this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') : '';
367
+		$this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') : '';
368
+		$this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) ? EE_Registry::instance()->CFG->organization->get_pretty('city') : '';
369
+		$this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) ? EE_Registry::instance()->CFG->organization->get_pretty('zip') : '';
370
+		$this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : '';
371
+		$this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) ? EE_Registry::instance()->CFG->organization->get_pretty('phone') : '';
372
+		$this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) ? EE_Registry::instance()->CFG->organization->get_pretty('vat') : '';
373
+		$this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) ? EE_Registry::instance()->CFG->currency->get_pretty('sign') : '$';
374
+		$this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') : FALSE;
375
+		$this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : '';
376
+		$this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : '';
377
+		$this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') : '';
378
+		$this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') : '';
379
+		$this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) ? EE_Registry::instance()->CFG->organization->get_pretty('google') : '';
380
+		$this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') : '';
381 381
 		//UXIP settings
382
-		$this->_template_args['ee_ueip_optin'] = isset( EE_Registry::instance()->CFG->core->ee_ueip_optin ) ? EE_Registry::instance()->CFG->core->get_pretty( 'ee_ueip_optin' ) : TRUE;
382
+		$this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') : TRUE;
383 383
 
384
-		$STA_ID = isset( EE_Registry::instance()->CFG->organization->STA_ID ) ? EE_Registry::instance()->CFG->organization->STA_ID : 4;
384
+		$STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) ? EE_Registry::instance()->CFG->organization->STA_ID : 4;
385 385
 		$this->_template_args['states'] = new EE_Question_Form_Input(
386
-				EE_Question::new_instance ( array(
386
+				EE_Question::new_instance(array(
387 387
 					'QST_ID'=> 0,
388 388
 					'QST_display_text'=> __('State/Province', 'event_espresso'),
389 389
 					'QST_system'=>'admin-state'
390 390
 				)),
391
-				EE_Answer::new_instance ( array(
391
+				EE_Answer::new_instance(array(
392 392
 					'ANS_ID' => 0,
393 393
 					'ANS_value' => $STA_ID
394 394
 				)),
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
 				)
401 401
 			);
402 402
 
403
-		$CNT_ISO = isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
403
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
404 404
 		$this->_template_args['countries'] = new EE_Question_Form_Input(
405
-				EE_Question::new_instance ( array(
405
+				EE_Question::new_instance(array(
406 406
 					'QST_ID'=> 0,
407 407
 					'QST_display_text'=> __('Country', 'event_espresso'),
408 408
 					'QST_system'=>'admin-country'
409 409
 				)),
410
-				EE_Answer::new_instance ( array(
410
+				EE_Answer::new_instance(array(
411 411
 					'ANS_ID' => 0,
412 412
 					'ANS_value' => $CNT_ISO
413 413
 				)),
@@ -419,51 +419,51 @@  discard block
 block discarded – undo
419 419
 				)
420 420
 			);
421 421
 
422
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
423
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
422
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
423
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
424 424
 
425 425
 		//PUE verification stuff
426
-		$ver_option_key = 'puvererr_' . basename( EE_PLUGIN_BASENAME );
427
-		$verify_fail = get_option( $ver_option_key );
428
-		$this->_template_args['site_license_key_verified'] = $verify_fail || !empty( $verify_fail ) || ( empty( $this->_template_args['site_license_key'] ) && empty( $verify_fail ) )? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
426
+		$ver_option_key = 'puvererr_'.basename(EE_PLUGIN_BASENAME);
427
+		$verify_fail = get_option($ver_option_key);
428
+		$this->_template_args['site_license_key_verified'] = $verify_fail || ! empty($verify_fail) || (empty($this->_template_args['site_license_key']) && empty($verify_fail)) ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
429 429
 
430
-		$this->_set_add_edit_form_tags( 'update_your_organization_settings' );
431
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
432
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', $this->_template_args, TRUE );
430
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
431
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
432
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'your_organization_settings.template.php', $this->_template_args, TRUE);
433 433
 
434 434
 		$this->display_admin_page_with_sidebar();
435 435
 	}
436 436
 
437 437
 	protected function _update_your_organization_settings() {
438
-		if ( is_main_site() )
439
-			EE_Registry::instance()->NET_CFG->core->site_license_key = isset( $this->_req_data['site_license_key'] ) ? sanitize_text_field( $this->_req_data['site_license_key'] ) : EE_Registry::instance()->NET_CFG->core->site_license_key;
440
-		EE_Registry::instance()->CFG->organization->name = isset( $this->_req_data['organization_name'] ) ? sanitize_text_field( $this->_req_data['organization_name'] ) : EE_Registry::instance()->CFG->organization->name;
441
-		EE_Registry::instance()->CFG->organization->address_1 = isset( $this->_req_data['organization_address_1'] ) ? sanitize_text_field( $this->_req_data['organization_address_1'] ) : EE_Registry::instance()->CFG->organization->address_1;
442
-		EE_Registry::instance()->CFG->organization->address_2 = isset( $this->_req_data['organization_address_2'] ) ? sanitize_text_field( $this->_req_data['organization_address_2'] ) : EE_Registry::instance()->CFG->organization->address_2;
443
-		EE_Registry::instance()->CFG->organization->city = isset( $this->_req_data['organization_city'] ) ? sanitize_text_field( $this->_req_data['organization_city'] ) : EE_Registry::instance()->CFG->organization->city;
444
-		EE_Registry::instance()->CFG->organization->STA_ID = isset( $this->_req_data['organization_state'] ) ? absint( $this->_req_data['organization_state'] ) : EE_Registry::instance()->CFG->organization->STA_ID;
445
-		EE_Registry::instance()->CFG->organization->CNT_ISO = isset( $this->_req_data['organization_country'] ) ? sanitize_text_field( $this->_req_data['organization_country'] ) : EE_Registry::instance()->CFG->organization->CNT_ISO;
446
-		EE_Registry::instance()->CFG->organization->zip = isset( $this->_req_data['organization_zip'] ) ? sanitize_text_field( $this->_req_data['organization_zip'] ) : EE_Registry::instance()->CFG->organization->zip;
447
-		EE_Registry::instance()->CFG->organization->email = isset( $this->_req_data['organization_email'] ) ? sanitize_email( $this->_req_data['organization_email'] ) : EE_Registry::instance()->CFG->organization->email;
448
-		EE_Registry::instance()->CFG->organization->vat = isset( $this->_req_data['organization_vat'] ) ? sanitize_text_field( $this->_req_data['organization_vat'] ) : EE_Registry::instance()->CFG->organization->vat;
449
-		EE_Registry::instance()->CFG->organization->phone = isset( $this->_req_data['organization_phone'] ) ? sanitize_text_field( $this->_req_data['organization_phone'] ) : EE_Registry::instance()->CFG->organization->phone;
450
-		EE_Registry::instance()->CFG->organization->logo_url = isset( $this->_req_data['organization_logo_url'] ) ? esc_url_raw( $this->_req_data['organization_logo_url'] ) : EE_Registry::instance()->CFG->organization->logo_url;
451
-		EE_Registry::instance()->CFG->organization->facebook = isset( $this->_req_data['organization_facebook'] ) ? esc_url_raw( $this->_req_data['organization_facebook'] ) : EE_Registry::instance()->CFG->organization->facebook;
452
-		EE_Registry::instance()->CFG->organization->twitter = isset( $this->_req_data['organization_twitter'] ) ? esc_url_raw( $this->_req_data['organization_twitter'] ) : EE_Registry::instance()->CFG->organization->twitter;
453
-		EE_Registry::instance()->CFG->organization->linkedin = isset( $this->_req_data['organization_linkedin'] ) ? esc_url_raw( $this->_req_data['organization_linkedin'] ) : EE_Registry::instance()->CFG->organization->linkedin;
454
-		EE_Registry::instance()->CFG->organization->pinterest = isset( $this->_req_data['organization_pinterest'] ) ? esc_url_raw( $this->_req_data['organization_pinterest'] ) : EE_Registry::instance()->CFG->organization->pinterest;
455
-		EE_Registry::instance()->CFG->organization->google = isset( $this->_req_data['organization_google'] ) ? esc_url_raw( $this->_req_data['organization_google'] ) : EE_Registry::instance()->CFG->organization->google;
456
-		EE_Registry::instance()->CFG->organization->instagram = isset( $this->_req_data['organization_instagram'] ) ? esc_url_raw( $this->_req_data['organization_instagram'] ) : EE_Registry::instance()->CFG->organization->instagram;
457
-		EE_Registry::instance()->CFG->core->ee_ueip_optin = isset( $this->_req_data['ueip_optin'] ) && !empty( $this->_req_data['ueip_optin'] ) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin;
458
-
459
-		EE_Registry::instance()->CFG->currency = new EE_Currency_Config( EE_Registry::instance()->CFG->organization->CNT_ISO );
460
-
461
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', EE_Registry::instance()->CFG );
438
+		if (is_main_site())
439
+			EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) ? sanitize_text_field($this->_req_data['site_license_key']) : EE_Registry::instance()->NET_CFG->core->site_license_key;
440
+		EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) ? sanitize_text_field($this->_req_data['organization_name']) : EE_Registry::instance()->CFG->organization->name;
441
+		EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) ? sanitize_text_field($this->_req_data['organization_address_1']) : EE_Registry::instance()->CFG->organization->address_1;
442
+		EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) ? sanitize_text_field($this->_req_data['organization_address_2']) : EE_Registry::instance()->CFG->organization->address_2;
443
+		EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) ? sanitize_text_field($this->_req_data['organization_city']) : EE_Registry::instance()->CFG->organization->city;
444
+		EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) ? absint($this->_req_data['organization_state']) : EE_Registry::instance()->CFG->organization->STA_ID;
445
+		EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) ? sanitize_text_field($this->_req_data['organization_country']) : EE_Registry::instance()->CFG->organization->CNT_ISO;
446
+		EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) ? sanitize_text_field($this->_req_data['organization_zip']) : EE_Registry::instance()->CFG->organization->zip;
447
+		EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) ? sanitize_email($this->_req_data['organization_email']) : EE_Registry::instance()->CFG->organization->email;
448
+		EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) ? sanitize_text_field($this->_req_data['organization_vat']) : EE_Registry::instance()->CFG->organization->vat;
449
+		EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) ? sanitize_text_field($this->_req_data['organization_phone']) : EE_Registry::instance()->CFG->organization->phone;
450
+		EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) ? esc_url_raw($this->_req_data['organization_logo_url']) : EE_Registry::instance()->CFG->organization->logo_url;
451
+		EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) ? esc_url_raw($this->_req_data['organization_facebook']) : EE_Registry::instance()->CFG->organization->facebook;
452
+		EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) ? esc_url_raw($this->_req_data['organization_twitter']) : EE_Registry::instance()->CFG->organization->twitter;
453
+		EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) ? esc_url_raw($this->_req_data['organization_linkedin']) : EE_Registry::instance()->CFG->organization->linkedin;
454
+		EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) ? esc_url_raw($this->_req_data['organization_pinterest']) : EE_Registry::instance()->CFG->organization->pinterest;
455
+		EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) ? esc_url_raw($this->_req_data['organization_google']) : EE_Registry::instance()->CFG->organization->google;
456
+		EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) ? esc_url_raw($this->_req_data['organization_instagram']) : EE_Registry::instance()->CFG->organization->instagram;
457
+		EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) && ! empty($this->_req_data['ueip_optin']) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin;
458
+
459
+		EE_Registry::instance()->CFG->currency = new EE_Currency_Config(EE_Registry::instance()->CFG->organization->CNT_ISO);
460
+
461
+		EE_Registry::instance()->CFG = apply_filters('FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', EE_Registry::instance()->CFG);
462 462
 
463 463
 		$what = 'Your Organization Settings';
464
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
464
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
465 465
 
466
-		$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'default' ) );
466
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
467 467
 
468 468
 	}
469 469
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
             ),
530 530
             'Admin Options',
531 531
             'updated',
532
-            array( 'action' => 'admin_option_settings' )
532
+            array('action' => 'admin_option_settings')
533 533
         );
534 534
 
535 535
 	}
@@ -543,20 +543,20 @@  discard block
 block discarded – undo
543 543
 
544 544
 	protected function _country_settings() {
545 545
 
546
-		$CNT_ISO = isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
547
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : $CNT_ISO;
546
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
547
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
548 548
 
549 549
 		//load field generator helper
550 550
 
551 551
 		$this->_template_args['values'] = $this->_yes_no_values;
552 552
 
553 553
 		$this->_template_args['countries'] = new EE_Question_Form_Input(
554
-				EE_Question::new_instance ( array(
554
+				EE_Question::new_instance(array(
555 555
 					'QST_ID'=> 0,
556 556
 					'QST_display_text'=> __('Select Country', 'event_espresso'),
557 557
 					'QST_system'=>'admin-country'
558 558
 				)),
559
-				EE_Answer::new_instance ( array(
559
+				EE_Answer::new_instance(array(
560 560
 					'ANS_ID' => 0,
561 561
 					'ANS_value' => $CNT_ISO
562 562
 				)),
@@ -569,14 +569,14 @@  discard block
 block discarded – undo
569 569
 			);
570 570
 //		EEH_Debug_Tools::printr( $this->_template_args['countries'], 'countries  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
571 571
 
572
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
573
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
572
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
573
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
574 574
 		$this->_template_args['country_details_settings'] = $this->display_country_settings();
575 575
 		$this->_template_args['country_states_settings'] = $this->display_country_states();
576 576
 
577
-		$this->_set_add_edit_form_tags( 'update_country_settings' );
578
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
579
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', $this->_template_args, TRUE );
577
+		$this->_set_add_edit_form_tags('update_country_settings');
578
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
579
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'countries_settings.template.php', $this->_template_args, TRUE);
580 580
 		$this->display_admin_page_with_no_sidebar();
581 581
 	}
582 582
 
@@ -589,43 +589,43 @@  discard block
 block discarded – undo
589 589
 	 * 		@param 	string 		$CNT_ISO
590 590
 	 * 		@return 		mixed		string | array
591 591
 	 */
592
-	public function display_country_settings( $CNT_ISO = '' ) {
592
+	public function display_country_settings($CNT_ISO = '') {
593 593
 
594
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : $CNT_ISO;
595
-		if ( ! $CNT_ISO ) {
594
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
595
+		if ( ! $CNT_ISO) {
596 596
 			return '';
597 597
 		}
598 598
 
599 599
 		// for ajax
600
-		remove_all_filters( 'FHEE__EEH_Form_Fields__label_html' );
601
-		remove_all_filters( 'FHEE__EEH_Form_Fields__input_html' );
602
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
603
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
604
-		$country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO );
600
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
601
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
602
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
603
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
604
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
605 605
 		//EEH_Debug_Tools::printr( $country, '$country  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
606 606
 		$country_input_types = array(
607
-			'CNT_active' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE  ),
608
-			'CNT_ISO' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
609
-			'CNT_ISO3' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
610
-			'RGN_ID' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
611
-			'CNT_name' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'regular-text' ),
612
-			'CNT_cur_code' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
613
-			'CNT_cur_single' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'medium-text' ),
614
-			'CNT_cur_plural' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'medium-text' ),
615
-			'CNT_cur_sign' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text', 'htmlentities' => FALSE ),
616
-			'CNT_cur_sign_b4' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE ),
617
-			'CNT_cur_dec_plc' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => 0, 'text' => '' ), array( 'id' => 1, 'text' => '' ), array( 'id' => 2, 'text' => '' ), array( 'id' => 3, 'text' => '' ))),
618
-			'CNT_cur_dec_mrk' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => ',', 'text' => __(', (comma)', 'event_espresso')), array( 'id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE ),
619
-			'CNT_cur_thsnds' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => ',', 'text' => __(', (comma)', 'event_espresso')), array( 'id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE ),
620
-			'CNT_tel_code' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
621
-			'CNT_is_EU' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE  )
607
+			'CNT_active' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE),
608
+			'CNT_ISO' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
609
+			'CNT_ISO3' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
610
+			'RGN_ID' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
611
+			'CNT_name' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'regular-text'),
612
+			'CNT_cur_code' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
613
+			'CNT_cur_single' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'medium-text'),
614
+			'CNT_cur_plural' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'medium-text'),
615
+			'CNT_cur_sign' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text', 'htmlentities' => FALSE),
616
+			'CNT_cur_sign_b4' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE),
617
+			'CNT_cur_dec_plc' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => 0, 'text' => ''), array('id' => 1, 'text' => ''), array('id' => 2, 'text' => ''), array('id' => 3, 'text' => ''))),
618
+			'CNT_cur_dec_mrk' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => ',', 'text' => __(', (comma)', 'event_espresso')), array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE),
619
+			'CNT_cur_thsnds' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => ',', 'text' => __(', (comma)', 'event_espresso')), array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE),
620
+			'CNT_tel_code' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
621
+			'CNT_is_EU' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE)
622 622
 		);
623
-		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( $country, $country_input_types );
624
-		$country_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', $this->_template_args, TRUE );
623
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($country, $country_input_types);
624
+		$country_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php', $this->_template_args, TRUE);
625 625
 
626
-		if ( defined( 'DOING_AJAX' )) {
627
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
628
-			echo json_encode( array( 'return_data' => $country_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'] ));
626
+		if (defined('DOING_AJAX')) {
627
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
628
+			echo json_encode(array('return_data' => $country_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors']));
629 629
 			die();
630 630
 		} else {
631 631
 			return $country_details_settings;
@@ -643,49 +643,49 @@  discard block
 block discarded – undo
643 643
 	 * 		@param 	string 		$CNT_ISO
644 644
 	 * 		@return 		string
645 645
 	 */
646
-	public function display_country_states( $CNT_ISO = '' ) {
646
+	public function display_country_states($CNT_ISO = '') {
647 647
 
648
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? sanitize_text_field( $this->_req_data['country'] ) : $CNT_ISO;
648
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
649 649
 
650
-		if ( ! $CNT_ISO ) {
650
+		if ( ! $CNT_ISO) {
651 651
 			return '';
652 652
 		}
653 653
 		// for ajax
654
-		remove_all_filters( 'FHEE__EEH_Form_Fields__label_html' );
655
-		remove_all_filters( 'FHEE__EEH_Form_Fields__input_html' );
656
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'state_form_field_label_wrap' ), 10, 2 );
657
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'state_form_field_input__wrap' ), 10, 2 );
658
-		$states = EEM_State::instance()->get_all_states_for_these_countries( array( $CNT_ISO => $CNT_ISO ));
654
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
655
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
656
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
657
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
658
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
659 659
 
660 660
 //			echo '<h4>$CNT_ISO : ' . $CNT_ISO . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
661 661
 //			global $wpdb;
662 662
 //			echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
663 663
 //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
664
-		if ( $states ) {
665
-			foreach ( $states as $STA_ID => $state ) {
666
-				if ( $state instanceof EE_State ) {
664
+		if ($states) {
665
+			foreach ($states as $STA_ID => $state) {
666
+				if ($state instanceof EE_State) {
667 667
 					//STA_abbrev 	STA_name 	STA_active
668 668
 					$state_input_types = array(
669
-						'STA_abbrev' => array( 'type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'mid-text' ),
670
-						'STA_name'   => array( 'type'       => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'regular-text' ),
671
-						'STA_active' => array( 'type' => 'RADIO_BTN', 'input_name' => 'states[' . $STA_ID . ']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true )
669
+						'STA_abbrev' => array('type' => 'TEXT', 'input_name' => 'states['.$STA_ID.']', 'class' => 'mid-text'),
670
+						'STA_name'   => array('type'       => 'TEXT', 'input_name' => 'states['.$STA_ID.']', 'class' => 'regular-text'),
671
+						'STA_active' => array('type' => 'RADIO_BTN', 'input_name' => 'states['.$STA_ID.']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true)
672 672
 					);
673
-					$this->_template_args[ 'states' ][ $STA_ID ][ 'inputs' ] = EE_Question_Form_Input::generate_question_form_inputs_for_object( $state, $state_input_types );
674
-					$query_args = array( 'action'     => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev() );
675
-					$this->_template_args[ 'states' ][ $STA_ID ][ 'delete_state_url' ] = EE_Admin_Page::add_query_args_and_nonce( $query_args, GEN_SET_ADMIN_URL );
673
+					$this->_template_args['states'][$STA_ID]['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($state, $state_input_types);
674
+					$query_args = array('action'     => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev());
675
+					$this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, GEN_SET_ADMIN_URL);
676 676
 				}
677 677
 			}
678 678
 		} else {
679 679
 			$this->_template_args['states'] = FALSE;
680 680
 		}
681 681
 //		EEH_Debug_Tools::printr( $this->_template_args['states'], 'states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
682
-		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'add_new_state' ),  GEN_SET_ADMIN_URL );
682
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'), GEN_SET_ADMIN_URL);
683 683
 
684
-		$state_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', $this->_template_args, TRUE );
684
+		$state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php', $this->_template_args, TRUE);
685 685
 
686
-		if ( defined( 'DOING_AJAX' )) {
687
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
688
-			echo json_encode( array( 'return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'] ));
686
+		if (defined('DOING_AJAX')) {
687
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
688
+			echo json_encode(array('return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors']));
689 689
 			die();
690 690
 		} else {
691 691
 			return $state_details_settings;
@@ -706,40 +706,39 @@  discard block
 block discarded – undo
706 706
 
707 707
 		$success = TRUE;
708 708
 
709
-		$CNT_ISO = isset( $this->_req_data['CNT_ISO'] ) ? strtoupper( sanitize_text_field( $this->_req_data['CNT_ISO'] )) : FALSE;
710
-		if ( ! $CNT_ISO ) {
711
-			EE_Error::add_error( __( 'No Country ISO code or an invalid Country ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
709
+		$CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : FALSE;
710
+		if ( ! $CNT_ISO) {
711
+			EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
712 712
 			$success = FALSE;
713 713
 		}
714
-		$STA_abbrev = isset( $this->_req_data['STA_abbrev'] ) ? sanitize_text_field( $this->_req_data['STA_abbrev'] ) : FALSE;
715
-		if ( ! $STA_abbrev ) {
716
-			EE_Error::add_error( __( 'No State ISO code or an invalid State ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
714
+		$STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : FALSE;
715
+		if ( ! $STA_abbrev) {
716
+			EE_Error::add_error(__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
717 717
 			$success = FALSE;
718 718
 		}
719
-		$STA_name = isset( $this->_req_data['STA_name'] ) ?  sanitize_text_field( $this->_req_data['STA_name'] ) :
720
-			FALSE;
721
-		if ( ! $STA_name ) {
722
-			EE_Error::add_error( __( 'No State name or an invalid State name was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
719
+		$STA_name = isset($this->_req_data['STA_name']) ? sanitize_text_field($this->_req_data['STA_name']) : FALSE;
720
+		if ( ! $STA_name) {
721
+			EE_Error::add_error(__('No State name or an invalid State name was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
723 722
 			$success = FALSE;
724 723
 		}
725 724
 
726
-		if ( $success ) {
725
+		if ($success) {
727 726
 			$cols_n_values = array(
728 727
 				'CNT_ISO' => $CNT_ISO,
729 728
 				'STA_abbrev' => $STA_abbrev,
730 729
 				'STA_name' => $STA_name,
731 730
 				'STA_active' => TRUE
732 731
 			);
733
-			$success = EEM_State::instance()->insert ( $cols_n_values );
734
-			EE_Error::add_success( __( 'The State was added successfully.', 'event_espresso' ) );
732
+			$success = EEM_State::instance()->insert($cols_n_values);
733
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
735 734
 		}
736 735
 
737
-		if ( defined( 'DOING_AJAX' )) {
738
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
739
-			echo json_encode( array_merge( $notices, array( 'return_data' => $CNT_ISO ) ) );
736
+		if (defined('DOING_AJAX')) {
737
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
738
+			echo json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
740 739
 			die();
741 740
 		} else {
742
-			$this->_redirect_after_action( $success, 'State', 'added', array( 'action' => 'country_settings' ) );
741
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
743 742
 		}
744 743
 	}
745 744
 
@@ -752,25 +751,25 @@  discard block
 block discarded – undo
752 751
 	 * 		@return 		boolean | void
753 752
 	 */
754 753
 	public function delete_state() {
755
-		$CNT_ISO = isset( $this->_req_data['CNT_ISO'] ) ? strtoupper( sanitize_text_field( $this->_req_data['CNT_ISO'] )) : FALSE;
756
-		$STA_ID = isset( $this->_req_data['STA_ID'] ) ? sanitize_text_field( $this->_req_data['STA_ID'] ) : FALSE;
757
-		$STA_abbrev = isset( $this->_req_data['STA_abbrev'] ) ? sanitize_text_field( $this->_req_data['STA_abbrev'] ) : FALSE;
758
-		if ( ! $STA_ID ) {
759
-			EE_Error::add_error( __( 'No State ID or an invalid State ID was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
754
+		$CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : FALSE;
755
+		$STA_ID = isset($this->_req_data['STA_ID']) ? sanitize_text_field($this->_req_data['STA_ID']) : FALSE;
756
+		$STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : FALSE;
757
+		if ( ! $STA_ID) {
758
+			EE_Error::add_error(__('No State ID or an invalid State ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
760 759
 			return FALSE;
761 760
 		}
762
-		$success = EEM_State::instance()->delete_by_ID( $STA_ID );
763
-		if ( $success !== FALSE ) {
764
-			do_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, array( 'STA_abbrev' => $STA_abbrev ));
765
-			EE_Error::add_success( __( 'The State was deleted successfully.', 'event_espresso' ));
761
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
762
+		if ($success !== FALSE) {
763
+			do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, array('STA_abbrev' => $STA_abbrev));
764
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
766 765
 		}
767
-		if ( defined( 'DOING_AJAX' )) {
768
-			$notices = EE_Error::get_notices( FALSE, FALSE );
766
+		if (defined('DOING_AJAX')) {
767
+			$notices = EE_Error::get_notices(FALSE, FALSE);
769 768
 			$notices['return_data'] = TRUE;
770
-			echo json_encode( $notices );
769
+			echo json_encode($notices);
771 770
 			die();
772 771
 		} else {
773
-			$this->_redirect_after_action( $success, 'State', 'deleted', array( 'action' => 'country_settings' ) );
772
+			$this->_redirect_after_action($success, 'State', 'deleted', array('action' => 'country_settings'));
774 773
 		}
775 774
 	}
776 775
 
@@ -786,63 +785,63 @@  discard block
 block discarded – undo
786 785
 	protected function _update_country_settings() {
787 786
 //		EEH_Debug_Tools::printr( $this->_req_data, '$this->_req_data  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
788 787
 		// grab the country ISO code
789
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : FALSE;
790
-		if ( ! $CNT_ISO ) {
791
-			EE_Error::add_error( __( 'No Country ISO code or an invalid Country ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
788
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : FALSE;
789
+		if ( ! $CNT_ISO) {
790
+			EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
792 791
 			return;
793 792
 		}
794 793
 		$cols_n_values = array();
795
-		$cols_n_values['CNT_ISO3'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'] ) ? strtoupper( sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'] )) : FALSE;
796
-		$cols_n_values['RGN_ID'] = isset( $this->_req_data['cntry'][$CNT_ISO]['RGN_ID'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['RGN_ID'] ) : NULL;
797
-		$cols_n_values['CNT_name'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_name'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_name'] ) : NULL;
798
-		$cols_n_values['CNT_cur_code'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'] ) ? strtoupper( sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'] )) : 'USD';
799
-		$cols_n_values['CNT_cur_single'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'] ) : 'dollar';
800
-		$cols_n_values['CNT_cur_plural'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'] ) : 'dollars';
801
-		$cols_n_values['CNT_cur_sign'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'] ) : '$';
802
-		$cols_n_values['CNT_cur_sign_b4'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'] ) : TRUE;
803
-		$cols_n_values['CNT_cur_dec_plc'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'] ) : 2;
804
-		$cols_n_values['CNT_cur_dec_mrk'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'] ) : '.';
805
-		$cols_n_values['CNT_cur_thsnds'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'] ) : ',';
806
-		$cols_n_values['CNT_tel_code'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'] ) : NULL;
807
-		$cols_n_values['CNT_is_EU'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'] ) : FALSE;
808
-		$cols_n_values['CNT_active'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_active'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_active'] ) : FALSE;
794
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) : FALSE;
795
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) : NULL;
796
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) : NULL;
797
+		$cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) : 'USD';
798
+		$cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) : 'dollar';
799
+		$cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) : 'dollars';
800
+		$cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) : '$';
801
+		$cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) : TRUE;
802
+		$cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) : 2;
803
+		$cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) : '.';
804
+		$cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) : ',';
805
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) : NULL;
806
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) : FALSE;
807
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) : FALSE;
809 808
 		// allow filtering of country data
810
-		$cols_n_values = apply_filters( 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', $cols_n_values );
809
+		$cols_n_values = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', $cols_n_values);
811 810
 		//EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
812 811
 		// where values
813
-		$where_cols_n_values = array( array( 'CNT_ISO' => $CNT_ISO ));
812
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
814 813
 		// run the update
815
-		$success = EEM_Country::instance()->update( $cols_n_values, $where_cols_n_values );
814
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
816 815
 //		global $wpdb;
817 816
 //		echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
818 817
 //		echo '<h4>$success : ' . $success . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
819
-		if ( isset( $this->_req_data['states'] ) && is_array( $this->_req_data['states'] ) && $success !== FALSE ) {
818
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== FALSE) {
820 819
 			// allow filtering of states data
821
-			$states = apply_filters( 'FHEE__General_Settings_Admin_Page___update_country_settings__states', $this->_req_data['states'] );
820
+			$states = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__states', $this->_req_data['states']);
822 821
 //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
823 822
 			// loop thru state data ( looks like : states[75][STA_name] )
824
-			foreach( $states as $STA_ID => $state ) {
823
+			foreach ($states as $STA_ID => $state) {
825 824
 				$cols_n_values = array(
826 825
 					'CNT_ISO' 		=> $CNT_ISO,
827
-					'STA_abbrev' => sanitize_text_field( $state['STA_abbrev'] ),
828
-					'STA_name' 	=> sanitize_text_field( $state['STA_name'] ),
829
-					'STA_active' 	=> (bool)absint( $state['STA_active'] )
826
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
827
+					'STA_name' 	=> sanitize_text_field($state['STA_name']),
828
+					'STA_active' 	=> (bool) absint($state['STA_active'])
830 829
 				);
831 830
 				// where values
832
-				$where_cols_n_values = array( array( 'STA_ID' => $STA_ID ));
831
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
833 832
 				// run the update
834
-				$success = EEM_State::instance()->update( $cols_n_values, $where_cols_n_values );
835
-				if ( $success !== FALSE ) {
836
-					do_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, $STA_ID, $cols_n_values );
833
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
834
+				if ($success !== FALSE) {
835
+					do_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, $STA_ID, $cols_n_values);
837 836
 				}
838 837
 			}
839 838
 		}
840 839
 		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
841
-		if ( isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO ) {
842
-			EE_Registry::instance()->CFG->currency = new EE_Currency_Config( $CNT_ISO );
840
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO) {
841
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
843 842
 			EE_Registry::instance()->CFG->update_espresso_config();
844 843
 		}
845
-		$this->_redirect_after_action( $success, 'Countries', 'updated', array( 'action' => 'country_settings', 'country' => $CNT_ISO ));
844
+		$this->_redirect_after_action($success, 'Countries', 'updated', array('action' => 'country_settings', 'country' => $CNT_ISO));
846 845
 	}
847 846
 
848 847
 
@@ -856,11 +855,11 @@  discard block
 block discarded – undo
856 855
 	 * 		@param 		string 		$label
857 856
 	 * 		@return 		string
858 857
 	 */
859
-	public function country_form_field_label_wrap( $label, $required_text ) {
858
+	public function country_form_field_label_wrap($label, $required_text) {
860 859
 		return '
861 860
 			<tr>
862 861
 				<th>
863
-					' . $label  . '
862
+					' . $label.'
864 863
 				</th>';
865 864
 	}
866 865
 
@@ -874,10 +873,10 @@  discard block
 block discarded – undo
874 873
 	 * 		@param 		string 		$label
875 874
 	 * 		@return 		string
876 875
 	 */
877
-	public function country_form_field_input__wrap( $input, $label ) {
876
+	public function country_form_field_input__wrap($input, $label) {
878 877
 		return '
879 878
 				<td class="general-settings-country-input-td">
880
-					' . $input . '
879
+					' . $input.'
881 880
 				</td>
882 881
 			</tr>';
883 882
 	}
@@ -893,7 +892,7 @@  discard block
 block discarded – undo
893 892
 	 * 		@param 		string 		$required_text
894 893
 	 * 		@return 		string
895 894
 	 */
896
-	public function state_form_field_label_wrap( $label, $required_text  ) {
895
+	public function state_form_field_label_wrap($label, $required_text) {
897 896
 		return $required_text;
898 897
 	}
899 898
 
@@ -907,10 +906,10 @@  discard block
 block discarded – undo
907 906
 	 * 		@param 		string 		$label
908 907
 	 * 		@return 		string
909 908
 	 */
910
-	public function state_form_field_input__wrap( $input, $label ) {
909
+	public function state_form_field_input__wrap($input, $label) {
911 910
 		return '
912 911
 				<td class="general-settings-country-state-input-td">
913
-					' . $input . '
912
+					' . $input.'
914 913
 				</td>';
915 914
 
916 915
 	}
@@ -933,10 +932,10 @@  discard block
 block discarded – undo
933 932
 	 * @param int $ee_page_id
934 933
 	 * @return string
935 934
 	 */
936
-	public static function edit_view_links( $ee_page_id ) {
937
-		$links = '<a href="' . add_query_arg( array( 'post' => $ee_page_id, 'action' => 'edit' ),  admin_url( 'post.php' )) . '" >' . __('Edit', 'event_espresso') . '</a>';
935
+	public static function edit_view_links($ee_page_id) {
936
+		$links = '<a href="'.add_query_arg(array('post' => $ee_page_id, 'action' => 'edit'), admin_url('post.php')).'" >'.__('Edit', 'event_espresso').'</a>';
938 937
 		$links .= ' &nbsp;|&nbsp; ';
939
-		$links .= '<a href="' . get_permalink( $ee_page_id ) . '" >' . __('View', 'event_espresso') . '</a>';
938
+		$links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
940 939
 		return $links;
941 940
 	}
942 941
 
@@ -949,27 +948,27 @@  discard block
 block discarded – undo
949 948
 	 * @param WP page object $ee_page
950 949
 	 * @return string
951 950
 	 */
952
-	public static function page_and_shortcode_status( $ee_page, $shortcode ) {
951
+	public static function page_and_shortcode_status($ee_page, $shortcode) {
953 952
 
954 953
 		// page status
955
-		if ( isset( $ee_page->post_status ) && $ee_page->post_status == 'publish') {
954
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
956 955
 			$pg_colour = 'green';
957
-			$pg_status = sprintf( __('Page%sStatus%sOK', 'event_espresso'), '&nbsp;' , '&nbsp;' );
956
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
958 957
 		 } else {
959 958
 			$pg_colour = 'red';
960
-			$pg_status = sprintf( __('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;'  );
959
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
961 960
 		}
962 961
 
963 962
 		// shortcode status
964
-		if ( isset( $ee_page->post_content ) && strpos( $ee_page->post_content, $shortcode ) !== FALSE ) {
963
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== FALSE) {
965 964
 			$sc_colour = 'green';
966
-			$sc_status = sprintf( __('Shortcode%sOK', 'event_espresso'), '&nbsp;' );
965
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
967 966
 		 } else {
968 967
 			$sc_colour = 'red';
969
-			$sc_status = sprintf( __('Shortcode%sProblem', 'event_espresso'), '&nbsp;' );
968
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
970 969
 		}
971 970
 
972
-		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' . $pg_status . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
971
+		return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'.$pg_status.'</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
973 972
 
974 973
 	}
975 974
 
@@ -984,20 +983,20 @@  discard block
 block discarded – undo
984 983
 	 * @param unknown_type $level
985 984
 	 * @return unknown
986 985
 	 */
987
-	public static function page_settings_dropdown( $default = 0, $parent = 0, $level = 0 ) {
986
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) {
988 987
 		global $wpdb;
989
-		$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", $parent) );
988
+		$items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", $parent));
990 989
 
991
-		if ( $items ) {
992
-			foreach ( $items as $item ) {
993
-				$pad = str_repeat( '&nbsp;', $level * 3 );
994
-				if ( $item->ID == $default)
990
+		if ($items) {
991
+			foreach ($items as $item) {
992
+				$pad = str_repeat('&nbsp;', $level * 3);
993
+				if ($item->ID == $default)
995 994
 					$current = ' selected="selected"';
996 995
 				else
997 996
 					$current = '';
998 997
 
999
-				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
1000
-				parent_dropdown( $default, $item->ID, $level +1 );
998
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad ".esc_html($item->post_title)."</option>";
999
+				parent_dropdown($default, $item->ID, $level + 1);
1001 1000
 			}
1002 1001
 		} else {
1003 1002
 			return false;
Please login to merge, or discard this patch.
modules/invalid_checkout_access/InvalidCheckoutAccess.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\modules\invalid_checkout_access;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -35,31 +35,31 @@  discard block
 block discarded – undo
35 35
 	 * @param \EE_Checkout $checkout
36 36
 	 * @return bool true if access to registration checkout appears to be invalid
37 37
 	 */
38
-	public function checkoutAccessIsInvalid( \EE_Checkout $checkout ) {
38
+	public function checkoutAccessIsInvalid(\EE_Checkout $checkout) {
39 39
 		if (
40 40
 			\EE_Config::instance()->registration->track_invalid_checkout_access()
41
-			&& ! ( $checkout->uts || $checkout->reg_url_link )
42
-			&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
41
+			&& ! ($checkout->uts || $checkout->reg_url_link)
42
+			&& ! (defined('DOING_AJAX') && DOING_AJAX)
43 43
 		) {
44 44
 			/** @var \EE_Request $request */
45
-			$request = \EE_Registry::instance()->load_core( 'EE_Request' );
45
+			$request = \EE_Registry::instance()->load_core('EE_Request');
46 46
 			$ip_address = $request->ip_address();
47
-			$ee_bot_checkout = get_option( InvalidCheckoutAccess::OPTION_KEY );
48
-			if ( $ee_bot_checkout === false ) {
47
+			$ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY);
48
+			if ($ee_bot_checkout === false) {
49 49
 				$ee_bot_checkout = array();
50
-				add_option( InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false );
50
+				add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false);
51 51
 			}
52
-			if ( ! isset( $ee_bot_checkout[ $ip_address ] ) ) {
53
-				$ee_bot_checkout[ $ip_address ] = array();
52
+			if ( ! isset($ee_bot_checkout[$ip_address])) {
53
+				$ee_bot_checkout[$ip_address] = array();
54 54
 			}
55
-			$http_referer = ( isset( $_SERVER['HTTP_REFERER'] ) )
56
-				? esc_attr( $_SERVER['HTTP_REFERER'] )
55
+			$http_referer = (isset($_SERVER['HTTP_REFERER']))
56
+				? esc_attr($_SERVER['HTTP_REFERER'])
57 57
 				: 0;
58
-			if ( ! isset( $ee_bot_checkout[ $ip_address ][ $http_referer ] ) ) {
59
-				$ee_bot_checkout[ $ip_address ][ $http_referer ] = 0;
58
+			if ( ! isset($ee_bot_checkout[$ip_address][$http_referer])) {
59
+				$ee_bot_checkout[$ip_address][$http_referer] = 0;
60 60
 			}
61
-			$ee_bot_checkout[ $ip_address ][ $http_referer ]++;
62
-			update_option( InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout );
61
+			$ee_bot_checkout[$ip_address][$http_referer]++;
62
+			update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout);
63 63
 			$checkout->redirect = true;
64 64
 			$checkout->redirect_url = get_post_type_archive_link('espresso_events');
65 65
             \EE_Error::add_error(
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 				'layout_strategy' => new \EE_Admin_Two_Column_Layout(),
89 89
 				'subsections'     => array(
90 90
 					'invalid_checkout_access_hdr'   => new \EE_Form_Section_HTML(
91
-						\EEH_HTML::h2( esc_html__( 'Invalid Checkout Access', 'event_espresso' ) )
91
+						\EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso'))
92 92
 					),
93 93
 					'ee_bot_checkout_data'          => new \EE_Text_Area_Input(
94 94
 						array(
95
-							'html_label_text' => esc_html__( 'Invalid Checkout Data', 'event_espresso' ),
95
+							'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'),
96 96
 							'default'         => var_export(
97
-								get_option( InvalidCheckoutAccess::OPTION_KEY, array() ),
97
+								get_option(InvalidCheckoutAccess::OPTION_KEY, array()),
98 98
 								true
99 99
 							),
100 100
 							'required'        => false,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 					),
107 107
 					'track_invalid_checkout_access' => new \EE_Yes_No_Input(
108 108
 						array(
109
-							'html_label_text'         => __( 'Track Invalid Checkout Access?', 'event_espresso' ),
109
+							'html_label_text'         => __('Track Invalid Checkout Access?', 'event_espresso'),
110 110
 							'html_help_text'          => esc_html__(
111 111
 								'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.',
112 112
 								'event_espresso'
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 					),
120 120
 					'delete_invalid_checkout_data'  => new \EE_Yes_No_Input(
121 121
 						array(
122
-							'html_label_text'         => __( 'Reset Invalid Checkout Data', 'event_espresso' ),
122
+							'html_label_text'         => __('Reset Invalid Checkout Data', 'event_espresso'),
123 123
 							'html_help_text'          => esc_html__(
124 124
 								'Setting this to "Yes" will delete all existing invalid checkout access data.',
125 125
 								'event_espresso'
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Registration_Config $EE_Registration_Config
142 142
 	 * @return \EE_Registration_Config
143 143
 	 */
144
-	public function processForm( \EE_Registration_Config $EE_Registration_Config ) {
144
+	public function processForm(\EE_Registration_Config $EE_Registration_Config) {
145 145
 		try {
146 146
 			$invalid_checkout_access_form = $this->getForm();
147 147
 			// if not displaying a form, then check for form submission
148
-			if ( $invalid_checkout_access_form->was_submitted() ) {
148
+			if ($invalid_checkout_access_form->was_submitted()) {
149 149
 				// capture form data
150 150
 				$invalid_checkout_access_form->receive_form_submission();
151 151
 				// validate form data
152
-				if ( $invalid_checkout_access_form->is_valid() ) {
152
+				if ($invalid_checkout_access_form->is_valid()) {
153 153
 					// grab validated data from form
154 154
 					$valid_data = $invalid_checkout_access_form->valid_data();
155 155
 					// ensure form inputs we want are set
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 							$valid_data['track_invalid_checkout_access']
164 164
 						);
165 165
 						// if deleting, then update option with empty array
166
-						if ( filter_var( $valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN ) ) {
167
-							update_option( InvalidCheckoutAccess::OPTION_KEY, array() );
166
+						if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) {
167
+							update_option(InvalidCheckoutAccess::OPTION_KEY, array());
168 168
 						}
169 169
 					} else {
170 170
 						\EE_Error::add_error(
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 						);
179 179
 					}
180 180
 				} else {
181
-					if ( $invalid_checkout_access_form->submission_error_message() !== '' ) {
181
+					if ($invalid_checkout_access_form->submission_error_message() !== '') {
182 182
 						\EE_Error::add_error(
183 183
 							$invalid_checkout_access_form->submission_error_message(),
184 184
 							__FILE__,
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 					}
189 189
 				}
190 190
 			}
191
-		} catch ( \EE_Error $e ) {
191
+		} catch (\EE_Error $e) {
192 192
 			$e->get_error();
193 193
 		}
194 194
 		return $EE_Registration_Config;
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 1 patch
Indentation   +385 added lines, -385 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/request_stack/EE_Request.core.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * class EE_Request
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 	public function set( $key, $value, $override_ee = FALSE ) {
134 134
 		// don't allow "ee" to be overwritten unless explicitly instructed to do so
135 135
 		if (
136
-		    $key !== 'ee'
137
-            || ( $key === 'ee' && empty( $this->_params['ee'] ))
138
-            || ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )
139
-        ) {
136
+			$key !== 'ee'
137
+			|| ( $key === 'ee' && empty( $this->_params['ee'] ))
138
+			|| ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )
139
+		) {
140 140
 			$this->_params[ $key ] = $value;
141 141
 		}
142 142
 	}
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 	 * @param array $post
70 70
 	 * @param array $cookie
71 71
 	 */
72
-	public function __construct( $get, $post, $cookie ) {
72
+	public function __construct($get, $post, $cookie) {
73 73
 		// grab request vars
74 74
 		$this->_get    = (array) $get;
75 75
 		$this->_post   = (array) $post;
76 76
 		$this->_cookie = (array) $cookie;
77 77
 		$this->_params = array_merge($this->_get, $this->_post);
78 78
 		// AJAX ???
79
-		$this->ajax       = defined( 'DOING_AJAX' ) ? true : false;
80
-		$this->front_ajax = $this->is_set( 'ee_front_ajax' ) && (int) $this->get( 'ee_front_ajax' ) === 1;
79
+		$this->ajax       = defined('DOING_AJAX') ? true : false;
80
+		$this->front_ajax = $this->is_set('ee_front_ajax') && (int) $this->get('ee_front_ajax') === 1;
81 81
 		// grab user IP
82 82
 		$this->_ip_address = $this->_visitor_ip();
83 83
 	}
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
 	 * @param bool $override_ee
131 131
 	 * @return    void
132 132
 	 */
133
-	public function set( $key, $value, $override_ee = FALSE ) {
133
+	public function set($key, $value, $override_ee = FALSE) {
134 134
 		// don't allow "ee" to be overwritten unless explicitly instructed to do so
135 135
 		if (
136 136
 		    $key !== 'ee'
137
-            || ( $key === 'ee' && empty( $this->_params['ee'] ))
138
-            || ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )
137
+            || ($key === 'ee' && empty($this->_params['ee']))
138
+            || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
139 139
         ) {
140
-			$this->_params[ $key ] = $value;
140
+			$this->_params[$key] = $value;
141 141
 		}
142 142
 	}
143 143
 
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	 * @param null $default
152 152
 	 * @return    mixed
153 153
 	 */
154
-	public function get( $key, $default = NULL ) {
155
-		return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default;
154
+	public function get($key, $default = NULL) {
155
+		return isset($this->_params[$key]) ? $this->_params[$key] : $default;
156 156
 	}
157 157
 
158 158
 
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param $key
165 165
 	 * @return    boolean
166 166
 	 */
167
-	public function is_set( $key ) {
168
-		return isset( $this->_params[ $key ] ) ? TRUE : FALSE;
167
+	public function is_set($key) {
168
+		return isset($this->_params[$key]) ? TRUE : FALSE;
169 169
 	}
170 170
 
171 171
 
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 	 * @param $key
178 178
 	 * @param bool $unset_from_global_too
179 179
 	 */
180
-	public function un_set( $key, $unset_from_global_too = false ) {
181
-		unset( $this->_params[ $key ] );
182
-		if ( $unset_from_global_too ) {
183
-			unset( $_REQUEST[ $key ] );
180
+	public function un_set($key, $unset_from_global_too = false) {
181
+		unset($this->_params[$key]);
182
+		if ($unset_from_global_too) {
183
+			unset($_REQUEST[$key]);
184 184
 		}
185 185
 	}
186 186
 
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
 			'HTTP_FORWARDED',
215 215
 			'REMOTE_ADDR'
216 216
 		);
217
-		foreach ( $server_keys as $key ) {
218
-			if ( isset( $_SERVER[ $key ] ) ) {
219
-				foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] ) ) as $ip ) {
220
-					if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== false ) {
217
+		foreach ($server_keys as $key) {
218
+			if (isset($_SERVER[$key])) {
219
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
220
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
221 221
 						$visitor_ip = $ip;
222 222
 					}
223 223
 				}
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
      *    _get_table_filters
228 228
      *
229 229
      * @access protected
230
-     * @return array
230
+     * @return string[]
231 231
      */
232 232
     protected function _get_table_filters()
233 233
     {
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         );
158 158
         $this->_primary_column = '_REG_ID';
159 159
         $this->_sortable_columns = array(
160
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
160
+            '_REG_date'     => array('_REG_date' => true), //true means its already sorted
161 161
             'ATT_fname'     => array('ATT_fname' => false),
162 162
             'event_name'    => array('event_name' => false),
163 163
             'DTT_EVT_start' => array('DTT_EVT_start' => false),
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     {
180 180
         $class = parent::_get_row_class($item);
181 181
         //add status class
182
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
182
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
183 183
         if ($this->_has_checkbox_column) {
184 184
             $class .= ' has-checkbox-column';
185 185
         }
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
         //setup date query.
328 328
         $beginning_string = EEM_Registration::instance()
329 329
                                             ->convert_datetime_for_query('REG_date',
330
-                                                $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
330
+                                                $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
331 331
                                                 'Y-m-d H:i:s');
332 332
         $end_string = EEM_Registration::instance()
333 333
                                       ->convert_datetime_for_query('REG_date',
334
-                                          $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
334
+                                          $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
335 335
                                           'Y-m-d H:i:s');
336 336
         $_where['REG_date'] = array(
337 337
             'BETWEEN',
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
             'BETWEEN',
365 365
             array(
366 366
                 EEM_Registration::instance()
367
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
367
+                                ->convert_datetime_for_query('REG_date', $current_date.$time_start, 'Y-m-d H:i:s'),
368 368
                 EEM_Registration::instance()
369
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
369
+                                ->convert_datetime_for_query('REG_date', $current_date.$time_end, 'Y-m-d H:i:s'),
370 370
             ),
371 371
         );
372 372
         $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
         $content .= '<div class="show-on-mobile-view-only">';
411 411
         $content .= '<br>';
412 412
         $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
413
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
414
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
413
+        $content .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
414
+        $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
415 415
         $content .= '</div>';
416 416
         return $content;
417 417
     }
@@ -482,10 +482,10 @@  discard block
 block discarded – undo
482 482
                   . $event_name
483 483
                   . '</a>' : $event_name;
484 484
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
485
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
485
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
486 486
             $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
487 487
                 'event_espresso'), $event_name);
488
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
488
+            $actions['event_filter'] .= '">'.__('View Registrations', 'event_espresso').'</a>';
489 489
         } else {
490 490
             $edit_event = $event_name;
491 491
             $actions['event_filter'] = '';
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
         $t = $item->get_first_related('Transaction');
552 552
         $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
553 553
         //append group count to name
554
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
554
+        $link .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
555 555
         //append reg_code
556
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
556
+        $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
557 557
         //reg status text for accessibility
558
-        $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
559
-                'sentence') . '</span>';
558
+        $link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false,
559
+                'sentence').'</span>';
560 560
         //trash/restore/delete actions
561 561
         $actions = array();
562 562
         if ($this->_view !== 'trash'
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
                 'action'  => 'trash_registrations',
569 569
                 '_REG_ID' => $item->ID(),
570 570
             ), REG_ADMIN_URL);
571
-            $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
572
-                    'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
571
+            $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Trash Registration',
572
+                    'event_espresso').'">'.__('Trash', 'event_espresso').'</a>';
573 573
         } elseif ($this->_view === 'trash') {
574 574
             // restore registration link
575 575
             if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
@@ -579,8 +579,8 @@  discard block
 block discarded – undo
579 579
                     'action'  => 'restore_registrations',
580 580
                     '_REG_ID' => $item->ID(),
581 581
                 ), REG_ADMIN_URL);
582
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
583
-                        'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
582
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Registration',
583
+                        'event_espresso').'">'.__('Restore', 'event_espresso').'</a>';
584 584
             }
585 585
             if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
586 586
                 'espresso_registrations_ee_delete_registrations', $item->ID())
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
                                                                               . $ticket->name()
649 649
                                                                               . '</span><br />' : '';
650 650
         if ($item->final_price() > 0) {
651
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
651
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
652 652
         } else {
653 653
             // free event
654 654
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
             : '<span class="TKT_name">'
676 676
               . $ticket->name()
677 677
               . '</span><br />';
678
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
678
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
679 679
         return $content;
680 680
     }
681 681
 
@@ -693,10 +693,10 @@  discard block
 block discarded – undo
693 693
         $payment_method = $item->payment_method();
694 694
         $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
695 695
             : __('Unknown', 'event_espresso');
696
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
696
+        $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
697 697
         if ($item->paid() > 0) {
698
-            $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
699
-                    $payment_method_name) . '</span>';
698
+            $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'),
699
+                    $payment_method_name).'</span>';
700 700
         }
701 701
         return $content;
702 702
     }
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
                   . esc_attr__('View Transaction', 'event_espresso')
729 729
                   . '">'
730 730
                   . $item->transaction()->pretty_total()
731
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
731
+                  . '</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
732 732
         } else {
733 733
             return __("None", "event_espresso");
734 734
         }
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
                       . esc_attr__('View Transaction', 'event_espresso')
766 766
                       . '">'
767 767
                       . $item->transaction()->pretty_paid()
768
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
768
+                      . '</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
769 769
             }
770 770
         }
771 771
         return '&nbsp;';
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
         $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
806 806
             'espresso_registrations_view_registration', $item->ID()) ? '
807 807
 			<li>
808
-			<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
808
+			<a href="' . $view_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
809 809
 				<div class="dashicons dashicons-clipboard"></div>
810 810
 			</a>
811 811
 			</li>' : '';
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
             'espresso_registrations_edit_attendee')
814 814
                                && $attendee instanceof EE_Attendee ? '
815 815
 			<li>
816
-			<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
816
+			<a href="' . $edit_lnk_url.'" title="'.esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text">
817 817
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
818 818
 			</a>
819 819
 			</li>' : '';
Please login to merge, or discard this patch.
Indentation   +818 added lines, -818 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -26,847 +26,847 @@  discard block
 block discarded – undo
26 26
 
27 27
 
28 28
 
29
-    private $_status;
30
-
31
-
32
-
33
-    /**
34
-     * An array of transaction details for the related transaction to the registration being processed.
35
-     * This is set via the _set_related_details method.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $_transaction_details = array();
40
-
41
-
42
-
43
-    /**
44
-     * An array of event details for the related event to the registration being processed.
45
-     * This is set via the _set_related_details method.
46
-     *
47
-     * @var array
48
-     */
49
-    protected $_event_details = array();
50
-
51
-
52
-
53
-    /**
54
-     * @param \Registrations_Admin_Page $admin_page
55
-     */
56
-    public function __construct(Registrations_Admin_Page $admin_page)
57
-    {
58
-        if ( ! empty($_GET['event_id'])) {
59
-            $extra_query_args = array();
60
-            foreach ($admin_page->get_views() as $key => $view_details) {
61
-                $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
62
-            }
63
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
64
-        }
65
-        parent::__construct($admin_page);
66
-        $this->_status = $this->_admin_page->get_registration_status_array();
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     *    _setup_data
73
-     *
74
-     * @access protected
75
-     * @return void
76
-     */
77
-    protected function _setup_data()
78
-    {
79
-        $this->_data = $this->_admin_page->get_registrations($this->_per_page);
80
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     *    _set_properties
87
-     *
88
-     * @access protected
89
-     * @return void
90
-     */
91
-    protected function _set_properties()
92
-    {
93
-        $this->_wp_list_args = array(
94
-            'singular' => __('registration', 'event_espresso'),
95
-            'plural'   => __('registrations', 'event_espresso'),
96
-            'ajax'     => true,
97
-            'screen'   => $this->_admin_page->get_current_screen()->id,
98
-        );
99
-        $ID_column_name = __('ID', 'event_espresso');
100
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
-        $ID_column_name .= __('Registrant Name', 'event_espresso');
102
-        $ID_column_name .= '</span> ';
103
-        if (isset($_GET['event_id'])) {
104
-            $this->_columns = array(
105
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
-                '_REG_ID'          => $ID_column_name,
107
-                'ATT_fname'        => __('Name', 'event_espresso'),
108
-                'ATT_email'        => __('Email', 'event_espresso'),
109
-                '_REG_date'        => __('Reg Date', 'event_espresso'),
110
-                'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
-                '_REG_final_price' => __('Final Price', 'event_espresso'),
112
-                'TXN_total'        => __('Total Txn', 'event_espresso'),
113
-                'TXN_paid'         => __('Paid', 'event_espresso'),
114
-                'actions'          => __('Actions', 'event_espresso'),
115
-            );
116
-            $this->_bottom_buttons = array(
117
-                'report' => array(
118
-                    'route'         => 'registrations_report',
119
-                    'extra_request' => array(
120
-                        'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
-                    ),
123
-                ),
124
-            );
125
-        } else {
126
-            $this->_columns = array(
127
-                'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
-                '_REG_ID'          => $ID_column_name,
129
-                'ATT_fname'        => __('Name', 'event_espresso'),
130
-                '_REG_date'        => __('TXN Date', 'event_espresso'),
131
-                'event_name'       => __('Event', 'event_espresso'),
132
-                'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
-                '_REG_final_price' => __('Price', 'event_espresso'),
134
-                '_REG_paid'        => __('Paid', 'event_espresso'),
135
-                'actions'          => __('Actions', 'event_espresso'),
136
-            );
137
-            $this->_bottom_buttons = array(
138
-                'report_all' => array(
139
-                    'route'         => 'registrations_report',
140
-                    'extra_request' => array(
141
-                        'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
-                    ),
143
-                ),
144
-            );
145
-        }
146
-        $this->_primary_column = '_REG_ID';
147
-        $this->_sortable_columns = array(
148
-            '_REG_date'     => array('_REG_date' => true),   //true means its already sorted
149
-            'ATT_fname'     => array('ATT_fname' => false),
150
-            'event_name'    => array('event_name' => false),
151
-            'DTT_EVT_start' => array('DTT_EVT_start' => false),
152
-            '_REG_ID'       => array('_REG_ID' => false),
153
-        );
154
-        $this->_hidden_columns = array();
155
-    }
156
-
157
-
158
-
159
-    /**
160
-     * This simply sets up the row class for the table rows.
161
-     * Allows for easier overriding of child methods for setting up sorting.
162
-     *
163
-     * @param  EE_Registration $item the current item
164
-     * @return string
165
-     */
166
-    protected function _get_row_class($item)
167
-    {
168
-        $class = parent::_get_row_class($item);
169
-        //add status class
170
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
171
-        if ($this->_has_checkbox_column) {
172
-            $class .= ' has-checkbox-column';
173
-        }
174
-        return $class;
175
-    }
176
-
177
-
178
-
179
-    /**
180
-     * Set the $_transaction_details property if not set yet.
181
-     *
182
-     * @param EE_Registration $registration
183
-     * @throws \EE_Error
184
-     */
185
-    protected function _set_related_details(EE_Registration $registration)
186
-    {
187
-        $transaction = $registration->get_first_related('Transaction');
188
-        $status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
189
-            : EEM_Transaction::failed_status_code;
190
-        $this->_transaction_details = array(
191
-            'transaction' => $transaction,
192
-            'status'      => $status,
193
-            'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
194
-            'title_attr'  => sprintf(__('View Transaction Details (%s)', 'event_espresso'),
195
-                EEH_Template::pretty_status($status, false, 'sentence')),
196
-        );
197
-        try {
198
-            $event = $registration->event();
199
-        } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
200
-            $event = null;
201
-        }
202
-        $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
203
-        $this->_event_details = array(
204
-            'event'      => $event,
205
-            'status'     => $status,
206
-            'id'         => $event instanceof EE_Event ? $event->ID() : 0,
207
-            'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'),
208
-                EEH_Template::pretty_status($status, false, 'sentence')),
209
-        );
210
-    }
211
-
212
-
213
-
214
-    /**
215
-     *    _get_table_filters
216
-     *
217
-     * @access protected
218
-     * @return array
219
-     */
220
-    protected function _get_table_filters()
221
-    {
222
-        $filters = array();
223
-        //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
224
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
225
-        $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
226
-        $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
227
-        $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
228
-        $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
229
-        $status = array();
230
-        $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
231
-        foreach ($this->_status as $key => $value) {
232
-            $status[] = array('id' => $key, 'text' => $value);
233
-        }
234
-        if ($this->_view !== 'incomplete') {
235
-            $filters[] = EEH_Form_Fields::select_input('_reg_status', $status,
236
-                isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
237
-                    : '');
238
-        }
239
-        if (isset($this->_req_data['event_id'])) {
240
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
241
-        }
242
-        return $filters;
243
-    }
244
-
245
-
246
-
247
-    /**
248
-     *    _add_view_counts
249
-     *
250
-     * @access protected
251
-     * @return void
252
-     * @throws \EE_Error
253
-     */
254
-    protected function _add_view_counts()
255
-    {
256
-        $this->_views['all']['count'] = $this->_total_registrations();
257
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
258
-        $this->_views['today']['count'] = $this->_total_registrations_today();
259
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
260
-            'espresso_registrations_trash_registrations')
261
-        ) {
262
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
263
-            $this->_views['trash']['count'] = $this->_total_registrations('trash');
264
-        }
265
-    }
266
-
267
-
268
-
269
-    /**
270
-     * _total_registrations
271
-     *
272
-     * @access protected
273
-     * @param string $view
274
-     * @return int
275
-     * @throws \EE_Error
276
-     */
277
-    protected function _total_registrations($view = '')
278
-    {
279
-        $_where = array();
280
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
281
-        if ($EVT_ID) {
282
-            $_where['EVT_ID'] = $EVT_ID;
283
-        }
284
-        switch ($view) {
285
-            case 'trash' :
286
-                return EEM_Registration::instance()->count_deleted(array($_where));
287
-                break;
288
-            case 'incomplete' :
289
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
290
-                break;
291
-            default :
292
-                $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
293
-        }
294
-        return EEM_Registration::instance()->count(array($_where));
295
-    }
296
-
297
-
298
-
299
-    /**
300
-     * _total_registrations_this_month
301
-     *
302
-     * @access protected
303
-     * @return int
304
-     * @throws \EE_Error
305
-     */
306
-    protected function _total_registrations_this_month()
307
-    {
308
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
309
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
310
-        $this_year_r = date('Y', current_time('timestamp'));
311
-        $time_start = ' 00:00:00';
312
-        $time_end = ' 23:59:59';
313
-        $this_month_r = date('m', current_time('timestamp'));
314
-        $days_this_month = date('t', current_time('timestamp'));
315
-        //setup date query.
316
-        $beginning_string = EEM_Registration::instance()
317
-                                            ->convert_datetime_for_query('REG_date',
318
-                                                $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
319
-                                                'Y-m-d H:i:s');
320
-        $end_string = EEM_Registration::instance()
321
-                                      ->convert_datetime_for_query('REG_date',
322
-                                          $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
323
-                                          'Y-m-d H:i:s');
324
-        $_where['REG_date'] = array(
325
-            'BETWEEN',
326
-            array(
327
-                $beginning_string,
328
-                $end_string,
329
-            ),
330
-        );
331
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
332
-        return EEM_Registration::instance()->count(array($_where));
333
-    }
334
-
335
-
336
-
337
-    /**
338
-     * _total_registrations_today
339
-     *
340
-     * @access protected
341
-     * @return int
342
-     * @throws \EE_Error
343
-     */
344
-    protected function _total_registrations_today()
345
-    {
346
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
347
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
348
-        $current_date = date('Y-m-d', current_time('timestamp'));
349
-        $time_start = ' 00:00:00';
350
-        $time_end = ' 23:59:59';
351
-        $_where['REG_date'] = array(
352
-            'BETWEEN',
353
-            array(
354
-                EEM_Registration::instance()
355
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
356
-                EEM_Registration::instance()
357
-                                ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
358
-            ),
359
-        );
360
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
361
-        return EEM_Registration::instance()->count(array($_where));
362
-    }
363
-
364
-
365
-
366
-    /**
367
-     * column_cb
368
-     *
369
-     * @access public
370
-     * @param \EE_Registration $item
371
-     * @return string
372
-     * @throws \EE_Error
373
-     */
374
-    public function column_cb($item)
375
-    {
376
-        /** checkbox/lock **/
377
-        $transaction = $item->get_first_related('Transaction');
378
-        $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0;
379
-        return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID())
380
-                                    . '<span class="ee-lock-icon"></span>'
381
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID());
382
-    }
383
-
384
-
385
-
386
-    /**
387
-     * column__REG_ID
388
-     *
389
-     * @access public
390
-     * @param \EE_Registration $item
391
-     * @return string
392
-     * @throws \EE_Error
393
-     */
394
-    public function column__REG_ID(EE_Registration $item)
395
-    {
396
-        $attendee = $item->attendee();
397
-        $content = $item->ID();
398
-        $content .= '<div class="show-on-mobile-view-only">';
399
-        $content .= '<br>';
400
-        $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
401
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
402
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
403
-        $content .= '</div>';
404
-        return $content;
405
-    }
406
-
407
-
408
-
409
-    /**
410
-     * column__REG_date
411
-     *
412
-     * @access public
413
-     * @param \EE_Registration $item
414
-     * @return string
415
-     * @throws \EE_Error
416
-     */
417
-    public function column__REG_date(EE_Registration $item)
418
-    {
419
-        $this->_set_related_details($item);
420
-        //Build row actions
421
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
422
-            'action' => 'view_transaction',
423
-            'TXN_ID' => $this->_transaction_details['id'],
424
-        ), TXN_ADMIN_URL);
425
-        $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
426
-            'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'
427
-                                                        . $this->_transaction_details['status']
428
-                                                        . '" href="'
429
-                                                        . $view_lnk_url
430
-                                                        . '" title="'
431
-                                                        . esc_attr($this->_transaction_details['title_attr'])
432
-                                                        . '">'
433
-                                                        . $item->get_i18n_datetime('REG_date')
434
-                                                        . '</a>' : $item->get_i18n_datetime('REG_date');
435
-        $view_link .= '<br><span class="ee-status-text-small">'
436
-                      . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
437
-                      . '</span>';
438
-        return $view_link;
439
-    }
440
-
441
-
442
-
443
-    /**
444
-     * column_event_name
445
-     *
446
-     * @access public
447
-     * @param \EE_Registration $item
448
-     * @return string
449
-     * @throws \EE_Error
450
-     */
451
-    public function column_event_name(EE_Registration $item)
452
-    {
453
-        $this->_set_related_details($item);
454
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
455
-        $EVT_ID = $item->event_ID();
456
-        $event_name = $item->event_name();
457
-        $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
458
-        $event_name = wp_trim_words($event_name, 30, '...');
459
-        if ($EVT_ID) {
460
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID),
461
-                EVENTS_ADMIN_URL);
462
-            $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
463
-                ? '<a class="ee-status-color-'
464
-                  . $this->_event_details['status']
465
-                  . '" href="'
466
-                  . $edit_event_url
467
-                  . '" title="'
468
-                  . esc_attr($this->_event_details['title_attr'])
469
-                  . '">'
470
-                  . $event_name
471
-                  . '</a>' : $event_name;
472
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
473
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
474
-            $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
475
-                'event_espresso'), $event_name);
476
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
477
-        } else {
478
-            $edit_event = $event_name;
479
-            $actions['event_filter'] = '';
480
-        }
481
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
482
-    }
483
-
484
-
485
-
486
-    /**
487
-     * column_DTT_EVT_start
488
-     *
489
-     * @access public
490
-     * @param \EE_Registration $item
491
-     * @return string
492
-     * @throws \EE_Error
493
-     */
494
-    public function column_DTT_EVT_start(EE_Registration $item)
495
-    {
496
-        $datetime_strings = array();
497
-        $ticket = $item->ticket(true);
498
-        if ($ticket instanceof EE_Ticket) {
499
-            $remove_defaults = array('default_where_conditions' => 'none');
500
-            $datetimes = $ticket->datetimes($remove_defaults);
501
-            foreach ($datetimes as $datetime) {
502
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
503
-            }
504
-            return implode("<br />", $datetime_strings);
505
-        } else {
506
-            return __('There is no ticket on this registration', 'event_espresso');
507
-        }
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     * column_ATT_fname
514
-     *
515
-     * @access public
516
-     * @param \EE_Registration $item
517
-     * @return string
518
-     * @throws \EE_Error
519
-     */
520
-    public function column_ATT_fname(EE_Registration $item)
521
-    {
522
-        $attendee = $item->attendee();
523
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
524
-            'action'  => 'view_registration',
525
-            '_REG_ID' => $item->ID(),
526
-        ), REG_ADMIN_URL);
527
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
528
-        $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
529
-            'espresso_registrations_view_registration', $item->ID()) ? '<a href="'
530
-                                                                       . $edit_lnk_url
531
-                                                                       . '" title="'
532
-                                                                       . esc_attr__('View Registration Details',
533
-                'event_espresso')
534
-                                                                       . '">'
535
-                                                                       . $attendee_name
536
-                                                                       . '</a>' : $attendee_name;
537
-        $link .= $item->count() === 1
538
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
539
-        $t = $item->get_first_related('Transaction');
540
-        $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
541
-        //append group count to name
542
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
543
-        //append reg_code
544
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
545
-        //reg status text for accessibility
546
-        $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
547
-                'sentence') . '</span>';
548
-        //trash/restore/delete actions
549
-        $actions = array();
550
-        if ($this->_view !== 'trash'
551
-            && $payment_count === 0
552
-            && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
553
-                'espresso_registrations_trash_registrations', $item->ID())
554
-        ) {
555
-            $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
556
-                'action'  => 'trash_registrations',
557
-                '_REG_ID' => $item->ID(),
558
-            ), REG_ADMIN_URL);
559
-            $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
560
-                    'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
561
-        } elseif ($this->_view === 'trash') {
562
-            // restore registration link
563
-            if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
564
-                'espresso_registrations_restore_registrations', $item->ID())
565
-            ) {
566
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
567
-                    'action'  => 'restore_registrations',
568
-                    '_REG_ID' => $item->ID(),
569
-                ), REG_ADMIN_URL);
570
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
571
-                        'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
572
-            }
573
-            if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
574
-                'espresso_registrations_ee_delete_registrations', $item->ID())
575
-            ) {
576
-                $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
577
-                    'action'  => 'delete_registrations',
578
-                    '_REG_ID' => $item->ID(),
579
-                ), REG_ADMIN_URL);
580
-                $actions['delete'] = '<a href="'
581
-                                     . $delete_lnk_url
582
-                                     . '" title="'
583
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
584
-                                     . '">'
585
-                                     . __('Delete', 'event_espresso')
586
-                                     . '</a>';
587
-            }
588
-        }
589
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
590
-    }
591
-
592
-
593
-
594
-    /**
595
-     * column_ATT_email
596
-     *
597
-     * @access public
598
-     * @param \EE_Registration $item
599
-     * @return string
600
-     * @throws \EE_Error
601
-     */
602
-    public function column_ATT_email(EE_Registration $item)
603
-    {
604
-        $attendee = $item->get_first_related('Attendee');
605
-        return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
606
-            : $attendee->email();
607
-    }
608
-
609
-
610
-
611
-    /**
612
-     * column__REG_count
613
-     *
614
-     * @access public
615
-     * @param \EE_Registration $item
616
-     * @return string
617
-     */
618
-    public function column__REG_count(EE_Registration $item)
619
-    {
620
-        return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
621
-    }
622
-
623
-
624
-
625
-    /**
626
-     * column_PRC_amount
627
-     *
628
-     * @access public
629
-     * @param \EE_Registration $item
630
-     * @return string
631
-     */
632
-    public function column_PRC_amount(EE_Registration $item)
633
-    {
634
-        $ticket = $item->ticket();
635
-        $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
636
-                                                                              . $ticket->name()
637
-                                                                              . '</span><br />' : '';
638
-        if ($item->final_price() > 0) {
639
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
640
-        } else {
641
-            // free event
642
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
643
-                        . __('free', 'event_espresso')
644
-                        . '</span>';
645
-        }
646
-        return $content;
647
-    }
648
-
649
-
650
-
651
-    /**
652
-     * column__REG_final_price
653
-     *
654
-     * @access public
655
-     * @param \EE_Registration $item
656
-     * @return string
657
-     */
658
-    public function column__REG_final_price(EE_Registration $item)
659
-    {
660
-        $ticket = $item->ticket();
661
-        $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
662
-            ? ''
663
-            : '<span class="TKT_name">'
664
-              . $ticket->name()
665
-              . '</span><br />';
666
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
667
-        return $content;
668
-    }
669
-
670
-
671
-
672
-    /**
673
-     * column__REG_paid
674
-     *
675
-     * @access public
676
-     * @param \EE_Registration $item
677
-     * @return string
678
-     */
679
-    public function column__REG_paid(EE_Registration $item)
680
-    {
681
-        $payment_method = $item->payment_method();
682
-        $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
683
-            : __('Unknown', 'event_espresso');
684
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
685
-        if ($item->paid() > 0) {
686
-            $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
687
-                    $payment_method_name) . '</span>';
688
-        }
689
-        return $content;
690
-    }
691
-
692
-
693
-
694
-    /**
695
-     * column_TXN_total
696
-     *
697
-     * @access public
698
-     * @param \EE_Registration $item
699
-     * @return string
700
-     * @throws \EE_Error
701
-     */
702
-    public function column_TXN_total(EE_Registration $item)
703
-    {
704
-        if ($item->transaction()) {
705
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
706
-                'action' => 'view_transaction',
707
-                'TXN_ID' => $item->transaction_ID(),
708
-            ), TXN_ADMIN_URL);
709
-            return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
710
-                'espresso_transactions_view_transaction', $item->transaction_ID())
711
-                ? '<span class="reg-pad-rght"><a class="status-'
712
-                  . $item->transaction()->status_ID()
713
-                  . '" href="'
714
-                  . $view_txn_lnk_url
715
-                  . '"  title="'
716
-                  . esc_attr__('View Transaction', 'event_espresso')
717
-                  . '">'
718
-                  . $item->transaction()->pretty_total()
719
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
720
-        } else {
721
-            return __("None", "event_espresso");
722
-        }
723
-    }
724
-
725
-
726
-
727
-    /**
728
-     * column_TXN_paid
729
-     *
730
-     * @access public
731
-     * @param \EE_Registration $item
732
-     * @return string
733
-     * @throws \EE_Error
734
-     */
735
-    public function column_TXN_paid(EE_Registration $item)
736
-    {
737
-        if ($item->count() === 1) {
738
-            $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
739
-            if ($transaction->paid() >= $transaction->total()) {
740
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
741
-            } else {
742
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
743
-                    'action' => 'view_transaction',
744
-                    'TXN_ID' => $item->transaction_ID(),
745
-                ), TXN_ADMIN_URL);
746
-                return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
747
-                    'espresso_transactions_view_transaction', $item->transaction_ID())
748
-                    ? '<span class="reg-pad-rght"><a class="status-'
749
-                      . $transaction->status_ID()
750
-                      . '" href="'
751
-                      . $view_txn_lnk_url
752
-                      . '"  title="'
753
-                      . esc_attr__('View Transaction', 'event_espresso')
754
-                      . '">'
755
-                      . $item->transaction()->pretty_paid()
756
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
757
-            }
758
-        }
759
-        return '&nbsp;';
760
-    }
761
-
762
-
763
-
764
-    /**
765
-     * column_actions
766
-     *
767
-     * @access public
768
-     * @param \EE_Registration $item
769
-     * @return string
770
-     * @throws \EE_Error
771
-     */
772
-    public function column_actions(EE_Registration $item)
773
-    {
774
-        $actions = array();
775
-        $attendee = $item->attendee();
776
-        $this->_set_related_details($item);
777
-        //Build row actions
778
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
779
-            'action'  => 'view_registration',
780
-            '_REG_ID' => $item->ID(),
781
-        ), REG_ADMIN_URL);
782
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
783
-            'action' => 'edit_attendee',
784
-            'post'   => $item->attendee_ID(),
785
-        ), REG_ADMIN_URL);
786
-        // page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
787
-        //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
788
-        $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
789
-            'action'  => 'resend_registration',
790
-            '_REG_ID' => $item->ID(),
791
-        ), REG_ADMIN_URL, true);
792
-        //Build row actions
793
-        $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
794
-            'espresso_registrations_view_registration', $item->ID()) ? '
29
+	private $_status;
30
+
31
+
32
+
33
+	/**
34
+	 * An array of transaction details for the related transaction to the registration being processed.
35
+	 * This is set via the _set_related_details method.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $_transaction_details = array();
40
+
41
+
42
+
43
+	/**
44
+	 * An array of event details for the related event to the registration being processed.
45
+	 * This is set via the _set_related_details method.
46
+	 *
47
+	 * @var array
48
+	 */
49
+	protected $_event_details = array();
50
+
51
+
52
+
53
+	/**
54
+	 * @param \Registrations_Admin_Page $admin_page
55
+	 */
56
+	public function __construct(Registrations_Admin_Page $admin_page)
57
+	{
58
+		if ( ! empty($_GET['event_id'])) {
59
+			$extra_query_args = array();
60
+			foreach ($admin_page->get_views() as $key => $view_details) {
61
+				$extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
62
+			}
63
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
64
+		}
65
+		parent::__construct($admin_page);
66
+		$this->_status = $this->_admin_page->get_registration_status_array();
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 *    _setup_data
73
+	 *
74
+	 * @access protected
75
+	 * @return void
76
+	 */
77
+	protected function _setup_data()
78
+	{
79
+		$this->_data = $this->_admin_page->get_registrations($this->_per_page);
80
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 *    _set_properties
87
+	 *
88
+	 * @access protected
89
+	 * @return void
90
+	 */
91
+	protected function _set_properties()
92
+	{
93
+		$this->_wp_list_args = array(
94
+			'singular' => __('registration', 'event_espresso'),
95
+			'plural'   => __('registrations', 'event_espresso'),
96
+			'ajax'     => true,
97
+			'screen'   => $this->_admin_page->get_current_screen()->id,
98
+		);
99
+		$ID_column_name = __('ID', 'event_espresso');
100
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
101
+		$ID_column_name .= __('Registrant Name', 'event_espresso');
102
+		$ID_column_name .= '</span> ';
103
+		if (isset($_GET['event_id'])) {
104
+			$this->_columns = array(
105
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
106
+				'_REG_ID'          => $ID_column_name,
107
+				'ATT_fname'        => __('Name', 'event_espresso'),
108
+				'ATT_email'        => __('Email', 'event_espresso'),
109
+				'_REG_date'        => __('Reg Date', 'event_espresso'),
110
+				'PRC_amount'       => __('TKT Price', 'event_espresso'),
111
+				'_REG_final_price' => __('Final Price', 'event_espresso'),
112
+				'TXN_total'        => __('Total Txn', 'event_espresso'),
113
+				'TXN_paid'         => __('Paid', 'event_espresso'),
114
+				'actions'          => __('Actions', 'event_espresso'),
115
+			);
116
+			$this->_bottom_buttons = array(
117
+				'report' => array(
118
+					'route'         => 'registrations_report',
119
+					'extra_request' => array(
120
+						'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
121
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
122
+					),
123
+				),
124
+			);
125
+		} else {
126
+			$this->_columns = array(
127
+				'cb'               => '<input type="checkbox" />', //Render a checkbox instead of text
128
+				'_REG_ID'          => $ID_column_name,
129
+				'ATT_fname'        => __('Name', 'event_espresso'),
130
+				'_REG_date'        => __('TXN Date', 'event_espresso'),
131
+				'event_name'       => __('Event', 'event_espresso'),
132
+				'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
133
+				'_REG_final_price' => __('Price', 'event_espresso'),
134
+				'_REG_paid'        => __('Paid', 'event_espresso'),
135
+				'actions'          => __('Actions', 'event_espresso'),
136
+			);
137
+			$this->_bottom_buttons = array(
138
+				'report_all' => array(
139
+					'route'         => 'registrations_report',
140
+					'extra_request' => array(
141
+						'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
142
+					),
143
+				),
144
+			);
145
+		}
146
+		$this->_primary_column = '_REG_ID';
147
+		$this->_sortable_columns = array(
148
+			'_REG_date'     => array('_REG_date' => true),   //true means its already sorted
149
+			'ATT_fname'     => array('ATT_fname' => false),
150
+			'event_name'    => array('event_name' => false),
151
+			'DTT_EVT_start' => array('DTT_EVT_start' => false),
152
+			'_REG_ID'       => array('_REG_ID' => false),
153
+		);
154
+		$this->_hidden_columns = array();
155
+	}
156
+
157
+
158
+
159
+	/**
160
+	 * This simply sets up the row class for the table rows.
161
+	 * Allows for easier overriding of child methods for setting up sorting.
162
+	 *
163
+	 * @param  EE_Registration $item the current item
164
+	 * @return string
165
+	 */
166
+	protected function _get_row_class($item)
167
+	{
168
+		$class = parent::_get_row_class($item);
169
+		//add status class
170
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
171
+		if ($this->_has_checkbox_column) {
172
+			$class .= ' has-checkbox-column';
173
+		}
174
+		return $class;
175
+	}
176
+
177
+
178
+
179
+	/**
180
+	 * Set the $_transaction_details property if not set yet.
181
+	 *
182
+	 * @param EE_Registration $registration
183
+	 * @throws \EE_Error
184
+	 */
185
+	protected function _set_related_details(EE_Registration $registration)
186
+	{
187
+		$transaction = $registration->get_first_related('Transaction');
188
+		$status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
189
+			: EEM_Transaction::failed_status_code;
190
+		$this->_transaction_details = array(
191
+			'transaction' => $transaction,
192
+			'status'      => $status,
193
+			'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
194
+			'title_attr'  => sprintf(__('View Transaction Details (%s)', 'event_espresso'),
195
+				EEH_Template::pretty_status($status, false, 'sentence')),
196
+		);
197
+		try {
198
+			$event = $registration->event();
199
+		} catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) {
200
+			$event = null;
201
+		}
202
+		$status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
203
+		$this->_event_details = array(
204
+			'event'      => $event,
205
+			'status'     => $status,
206
+			'id'         => $event instanceof EE_Event ? $event->ID() : 0,
207
+			'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'),
208
+				EEH_Template::pretty_status($status, false, 'sentence')),
209
+		);
210
+	}
211
+
212
+
213
+
214
+	/**
215
+	 *    _get_table_filters
216
+	 *
217
+	 * @access protected
218
+	 * @return array
219
+	 */
220
+	protected function _get_table_filters()
221
+	{
222
+		$filters = array();
223
+		//todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
224
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
225
+		$cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
226
+		$reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
227
+		$filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
228
+		$filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
229
+		$status = array();
230
+		$status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
231
+		foreach ($this->_status as $key => $value) {
232
+			$status[] = array('id' => $key, 'text' => $value);
233
+		}
234
+		if ($this->_view !== 'incomplete') {
235
+			$filters[] = EEH_Form_Fields::select_input('_reg_status', $status,
236
+				isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
237
+					: '');
238
+		}
239
+		if (isset($this->_req_data['event_id'])) {
240
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
241
+		}
242
+		return $filters;
243
+	}
244
+
245
+
246
+
247
+	/**
248
+	 *    _add_view_counts
249
+	 *
250
+	 * @access protected
251
+	 * @return void
252
+	 * @throws \EE_Error
253
+	 */
254
+	protected function _add_view_counts()
255
+	{
256
+		$this->_views['all']['count'] = $this->_total_registrations();
257
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
258
+		$this->_views['today']['count'] = $this->_total_registrations_today();
259
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations',
260
+			'espresso_registrations_trash_registrations')
261
+		) {
262
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
263
+			$this->_views['trash']['count'] = $this->_total_registrations('trash');
264
+		}
265
+	}
266
+
267
+
268
+
269
+	/**
270
+	 * _total_registrations
271
+	 *
272
+	 * @access protected
273
+	 * @param string $view
274
+	 * @return int
275
+	 * @throws \EE_Error
276
+	 */
277
+	protected function _total_registrations($view = '')
278
+	{
279
+		$_where = array();
280
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
281
+		if ($EVT_ID) {
282
+			$_where['EVT_ID'] = $EVT_ID;
283
+		}
284
+		switch ($view) {
285
+			case 'trash' :
286
+				return EEM_Registration::instance()->count_deleted(array($_where));
287
+				break;
288
+			case 'incomplete' :
289
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
290
+				break;
291
+			default :
292
+				$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
293
+		}
294
+		return EEM_Registration::instance()->count(array($_where));
295
+	}
296
+
297
+
298
+
299
+	/**
300
+	 * _total_registrations_this_month
301
+	 *
302
+	 * @access protected
303
+	 * @return int
304
+	 * @throws \EE_Error
305
+	 */
306
+	protected function _total_registrations_this_month()
307
+	{
308
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
309
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
310
+		$this_year_r = date('Y', current_time('timestamp'));
311
+		$time_start = ' 00:00:00';
312
+		$time_end = ' 23:59:59';
313
+		$this_month_r = date('m', current_time('timestamp'));
314
+		$days_this_month = date('t', current_time('timestamp'));
315
+		//setup date query.
316
+		$beginning_string = EEM_Registration::instance()
317
+											->convert_datetime_for_query('REG_date',
318
+												$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
319
+												'Y-m-d H:i:s');
320
+		$end_string = EEM_Registration::instance()
321
+									  ->convert_datetime_for_query('REG_date',
322
+										  $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
323
+										  'Y-m-d H:i:s');
324
+		$_where['REG_date'] = array(
325
+			'BETWEEN',
326
+			array(
327
+				$beginning_string,
328
+				$end_string,
329
+			),
330
+		);
331
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
332
+		return EEM_Registration::instance()->count(array($_where));
333
+	}
334
+
335
+
336
+
337
+	/**
338
+	 * _total_registrations_today
339
+	 *
340
+	 * @access protected
341
+	 * @return int
342
+	 * @throws \EE_Error
343
+	 */
344
+	protected function _total_registrations_today()
345
+	{
346
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
347
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
348
+		$current_date = date('Y-m-d', current_time('timestamp'));
349
+		$time_start = ' 00:00:00';
350
+		$time_end = ' 23:59:59';
351
+		$_where['REG_date'] = array(
352
+			'BETWEEN',
353
+			array(
354
+				EEM_Registration::instance()
355
+								->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'),
356
+				EEM_Registration::instance()
357
+								->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'),
358
+			),
359
+		);
360
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
361
+		return EEM_Registration::instance()->count(array($_where));
362
+	}
363
+
364
+
365
+
366
+	/**
367
+	 * column_cb
368
+	 *
369
+	 * @access public
370
+	 * @param \EE_Registration $item
371
+	 * @return string
372
+	 * @throws \EE_Error
373
+	 */
374
+	public function column_cb($item)
375
+	{
376
+		/** checkbox/lock **/
377
+		$transaction = $item->get_first_related('Transaction');
378
+		$payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0;
379
+		return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID())
380
+									. '<span class="ee-lock-icon"></span>'
381
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID());
382
+	}
383
+
384
+
385
+
386
+	/**
387
+	 * column__REG_ID
388
+	 *
389
+	 * @access public
390
+	 * @param \EE_Registration $item
391
+	 * @return string
392
+	 * @throws \EE_Error
393
+	 */
394
+	public function column__REG_ID(EE_Registration $item)
395
+	{
396
+		$attendee = $item->attendee();
397
+		$content = $item->ID();
398
+		$content .= '<div class="show-on-mobile-view-only">';
399
+		$content .= '<br>';
400
+		$content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
401
+		$content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
402
+		$content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
403
+		$content .= '</div>';
404
+		return $content;
405
+	}
406
+
407
+
408
+
409
+	/**
410
+	 * column__REG_date
411
+	 *
412
+	 * @access public
413
+	 * @param \EE_Registration $item
414
+	 * @return string
415
+	 * @throws \EE_Error
416
+	 */
417
+	public function column__REG_date(EE_Registration $item)
418
+	{
419
+		$this->_set_related_details($item);
420
+		//Build row actions
421
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
422
+			'action' => 'view_transaction',
423
+			'TXN_ID' => $this->_transaction_details['id'],
424
+		), TXN_ADMIN_URL);
425
+		$view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
426
+			'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'
427
+														. $this->_transaction_details['status']
428
+														. '" href="'
429
+														. $view_lnk_url
430
+														. '" title="'
431
+														. esc_attr($this->_transaction_details['title_attr'])
432
+														. '">'
433
+														. $item->get_i18n_datetime('REG_date')
434
+														. '</a>' : $item->get_i18n_datetime('REG_date');
435
+		$view_link .= '<br><span class="ee-status-text-small">'
436
+					  . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
437
+					  . '</span>';
438
+		return $view_link;
439
+	}
440
+
441
+
442
+
443
+	/**
444
+	 * column_event_name
445
+	 *
446
+	 * @access public
447
+	 * @param \EE_Registration $item
448
+	 * @return string
449
+	 * @throws \EE_Error
450
+	 */
451
+	public function column_event_name(EE_Registration $item)
452
+	{
453
+		$this->_set_related_details($item);
454
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
455
+		$EVT_ID = $item->event_ID();
456
+		$event_name = $item->event_name();
457
+		$event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
458
+		$event_name = wp_trim_words($event_name, 30, '...');
459
+		if ($EVT_ID) {
460
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID),
461
+				EVENTS_ADMIN_URL);
462
+			$edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
463
+				? '<a class="ee-status-color-'
464
+				  . $this->_event_details['status']
465
+				  . '" href="'
466
+				  . $edit_event_url
467
+				  . '" title="'
468
+				  . esc_attr($this->_event_details['title_attr'])
469
+				  . '">'
470
+				  . $event_name
471
+				  . '</a>' : $event_name;
472
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
473
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
474
+			$actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s',
475
+				'event_espresso'), $event_name);
476
+			$actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
477
+		} else {
478
+			$edit_event = $event_name;
479
+			$actions['event_filter'] = '';
480
+		}
481
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
482
+	}
483
+
484
+
485
+
486
+	/**
487
+	 * column_DTT_EVT_start
488
+	 *
489
+	 * @access public
490
+	 * @param \EE_Registration $item
491
+	 * @return string
492
+	 * @throws \EE_Error
493
+	 */
494
+	public function column_DTT_EVT_start(EE_Registration $item)
495
+	{
496
+		$datetime_strings = array();
497
+		$ticket = $item->ticket(true);
498
+		if ($ticket instanceof EE_Ticket) {
499
+			$remove_defaults = array('default_where_conditions' => 'none');
500
+			$datetimes = $ticket->datetimes($remove_defaults);
501
+			foreach ($datetimes as $datetime) {
502
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
503
+			}
504
+			return implode("<br />", $datetime_strings);
505
+		} else {
506
+			return __('There is no ticket on this registration', 'event_espresso');
507
+		}
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 * column_ATT_fname
514
+	 *
515
+	 * @access public
516
+	 * @param \EE_Registration $item
517
+	 * @return string
518
+	 * @throws \EE_Error
519
+	 */
520
+	public function column_ATT_fname(EE_Registration $item)
521
+	{
522
+		$attendee = $item->attendee();
523
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
524
+			'action'  => 'view_registration',
525
+			'_REG_ID' => $item->ID(),
526
+		), REG_ADMIN_URL);
527
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
528
+		$link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
529
+			'espresso_registrations_view_registration', $item->ID()) ? '<a href="'
530
+																	   . $edit_lnk_url
531
+																	   . '" title="'
532
+																	   . esc_attr__('View Registration Details',
533
+				'event_espresso')
534
+																	   . '">'
535
+																	   . $attendee_name
536
+																	   . '</a>' : $attendee_name;
537
+		$link .= $item->count() === 1
538
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
539
+		$t = $item->get_first_related('Transaction');
540
+		$payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
541
+		//append group count to name
542
+		$link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
543
+		//append reg_code
544
+		$link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
545
+		//reg status text for accessibility
546
+		$link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false,
547
+				'sentence') . '</span>';
548
+		//trash/restore/delete actions
549
+		$actions = array();
550
+		if ($this->_view !== 'trash'
551
+			&& $payment_count === 0
552
+			&& EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
553
+				'espresso_registrations_trash_registrations', $item->ID())
554
+		) {
555
+			$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
556
+				'action'  => 'trash_registrations',
557
+				'_REG_ID' => $item->ID(),
558
+			), REG_ADMIN_URL);
559
+			$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration',
560
+					'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
561
+		} elseif ($this->_view === 'trash') {
562
+			// restore registration link
563
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
564
+				'espresso_registrations_restore_registrations', $item->ID())
565
+			) {
566
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
567
+					'action'  => 'restore_registrations',
568
+					'_REG_ID' => $item->ID(),
569
+				), REG_ADMIN_URL);
570
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration',
571
+						'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>';
572
+			}
573
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration',
574
+				'espresso_registrations_ee_delete_registrations', $item->ID())
575
+			) {
576
+				$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
577
+					'action'  => 'delete_registrations',
578
+					'_REG_ID' => $item->ID(),
579
+				), REG_ADMIN_URL);
580
+				$actions['delete'] = '<a href="'
581
+									 . $delete_lnk_url
582
+									 . '" title="'
583
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
584
+									 . '">'
585
+									 . __('Delete', 'event_espresso')
586
+									 . '</a>';
587
+			}
588
+		}
589
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
590
+	}
591
+
592
+
593
+
594
+	/**
595
+	 * column_ATT_email
596
+	 *
597
+	 * @access public
598
+	 * @param \EE_Registration $item
599
+	 * @return string
600
+	 * @throws \EE_Error
601
+	 */
602
+	public function column_ATT_email(EE_Registration $item)
603
+	{
604
+		$attendee = $item->get_first_related('Attendee');
605
+		return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
606
+			: $attendee->email();
607
+	}
608
+
609
+
610
+
611
+	/**
612
+	 * column__REG_count
613
+	 *
614
+	 * @access public
615
+	 * @param \EE_Registration $item
616
+	 * @return string
617
+	 */
618
+	public function column__REG_count(EE_Registration $item)
619
+	{
620
+		return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
621
+	}
622
+
623
+
624
+
625
+	/**
626
+	 * column_PRC_amount
627
+	 *
628
+	 * @access public
629
+	 * @param \EE_Registration $item
630
+	 * @return string
631
+	 */
632
+	public function column_PRC_amount(EE_Registration $item)
633
+	{
634
+		$ticket = $item->ticket();
635
+		$content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
636
+																			  . $ticket->name()
637
+																			  . '</span><br />' : '';
638
+		if ($item->final_price() > 0) {
639
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
640
+		} else {
641
+			// free event
642
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
643
+						. __('free', 'event_espresso')
644
+						. '</span>';
645
+		}
646
+		return $content;
647
+	}
648
+
649
+
650
+
651
+	/**
652
+	 * column__REG_final_price
653
+	 *
654
+	 * @access public
655
+	 * @param \EE_Registration $item
656
+	 * @return string
657
+	 */
658
+	public function column__REG_final_price(EE_Registration $item)
659
+	{
660
+		$ticket = $item->ticket();
661
+		$content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
662
+			? ''
663
+			: '<span class="TKT_name">'
664
+			  . $ticket->name()
665
+			  . '</span><br />';
666
+		$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
667
+		return $content;
668
+	}
669
+
670
+
671
+
672
+	/**
673
+	 * column__REG_paid
674
+	 *
675
+	 * @access public
676
+	 * @param \EE_Registration $item
677
+	 * @return string
678
+	 */
679
+	public function column__REG_paid(EE_Registration $item)
680
+	{
681
+		$payment_method = $item->payment_method();
682
+		$payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
683
+			: __('Unknown', 'event_espresso');
684
+		$content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
685
+		if ($item->paid() > 0) {
686
+			$content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'),
687
+					$payment_method_name) . '</span>';
688
+		}
689
+		return $content;
690
+	}
691
+
692
+
693
+
694
+	/**
695
+	 * column_TXN_total
696
+	 *
697
+	 * @access public
698
+	 * @param \EE_Registration $item
699
+	 * @return string
700
+	 * @throws \EE_Error
701
+	 */
702
+	public function column_TXN_total(EE_Registration $item)
703
+	{
704
+		if ($item->transaction()) {
705
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
706
+				'action' => 'view_transaction',
707
+				'TXN_ID' => $item->transaction_ID(),
708
+			), TXN_ADMIN_URL);
709
+			return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
710
+				'espresso_transactions_view_transaction', $item->transaction_ID())
711
+				? '<span class="reg-pad-rght"><a class="status-'
712
+				  . $item->transaction()->status_ID()
713
+				  . '" href="'
714
+				  . $view_txn_lnk_url
715
+				  . '"  title="'
716
+				  . esc_attr__('View Transaction', 'event_espresso')
717
+				  . '">'
718
+				  . $item->transaction()->pretty_total()
719
+				  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
720
+		} else {
721
+			return __("None", "event_espresso");
722
+		}
723
+	}
724
+
725
+
726
+
727
+	/**
728
+	 * column_TXN_paid
729
+	 *
730
+	 * @access public
731
+	 * @param \EE_Registration $item
732
+	 * @return string
733
+	 * @throws \EE_Error
734
+	 */
735
+	public function column_TXN_paid(EE_Registration $item)
736
+	{
737
+		if ($item->count() === 1) {
738
+			$transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
739
+			if ($transaction->paid() >= $transaction->total()) {
740
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
741
+			} else {
742
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
743
+					'action' => 'view_transaction',
744
+					'TXN_ID' => $item->transaction_ID(),
745
+				), TXN_ADMIN_URL);
746
+				return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
747
+					'espresso_transactions_view_transaction', $item->transaction_ID())
748
+					? '<span class="reg-pad-rght"><a class="status-'
749
+					  . $transaction->status_ID()
750
+					  . '" href="'
751
+					  . $view_txn_lnk_url
752
+					  . '"  title="'
753
+					  . esc_attr__('View Transaction', 'event_espresso')
754
+					  . '">'
755
+					  . $item->transaction()->pretty_paid()
756
+					  . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
757
+			}
758
+		}
759
+		return '&nbsp;';
760
+	}
761
+
762
+
763
+
764
+	/**
765
+	 * column_actions
766
+	 *
767
+	 * @access public
768
+	 * @param \EE_Registration $item
769
+	 * @return string
770
+	 * @throws \EE_Error
771
+	 */
772
+	public function column_actions(EE_Registration $item)
773
+	{
774
+		$actions = array();
775
+		$attendee = $item->attendee();
776
+		$this->_set_related_details($item);
777
+		//Build row actions
778
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
779
+			'action'  => 'view_registration',
780
+			'_REG_ID' => $item->ID(),
781
+		), REG_ADMIN_URL);
782
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
783
+			'action' => 'edit_attendee',
784
+			'post'   => $item->attendee_ID(),
785
+		), REG_ADMIN_URL);
786
+		// page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
787
+		//$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
788
+		$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
789
+			'action'  => 'resend_registration',
790
+			'_REG_ID' => $item->ID(),
791
+		), REG_ADMIN_URL, true);
792
+		//Build row actions
793
+		$actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration',
794
+			'espresso_registrations_view_registration', $item->ID()) ? '
795 795
 			<li>
796 796
 			<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
797 797
 				<div class="dashicons dashicons-clipboard"></div>
798 798
 			</a>
799 799
 			</li>' : '';
800
-        $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts',
801
-            'espresso_registrations_edit_attendee')
802
-                               && $attendee instanceof EE_Attendee ? '
800
+		$actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts',
801
+			'espresso_registrations_edit_attendee')
802
+							   && $attendee instanceof EE_Attendee ? '
803 803
 			<li>
804 804
 			<a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
805 805
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
806 806
 			</a>
807 807
 			</li>' : '';
808
-        $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
809
-                                     && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
810
-            'espresso_registrations_resend_registration', $item->ID()) ? '
808
+		$actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
809
+									 && EE_Registry::instance()->CAP->current_user_can('ee_send_message',
810
+			'espresso_registrations_resend_registration', $item->ID()) ? '
811 811
 			<li>
812 812
 			<a href="'
813
-                                                                         . $resend_reg_lnk_url
814
-                                                                         . '" title="'
815
-                                                                         . esc_attr__('Resend Registration Details',
816
-                'event_espresso')
817
-                                                                         . '" class="tiny-text">
813
+																		 . $resend_reg_lnk_url
814
+																		 . '" title="'
815
+																		 . esc_attr__('Resend Registration Details',
816
+				'event_espresso')
817
+																		 . '" class="tiny-text">
818 818
 				<div class="dashicons dashicons-email-alt"></div>
819 819
 			</a>
820 820
 			</li>' : '';
821
-        // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
822
-        $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
823
-            'action' => 'view_transaction',
824
-            'TXN_ID' => $this->_transaction_details['id'],
825
-        ), TXN_ADMIN_URL);
826
-        $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
827
-            'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? '
821
+		// page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
822
+		$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
823
+			'action' => 'view_transaction',
824
+			'TXN_ID' => $this->_transaction_details['id'],
825
+		), TXN_ADMIN_URL);
826
+		$actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction',
827
+			'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? '
828 828
 			<li>
829 829
 			<a class="ee-status-color-'
830
-                                                                                           . $this->_transaction_details['status']
831
-                                                                                           . ' tiny-text" href="'
832
-                                                                                           . $view_txn_lnk_url
833
-                                                                                           . '"  title="'
834
-                                                                                           . $this->_transaction_details['title_attr']
835
-                                                                                           . '">
830
+																						   . $this->_transaction_details['status']
831
+																						   . ' tiny-text" href="'
832
+																						   . $view_txn_lnk_url
833
+																						   . '"  title="'
834
+																						   . $this->_transaction_details['title_attr']
835
+																						   . '">
836 836
 				<div class="dashicons dashicons-cart"></div>
837 837
 			</a>
838 838
 			</li>' : '';
839
-        //invoice link
840
-        $actions['dl_invoice_lnk'] = '';
841
-        $dl_invoice_lnk_url = $item->invoice_url();
842
-        //only show invoice link if message type is active.
843
-        if ($attendee instanceof EE_Attendee
844
-            && $item->is_primary_registrant()
845
-            && EEH_MSG_Template::is_mt_active('invoice')
846
-        ) {
847
-            $actions['dl_invoice_lnk'] = '
839
+		//invoice link
840
+		$actions['dl_invoice_lnk'] = '';
841
+		$dl_invoice_lnk_url = $item->invoice_url();
842
+		//only show invoice link if message type is active.
843
+		if ($attendee instanceof EE_Attendee
844
+			&& $item->is_primary_registrant()
845
+			&& EEH_MSG_Template::is_mt_active('invoice')
846
+		) {
847
+			$actions['dl_invoice_lnk'] = '
848 848
 		<li>
849 849
 			<a title="'
850
-                                         . esc_attr__('View Transaction Invoice', 'event_espresso')
851
-                                         . '" target="_blank" href="'
852
-                                         . $dl_invoice_lnk_url
853
-                                         . '" class="tiny-text">
850
+										 . esc_attr__('View Transaction Invoice', 'event_espresso')
851
+										 . '" target="_blank" href="'
852
+										 . $dl_invoice_lnk_url
853
+										 . '" class="tiny-text">
854 854
 				<span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
855 855
 			</a>
856 856
 		</li>';
857
-        }
858
-        $actions['filtered_messages_link'] = '';
859
-        //message list table link (filtered by REG_ID
860
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
861
-            $actions['filtered_messages_link'] = '<li>'
862
-                                                 . EEH_MSG_Template::get_message_action_link('see_notifications_for',
863
-                    null, array(
864
-                        '_REG_ID' => $item->ID(),
865
-                    ))
866
-                                                 . '</li>';
867
-        }
868
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
869
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
870
-    }
857
+		}
858
+		$actions['filtered_messages_link'] = '';
859
+		//message list table link (filtered by REG_ID
860
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
861
+			$actions['filtered_messages_link'] = '<li>'
862
+												 . EEH_MSG_Template::get_message_action_link('see_notifications_for',
863
+					null, array(
864
+						'_REG_ID' => $item->ID(),
865
+					))
866
+												 . '</li>';
867
+		}
868
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
869
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
870
+	}
871 871
 
872 872
 }
Please login to merge, or discard this patch.