Completed
Branch BUG/double-ampersand-in-regist... (95cab8)
by
unknown
11:07 queued 26s
created
modules/batch/EED_Batch.module.php 3 patches
Indentation   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -23,355 +23,355 @@
 block discarded – undo
23 23
 class EED_Batch extends EED_Module
24 24
 {
25 25
 
26
-    /**
27
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
28
-     * processes data only
29
-     */
30
-    const batch_job = 'job';
31
-    /**
32
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
33
-     * produces a file for download
34
-     */
35
-    const batch_file_job = 'file';
36
-    /**
37
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT
38
-     * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ]
39
-     * at all
40
-     */
41
-    const batch_not_job = 'none';
26
+	/**
27
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
28
+	 * processes data only
29
+	 */
30
+	const batch_job = 'job';
31
+	/**
32
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
33
+	 * produces a file for download
34
+	 */
35
+	const batch_file_job = 'file';
36
+	/**
37
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT
38
+	 * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ]
39
+	 * at all
40
+	 */
41
+	const batch_not_job = 'none';
42 42
 
43
-    /**
44
-     *
45
-     * @var string 'file', or 'job', or false to indicate its not a batch request at all
46
-     */
47
-    protected $_batch_request_type = null;
43
+	/**
44
+	 *
45
+	 * @var string 'file', or 'job', or false to indicate its not a batch request at all
46
+	 */
47
+	protected $_batch_request_type = null;
48 48
 
49
-    /**
50
-     * Because we want to use the response in both the localized JS and in the body
51
-     * we need to make this response available between method calls
52
-     *
53
-     * @var \EventEspressoBatchRequest\Helpers\JobStepResponse
54
-     */
55
-    protected $_job_step_response = null;
49
+	/**
50
+	 * Because we want to use the response in both the localized JS and in the body
51
+	 * we need to make this response available between method calls
52
+	 *
53
+	 * @var \EventEspressoBatchRequest\Helpers\JobStepResponse
54
+	 */
55
+	protected $_job_step_response = null;
56 56
 
57
-    /**
58
-     * Gets the batch instance
59
-     *
60
-     * @return EED_Batch
61
-     */
62
-    public static function instance()
63
-    {
64
-        return self::get_instance();
65
-    }
57
+	/**
58
+	 * Gets the batch instance
59
+	 *
60
+	 * @return EED_Batch
61
+	 */
62
+	public static function instance()
63
+	{
64
+		return self::get_instance();
65
+	}
66 66
 
67
-    /**
68
-     * Sets hooks to enable batch jobs on the frontend. Disabled by default
69
-     * because it's an attack vector and there are currently no implementations
70
-     */
71
-    public static function set_hooks()
72
-    {
73
-        // because this is a possibel attack vector, let's have this disabled until
74
-        // we at least have a real use for it on the frontend
75
-        if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) {
76
-            add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
77
-            add_filter('template_include', array(self::instance(), 'override_template'), 99);
78
-        }
79
-    }
67
+	/**
68
+	 * Sets hooks to enable batch jobs on the frontend. Disabled by default
69
+	 * because it's an attack vector and there are currently no implementations
70
+	 */
71
+	public static function set_hooks()
72
+	{
73
+		// because this is a possibel attack vector, let's have this disabled until
74
+		// we at least have a real use for it on the frontend
75
+		if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) {
76
+			add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
77
+			add_filter('template_include', array(self::instance(), 'override_template'), 99);
78
+		}
79
+	}
80 80
 
81
-    /**
82
-     * Initializes some hooks for the admin in order to run batch jobs
83
-     */
84
-    public static function set_hooks_admin()
85
-    {
86
-        add_action('admin_menu', array(self::instance(), 'register_admin_pages'));
87
-        add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
81
+	/**
82
+	 * Initializes some hooks for the admin in order to run batch jobs
83
+	 */
84
+	public static function set_hooks_admin()
85
+	{
86
+		add_action('admin_menu', array(self::instance(), 'register_admin_pages'));
87
+		add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
88 88
 
89
-        // ajax
90
-        add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue'));
91
-        add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
92
-        add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue'));
93
-        add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
94
-    }
89
+		// ajax
90
+		add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue'));
91
+		add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
92
+		add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue'));
93
+		add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
94
+	}
95 95
 
96
-    /**
97
-     * Enqueues batch scripts on the frontend or admin, and creates a job
98
-     */
99
-    public function enqueue_scripts()
100
-    {
101
-        if (isset($_REQUEST['espresso_batch'])
102
-            ||
103
-            (
104
-                isset($_REQUEST['page'])
105
-                && $_REQUEST['page'] == 'espresso_batch'
106
-            )
107
-        ) {
108
-            switch ($this->batch_request_type()) {
109
-                case self::batch_job:
110
-                    $this->enqueue_scripts_styles_batch_create();
111
-                    break;
112
-                case self::batch_file_job:
113
-                    $this->enqueue_scripts_styles_batch_file_create();
114
-                    break;
115
-            }
116
-        }
117
-    }
96
+	/**
97
+	 * Enqueues batch scripts on the frontend or admin, and creates a job
98
+	 */
99
+	public function enqueue_scripts()
100
+	{
101
+		if (isset($_REQUEST['espresso_batch'])
102
+			||
103
+			(
104
+				isset($_REQUEST['page'])
105
+				&& $_REQUEST['page'] == 'espresso_batch'
106
+			)
107
+		) {
108
+			switch ($this->batch_request_type()) {
109
+				case self::batch_job:
110
+					$this->enqueue_scripts_styles_batch_create();
111
+					break;
112
+				case self::batch_file_job:
113
+					$this->enqueue_scripts_styles_batch_file_create();
114
+					break;
115
+			}
116
+		}
117
+	}
118 118
 
119
-    /**
120
-     * Create a batch job, enqueues a script to run it, and localizes some data for it
121
-     */
122
-    public function enqueue_scripts_styles_batch_create()
123
-    {
124
-        $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
125
-        wp_enqueue_script(
126
-            'batch_runner_init',
127
-            BATCH_URL . 'assets/batch_runner_init.js',
128
-            array('batch_runner'),
129
-            EVENT_ESPRESSO_VERSION,
130
-            true
131
-        );
132
-        wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array());
119
+	/**
120
+	 * Create a batch job, enqueues a script to run it, and localizes some data for it
121
+	 */
122
+	public function enqueue_scripts_styles_batch_create()
123
+	{
124
+		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
125
+		wp_enqueue_script(
126
+			'batch_runner_init',
127
+			BATCH_URL . 'assets/batch_runner_init.js',
128
+			array('batch_runner'),
129
+			EVENT_ESPRESSO_VERSION,
130
+			true
131
+		);
132
+		wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array());
133 133
 
134 134
 
135
-        wp_localize_script(
136
-            'batch_runner_init',
137
-            'ee_job_i18n',
138
-            array(
139
-                'return_url' => $this->getReturnUrl(),
140
-            )
141
-        );
142
-    }
135
+		wp_localize_script(
136
+			'batch_runner_init',
137
+			'ee_job_i18n',
138
+			array(
139
+				'return_url' => $this->getReturnUrl(),
140
+			)
141
+		);
142
+	}
143 143
 
144
-    /**
145
-     * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it
146
-     */
147
-    public function enqueue_scripts_styles_batch_file_create()
148
-    {
149
-        // creates a job based on the request variable
150
-        $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
151
-        wp_enqueue_script(
152
-            'batch_file_runner_init',
153
-            BATCH_URL . 'assets/batch_file_runner_init.js',
154
-            array('batch_runner'),
155
-            EVENT_ESPRESSO_VERSION,
156
-            true
157
-        );
158
-        wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array());
159
-        wp_localize_script(
160
-            'batch_file_runner_init',
161
-            'ee_job_i18n',
162
-            array(
163
-                'download_and_redirecting' => sprintf(
164
-                    __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
165
-                    '<a href="' . $_REQUEST['return_url'] . '">',
166
-                    '</a>'
167
-                ),
168
-                'return_url'               => $this->getReturnUrl(),
169
-            )
170
-        );
171
-    }
144
+	/**
145
+	 * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it
146
+	 */
147
+	public function enqueue_scripts_styles_batch_file_create()
148
+	{
149
+		// creates a job based on the request variable
150
+		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
151
+		wp_enqueue_script(
152
+			'batch_file_runner_init',
153
+			BATCH_URL . 'assets/batch_file_runner_init.js',
154
+			array('batch_runner'),
155
+			EVENT_ESPRESSO_VERSION,
156
+			true
157
+		);
158
+		wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array());
159
+		wp_localize_script(
160
+			'batch_file_runner_init',
161
+			'ee_job_i18n',
162
+			array(
163
+				'download_and_redirecting' => sprintf(
164
+					__('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
165
+					'<a href="' . $_REQUEST['return_url'] . '">',
166
+					'</a>'
167
+				),
168
+				'return_url'               => $this->getReturnUrl(),
169
+			)
170
+		);
171
+	}
172 172
 
173
-    /**
174
-     * Get the return URL. Some code got reformatted to use ee_return_url, because something was interfering whenever
175
-     * it spotted "return_url" in querystrings
176
-     * @since $VID:$
177
-     * @return string|void
178
-     */
179
-    protected function getReturnUrl()
180
-    {
181
-        if(isset($_REQUEST['ee_return_url'])) {
182
-    return $_REQUEST['ee_return_url'];
183
-        } elseif(isset($_REQUEST['return_url'])) {
184
-            return $_REQUEST['return_url'];
185
-        }else{
186
-            return site_url();
187
-        }
188
-    }
173
+	/**
174
+	 * Get the return URL. Some code got reformatted to use ee_return_url, because something was interfering whenever
175
+	 * it spotted "return_url" in querystrings
176
+	 * @since $VID:$
177
+	 * @return string|void
178
+	 */
179
+	protected function getReturnUrl()
180
+	{
181
+		if(isset($_REQUEST['ee_return_url'])) {
182
+	return $_REQUEST['ee_return_url'];
183
+		} elseif(isset($_REQUEST['return_url'])) {
184
+			return $_REQUEST['return_url'];
185
+		}else{
186
+			return site_url();
187
+		}
188
+	}
189 189
 
190
-    /**
191
-     * Enqueues scripts and styles common to any batch job, and creates
192
-     * a job from the request data, and stores the response in the
193
-     * $this->_job_step_response property
194
-     *
195
-     * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
196
-     */
197
-    protected function _enqueue_batch_job_scripts_and_styles_and_start_job()
198
-    {
199
-        wp_register_script(
200
-            'progress_bar',
201
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js',
202
-            array('jquery')
203
-        );
204
-        wp_enqueue_style(
205
-            'progress_bar',
206
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css',
207
-            array(),
208
-            EVENT_ESPRESSO_VERSION
209
-        );
210
-        wp_enqueue_script(
211
-            'batch_runner',
212
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js',
213
-            array('progress_bar')
214
-        );
215
-        // just copy the bits of EE admin's eei18n that we need in the JS
216
-        wp_localize_script(
217
-            'batch_runner',
218
-            'eei18n',
219
-            array(
220
-                'ajax_url'      => WP_AJAX_URL,
221
-                'is_admin'      => (bool) is_admin(),
222
-                'error_message' => esc_html__('An error occurred and the job has been stopped.', 'event_espresso'),
223
-            )
224
-        );
225
-        $job_handler_classname = stripslashes($_GET['job_handler']);
226
-        $request_data = array_diff_key(
227
-            $_REQUEST,
228
-            array_flip(array('action', 'page', 'ee', 'batch'))
229
-        );
230
-        $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
231
-        // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
232
-        $job_response = $batch_runner->create_job($job_handler_classname, $request_data);
233
-        // remember the response for later. We need it to display the page body
234
-        $this->_job_step_response = $job_response;
235
-        return $job_response;
236
-    }
190
+	/**
191
+	 * Enqueues scripts and styles common to any batch job, and creates
192
+	 * a job from the request data, and stores the response in the
193
+	 * $this->_job_step_response property
194
+	 *
195
+	 * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
196
+	 */
197
+	protected function _enqueue_batch_job_scripts_and_styles_and_start_job()
198
+	{
199
+		wp_register_script(
200
+			'progress_bar',
201
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js',
202
+			array('jquery')
203
+		);
204
+		wp_enqueue_style(
205
+			'progress_bar',
206
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css',
207
+			array(),
208
+			EVENT_ESPRESSO_VERSION
209
+		);
210
+		wp_enqueue_script(
211
+			'batch_runner',
212
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js',
213
+			array('progress_bar')
214
+		);
215
+		// just copy the bits of EE admin's eei18n that we need in the JS
216
+		wp_localize_script(
217
+			'batch_runner',
218
+			'eei18n',
219
+			array(
220
+				'ajax_url'      => WP_AJAX_URL,
221
+				'is_admin'      => (bool) is_admin(),
222
+				'error_message' => esc_html__('An error occurred and the job has been stopped.', 'event_espresso'),
223
+			)
224
+		);
225
+		$job_handler_classname = stripslashes($_GET['job_handler']);
226
+		$request_data = array_diff_key(
227
+			$_REQUEST,
228
+			array_flip(array('action', 'page', 'ee', 'batch'))
229
+		);
230
+		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
231
+		// eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
232
+		$job_response = $batch_runner->create_job($job_handler_classname, $request_data);
233
+		// remember the response for later. We need it to display the page body
234
+		$this->_job_step_response = $job_response;
235
+		return $job_response;
236
+	}
237 237
 
238
-    /**
239
-     * If we are doing a frontend batch job, this makes it so WP shows our template's HTML
240
-     *
241
-     * @param string $template
242
-     * @return string
243
-     */
244
-    public function override_template($template)
245
-    {
246
-        if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) {
247
-            return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html';
248
-        }
249
-        return $template;
250
-    }
238
+	/**
239
+	 * If we are doing a frontend batch job, this makes it so WP shows our template's HTML
240
+	 *
241
+	 * @param string $template
242
+	 * @return string
243
+	 */
244
+	public function override_template($template)
245
+	{
246
+		if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) {
247
+			return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html';
248
+		}
249
+		return $template;
250
+	}
251 251
 
252
-    /**
253
-     * Adds an admin page which doesn't appear in the admin menu
254
-     */
255
-    public function register_admin_pages()
256
-    {
257
-        add_submenu_page(
258
-            '', // parent slug. we don't want this to actually appear in the menu
259
-            __('Batch Job', 'event_espresso'), // page title
260
-            'n/a', // menu title
261
-            'read', // we want this page to actually be accessible to anyone,
262
-            'espresso_batch', // menu slug
263
-            array(self::instance(), 'show_admin_page')
264
-        );
265
-    }
252
+	/**
253
+	 * Adds an admin page which doesn't appear in the admin menu
254
+	 */
255
+	public function register_admin_pages()
256
+	{
257
+		add_submenu_page(
258
+			'', // parent slug. we don't want this to actually appear in the menu
259
+			__('Batch Job', 'event_espresso'), // page title
260
+			'n/a', // menu title
261
+			'read', // we want this page to actually be accessible to anyone,
262
+			'espresso_batch', // menu slug
263
+			array(self::instance(), 'show_admin_page')
264
+		);
265
+	}
266 266
 
267
-    /**
268
-     * Renders the admin page, after most of the work was already done during enqueuing scripts
269
-     * of creating the job and localizing some data
270
-     */
271
-    public function show_admin_page()
272
-    {
273
-        echo EEH_Template::locate_template(
274
-            EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html',
275
-            array('batch_request_type' => $this->batch_request_type())
276
-        );
277
-    }
267
+	/**
268
+	 * Renders the admin page, after most of the work was already done during enqueuing scripts
269
+	 * of creating the job and localizing some data
270
+	 */
271
+	public function show_admin_page()
272
+	{
273
+		echo EEH_Template::locate_template(
274
+			EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html',
275
+			array('batch_request_type' => $this->batch_request_type())
276
+		);
277
+	}
278 278
 
279
-    /**
280
-     * Receives ajax calls for continuing a job
281
-     */
282
-    public function batch_continue()
283
-    {
284
-        $job_id = sanitize_text_field($_REQUEST['job_id']);
285
-        $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
286
-        $response_obj = $batch_runner->continue_job($job_id);
287
-        $this->_return_json($response_obj->to_array());
288
-    }
279
+	/**
280
+	 * Receives ajax calls for continuing a job
281
+	 */
282
+	public function batch_continue()
283
+	{
284
+		$job_id = sanitize_text_field($_REQUEST['job_id']);
285
+		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
286
+		$response_obj = $batch_runner->continue_job($job_id);
287
+		$this->_return_json($response_obj->to_array());
288
+	}
289 289
 
290
-    /**
291
-     * Receives the ajax call to cleanup a job
292
-     *
293
-     * @return type
294
-     */
295
-    public function batch_cleanup()
296
-    {
297
-        $job_id = sanitize_text_field($_REQUEST['job_id']);
298
-        $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
299
-        $response_obj = $batch_runner->cleanup_job($job_id);
300
-        $this->_return_json($response_obj->to_array());
301
-    }
290
+	/**
291
+	 * Receives the ajax call to cleanup a job
292
+	 *
293
+	 * @return type
294
+	 */
295
+	public function batch_cleanup()
296
+	{
297
+		$job_id = sanitize_text_field($_REQUEST['job_id']);
298
+		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
299
+		$response_obj = $batch_runner->cleanup_job($job_id);
300
+		$this->_return_json($response_obj->to_array());
301
+	}
302 302
 
303 303
 
304
-    /**
305
-     * Returns a json response
306
-     *
307
-     * @param array $data The data we want to send echo via in the JSON response's "data" element
308
-     *
309
-     * The returned json object is created from an array in the following format:
310
-     * array(
311
-     *    'notices' => '', // - contains any EE_Error formatted notices
312
-     *    'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
313
-     *    We're also going to include the template args with every package (so js can pick out any specific template
314
-     *    args that might be included in here)
315
-     *    'isEEajax' => true,//indicates this is a response from EE
316
-     * )
317
-     */
318
-    protected function _return_json($data)
319
-    {
320
-        $json = array(
321
-            'notices'  => EE_Error::get_notices(),
322
-            'data'     => $data,
323
-            'isEEajax' => true
324
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
325
-        );
304
+	/**
305
+	 * Returns a json response
306
+	 *
307
+	 * @param array $data The data we want to send echo via in the JSON response's "data" element
308
+	 *
309
+	 * The returned json object is created from an array in the following format:
310
+	 * array(
311
+	 *    'notices' => '', // - contains any EE_Error formatted notices
312
+	 *    'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
313
+	 *    We're also going to include the template args with every package (so js can pick out any specific template
314
+	 *    args that might be included in here)
315
+	 *    'isEEajax' => true,//indicates this is a response from EE
316
+	 * )
317
+	 */
318
+	protected function _return_json($data)
319
+	{
320
+		$json = array(
321
+			'notices'  => EE_Error::get_notices(),
322
+			'data'     => $data,
323
+			'isEEajax' => true
324
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
325
+		);
326 326
 
327 327
 
328
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
329
-        if (null === error_get_last() || ! headers_sent()) {
330
-            header('Content-Type: application/json; charset=UTF-8');
331
-        }
332
-        echo wp_json_encode($json);
333
-        exit();
334
-    }
328
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
329
+		if (null === error_get_last() || ! headers_sent()) {
330
+			header('Content-Type: application/json; charset=UTF-8');
331
+		}
332
+		echo wp_json_encode($json);
333
+		exit();
334
+	}
335 335
 
336
-    /**
337
-     * Gets the job step response which was done during the enqueuing of scripts
338
-     *
339
-     * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
340
-     */
341
-    public function job_step_response()
342
-    {
343
-        return $this->_job_step_response;
344
-    }
336
+	/**
337
+	 * Gets the job step response which was done during the enqueuing of scripts
338
+	 *
339
+	 * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
340
+	 */
341
+	public function job_step_response()
342
+	{
343
+		return $this->_job_step_response;
344
+	}
345 345
 
346
-    /**
347
-     * Gets the batch request type indicated in the $_REQUEST
348
-     *
349
-     * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job
350
-     */
351
-    public function batch_request_type()
352
-    {
353
-        if ($this->_batch_request_type === null) {
354
-            if (isset($_GET['batch'])) {
355
-                if ($_GET['batch'] == self::batch_job) {
356
-                    $this->_batch_request_type = self::batch_job;
357
-                } elseif ($_GET['batch'] == self::batch_file_job) {
358
-                    $this->_batch_request_type = self::batch_file_job;
359
-                }
360
-            }
361
-            // if we didn't find that it was a batch request, indicate it wasn't
362
-            if ($this->_batch_request_type === null) {
363
-                $this->_batch_request_type = self::batch_not_job;
364
-            }
365
-        }
366
-        return $this->_batch_request_type;
367
-    }
346
+	/**
347
+	 * Gets the batch request type indicated in the $_REQUEST
348
+	 *
349
+	 * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job
350
+	 */
351
+	public function batch_request_type()
352
+	{
353
+		if ($this->_batch_request_type === null) {
354
+			if (isset($_GET['batch'])) {
355
+				if ($_GET['batch'] == self::batch_job) {
356
+					$this->_batch_request_type = self::batch_job;
357
+				} elseif ($_GET['batch'] == self::batch_file_job) {
358
+					$this->_batch_request_type = self::batch_file_job;
359
+				}
360
+			}
361
+			// if we didn't find that it was a batch request, indicate it wasn't
362
+			if ($this->_batch_request_type === null) {
363
+				$this->_batch_request_type = self::batch_not_job;
364
+			}
365
+		}
366
+		return $this->_batch_request_type;
367
+	}
368 368
 
369
-    /**
370
-     * Unnecessary
371
-     *
372
-     * @param type $WP
373
-     */
374
-    public function run($WP)
375
-    {
376
-    }
369
+	/**
370
+	 * Unnecessary
371
+	 *
372
+	 * @param type $WP
373
+	 */
374
+	public function run($WP)
375
+	{
376
+	}
377 377
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
125 125
         wp_enqueue_script(
126 126
             'batch_runner_init',
127
-            BATCH_URL . 'assets/batch_runner_init.js',
127
+            BATCH_URL.'assets/batch_runner_init.js',
128 128
             array('batch_runner'),
129 129
             EVENT_ESPRESSO_VERSION,
130 130
             true
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
151 151
         wp_enqueue_script(
152 152
             'batch_file_runner_init',
153
-            BATCH_URL . 'assets/batch_file_runner_init.js',
153
+            BATCH_URL.'assets/batch_file_runner_init.js',
154 154
             array('batch_runner'),
155 155
             EVENT_ESPRESSO_VERSION,
156 156
             true
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             array(
163 163
                 'download_and_redirecting' => sprintf(
164 164
                     __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
165
-                    '<a href="' . $_REQUEST['return_url'] . '">',
165
+                    '<a href="'.$_REQUEST['return_url'].'">',
166 166
                     '</a>'
167 167
                 ),
168 168
                 'return_url'               => $this->getReturnUrl(),
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
      */
179 179
     protected function getReturnUrl()
180 180
     {
181
-        if(isset($_REQUEST['ee_return_url'])) {
181
+        if (isset($_REQUEST['ee_return_url'])) {
182 182
     return $_REQUEST['ee_return_url'];
183
-        } elseif(isset($_REQUEST['return_url'])) {
183
+        } elseif (isset($_REQUEST['return_url'])) {
184 184
             return $_REQUEST['return_url'];
185
-        }else{
185
+        } else {
186 186
             return site_url();
187 187
         }
188 188
     }
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
     {
199 199
         wp_register_script(
200 200
             'progress_bar',
201
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js',
201
+            EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js',
202 202
             array('jquery')
203 203
         );
204 204
         wp_enqueue_style(
205 205
             'progress_bar',
206
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css',
206
+            EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css',
207 207
             array(),
208 208
             EVENT_ESPRESSO_VERSION
209 209
         );
210 210
         wp_enqueue_script(
211 211
             'batch_runner',
212
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js',
212
+            EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js',
213 213
             array('progress_bar')
214 214
         );
215 215
         // just copy the bits of EE admin's eei18n that we need in the JS
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     public function override_template($template)
245 245
     {
246 246
         if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) {
247
-            return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html';
247
+            return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html';
248 248
         }
249 249
         return $template;
250 250
     }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
     public function show_admin_page()
272 272
     {
273 273
         echo EEH_Template::locate_template(
274
-            EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html',
274
+            EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html',
275 275
             array('batch_request_type' => $this->batch_request_type())
276 276
         );
277 277
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@
 block discarded – undo
182 182
     return $_REQUEST['ee_return_url'];
183 183
         } elseif(isset($_REQUEST['return_url'])) {
184 184
             return $_REQUEST['return_url'];
185
-        }else{
185
+        } else{
186 186
             return site_url();
187 187
         }
188 188
     }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +967 added lines, -967 removed lines patch added patch discarded remove patch
@@ -24,1048 +24,1048 @@
 block discarded – undo
24 24
 {
25 25
 
26 26
 
27
-    /**
28
-     * @var array
29
-     */
30
-    private $_status;
27
+	/**
28
+	 * @var array
29
+	 */
30
+	private $_status;
31 31
 
32 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();
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 40
 
41 41
 
42
-    /**
43
-     * An array of event details for the related event to the registration being processed.
44
-     * This is set via the _set_related_details method.
45
-     *
46
-     * @var array
47
-     */
48
-    protected $_event_details = array();
42
+	/**
43
+	 * An array of event details for the related event to the registration being processed.
44
+	 * This is set via the _set_related_details method.
45
+	 *
46
+	 * @var array
47
+	 */
48
+	protected $_event_details = array();
49 49
 
50 50
 
51
-    /**
52
-     * @param \Registrations_Admin_Page $admin_page
53
-     */
54
-    public function __construct(Registrations_Admin_Page $admin_page)
55
-    {
56
-        if (! empty($_GET['event_id'])) {
57
-            $extra_query_args = array();
58
-            foreach ($admin_page->get_views() as $key => $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = array('event_id' => $_GET['event_id']);
60
-            }
61
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
-        }
63
-        parent::__construct($admin_page);
64
-        $this->_status = $this->_admin_page->get_registration_status_array();
65
-    }
51
+	/**
52
+	 * @param \Registrations_Admin_Page $admin_page
53
+	 */
54
+	public function __construct(Registrations_Admin_Page $admin_page)
55
+	{
56
+		if (! empty($_GET['event_id'])) {
57
+			$extra_query_args = array();
58
+			foreach ($admin_page->get_views() as $key => $view_details) {
59
+				$extra_query_args[ $view_details['slug'] ] = array('event_id' => $_GET['event_id']);
60
+			}
61
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
+		}
63
+		parent::__construct($admin_page);
64
+		$this->_status = $this->_admin_page->get_registration_status_array();
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     *    _setup_data
70
-     *
71
-     * @access protected
72
-     * @return void
73
-     */
74
-    protected function _setup_data()
75
-    {
76
-        $this->_data = $this->_admin_page->get_registrations($this->_per_page);
77
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
78
-    }
68
+	/**
69
+	 *    _setup_data
70
+	 *
71
+	 * @access protected
72
+	 * @return void
73
+	 */
74
+	protected function _setup_data()
75
+	{
76
+		$this->_data = $this->_admin_page->get_registrations($this->_per_page);
77
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     *    _set_properties
83
-     *
84
-     * @access protected
85
-     * @return void
86
-     */
87
-    protected function _set_properties()
88
-    {
89
-        $this->_wp_list_args = array(
90
-            'singular' => __('registration', 'event_espresso'),
91
-            'plural'   => __('registrations', 'event_espresso'),
92
-            'ajax'     => true,
93
-            'screen'   => $this->_admin_page->get_current_screen()->id,
94
-        );
95
-        $ID_column_name = __('ID', 'event_espresso');
96
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
97
-        $ID_column_name .= __('Registrant Name', 'event_espresso');
98
-        $ID_column_name .= '</span> ';
99
-        if (isset($_GET['event_id'])) {
100
-            $this->_columns = array(
101
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
102
-                '_REG_ID'          => $ID_column_name,
103
-                'ATT_fname'        => __('Name', 'event_espresso'),
104
-                'ATT_email'        => __('Email', 'event_espresso'),
105
-                '_REG_date'        => __('Reg Date', 'event_espresso'),
106
-                'PRC_amount'       => __('TKT Price', 'event_espresso'),
107
-                '_REG_final_price' => __('Final Price', 'event_espresso'),
108
-                'TXN_total'        => __('Total Txn', 'event_espresso'),
109
-                'TXN_paid'         => __('Paid', 'event_espresso'),
110
-                'actions'          => __('Actions', 'event_espresso'),
111
-            );
112
-            $this->_bottom_buttons = array(
113
-                'report' => array(
114
-                    'route'         => 'registrations_report',
115
-                    'extra_request' => array(
116
-                        'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
117
-                        'ee_return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
118
-                    ),
119
-                ),
120
-            );
121
-        } else {
122
-            $this->_columns = array(
123
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
124
-                '_REG_ID'          => $ID_column_name,
125
-                'ATT_fname'        => __('Name', 'event_espresso'),
126
-                '_REG_date'        => __('TXN Date', 'event_espresso'),
127
-                'event_name'       => __('Event', 'event_espresso'),
128
-                'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
129
-                '_REG_final_price' => __('Price', 'event_espresso'),
130
-                '_REG_paid'        => __('Paid', 'event_espresso'),
131
-                'actions'          => __('Actions', 'event_espresso'),
132
-            );
133
-            $this->_bottom_buttons = array(
134
-                'report_all' => array(
135
-                    'route'         => 'registrations_report',
136
-                    'extra_request' => array(
137
-                        'ee_return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
138
-                    ),
139
-                ),
140
-            );
141
-        }
142
-        $this->_bottom_buttons['report_filtered'] = array(
143
-            'route'         => 'registrations_report',
144
-            'extra_request' => array(
145
-                'use_filters' => true,
146
-                'ee_return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
147
-            ),
148
-        );
149
-        $filters = array_diff_key(
150
-            $this->_req_data,
151
-            array_flip(
152
-                array(
153
-                    'page',
154
-                    'action',
155
-                    'default_nonce',
156
-                )
157
-            )
158
-        );
159
-        if (!empty($filters)) {
160
-            $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
161
-        }
162
-        $this->_primary_column = '_REG_ID';
163
-        $this->_sortable_columns = array(
164
-            '_REG_date'     => array('_REG_date' => true),   // true means its already sorted
165
-            /**
166
-             * Allows users to change the default sort if they wish.
167
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
168
-             * name.
169
-             */
170
-            'ATT_fname'     => array(
171
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
172
-                true,
173
-                $this,
174
-            )
175
-                ? array('ATT_lname' => false)
176
-                : array('ATT_fname' => false),
177
-            'event_name'    => array('event_name' => false),
178
-            'DTT_EVT_start' => array('DTT_EVT_start' => false),
179
-            '_REG_ID'       => array('_REG_ID' => false),
180
-        );
181
-        $this->_hidden_columns = array();
182
-    }
81
+	/**
82
+	 *    _set_properties
83
+	 *
84
+	 * @access protected
85
+	 * @return void
86
+	 */
87
+	protected function _set_properties()
88
+	{
89
+		$this->_wp_list_args = array(
90
+			'singular' => __('registration', 'event_espresso'),
91
+			'plural'   => __('registrations', 'event_espresso'),
92
+			'ajax'     => true,
93
+			'screen'   => $this->_admin_page->get_current_screen()->id,
94
+		);
95
+		$ID_column_name = __('ID', 'event_espresso');
96
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
97
+		$ID_column_name .= __('Registrant Name', 'event_espresso');
98
+		$ID_column_name .= '</span> ';
99
+		if (isset($_GET['event_id'])) {
100
+			$this->_columns = array(
101
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
102
+				'_REG_ID'          => $ID_column_name,
103
+				'ATT_fname'        => __('Name', 'event_espresso'),
104
+				'ATT_email'        => __('Email', 'event_espresso'),
105
+				'_REG_date'        => __('Reg Date', 'event_espresso'),
106
+				'PRC_amount'       => __('TKT Price', 'event_espresso'),
107
+				'_REG_final_price' => __('Final Price', 'event_espresso'),
108
+				'TXN_total'        => __('Total Txn', 'event_espresso'),
109
+				'TXN_paid'         => __('Paid', 'event_espresso'),
110
+				'actions'          => __('Actions', 'event_espresso'),
111
+			);
112
+			$this->_bottom_buttons = array(
113
+				'report' => array(
114
+					'route'         => 'registrations_report',
115
+					'extra_request' => array(
116
+						'EVT_ID'     => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
117
+						'ee_return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
118
+					),
119
+				),
120
+			);
121
+		} else {
122
+			$this->_columns = array(
123
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
124
+				'_REG_ID'          => $ID_column_name,
125
+				'ATT_fname'        => __('Name', 'event_espresso'),
126
+				'_REG_date'        => __('TXN Date', 'event_espresso'),
127
+				'event_name'       => __('Event', 'event_espresso'),
128
+				'DTT_EVT_start'    => __('Event Date', 'event_espresso'),
129
+				'_REG_final_price' => __('Price', 'event_espresso'),
130
+				'_REG_paid'        => __('Paid', 'event_espresso'),
131
+				'actions'          => __('Actions', 'event_espresso'),
132
+			);
133
+			$this->_bottom_buttons = array(
134
+				'report_all' => array(
135
+					'route'         => 'registrations_report',
136
+					'extra_request' => array(
137
+						'ee_return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
138
+					),
139
+				),
140
+			);
141
+		}
142
+		$this->_bottom_buttons['report_filtered'] = array(
143
+			'route'         => 'registrations_report',
144
+			'extra_request' => array(
145
+				'use_filters' => true,
146
+				'ee_return_url'  => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"),
147
+			),
148
+		);
149
+		$filters = array_diff_key(
150
+			$this->_req_data,
151
+			array_flip(
152
+				array(
153
+					'page',
154
+					'action',
155
+					'default_nonce',
156
+				)
157
+			)
158
+		);
159
+		if (!empty($filters)) {
160
+			$this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
161
+		}
162
+		$this->_primary_column = '_REG_ID';
163
+		$this->_sortable_columns = array(
164
+			'_REG_date'     => array('_REG_date' => true),   // true means its already sorted
165
+			/**
166
+			 * Allows users to change the default sort if they wish.
167
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
168
+			 * name.
169
+			 */
170
+			'ATT_fname'     => array(
171
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
172
+				true,
173
+				$this,
174
+			)
175
+				? array('ATT_lname' => false)
176
+				: array('ATT_fname' => false),
177
+			'event_name'    => array('event_name' => false),
178
+			'DTT_EVT_start' => array('DTT_EVT_start' => false),
179
+			'_REG_ID'       => array('_REG_ID' => false),
180
+		);
181
+		$this->_hidden_columns = array();
182
+	}
183 183
 
184 184
 
185
-    /**
186
-     * This simply sets up the row class for the table rows.
187
-     * Allows for easier overriding of child methods for setting up sorting.
188
-     *
189
-     * @param  EE_Registration $item the current item
190
-     * @return string
191
-     */
192
-    protected function _get_row_class($item)
193
-    {
194
-        $class = parent::_get_row_class($item);
195
-        // add status class
196
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
197
-        if ($this->_has_checkbox_column) {
198
-            $class .= ' has-checkbox-column';
199
-        }
200
-        return $class;
201
-    }
185
+	/**
186
+	 * This simply sets up the row class for the table rows.
187
+	 * Allows for easier overriding of child methods for setting up sorting.
188
+	 *
189
+	 * @param  EE_Registration $item the current item
190
+	 * @return string
191
+	 */
192
+	protected function _get_row_class($item)
193
+	{
194
+		$class = parent::_get_row_class($item);
195
+		// add status class
196
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
197
+		if ($this->_has_checkbox_column) {
198
+			$class .= ' has-checkbox-column';
199
+		}
200
+		return $class;
201
+	}
202 202
 
203 203
 
204
-    /**
205
-     * Set the $_transaction_details property if not set yet.
206
-     *
207
-     * @param EE_Registration $registration
208
-     * @throws EE_Error
209
-     * @throws InvalidArgumentException
210
-     * @throws ReflectionException
211
-     * @throws InvalidDataTypeException
212
-     * @throws InvalidInterfaceException
213
-     */
214
-    protected function _set_related_details(EE_Registration $registration)
215
-    {
216
-        $transaction = $registration->get_first_related('Transaction');
217
-        $status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
218
-            : EEM_Transaction::failed_status_code;
219
-        $this->_transaction_details = array(
220
-            'transaction' => $transaction,
221
-            'status'      => $status,
222
-            'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
223
-            'title_attr'  => sprintf(
224
-                __('View Transaction Details (%s)', 'event_espresso'),
225
-                EEH_Template::pretty_status($status, false, 'sentence')
226
-            ),
227
-        );
228
-        try {
229
-            $event = $registration->event();
230
-        } catch (EntityNotFoundException $e) {
231
-            $event = null;
232
-        }
233
-        $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
234
-        $this->_event_details = array(
235
-            'event'      => $event,
236
-            'status'     => $status,
237
-            'id'         => $event instanceof EE_Event ? $event->ID() : 0,
238
-            'title_attr' => sprintf(
239
-                __('Edit Event (%s)', 'event_espresso'),
240
-                EEH_Template::pretty_status($status, false, 'sentence')
241
-            ),
242
-        );
243
-    }
204
+	/**
205
+	 * Set the $_transaction_details property if not set yet.
206
+	 *
207
+	 * @param EE_Registration $registration
208
+	 * @throws EE_Error
209
+	 * @throws InvalidArgumentException
210
+	 * @throws ReflectionException
211
+	 * @throws InvalidDataTypeException
212
+	 * @throws InvalidInterfaceException
213
+	 */
214
+	protected function _set_related_details(EE_Registration $registration)
215
+	{
216
+		$transaction = $registration->get_first_related('Transaction');
217
+		$status = $transaction instanceof EE_Transaction ? $transaction->status_ID()
218
+			: EEM_Transaction::failed_status_code;
219
+		$this->_transaction_details = array(
220
+			'transaction' => $transaction,
221
+			'status'      => $status,
222
+			'id'          => $transaction instanceof EE_Transaction ? $transaction->ID() : 0,
223
+			'title_attr'  => sprintf(
224
+				__('View Transaction Details (%s)', 'event_espresso'),
225
+				EEH_Template::pretty_status($status, false, 'sentence')
226
+			),
227
+		);
228
+		try {
229
+			$event = $registration->event();
230
+		} catch (EntityNotFoundException $e) {
231
+			$event = null;
232
+		}
233
+		$status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive;
234
+		$this->_event_details = array(
235
+			'event'      => $event,
236
+			'status'     => $status,
237
+			'id'         => $event instanceof EE_Event ? $event->ID() : 0,
238
+			'title_attr' => sprintf(
239
+				__('Edit Event (%s)', 'event_espresso'),
240
+				EEH_Template::pretty_status($status, false, 'sentence')
241
+			),
242
+		);
243
+	}
244 244
 
245 245
 
246
-    /**
247
-     *    _get_table_filters
248
-     *
249
-     * @access protected
250
-     * @return array
251
-     */
252
-    protected function _get_table_filters()
253
-    {
254
-        $filters = array();
255
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
256
-        // methods.
257
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
258
-        $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
259
-        $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
260
-        $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
261
-        $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
262
-        $status = array();
263
-        $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
264
-        foreach ($this->_status as $key => $value) {
265
-            $status[] = array('id' => $key, 'text' => $value);
266
-        }
267
-        if ($this->_view !== 'incomplete') {
268
-            $filters[] = EEH_Form_Fields::select_input(
269
-                '_reg_status',
270
-                $status,
271
-                isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
272
-                    : ''
273
-            );
274
-        }
275
-        if (isset($this->_req_data['event_id'])) {
276
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
277
-        }
278
-        return $filters;
279
-    }
246
+	/**
247
+	 *    _get_table_filters
248
+	 *
249
+	 * @access protected
250
+	 * @return array
251
+	 */
252
+	protected function _get_table_filters()
253
+	{
254
+		$filters = array();
255
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
256
+		// methods.
257
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
258
+		$cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
259
+		$reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : '';
260
+		$filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
261
+		$filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
262
+		$status = array();
263
+		$status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso'));
264
+		foreach ($this->_status as $key => $value) {
265
+			$status[] = array('id' => $key, 'text' => $value);
266
+		}
267
+		if ($this->_view !== 'incomplete') {
268
+			$filters[] = EEH_Form_Fields::select_input(
269
+				'_reg_status',
270
+				$status,
271
+				isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
272
+					: ''
273
+			);
274
+		}
275
+		if (isset($this->_req_data['event_id'])) {
276
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
277
+		}
278
+		return $filters;
279
+	}
280 280
 
281 281
 
282
-    /**
283
-     *    _add_view_counts
284
-     *
285
-     * @access protected
286
-     * @return void
287
-     * @throws EE_Error
288
-     * @throws InvalidArgumentException
289
-     * @throws InvalidDataTypeException
290
-     * @throws InvalidInterfaceException
291
-     */
292
-    protected function _add_view_counts()
293
-    {
294
-        $this->_views['all']['count'] = $this->_total_registrations();
295
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
296
-        $this->_views['today']['count'] = $this->_total_registrations_today();
297
-        if (EE_Registry::instance()->CAP->current_user_can(
298
-            'ee_delete_registrations',
299
-            'espresso_registrations_trash_registrations'
300
-        )) {
301
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
302
-            $this->_views['trash']['count'] = $this->_total_registrations('trash');
303
-        }
304
-    }
282
+	/**
283
+	 *    _add_view_counts
284
+	 *
285
+	 * @access protected
286
+	 * @return void
287
+	 * @throws EE_Error
288
+	 * @throws InvalidArgumentException
289
+	 * @throws InvalidDataTypeException
290
+	 * @throws InvalidInterfaceException
291
+	 */
292
+	protected function _add_view_counts()
293
+	{
294
+		$this->_views['all']['count'] = $this->_total_registrations();
295
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
296
+		$this->_views['today']['count'] = $this->_total_registrations_today();
297
+		if (EE_Registry::instance()->CAP->current_user_can(
298
+			'ee_delete_registrations',
299
+			'espresso_registrations_trash_registrations'
300
+		)) {
301
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
302
+			$this->_views['trash']['count'] = $this->_total_registrations('trash');
303
+		}
304
+	}
305 305
 
306 306
 
307
-    /**
308
-     * _total_registrations
309
-     *
310
-     * @access protected
311
-     * @param string $view
312
-     * @return int
313
-     * @throws EE_Error
314
-     * @throws InvalidArgumentException
315
-     * @throws InvalidDataTypeException
316
-     * @throws InvalidInterfaceException
317
-     */
318
-    protected function _total_registrations($view = '')
319
-    {
320
-        $_where = array();
321
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
322
-        if ($EVT_ID) {
323
-            $_where['EVT_ID'] = $EVT_ID;
324
-        }
325
-        switch ($view) {
326
-            case 'trash':
327
-                return EEM_Registration::instance()->count_deleted(array($_where));
328
-                break;
329
-            case 'incomplete':
330
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
331
-                break;
332
-            default:
333
-                $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
334
-        }
335
-        return EEM_Registration::instance()->count(array($_where));
336
-    }
307
+	/**
308
+	 * _total_registrations
309
+	 *
310
+	 * @access protected
311
+	 * @param string $view
312
+	 * @return int
313
+	 * @throws EE_Error
314
+	 * @throws InvalidArgumentException
315
+	 * @throws InvalidDataTypeException
316
+	 * @throws InvalidInterfaceException
317
+	 */
318
+	protected function _total_registrations($view = '')
319
+	{
320
+		$_where = array();
321
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
322
+		if ($EVT_ID) {
323
+			$_where['EVT_ID'] = $EVT_ID;
324
+		}
325
+		switch ($view) {
326
+			case 'trash':
327
+				return EEM_Registration::instance()->count_deleted(array($_where));
328
+				break;
329
+			case 'incomplete':
330
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
331
+				break;
332
+			default:
333
+				$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
334
+		}
335
+		return EEM_Registration::instance()->count(array($_where));
336
+	}
337 337
 
338 338
 
339
-    /**
340
-     * _total_registrations_this_month
341
-     *
342
-     * @access protected
343
-     * @return int
344
-     * @throws EE_Error
345
-     * @throws InvalidArgumentException
346
-     * @throws InvalidDataTypeException
347
-     * @throws InvalidInterfaceException
348
-     */
349
-    protected function _total_registrations_this_month()
350
-    {
351
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
352
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
353
-        $this_year_r = date('Y', current_time('timestamp'));
354
-        $time_start = ' 00:00:00';
355
-        $time_end = ' 23:59:59';
356
-        $this_month_r = date('m', current_time('timestamp'));
357
-        $days_this_month = date('t', current_time('timestamp'));
358
-        // setup date query.
359
-        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
360
-            'REG_date',
361
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
362
-            'Y-m-d H:i:s'
363
-        );
364
-        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
365
-            'REG_date',
366
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
367
-            'Y-m-d H:i:s'
368
-        );
369
-        $_where['REG_date'] = array(
370
-            'BETWEEN',
371
-            array(
372
-                $beginning_string,
373
-                $end_string,
374
-            ),
375
-        );
376
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
377
-        return EEM_Registration::instance()->count(array($_where));
378
-    }
339
+	/**
340
+	 * _total_registrations_this_month
341
+	 *
342
+	 * @access protected
343
+	 * @return int
344
+	 * @throws EE_Error
345
+	 * @throws InvalidArgumentException
346
+	 * @throws InvalidDataTypeException
347
+	 * @throws InvalidInterfaceException
348
+	 */
349
+	protected function _total_registrations_this_month()
350
+	{
351
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
352
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
353
+		$this_year_r = date('Y', current_time('timestamp'));
354
+		$time_start = ' 00:00:00';
355
+		$time_end = ' 23:59:59';
356
+		$this_month_r = date('m', current_time('timestamp'));
357
+		$days_this_month = date('t', current_time('timestamp'));
358
+		// setup date query.
359
+		$beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
360
+			'REG_date',
361
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
362
+			'Y-m-d H:i:s'
363
+		);
364
+		$end_string = EEM_Registration::instance()->convert_datetime_for_query(
365
+			'REG_date',
366
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
367
+			'Y-m-d H:i:s'
368
+		);
369
+		$_where['REG_date'] = array(
370
+			'BETWEEN',
371
+			array(
372
+				$beginning_string,
373
+				$end_string,
374
+			),
375
+		);
376
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
377
+		return EEM_Registration::instance()->count(array($_where));
378
+	}
379 379
 
380 380
 
381
-    /**
382
-     * _total_registrations_today
383
-     *
384
-     * @access protected
385
-     * @return int
386
-     * @throws EE_Error
387
-     * @throws InvalidArgumentException
388
-     * @throws InvalidDataTypeException
389
-     * @throws InvalidInterfaceException
390
-     */
391
-    protected function _total_registrations_today()
392
-    {
393
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
394
-        $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
395
-        $current_date = date('Y-m-d', current_time('timestamp'));
396
-        $time_start = ' 00:00:00';
397
-        $time_end = ' 23:59:59';
398
-        $_where['REG_date'] = array(
399
-            'BETWEEN',
400
-            array(
401
-                EEM_Registration::instance()->convert_datetime_for_query(
402
-                    'REG_date',
403
-                    $current_date . $time_start,
404
-                    'Y-m-d H:i:s'
405
-                ),
406
-                EEM_Registration::instance()->convert_datetime_for_query(
407
-                    'REG_date',
408
-                    $current_date . $time_end,
409
-                    'Y-m-d H:i:s'
410
-                ),
411
-            ),
412
-        );
413
-        $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
414
-        return EEM_Registration::instance()->count(array($_where));
415
-    }
381
+	/**
382
+	 * _total_registrations_today
383
+	 *
384
+	 * @access protected
385
+	 * @return int
386
+	 * @throws EE_Error
387
+	 * @throws InvalidArgumentException
388
+	 * @throws InvalidDataTypeException
389
+	 * @throws InvalidInterfaceException
390
+	 */
391
+	protected function _total_registrations_today()
392
+	{
393
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
394
+		$_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array();
395
+		$current_date = date('Y-m-d', current_time('timestamp'));
396
+		$time_start = ' 00:00:00';
397
+		$time_end = ' 23:59:59';
398
+		$_where['REG_date'] = array(
399
+			'BETWEEN',
400
+			array(
401
+				EEM_Registration::instance()->convert_datetime_for_query(
402
+					'REG_date',
403
+					$current_date . $time_start,
404
+					'Y-m-d H:i:s'
405
+				),
406
+				EEM_Registration::instance()->convert_datetime_for_query(
407
+					'REG_date',
408
+					$current_date . $time_end,
409
+					'Y-m-d H:i:s'
410
+				),
411
+			),
412
+		);
413
+		$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
414
+		return EEM_Registration::instance()->count(array($_where));
415
+	}
416 416
 
417 417
 
418
-    /**
419
-     * column_cb
420
-     *
421
-     * @access public
422
-     * @param \EE_Registration $item
423
-     * @return string
424
-     * @throws EE_Error
425
-     * @throws InvalidArgumentException
426
-     * @throws InvalidDataTypeException
427
-     * @throws InvalidInterfaceException
428
-     * @throws ReflectionException
429
-     */
430
-    public function column_cb($item)
431
-    {
432
-        /** checkbox/lock **/
433
-        $transaction = $item->get_first_related('Transaction');
434
-        $payment_count = $transaction instanceof EE_Transaction
435
-            ? $transaction->count_related('Payment')
436
-            : 0;
437
-        return $payment_count > 0
438
-               || ! EE_Registry::instance()->CAP->current_user_can(
439
-                   'ee_edit_registration',
440
-                   'registration_list_table_checkbox_input',
441
-                   $item->ID()
442
-               )
443
-            ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
444
-              . '<span class="ee-lock-icon"></span>'
445
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
446
-    }
418
+	/**
419
+	 * column_cb
420
+	 *
421
+	 * @access public
422
+	 * @param \EE_Registration $item
423
+	 * @return string
424
+	 * @throws EE_Error
425
+	 * @throws InvalidArgumentException
426
+	 * @throws InvalidDataTypeException
427
+	 * @throws InvalidInterfaceException
428
+	 * @throws ReflectionException
429
+	 */
430
+	public function column_cb($item)
431
+	{
432
+		/** checkbox/lock **/
433
+		$transaction = $item->get_first_related('Transaction');
434
+		$payment_count = $transaction instanceof EE_Transaction
435
+			? $transaction->count_related('Payment')
436
+			: 0;
437
+		return $payment_count > 0
438
+			   || ! EE_Registry::instance()->CAP->current_user_can(
439
+				   'ee_edit_registration',
440
+				   'registration_list_table_checkbox_input',
441
+				   $item->ID()
442
+			   )
443
+			? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
444
+			  . '<span class="ee-lock-icon"></span>'
445
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
446
+	}
447 447
 
448 448
 
449
-    /**
450
-     * column__REG_ID
451
-     *
452
-     * @access public
453
-     * @param \EE_Registration $item
454
-     * @return string
455
-     * @throws EE_Error
456
-     * @throws InvalidArgumentException
457
-     * @throws InvalidDataTypeException
458
-     * @throws InvalidInterfaceException
459
-     * @throws ReflectionException
460
-     */
461
-    public function column__REG_ID(EE_Registration $item)
462
-    {
463
-        $attendee = $item->attendee();
464
-        $content = $item->ID();
465
-        $content .= '<div class="show-on-mobile-view-only">';
466
-        $content .= '<br>';
467
-        $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
468
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
469
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
470
-        $content .= '</div>';
471
-        return $content;
472
-    }
449
+	/**
450
+	 * column__REG_ID
451
+	 *
452
+	 * @access public
453
+	 * @param \EE_Registration $item
454
+	 * @return string
455
+	 * @throws EE_Error
456
+	 * @throws InvalidArgumentException
457
+	 * @throws InvalidDataTypeException
458
+	 * @throws InvalidInterfaceException
459
+	 * @throws ReflectionException
460
+	 */
461
+	public function column__REG_ID(EE_Registration $item)
462
+	{
463
+		$attendee = $item->attendee();
464
+		$content = $item->ID();
465
+		$content .= '<div class="show-on-mobile-view-only">';
466
+		$content .= '<br>';
467
+		$content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
468
+		$content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
469
+		$content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
470
+		$content .= '</div>';
471
+		return $content;
472
+	}
473 473
 
474 474
 
475
-    /**
476
-     * column__REG_date
477
-     *
478
-     * @access public
479
-     * @param \EE_Registration $item
480
-     * @return string
481
-     * @throws EE_Error
482
-     * @throws InvalidArgumentException
483
-     * @throws InvalidDataTypeException
484
-     * @throws InvalidInterfaceException
485
-     * @throws ReflectionException
486
-     */
487
-    public function column__REG_date(EE_Registration $item)
488
-    {
489
-        $this->_set_related_details($item);
490
-        // Build row actions
491
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
492
-            array(
493
-                'action' => 'view_transaction',
494
-                'TXN_ID' => $this->_transaction_details['id'],
495
-            ),
496
-            TXN_ADMIN_URL
497
-        );
498
-        $view_link = EE_Registry::instance()->CAP->current_user_can(
499
-            'ee_read_transaction',
500
-            'espresso_transactions_view_transaction'
501
-        )
502
-            ? '<a class="ee-status-color-'
503
-              . $this->_transaction_details['status']
504
-              . '" href="'
505
-              . $view_lnk_url
506
-              . '" title="'
507
-              . esc_attr($this->_transaction_details['title_attr'])
508
-              . '">'
509
-              . $item->get_i18n_datetime('REG_date')
510
-              . '</a>' : $item->get_i18n_datetime('REG_date');
511
-        $view_link .= '<br><span class="ee-status-text-small">'
512
-                      . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
513
-                      . '</span>';
514
-        return $view_link;
515
-    }
475
+	/**
476
+	 * column__REG_date
477
+	 *
478
+	 * @access public
479
+	 * @param \EE_Registration $item
480
+	 * @return string
481
+	 * @throws EE_Error
482
+	 * @throws InvalidArgumentException
483
+	 * @throws InvalidDataTypeException
484
+	 * @throws InvalidInterfaceException
485
+	 * @throws ReflectionException
486
+	 */
487
+	public function column__REG_date(EE_Registration $item)
488
+	{
489
+		$this->_set_related_details($item);
490
+		// Build row actions
491
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
492
+			array(
493
+				'action' => 'view_transaction',
494
+				'TXN_ID' => $this->_transaction_details['id'],
495
+			),
496
+			TXN_ADMIN_URL
497
+		);
498
+		$view_link = EE_Registry::instance()->CAP->current_user_can(
499
+			'ee_read_transaction',
500
+			'espresso_transactions_view_transaction'
501
+		)
502
+			? '<a class="ee-status-color-'
503
+			  . $this->_transaction_details['status']
504
+			  . '" href="'
505
+			  . $view_lnk_url
506
+			  . '" title="'
507
+			  . esc_attr($this->_transaction_details['title_attr'])
508
+			  . '">'
509
+			  . $item->get_i18n_datetime('REG_date')
510
+			  . '</a>' : $item->get_i18n_datetime('REG_date');
511
+		$view_link .= '<br><span class="ee-status-text-small">'
512
+					  . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
513
+					  . '</span>';
514
+		return $view_link;
515
+	}
516 516
 
517 517
 
518
-    /**
519
-     * column_event_name
520
-     *
521
-     * @access public
522
-     * @param \EE_Registration $item
523
-     * @return string
524
-     * @throws EE_Error
525
-     * @throws InvalidArgumentException
526
-     * @throws InvalidDataTypeException
527
-     * @throws InvalidInterfaceException
528
-     * @throws ReflectionException
529
-     */
530
-    public function column_event_name(EE_Registration $item)
531
-    {
532
-        $this->_set_related_details($item);
533
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
534
-        $EVT_ID = $item->event_ID();
535
-        $event_name = $item->event_name();
536
-        $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
537
-        $event_name = wp_trim_words($event_name, 30, '...');
538
-        if ($EVT_ID) {
539
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
540
-                array('action' => 'edit', 'post' => $EVT_ID),
541
-                EVENTS_ADMIN_URL
542
-            );
543
-            $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
544
-                ? '<a class="ee-status-color-'
545
-                  . $this->_event_details['status']
546
-                  . '" href="'
547
-                  . $edit_event_url
548
-                  . '" title="'
549
-                  . esc_attr($this->_event_details['title_attr'])
550
-                  . '">'
551
-                  . $event_name
552
-                  . '</a>' : $event_name;
553
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
554
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
555
-            $actions['event_filter'] .= sprintf(
556
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
557
-                $event_name
558
-            );
559
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
560
-        } else {
561
-            $edit_event = $event_name;
562
-            $actions['event_filter'] = '';
563
-        }
564
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
565
-    }
518
+	/**
519
+	 * column_event_name
520
+	 *
521
+	 * @access public
522
+	 * @param \EE_Registration $item
523
+	 * @return string
524
+	 * @throws EE_Error
525
+	 * @throws InvalidArgumentException
526
+	 * @throws InvalidDataTypeException
527
+	 * @throws InvalidInterfaceException
528
+	 * @throws ReflectionException
529
+	 */
530
+	public function column_event_name(EE_Registration $item)
531
+	{
532
+		$this->_set_related_details($item);
533
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
534
+		$EVT_ID = $item->event_ID();
535
+		$event_name = $item->event_name();
536
+		$event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso');
537
+		$event_name = wp_trim_words($event_name, 30, '...');
538
+		if ($EVT_ID) {
539
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
540
+				array('action' => 'edit', 'post' => $EVT_ID),
541
+				EVENTS_ADMIN_URL
542
+			);
543
+			$edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
544
+				? '<a class="ee-status-color-'
545
+				  . $this->_event_details['status']
546
+				  . '" href="'
547
+				  . $edit_event_url
548
+				  . '" title="'
549
+				  . esc_attr($this->_event_details['title_attr'])
550
+				  . '">'
551
+				  . $event_name
552
+				  . '</a>' : $event_name;
553
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
554
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
555
+			$actions['event_filter'] .= sprintf(
556
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
557
+				$event_name
558
+			);
559
+			$actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
560
+		} else {
561
+			$edit_event = $event_name;
562
+			$actions['event_filter'] = '';
563
+		}
564
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
565
+	}
566 566
 
567 567
 
568
-    /**
569
-     * column_DTT_EVT_start
570
-     *
571
-     * @access public
572
-     * @param \EE_Registration $item
573
-     * @return string
574
-     * @throws EE_Error
575
-     * @throws InvalidArgumentException
576
-     * @throws InvalidDataTypeException
577
-     * @throws InvalidInterfaceException
578
-     * @throws ReflectionException
579
-     */
580
-    public function column_DTT_EVT_start(EE_Registration $item)
581
-    {
582
-        $datetime_strings = array();
583
-        $ticket = $item->ticket(true);
584
-        if ($ticket instanceof EE_Ticket) {
585
-            $remove_defaults = array('default_where_conditions' => 'none');
586
-            $datetimes = $ticket->datetimes($remove_defaults);
587
-            foreach ($datetimes as $datetime) {
588
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
589
-            }
590
-            return $this->generateDisplayForDatetimes($datetime_strings);
591
-        }
592
-        return __('There is no ticket on this registration', 'event_espresso');
593
-    }
568
+	/**
569
+	 * column_DTT_EVT_start
570
+	 *
571
+	 * @access public
572
+	 * @param \EE_Registration $item
573
+	 * @return string
574
+	 * @throws EE_Error
575
+	 * @throws InvalidArgumentException
576
+	 * @throws InvalidDataTypeException
577
+	 * @throws InvalidInterfaceException
578
+	 * @throws ReflectionException
579
+	 */
580
+	public function column_DTT_EVT_start(EE_Registration $item)
581
+	{
582
+		$datetime_strings = array();
583
+		$ticket = $item->ticket(true);
584
+		if ($ticket instanceof EE_Ticket) {
585
+			$remove_defaults = array('default_where_conditions' => 'none');
586
+			$datetimes = $ticket->datetimes($remove_defaults);
587
+			foreach ($datetimes as $datetime) {
588
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
589
+			}
590
+			return $this->generateDisplayForDatetimes($datetime_strings);
591
+		}
592
+		return __('There is no ticket on this registration', 'event_espresso');
593
+	}
594 594
 
595 595
 
596
-    /**
597
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
598
-     *
599
-     * @param array $datetime_strings
600
-     * @return string
601
-     */
602
-    public function generateDisplayForDateTimes(array $datetime_strings)
603
-    {
604
-        $content = '<div class="ee-registration-event-datetimes-container">';
605
-        $expand_toggle = count($datetime_strings) > 1
606
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
607
-              . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
608
-            : '';
609
-        // get first item for initial visibility
610
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
611
-        $content .= $expand_toggle;
612
-        if ($datetime_strings) {
613
-            $content .= '<div style="clear:both"></div>';
614
-            $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
615
-            $content .= implode("<br />", $datetime_strings);
616
-            $content .= '</div>';
617
-        }
618
-        $content .= '</div>';
619
-        return $content;
620
-    }
596
+	/**
597
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
598
+	 *
599
+	 * @param array $datetime_strings
600
+	 * @return string
601
+	 */
602
+	public function generateDisplayForDateTimes(array $datetime_strings)
603
+	{
604
+		$content = '<div class="ee-registration-event-datetimes-container">';
605
+		$expand_toggle = count($datetime_strings) > 1
606
+			? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
607
+			  . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
608
+			: '';
609
+		// get first item for initial visibility
610
+		$content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
611
+		$content .= $expand_toggle;
612
+		if ($datetime_strings) {
613
+			$content .= '<div style="clear:both"></div>';
614
+			$content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
615
+			$content .= implode("<br />", $datetime_strings);
616
+			$content .= '</div>';
617
+		}
618
+		$content .= '</div>';
619
+		return $content;
620
+	}
621 621
 
622 622
 
623
-    /**
624
-     * column_ATT_fname
625
-     *
626
-     * @access public
627
-     * @param \EE_Registration $item
628
-     * @return string
629
-     * @throws EE_Error
630
-     * @throws InvalidArgumentException
631
-     * @throws InvalidDataTypeException
632
-     * @throws InvalidInterfaceException
633
-     * @throws ReflectionException
634
-     */
635
-    public function column_ATT_fname(EE_Registration $item)
636
-    {
637
-        $attendee = $item->attendee();
638
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
639
-            array(
640
-                'action'  => 'view_registration',
641
-                '_REG_ID' => $item->ID(),
642
-            ),
643
-            REG_ADMIN_URL
644
-        );
645
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
646
-        $link = EE_Registry::instance()->CAP->current_user_can(
647
-            'ee_read_registration',
648
-            'espresso_registrations_view_registration',
649
-            $item->ID()
650
-        )
651
-            ? '<a href="'
652
-              . $edit_lnk_url
653
-              . '" title="'
654
-              . esc_attr__('View Registration Details', 'event_espresso')
655
-              . '">'
656
-              . $attendee_name
657
-              . '</a>' : $attendee_name;
658
-        $link .= $item->count() === 1
659
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
660
-        $t = $item->get_first_related('Transaction');
661
-        $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
662
-        // append group count to name
663
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
664
-        // append reg_code
665
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
666
-        // reg status text for accessibility
667
-        $link .= '<br><span class="ee-status-text-small">'
668
-                 . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
669
-                 . '</span>';
670
-        // trash/restore/delete actions
671
-        $actions = array();
672
-        if ($this->_view !== 'trash'
673
-            && $payment_count === 0
674
-            && EE_Registry::instance()->CAP->current_user_can(
675
-                'ee_delete_registration',
676
-                'espresso_registrations_trash_registrations',
677
-                $item->ID()
678
-            )) {
679
-            $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
680
-                array(
681
-                    'action'  => 'trash_registrations',
682
-                    '_REG_ID' => $item->ID(),
683
-                ),
684
-                REG_ADMIN_URL
685
-            );
686
-            $actions['trash'] = '<a href="'
687
-                                . $trash_lnk_url
688
-                                . '" title="'
689
-                                . esc_attr__('Trash Registration', 'event_espresso')
690
-                                . '">' . __('Trash', 'event_espresso') . '</a>';
691
-        } elseif ($this->_view === 'trash') {
692
-            // restore registration link
693
-            if (EE_Registry::instance()->CAP->current_user_can(
694
-                'ee_delete_registration',
695
-                'espresso_registrations_restore_registrations',
696
-                $item->ID()
697
-            )) {
698
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
699
-                    array(
700
-                        'action'  => 'restore_registrations',
701
-                        '_REG_ID' => $item->ID(),
702
-                    ),
703
-                    REG_ADMIN_URL
704
-                );
705
-                $actions['restore'] = '<a href="'
706
-                                      . $restore_lnk_url
707
-                                      . '" title="'
708
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
709
-                                      . __('Restore', 'event_espresso') . '</a>';
710
-            }
711
-            if (EE_Registry::instance()->CAP->current_user_can(
712
-                'ee_delete_registration',
713
-                'espresso_registrations_ee_delete_registrations',
714
-                $item->ID()
715
-            )) {
716
-                $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
717
-                    array(
718
-                        'action'  => 'delete_registrations',
719
-                        '_REG_ID' => $item->ID(),
720
-                    ),
721
-                    REG_ADMIN_URL
722
-                );
723
-                $actions['delete'] = '<a href="'
724
-                                     . $delete_lnk_url
725
-                                     . '" title="'
726
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
727
-                                     . '">'
728
-                                     . __('Delete', 'event_espresso')
729
-                                     . '</a>';
730
-            }
731
-        }
732
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
733
-    }
623
+	/**
624
+	 * column_ATT_fname
625
+	 *
626
+	 * @access public
627
+	 * @param \EE_Registration $item
628
+	 * @return string
629
+	 * @throws EE_Error
630
+	 * @throws InvalidArgumentException
631
+	 * @throws InvalidDataTypeException
632
+	 * @throws InvalidInterfaceException
633
+	 * @throws ReflectionException
634
+	 */
635
+	public function column_ATT_fname(EE_Registration $item)
636
+	{
637
+		$attendee = $item->attendee();
638
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
639
+			array(
640
+				'action'  => 'view_registration',
641
+				'_REG_ID' => $item->ID(),
642
+			),
643
+			REG_ADMIN_URL
644
+		);
645
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
646
+		$link = EE_Registry::instance()->CAP->current_user_can(
647
+			'ee_read_registration',
648
+			'espresso_registrations_view_registration',
649
+			$item->ID()
650
+		)
651
+			? '<a href="'
652
+			  . $edit_lnk_url
653
+			  . '" title="'
654
+			  . esc_attr__('View Registration Details', 'event_espresso')
655
+			  . '">'
656
+			  . $attendee_name
657
+			  . '</a>' : $attendee_name;
658
+		$link .= $item->count() === 1
659
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : '';
660
+		$t = $item->get_first_related('Transaction');
661
+		$payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
662
+		// append group count to name
663
+		$link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
664
+		// append reg_code
665
+		$link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
666
+		// reg status text for accessibility
667
+		$link .= '<br><span class="ee-status-text-small">'
668
+				 . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
669
+				 . '</span>';
670
+		// trash/restore/delete actions
671
+		$actions = array();
672
+		if ($this->_view !== 'trash'
673
+			&& $payment_count === 0
674
+			&& EE_Registry::instance()->CAP->current_user_can(
675
+				'ee_delete_registration',
676
+				'espresso_registrations_trash_registrations',
677
+				$item->ID()
678
+			)) {
679
+			$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
680
+				array(
681
+					'action'  => 'trash_registrations',
682
+					'_REG_ID' => $item->ID(),
683
+				),
684
+				REG_ADMIN_URL
685
+			);
686
+			$actions['trash'] = '<a href="'
687
+								. $trash_lnk_url
688
+								. '" title="'
689
+								. esc_attr__('Trash Registration', 'event_espresso')
690
+								. '">' . __('Trash', 'event_espresso') . '</a>';
691
+		} elseif ($this->_view === 'trash') {
692
+			// restore registration link
693
+			if (EE_Registry::instance()->CAP->current_user_can(
694
+				'ee_delete_registration',
695
+				'espresso_registrations_restore_registrations',
696
+				$item->ID()
697
+			)) {
698
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
699
+					array(
700
+						'action'  => 'restore_registrations',
701
+						'_REG_ID' => $item->ID(),
702
+					),
703
+					REG_ADMIN_URL
704
+				);
705
+				$actions['restore'] = '<a href="'
706
+									  . $restore_lnk_url
707
+									  . '" title="'
708
+									  . esc_attr__('Restore Registration', 'event_espresso') . '">'
709
+									  . __('Restore', 'event_espresso') . '</a>';
710
+			}
711
+			if (EE_Registry::instance()->CAP->current_user_can(
712
+				'ee_delete_registration',
713
+				'espresso_registrations_ee_delete_registrations',
714
+				$item->ID()
715
+			)) {
716
+				$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
717
+					array(
718
+						'action'  => 'delete_registrations',
719
+						'_REG_ID' => $item->ID(),
720
+					),
721
+					REG_ADMIN_URL
722
+				);
723
+				$actions['delete'] = '<a href="'
724
+									 . $delete_lnk_url
725
+									 . '" title="'
726
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
727
+									 . '">'
728
+									 . __('Delete', 'event_espresso')
729
+									 . '</a>';
730
+			}
731
+		}
732
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
733
+	}
734 734
 
735 735
 
736
-    /**
737
-     * column_ATT_email
738
-     *
739
-     * @access public
740
-     * @param \EE_Registration $item
741
-     * @return string
742
-     * @throws EE_Error
743
-     * @throws InvalidArgumentException
744
-     * @throws InvalidDataTypeException
745
-     * @throws InvalidInterfaceException
746
-     * @throws ReflectionException
747
-     */
748
-    public function column_ATT_email(EE_Registration $item)
749
-    {
750
-        $attendee = $item->get_first_related('Attendee');
751
-        return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
752
-            : $attendee->email();
753
-    }
736
+	/**
737
+	 * column_ATT_email
738
+	 *
739
+	 * @access public
740
+	 * @param \EE_Registration $item
741
+	 * @return string
742
+	 * @throws EE_Error
743
+	 * @throws InvalidArgumentException
744
+	 * @throws InvalidDataTypeException
745
+	 * @throws InvalidInterfaceException
746
+	 * @throws ReflectionException
747
+	 */
748
+	public function column_ATT_email(EE_Registration $item)
749
+	{
750
+		$attendee = $item->get_first_related('Attendee');
751
+		return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso')
752
+			: $attendee->email();
753
+	}
754 754
 
755 755
 
756
-    /**
757
-     * column__REG_count
758
-     *
759
-     * @access public
760
-     * @param \EE_Registration $item
761
-     * @return string
762
-     */
763
-    public function column__REG_count(EE_Registration $item)
764
-    {
765
-        return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
766
-    }
756
+	/**
757
+	 * column__REG_count
758
+	 *
759
+	 * @access public
760
+	 * @param \EE_Registration $item
761
+	 * @return string
762
+	 */
763
+	public function column__REG_count(EE_Registration $item)
764
+	{
765
+		return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
766
+	}
767 767
 
768 768
 
769
-    /**
770
-     * column_PRC_amount
771
-     *
772
-     * @access public
773
-     * @param \EE_Registration $item
774
-     * @return string
775
-     * @throws EE_Error
776
-     */
777
-    public function column_PRC_amount(EE_Registration $item)
778
-    {
779
-        $ticket = $item->ticket();
780
-        $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
781
-                                                                              . $ticket->name()
782
-                                                                              . '</span><br />' : '';
783
-        if ($item->final_price() > 0) {
784
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
785
-        } else {
786
-            // free event
787
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
788
-                        . __('free', 'event_espresso')
789
-                        . '</span>';
790
-        }
791
-        return $content;
792
-    }
769
+	/**
770
+	 * column_PRC_amount
771
+	 *
772
+	 * @access public
773
+	 * @param \EE_Registration $item
774
+	 * @return string
775
+	 * @throws EE_Error
776
+	 */
777
+	public function column_PRC_amount(EE_Registration $item)
778
+	{
779
+		$ticket = $item->ticket();
780
+		$content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'
781
+																			  . $ticket->name()
782
+																			  . '</span><br />' : '';
783
+		if ($item->final_price() > 0) {
784
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
785
+		} else {
786
+			// free event
787
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
788
+						. __('free', 'event_espresso')
789
+						. '</span>';
790
+		}
791
+		return $content;
792
+	}
793 793
 
794 794
 
795
-    /**
796
-     * column__REG_final_price
797
-     *
798
-     * @access public
799
-     * @param \EE_Registration $item
800
-     * @return string
801
-     * @throws EE_Error
802
-     */
803
-    public function column__REG_final_price(EE_Registration $item)
804
-    {
805
-        $ticket = $item->ticket();
806
-        $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
807
-            ? ''
808
-            : '<span class="TKT_name">'
809
-              . $ticket->name()
810
-              . '</span><br />';
811
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
812
-        return $content;
813
-    }
795
+	/**
796
+	 * column__REG_final_price
797
+	 *
798
+	 * @access public
799
+	 * @param \EE_Registration $item
800
+	 * @return string
801
+	 * @throws EE_Error
802
+	 */
803
+	public function column__REG_final_price(EE_Registration $item)
804
+	{
805
+		$ticket = $item->ticket();
806
+		$content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket
807
+			? ''
808
+			: '<span class="TKT_name">'
809
+			  . $ticket->name()
810
+			  . '</span><br />';
811
+		$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
812
+		return $content;
813
+	}
814 814
 
815 815
 
816
-    /**
817
-     * column__REG_paid
818
-     *
819
-     * @access public
820
-     * @param \EE_Registration $item
821
-     * @return string
822
-     * @throws EE_Error
823
-     */
824
-    public function column__REG_paid(EE_Registration $item)
825
-    {
826
-        $payment_method = $item->payment_method();
827
-        $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
828
-            : __('Unknown', 'event_espresso');
829
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
830
-        if ($item->paid() > 0) {
831
-            $content .= '<br><span class="ee-status-text-small">'
832
-                        . sprintf(
833
-                            __('...via %s', 'event_espresso'),
834
-                            $payment_method_name
835
-                        )
836
-                        . '</span>';
837
-        }
838
-        return $content;
839
-    }
816
+	/**
817
+	 * column__REG_paid
818
+	 *
819
+	 * @access public
820
+	 * @param \EE_Registration $item
821
+	 * @return string
822
+	 * @throws EE_Error
823
+	 */
824
+	public function column__REG_paid(EE_Registration $item)
825
+	{
826
+		$payment_method = $item->payment_method();
827
+		$payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
828
+			: __('Unknown', 'event_espresso');
829
+		$content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
830
+		if ($item->paid() > 0) {
831
+			$content .= '<br><span class="ee-status-text-small">'
832
+						. sprintf(
833
+							__('...via %s', 'event_espresso'),
834
+							$payment_method_name
835
+						)
836
+						. '</span>';
837
+		}
838
+		return $content;
839
+	}
840 840
 
841 841
 
842
-    /**
843
-     * column_TXN_total
844
-     *
845
-     * @access public
846
-     * @param \EE_Registration $item
847
-     * @return string
848
-     * @throws EE_Error
849
-     * @throws EntityNotFoundException
850
-     * @throws InvalidArgumentException
851
-     * @throws InvalidDataTypeException
852
-     * @throws InvalidInterfaceException
853
-     */
854
-    public function column_TXN_total(EE_Registration $item)
855
-    {
856
-        if ($item->transaction()) {
857
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
858
-                array(
859
-                    'action' => 'view_transaction',
860
-                    'TXN_ID' => $item->transaction_ID(),
861
-                ),
862
-                TXN_ADMIN_URL
863
-            );
864
-            return EE_Registry::instance()->CAP->current_user_can(
865
-                'ee_read_transaction',
866
-                'espresso_transactions_view_transaction',
867
-                $item->transaction_ID()
868
-            )
869
-                ? '<span class="reg-pad-rght"><a class="status-'
870
-                  . $item->transaction()->status_ID()
871
-                  . '" href="'
872
-                  . $view_txn_lnk_url
873
-                  . '"  title="'
874
-                  . esc_attr__('View Transaction', 'event_espresso')
875
-                  . '">'
876
-                  . $item->transaction()->pretty_total()
877
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
878
-        } else {
879
-            return __("None", "event_espresso");
880
-        }
881
-    }
842
+	/**
843
+	 * column_TXN_total
844
+	 *
845
+	 * @access public
846
+	 * @param \EE_Registration $item
847
+	 * @return string
848
+	 * @throws EE_Error
849
+	 * @throws EntityNotFoundException
850
+	 * @throws InvalidArgumentException
851
+	 * @throws InvalidDataTypeException
852
+	 * @throws InvalidInterfaceException
853
+	 */
854
+	public function column_TXN_total(EE_Registration $item)
855
+	{
856
+		if ($item->transaction()) {
857
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
858
+				array(
859
+					'action' => 'view_transaction',
860
+					'TXN_ID' => $item->transaction_ID(),
861
+				),
862
+				TXN_ADMIN_URL
863
+			);
864
+			return EE_Registry::instance()->CAP->current_user_can(
865
+				'ee_read_transaction',
866
+				'espresso_transactions_view_transaction',
867
+				$item->transaction_ID()
868
+			)
869
+				? '<span class="reg-pad-rght"><a class="status-'
870
+				  . $item->transaction()->status_ID()
871
+				  . '" href="'
872
+				  . $view_txn_lnk_url
873
+				  . '"  title="'
874
+				  . esc_attr__('View Transaction', 'event_espresso')
875
+				  . '">'
876
+				  . $item->transaction()->pretty_total()
877
+				  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
878
+		} else {
879
+			return __("None", "event_espresso");
880
+		}
881
+	}
882 882
 
883 883
 
884
-    /**
885
-     * column_TXN_paid
886
-     *
887
-     * @access public
888
-     * @param \EE_Registration $item
889
-     * @return string
890
-     * @throws EE_Error
891
-     * @throws EntityNotFoundException
892
-     * @throws InvalidArgumentException
893
-     * @throws InvalidDataTypeException
894
-     * @throws InvalidInterfaceException
895
-     */
896
-    public function column_TXN_paid(EE_Registration $item)
897
-    {
898
-        if ($item->count() === 1) {
899
-            $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
900
-            if ($transaction->paid() >= $transaction->total()) {
901
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
902
-            } else {
903
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
904
-                    array(
905
-                        'action' => 'view_transaction',
906
-                        'TXN_ID' => $item->transaction_ID(),
907
-                    ),
908
-                    TXN_ADMIN_URL
909
-                );
910
-                return EE_Registry::instance()->CAP->current_user_can(
911
-                    'ee_read_transaction',
912
-                    'espresso_transactions_view_transaction',
913
-                    $item->transaction_ID()
914
-                )
915
-                    ? '<span class="reg-pad-rght"><a class="status-'
916
-                      . $transaction->status_ID()
917
-                      . '" href="'
918
-                      . $view_txn_lnk_url
919
-                      . '"  title="'
920
-                      . esc_attr__('View Transaction', 'event_espresso')
921
-                      . '">'
922
-                      . $item->transaction()->pretty_paid()
923
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
924
-            }
925
-        }
926
-        return '&nbsp;';
927
-    }
884
+	/**
885
+	 * column_TXN_paid
886
+	 *
887
+	 * @access public
888
+	 * @param \EE_Registration $item
889
+	 * @return string
890
+	 * @throws EE_Error
891
+	 * @throws EntityNotFoundException
892
+	 * @throws InvalidArgumentException
893
+	 * @throws InvalidDataTypeException
894
+	 * @throws InvalidInterfaceException
895
+	 */
896
+	public function column_TXN_paid(EE_Registration $item)
897
+	{
898
+		if ($item->count() === 1) {
899
+			$transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance();
900
+			if ($transaction->paid() >= $transaction->total()) {
901
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
902
+			} else {
903
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
904
+					array(
905
+						'action' => 'view_transaction',
906
+						'TXN_ID' => $item->transaction_ID(),
907
+					),
908
+					TXN_ADMIN_URL
909
+				);
910
+				return EE_Registry::instance()->CAP->current_user_can(
911
+					'ee_read_transaction',
912
+					'espresso_transactions_view_transaction',
913
+					$item->transaction_ID()
914
+				)
915
+					? '<span class="reg-pad-rght"><a class="status-'
916
+					  . $transaction->status_ID()
917
+					  . '" href="'
918
+					  . $view_txn_lnk_url
919
+					  . '"  title="'
920
+					  . esc_attr__('View Transaction', 'event_espresso')
921
+					  . '">'
922
+					  . $item->transaction()->pretty_paid()
923
+					  . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
924
+			}
925
+		}
926
+		return '&nbsp;';
927
+	}
928 928
 
929 929
 
930
-    /**
931
-     * column_actions
932
-     *
933
-     * @access public
934
-     * @param \EE_Registration $item
935
-     * @return string
936
-     * @throws EE_Error
937
-     * @throws InvalidArgumentException
938
-     * @throws InvalidDataTypeException
939
-     * @throws InvalidInterfaceException
940
-     * @throws ReflectionException
941
-     */
942
-    public function column_actions(EE_Registration $item)
943
-    {
944
-        $actions = array();
945
-        $attendee = $item->attendee();
946
-        $this->_set_related_details($item);
947
-        // Build row actions
948
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
949
-            array(
950
-                'action'  => 'view_registration',
951
-                '_REG_ID' => $item->ID(),
952
-            ),
953
-            REG_ADMIN_URL
954
-        );
955
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
956
-            array(
957
-                'action' => 'edit_attendee',
958
-                'post'   => $item->attendee_ID(),
959
-            ),
960
-            REG_ADMIN_URL
961
-        );
962
-        // page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
963
-        // $resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
964
-        $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
965
-            array(
966
-                'action'  => 'resend_registration',
967
-                '_REG_ID' => $item->ID(),
968
-            ),
969
-            REG_ADMIN_URL,
970
-            true
971
-        );
972
-        // Build row actions
973
-        $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can(
974
-            'ee_read_registration',
975
-            'espresso_registrations_view_registration',
976
-            $item->ID()
977
-        ) ? '<li><a href="'
978
-            . $view_lnk_url
979
-            . '" title="'
980
-            . esc_attr__('View Registration Details', 'event_espresso')
981
-            . '" class="tiny-text">
930
+	/**
931
+	 * column_actions
932
+	 *
933
+	 * @access public
934
+	 * @param \EE_Registration $item
935
+	 * @return string
936
+	 * @throws EE_Error
937
+	 * @throws InvalidArgumentException
938
+	 * @throws InvalidDataTypeException
939
+	 * @throws InvalidInterfaceException
940
+	 * @throws ReflectionException
941
+	 */
942
+	public function column_actions(EE_Registration $item)
943
+	{
944
+		$actions = array();
945
+		$attendee = $item->attendee();
946
+		$this->_set_related_details($item);
947
+		// Build row actions
948
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
949
+			array(
950
+				'action'  => 'view_registration',
951
+				'_REG_ID' => $item->ID(),
952
+			),
953
+			REG_ADMIN_URL
954
+		);
955
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
956
+			array(
957
+				'action' => 'edit_attendee',
958
+				'post'   => $item->attendee_ID(),
959
+			),
960
+			REG_ADMIN_URL
961
+		);
962
+		// page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
963
+		// $resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
964
+		$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
965
+			array(
966
+				'action'  => 'resend_registration',
967
+				'_REG_ID' => $item->ID(),
968
+			),
969
+			REG_ADMIN_URL,
970
+			true
971
+		);
972
+		// Build row actions
973
+		$actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can(
974
+			'ee_read_registration',
975
+			'espresso_registrations_view_registration',
976
+			$item->ID()
977
+		) ? '<li><a href="'
978
+			. $view_lnk_url
979
+			. '" title="'
980
+			. esc_attr__('View Registration Details', 'event_espresso')
981
+			. '" class="tiny-text">
982 982
 				<div class="dashicons dashicons-clipboard"></div>
983 983
 			</a>
984 984
 			</li>'
985
-            : '';
986
-        $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can(
987
-            'ee_edit_contacts',
988
-            'espresso_registrations_edit_attendee'
989
-        )
990
-                               && $attendee instanceof EE_Attendee
991
-            ? '
985
+			: '';
986
+		$actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can(
987
+			'ee_edit_contacts',
988
+			'espresso_registrations_edit_attendee'
989
+		)
990
+							   && $attendee instanceof EE_Attendee
991
+			? '
992 992
 			<li>
993 993
 			<a href="' . $edit_lnk_url . '" title="'
994
-              . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
994
+			  . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
995 995
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
996 996
 			</a>
997 997
 			</li>' : '';
998
-        $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
999
-                                     && EE_Registry::instance()->CAP->current_user_can(
1000
-                                         'ee_send_message',
1001
-                                         'espresso_registrations_resend_registration',
1002
-                                         $item->ID()
1003
-                                     )
1004
-            ? '
998
+		$actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee
999
+									 && EE_Registry::instance()->CAP->current_user_can(
1000
+										 'ee_send_message',
1001
+										 'espresso_registrations_resend_registration',
1002
+										 $item->ID()
1003
+									 )
1004
+			? '
1005 1005
 			<li>
1006 1006
 			<a href="'
1007
-              . $resend_reg_lnk_url
1008
-              . '" title="'
1009
-              . esc_attr__('Resend Registration Details', 'event_espresso')
1010
-              . '" class="tiny-text">
1007
+			  . $resend_reg_lnk_url
1008
+			  . '" title="'
1009
+			  . esc_attr__('Resend Registration Details', 'event_espresso')
1010
+			  . '" class="tiny-text">
1011 1011
 				<div class="dashicons dashicons-email-alt"></div>
1012 1012
 			</a>
1013 1013
 			</li>' : '';
1014
-        // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
1015
-        $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1016
-            array(
1017
-                'action' => 'view_transaction',
1018
-                'TXN_ID' => $this->_transaction_details['id'],
1019
-            ),
1020
-            TXN_ADMIN_URL
1021
-        );
1022
-        $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can(
1023
-            'ee_read_transaction',
1024
-            'espresso_transactions_view_transaction',
1025
-            $this->_transaction_details['id']
1026
-        )
1027
-            ? '
1014
+		// page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
1015
+		$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1016
+			array(
1017
+				'action' => 'view_transaction',
1018
+				'TXN_ID' => $this->_transaction_details['id'],
1019
+			),
1020
+			TXN_ADMIN_URL
1021
+		);
1022
+		$actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can(
1023
+			'ee_read_transaction',
1024
+			'espresso_transactions_view_transaction',
1025
+			$this->_transaction_details['id']
1026
+		)
1027
+			? '
1028 1028
 			<li>
1029 1029
 			<a class="ee-status-color-'
1030
-              . $this->_transaction_details['status']
1031
-              . ' tiny-text" href="'
1032
-              . $view_txn_lnk_url
1033
-              . '"  title="'
1034
-              . $this->_transaction_details['title_attr']
1035
-              . '">
1030
+			  . $this->_transaction_details['status']
1031
+			  . ' tiny-text" href="'
1032
+			  . $view_txn_lnk_url
1033
+			  . '"  title="'
1034
+			  . $this->_transaction_details['title_attr']
1035
+			  . '">
1036 1036
 				<div class="dashicons dashicons-cart"></div>
1037 1037
 			</a>
1038 1038
 			</li>' : '';
1039
-        // invoice link
1040
-        $actions['dl_invoice_lnk'] = '';
1041
-        $dl_invoice_lnk_url = $item->invoice_url();
1042
-        // only show invoice link if message type is active.
1043
-        if ($attendee instanceof EE_Attendee
1044
-            && $item->is_primary_registrant()
1045
-            && EEH_MSG_Template::is_mt_active('invoice')
1046
-        ) {
1047
-            $actions['dl_invoice_lnk'] = '
1039
+		// invoice link
1040
+		$actions['dl_invoice_lnk'] = '';
1041
+		$dl_invoice_lnk_url = $item->invoice_url();
1042
+		// only show invoice link if message type is active.
1043
+		if ($attendee instanceof EE_Attendee
1044
+			&& $item->is_primary_registrant()
1045
+			&& EEH_MSG_Template::is_mt_active('invoice')
1046
+		) {
1047
+			$actions['dl_invoice_lnk'] = '
1048 1048
 		<li>
1049 1049
 			<a title="'
1050
-                                         . esc_attr__('View Transaction Invoice', 'event_espresso')
1051
-                                         . '" target="_blank" href="'
1052
-                                         . $dl_invoice_lnk_url
1053
-                                         . '" class="tiny-text">
1050
+										 . esc_attr__('View Transaction Invoice', 'event_espresso')
1051
+										 . '" target="_blank" href="'
1052
+										 . $dl_invoice_lnk_url
1053
+										 . '" class="tiny-text">
1054 1054
 				<span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1055 1055
 			</a>
1056 1056
 		</li>';
1057
-        }
1058
-        $actions['filtered_messages_link'] = '';
1059
-        // message list table link (filtered by REG_ID
1060
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
1061
-            $actions['filtered_messages_link'] = '<li>'
1062
-                                                 . EEH_MSG_Template::get_message_action_link(
1063
-                                                     'see_notifications_for',
1064
-                                                     null,
1065
-                                                     array('_REG_ID' => $item->ID())
1066
-                                                 ) . '</li>';
1067
-        }
1068
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1069
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1070
-    }
1057
+		}
1058
+		$actions['filtered_messages_link'] = '';
1059
+		// message list table link (filtered by REG_ID
1060
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
1061
+			$actions['filtered_messages_link'] = '<li>'
1062
+												 . EEH_MSG_Template::get_message_action_link(
1063
+													 'see_notifications_for',
1064
+													 null,
1065
+													 array('_REG_ID' => $item->ID())
1066
+												 ) . '</li>';
1067
+		}
1068
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1069
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1070
+	}
1071 1071
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function __construct(Registrations_Admin_Page $admin_page)
55 55
     {
56
-        if (! empty($_GET['event_id'])) {
56
+        if ( ! empty($_GET['event_id'])) {
57 57
             $extra_query_args = array();
58 58
             foreach ($admin_page->get_views() as $key => $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = array('event_id' => $_GET['event_id']);
59
+                $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']);
60 60
             }
61 61
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62 62
         }
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
                 )
157 157
             )
158 158
         );
159
-        if (!empty($filters)) {
159
+        if ( ! empty($filters)) {
160 160
             $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
161 161
         }
162 162
         $this->_primary_column = '_REG_ID';
163 163
         $this->_sortable_columns = array(
164
-            '_REG_date'     => array('_REG_date' => true),   // true means its already sorted
164
+            '_REG_date'     => array('_REG_date' => true), // true means its already sorted
165 165
             /**
166 166
              * Allows users to change the default sort if they wish.
167 167
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     {
194 194
         $class = parent::_get_row_class($item);
195 195
         // add status class
196
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
196
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
197 197
         if ($this->_has_checkbox_column) {
198 198
             $class .= ' has-checkbox-column';
199 199
         }
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
         // setup date query.
359 359
         $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
360 360
             'REG_date',
361
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
361
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
362 362
             'Y-m-d H:i:s'
363 363
         );
364 364
         $end_string = EEM_Registration::instance()->convert_datetime_for_query(
365 365
             'REG_date',
366
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
366
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
367 367
             'Y-m-d H:i:s'
368 368
         );
369 369
         $_where['REG_date'] = array(
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
             array(
401 401
                 EEM_Registration::instance()->convert_datetime_for_query(
402 402
                     'REG_date',
403
-                    $current_date . $time_start,
403
+                    $current_date.$time_start,
404 404
                     'Y-m-d H:i:s'
405 405
                 ),
406 406
                 EEM_Registration::instance()->convert_datetime_for_query(
407 407
                     'REG_date',
408
-                    $current_date . $time_end,
408
+                    $current_date.$time_end,
409 409
                     'Y-m-d H:i:s'
410 410
                 ),
411 411
             ),
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
         $content .= '<div class="show-on-mobile-view-only">';
466 466
         $content .= '<br>';
467 467
         $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
468
-        $content .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
469
-        $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
468
+        $content .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
469
+        $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
470 470
         $content .= '</div>';
471 471
         return $content;
472 472
     }
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
                   . $event_name
552 552
                   . '</a>' : $event_name;
553 553
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL);
554
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
554
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
555 555
             $actions['event_filter'] .= sprintf(
556 556
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
557 557
                 $event_name
558 558
             );
559
-            $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>';
559
+            $actions['event_filter'] .= '">'.__('View Registrations', 'event_espresso').'</a>';
560 560
         } else {
561 561
             $edit_event = $event_name;
562 562
             $actions['event_filter'] = '';
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
     {
604 604
         $content = '<div class="ee-registration-event-datetimes-container">';
605 605
         $expand_toggle = count($datetime_strings) > 1
606
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
606
+            ? ' <span title="'.esc_attr__('Click to view all dates', 'event_espresso')
607 607
               . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
608 608
             : '';
609 609
         // get first item for initial visibility
610
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
610
+        $content .= '<div class="left">'.array_shift($datetime_strings).'</div>';
611 611
         $content .= $expand_toggle;
612 612
         if ($datetime_strings) {
613 613
             $content .= '<div style="clear:both"></div>';
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
         $t = $item->get_first_related('Transaction');
661 661
         $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0;
662 662
         // append group count to name
663
-        $link .= '&nbsp;' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
663
+        $link .= '&nbsp;'.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
664 664
         // append reg_code
665
-        $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
665
+        $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
666 666
         // reg status text for accessibility
667 667
         $link .= '<br><span class="ee-status-text-small">'
668 668
                  . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
                                 . $trash_lnk_url
688 688
                                 . '" title="'
689 689
                                 . esc_attr__('Trash Registration', 'event_espresso')
690
-                                . '">' . __('Trash', 'event_espresso') . '</a>';
690
+                                . '">'.__('Trash', 'event_espresso').'</a>';
691 691
         } elseif ($this->_view === 'trash') {
692 692
             // restore registration link
693 693
             if (EE_Registry::instance()->CAP->current_user_can(
@@ -705,8 +705,8 @@  discard block
 block discarded – undo
705 705
                 $actions['restore'] = '<a href="'
706 706
                                       . $restore_lnk_url
707 707
                                       . '" title="'
708
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
709
-                                      . __('Restore', 'event_espresso') . '</a>';
708
+                                      . esc_attr__('Restore Registration', 'event_espresso').'">'
709
+                                      . __('Restore', 'event_espresso').'</a>';
710 710
             }
711 711
             if (EE_Registry::instance()->CAP->current_user_can(
712 712
                 'ee_delete_registration',
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
                                                                               . $ticket->name()
782 782
                                                                               . '</span><br />' : '';
783 783
         if ($item->final_price() > 0) {
784
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
784
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
785 785
         } else {
786 786
             // free event
787 787
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
             : '<span class="TKT_name">'
809 809
               . $ticket->name()
810 810
               . '</span><br />';
811
-        $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
811
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
812 812
         return $content;
813 813
     }
814 814
 
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
         $payment_method = $item->payment_method();
827 827
         $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name()
828 828
             : __('Unknown', 'event_espresso');
829
-        $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
829
+        $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
830 830
         if ($item->paid() > 0) {
831 831
             $content .= '<br><span class="ee-status-text-small">'
832 832
                         . sprintf(
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
                   . esc_attr__('View Transaction', 'event_espresso')
875 875
                   . '">'
876 876
                   . $item->transaction()->pretty_total()
877
-                  . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
877
+                  . '</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
878 878
         } else {
879 879
             return __("None", "event_espresso");
880 880
         }
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
                       . esc_attr__('View Transaction', 'event_espresso')
921 921
                       . '">'
922 922
                       . $item->transaction()->pretty_paid()
923
-                      . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
923
+                      . '</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
924 924
             }
925 925
         }
926 926
         return '&nbsp;';
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
                                && $attendee instanceof EE_Attendee
991 991
             ? '
992 992
 			<li>
993
-			<a href="' . $edit_lnk_url . '" title="'
994
-              . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
993
+			<a href="' . $edit_lnk_url.'" title="'
994
+              . esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text">
995 995
 				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
996 996
 			</a>
997 997
 			</li>' : '';
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
                                                      'see_notifications_for',
1064 1064
                                                      null,
1065 1065
                                                      array('_REG_ID' => $item->ID())
1066
-                                                 ) . '</li>';
1066
+                                                 ).'</li>';
1067 1067
         }
1068 1068
         $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1069 1069
         return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3831 added lines, -3831 removed lines patch added patch discarded remove patch
@@ -19,2404 +19,2404 @@  discard block
 block discarded – undo
19 19
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
20 20
 {
21 21
 
22
-    /**
23
-     * @var EE_Registration
24
-     */
25
-    private $_registration;
26
-
27
-    /**
28
-     * @var EE_Event
29
-     */
30
-    private $_reg_event;
31
-
32
-    /**
33
-     * @var EE_Session
34
-     */
35
-    private $_session;
36
-
37
-    private static $_reg_status;
38
-
39
-    /**
40
-     * Form for displaying the custom questions for this registration.
41
-     * This gets used a few times throughout the request so its best to cache it
42
-     *
43
-     * @var EE_Registration_Custom_Questions_Form
44
-     */
45
-    protected $_reg_custom_questions_form = null;
46
-
47
-
48
-    /**
49
-     *        constructor
50
-     *
51
-     * @Constructor
52
-     * @access public
53
-     * @param bool $routing
54
-     * @return Registrations_Admin_Page
55
-     */
56
-    public function __construct($routing = true)
57
-    {
58
-        parent::__construct($routing);
59
-        add_action('wp_loaded', array($this, 'wp_loaded'));
60
-    }
61
-
62
-
63
-    public function wp_loaded()
64
-    {
65
-        // when adding a new registration...
66
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67
-            EE_System::do_not_cache();
68
-            if (! isset($this->_req_data['processing_registration'])
69
-                || absint($this->_req_data['processing_registration']) !== 1
70
-            ) {
71
-                // and it's NOT the attendee information reg step
72
-                // force cookie expiration by setting time to last week
73
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
74
-                // and update the global
75
-                $_COOKIE['ee_registration_added'] = 0;
76
-            }
77
-        }
78
-    }
79
-
80
-
81
-    protected function _init_page_props()
82
-    {
83
-        $this->page_slug = REG_PG_SLUG;
84
-        $this->_admin_base_url = REG_ADMIN_URL;
85
-        $this->_admin_base_path = REG_ADMIN;
86
-        $this->page_label = esc_html__('Registrations', 'event_espresso');
87
-        $this->_cpt_routes = array(
88
-            'add_new_attendee' => 'espresso_attendees',
89
-            'edit_attendee'    => 'espresso_attendees',
90
-            'insert_attendee'  => 'espresso_attendees',
91
-            'update_attendee'  => 'espresso_attendees',
92
-        );
93
-        $this->_cpt_model_names = array(
94
-            'add_new_attendee' => 'EEM_Attendee',
95
-            'edit_attendee'    => 'EEM_Attendee',
96
-        );
97
-        $this->_cpt_edit_routes = array(
98
-            'espresso_attendees' => 'edit_attendee',
99
-        );
100
-        $this->_pagenow_map = array(
101
-            'add_new_attendee' => 'post-new.php',
102
-            'edit_attendee'    => 'post.php',
103
-            'trash'            => 'post.php',
104
-        );
105
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
106
-        // add filters so that the comment urls don't take users to a confusing 404 page
107
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
108
-    }
109
-
110
-
111
-    public function clear_comment_link($link, $comment, $args)
112
-    {
113
-        // gotta make sure this only happens on this route
114
-        $post_type = get_post_type($comment->comment_post_ID);
115
-        if ($post_type === 'espresso_attendees') {
116
-            return '#commentsdiv';
117
-        }
118
-        return $link;
119
-    }
120
-
121
-
122
-    protected function _ajax_hooks()
123
-    {
124
-        // todo: all hooks for registrations ajax goes in here
125
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
126
-    }
127
-
128
-
129
-    protected function _define_page_props()
130
-    {
131
-        $this->_admin_page_title = $this->page_label;
132
-        $this->_labels = array(
133
-            'buttons'                      => array(
134
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
135
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
136
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
137
-                'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
138
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
139
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
140
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
141
-                'contact_list_export' => esc_html__("Export Data", "event_espresso"),
142
-            ),
143
-            'publishbox'                   => array(
144
-                'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
145
-                'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
146
-            ),
147
-            'hide_add_button_on_cpt_route' => array(
148
-                'edit_attendee' => true,
149
-            ),
150
-        );
151
-    }
152
-
153
-
154
-    /**
155
-     *        grab url requests and route them
156
-     *
157
-     * @access private
158
-     * @return void
159
-     */
160
-    public function _set_page_routes()
161
-    {
162
-        $this->_get_registration_status_array();
163
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
164
-            ? $this->_req_data['_REG_ID'] : 0;
165
-        $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
166
-            ? $this->_req_data['reg_status_change_form']['REG_ID']
167
-            : $reg_id;
168
-        $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
169
-            ? $this->_req_data['ATT_ID'] : 0;
170
-        $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
171
-            ? $this->_req_data['post']
172
-            : $att_id;
173
-        $this->_page_routes = array(
174
-            'default'                             => array(
175
-                'func'       => '_registrations_overview_list_table',
176
-                'capability' => 'ee_read_registrations',
177
-            ),
178
-            'view_registration'                   => array(
179
-                'func'       => '_registration_details',
180
-                'capability' => 'ee_read_registration',
181
-                'obj_id'     => $reg_id,
182
-            ),
183
-            'edit_registration'                   => array(
184
-                'func'               => '_update_attendee_registration_form',
185
-                'noheader'           => true,
186
-                'headers_sent_route' => 'view_registration',
187
-                'capability'         => 'ee_edit_registration',
188
-                'obj_id'             => $reg_id,
189
-                '_REG_ID'            => $reg_id,
190
-            ),
191
-            'trash_registrations'                 => array(
192
-                'func'       => '_trash_or_restore_registrations',
193
-                'args'       => array('trash' => true),
194
-                'noheader'   => true,
195
-                'capability' => 'ee_delete_registrations',
196
-            ),
197
-            'restore_registrations'               => array(
198
-                'func'       => '_trash_or_restore_registrations',
199
-                'args'       => array('trash' => false),
200
-                'noheader'   => true,
201
-                'capability' => 'ee_delete_registrations',
202
-            ),
203
-            'delete_registrations'                => array(
204
-                'func'       => '_delete_registrations',
205
-                'noheader'   => true,
206
-                'capability' => 'ee_delete_registrations',
207
-            ),
208
-            'new_registration'                    => array(
209
-                'func'       => 'new_registration',
210
-                'capability' => 'ee_edit_registrations',
211
-            ),
212
-            'process_reg_step'                    => array(
213
-                'func'       => 'process_reg_step',
214
-                'noheader'   => true,
215
-                'capability' => 'ee_edit_registrations',
216
-            ),
217
-            'redirect_to_txn'                     => array(
218
-                'func'       => 'redirect_to_txn',
219
-                'noheader'   => true,
220
-                'capability' => 'ee_edit_registrations',
221
-            ),
222
-            'change_reg_status'                   => array(
223
-                'func'       => '_change_reg_status',
224
-                'noheader'   => true,
225
-                'capability' => 'ee_edit_registration',
226
-                'obj_id'     => $reg_id,
227
-            ),
228
-            'approve_registration'                => array(
229
-                'func'       => 'approve_registration',
230
-                'noheader'   => true,
231
-                'capability' => 'ee_edit_registration',
232
-                'obj_id'     => $reg_id,
233
-            ),
234
-            'approve_and_notify_registration'     => array(
235
-                'func'       => 'approve_registration',
236
-                'noheader'   => true,
237
-                'args'       => array(true),
238
-                'capability' => 'ee_edit_registration',
239
-                'obj_id'     => $reg_id,
240
-            ),
241
-            'approve_registrations'               => array(
242
-                'func'       => 'bulk_action_on_registrations',
243
-                'noheader'   => true,
244
-                'capability' => 'ee_edit_registrations',
245
-                'args'       => array('approve'),
246
-            ),
247
-            'approve_and_notify_registrations'    => array(
248
-                'func'       => 'bulk_action_on_registrations',
249
-                'noheader'   => true,
250
-                'capability' => 'ee_edit_registrations',
251
-                'args'       => array('approve', true),
252
-            ),
253
-            'decline_registration'                => array(
254
-                'func'       => 'decline_registration',
255
-                'noheader'   => true,
256
-                'capability' => 'ee_edit_registration',
257
-                'obj_id'     => $reg_id,
258
-            ),
259
-            'decline_and_notify_registration'     => array(
260
-                'func'       => 'decline_registration',
261
-                'noheader'   => true,
262
-                'args'       => array(true),
263
-                'capability' => 'ee_edit_registration',
264
-                'obj_id'     => $reg_id,
265
-            ),
266
-            'decline_registrations'               => array(
267
-                'func'       => 'bulk_action_on_registrations',
268
-                'noheader'   => true,
269
-                'capability' => 'ee_edit_registrations',
270
-                'args'       => array('decline'),
271
-            ),
272
-            'decline_and_notify_registrations'    => array(
273
-                'func'       => 'bulk_action_on_registrations',
274
-                'noheader'   => true,
275
-                'capability' => 'ee_edit_registrations',
276
-                'args'       => array('decline', true),
277
-            ),
278
-            'pending_registration'                => array(
279
-                'func'       => 'pending_registration',
280
-                'noheader'   => true,
281
-                'capability' => 'ee_edit_registration',
282
-                'obj_id'     => $reg_id,
283
-            ),
284
-            'pending_and_notify_registration'     => array(
285
-                'func'       => 'pending_registration',
286
-                'noheader'   => true,
287
-                'args'       => array(true),
288
-                'capability' => 'ee_edit_registration',
289
-                'obj_id'     => $reg_id,
290
-            ),
291
-            'pending_registrations'               => array(
292
-                'func'       => 'bulk_action_on_registrations',
293
-                'noheader'   => true,
294
-                'capability' => 'ee_edit_registrations',
295
-                'args'       => array('pending'),
296
-            ),
297
-            'pending_and_notify_registrations'    => array(
298
-                'func'       => 'bulk_action_on_registrations',
299
-                'noheader'   => true,
300
-                'capability' => 'ee_edit_registrations',
301
-                'args'       => array('pending', true),
302
-            ),
303
-            'no_approve_registration'             => array(
304
-                'func'       => 'not_approve_registration',
305
-                'noheader'   => true,
306
-                'capability' => 'ee_edit_registration',
307
-                'obj_id'     => $reg_id,
308
-            ),
309
-            'no_approve_and_notify_registration'  => array(
310
-                'func'       => 'not_approve_registration',
311
-                'noheader'   => true,
312
-                'args'       => array(true),
313
-                'capability' => 'ee_edit_registration',
314
-                'obj_id'     => $reg_id,
315
-            ),
316
-            'no_approve_registrations'            => array(
317
-                'func'       => 'bulk_action_on_registrations',
318
-                'noheader'   => true,
319
-                'capability' => 'ee_edit_registrations',
320
-                'args'       => array('not_approve'),
321
-            ),
322
-            'no_approve_and_notify_registrations' => array(
323
-                'func'       => 'bulk_action_on_registrations',
324
-                'noheader'   => true,
325
-                'capability' => 'ee_edit_registrations',
326
-                'args'       => array('not_approve', true),
327
-            ),
328
-            'cancel_registration'                 => array(
329
-                'func'       => 'cancel_registration',
330
-                'noheader'   => true,
331
-                'capability' => 'ee_edit_registration',
332
-                'obj_id'     => $reg_id,
333
-            ),
334
-            'cancel_and_notify_registration'      => array(
335
-                'func'       => 'cancel_registration',
336
-                'noheader'   => true,
337
-                'args'       => array(true),
338
-                'capability' => 'ee_edit_registration',
339
-                'obj_id'     => $reg_id,
340
-            ),
341
-            'cancel_registrations'                => array(
342
-                'func'       => 'bulk_action_on_registrations',
343
-                'noheader'   => true,
344
-                'capability' => 'ee_edit_registrations',
345
-                'args'       => array('cancel'),
346
-            ),
347
-            'cancel_and_notify_registrations'     => array(
348
-                'func'       => 'bulk_action_on_registrations',
349
-                'noheader'   => true,
350
-                'capability' => 'ee_edit_registrations',
351
-                'args'       => array('cancel', true),
352
-            ),
353
-            'wait_list_registration'              => array(
354
-                'func'       => 'wait_list_registration',
355
-                'noheader'   => true,
356
-                'capability' => 'ee_edit_registration',
357
-                'obj_id'     => $reg_id,
358
-            ),
359
-            'wait_list_and_notify_registration'   => array(
360
-                'func'       => 'wait_list_registration',
361
-                'noheader'   => true,
362
-                'args'       => array(true),
363
-                'capability' => 'ee_edit_registration',
364
-                'obj_id'     => $reg_id,
365
-            ),
366
-            'contact_list'                        => array(
367
-                'func'       => '_attendee_contact_list_table',
368
-                'capability' => 'ee_read_contacts',
369
-            ),
370
-            'add_new_attendee'                    => array(
371
-                'func' => '_create_new_cpt_item',
372
-                'args' => array(
373
-                    'new_attendee' => true,
374
-                    'capability'   => 'ee_edit_contacts',
375
-                ),
376
-            ),
377
-            'edit_attendee'                       => array(
378
-                'func'       => '_edit_cpt_item',
379
-                'capability' => 'ee_edit_contacts',
380
-                'obj_id'     => $att_id,
381
-            ),
382
-            'duplicate_attendee'                  => array(
383
-                'func'       => '_duplicate_attendee',
384
-                'noheader'   => true,
385
-                'capability' => 'ee_edit_contacts',
386
-                'obj_id'     => $att_id,
387
-            ),
388
-            'insert_attendee'                     => array(
389
-                'func'       => '_insert_or_update_attendee',
390
-                'args'       => array(
391
-                    'new_attendee' => true,
392
-                ),
393
-                'noheader'   => true,
394
-                'capability' => 'ee_edit_contacts',
395
-            ),
396
-            'update_attendee'                     => array(
397
-                'func'       => '_insert_or_update_attendee',
398
-                'args'       => array(
399
-                    'new_attendee' => false,
400
-                ),
401
-                'noheader'   => true,
402
-                'capability' => 'ee_edit_contacts',
403
-                'obj_id'     => $att_id,
404
-            ),
405
-            'trash_attendees'                     => array(
406
-                'func'       => '_trash_or_restore_attendees',
407
-                'args'       => array(
408
-                    'trash' => 'true',
409
-                ),
410
-                'noheader'   => true,
411
-                'capability' => 'ee_delete_contacts',
412
-            ),
413
-            'trash_attendee'                      => array(
414
-                'func'       => '_trash_or_restore_attendees',
415
-                'args'       => array(
416
-                    'trash' => true,
417
-                ),
418
-                'noheader'   => true,
419
-                'capability' => 'ee_delete_contacts',
420
-                'obj_id'     => $att_id,
421
-            ),
422
-            'restore_attendees'                   => array(
423
-                'func'       => '_trash_or_restore_attendees',
424
-                'args'       => array(
425
-                    'trash' => false,
426
-                ),
427
-                'noheader'   => true,
428
-                'capability' => 'ee_delete_contacts',
429
-                'obj_id'     => $att_id,
430
-            ),
431
-            'resend_registration'                 => array(
432
-                'func'       => '_resend_registration',
433
-                'noheader'   => true,
434
-                'capability' => 'ee_send_message',
435
-            ),
436
-            'registrations_report'                => array(
437
-                'func'       => '_registrations_report',
438
-                'noheader'   => true,
439
-                'capability' => 'ee_read_registrations',
440
-            ),
441
-            'contact_list_export'                 => array(
442
-                'func'       => '_contact_list_export',
443
-                'noheader'   => true,
444
-                'capability' => 'export',
445
-            ),
446
-            'contact_list_report'                 => array(
447
-                'func'       => '_contact_list_report',
448
-                'noheader'   => true,
449
-                'capability' => 'ee_read_contacts',
450
-            ),
451
-        );
452
-    }
453
-
454
-
455
-    protected function _set_page_config()
456
-    {
457
-        $this->_page_config = array(
458
-            'default'           => array(
459
-                'nav'           => array(
460
-                    'label' => esc_html__('Overview', 'event_espresso'),
461
-                    'order' => 5,
462
-                ),
463
-                'help_tabs'     => array(
464
-                    'registrations_overview_help_tab'                       => array(
465
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
466
-                        'filename' => 'registrations_overview',
467
-                    ),
468
-                    'registrations_overview_table_column_headings_help_tab' => array(
469
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
470
-                        'filename' => 'registrations_overview_table_column_headings',
471
-                    ),
472
-                    'registrations_overview_filters_help_tab'               => array(
473
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
474
-                        'filename' => 'registrations_overview_filters',
475
-                    ),
476
-                    'registrations_overview_views_help_tab'                 => array(
477
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
478
-                        'filename' => 'registrations_overview_views',
479
-                    ),
480
-                    'registrations_regoverview_other_help_tab'              => array(
481
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
482
-                        'filename' => 'registrations_overview_other',
483
-                    ),
484
-                ),
485
-                'help_tour'     => array('Registration_Overview_Help_Tour'),
486
-                'qtips'         => array('Registration_List_Table_Tips'),
487
-                'list_table'    => 'EE_Registrations_List_Table',
488
-                'require_nonce' => false,
489
-            ),
490
-            'view_registration' => array(
491
-                'nav'           => array(
492
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
493
-                    'order'      => 15,
494
-                    'url'        => isset($this->_req_data['_REG_ID'])
495
-                        ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
496
-                        : $this->_admin_base_url,
497
-                    'persistent' => false,
498
-                ),
499
-                'help_tabs'     => array(
500
-                    'registrations_details_help_tab'                    => array(
501
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
502
-                        'filename' => 'registrations_details',
503
-                    ),
504
-                    'registrations_details_table_help_tab'              => array(
505
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
506
-                        'filename' => 'registrations_details_table',
507
-                    ),
508
-                    'registrations_details_form_answers_help_tab'       => array(
509
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
510
-                        'filename' => 'registrations_details_form_answers',
511
-                    ),
512
-                    'registrations_details_registrant_details_help_tab' => array(
513
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
514
-                        'filename' => 'registrations_details_registrant_details',
515
-                    ),
516
-                ),
517
-                'help_tour'     => array('Registration_Details_Help_Tour'),
518
-                'metaboxes'     => array_merge(
519
-                    $this->_default_espresso_metaboxes,
520
-                    array('_registration_details_metaboxes')
521
-                ),
522
-                'require_nonce' => false,
523
-            ),
524
-            'new_registration'  => array(
525
-                'nav'           => array(
526
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
527
-                    'url'        => '#',
528
-                    'order'      => 15,
529
-                    'persistent' => false,
530
-                ),
531
-                'metaboxes'     => $this->_default_espresso_metaboxes,
532
-                'labels'        => array(
533
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
534
-                ),
535
-                'require_nonce' => false,
536
-            ),
537
-            'add_new_attendee'  => array(
538
-                'nav'           => array(
539
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
540
-                    'order'      => 15,
541
-                    'persistent' => false,
542
-                ),
543
-                'metaboxes'     => array_merge(
544
-                    $this->_default_espresso_metaboxes,
545
-                    array('_publish_post_box', 'attendee_editor_metaboxes')
546
-                ),
547
-                'require_nonce' => false,
548
-            ),
549
-            'edit_attendee'     => array(
550
-                'nav'           => array(
551
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
552
-                    'order'      => 15,
553
-                    'persistent' => false,
554
-                    'url'        => isset($this->_req_data['ATT_ID'])
555
-                        ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
556
-                        : $this->_admin_base_url,
557
-                ),
558
-                'metaboxes'     => array('attendee_editor_metaboxes'),
559
-                'require_nonce' => false,
560
-            ),
561
-            'contact_list'      => array(
562
-                'nav'           => array(
563
-                    'label' => esc_html__('Contact List', 'event_espresso'),
564
-                    'order' => 20,
565
-                ),
566
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
567
-                'help_tabs'     => array(
568
-                    'registrations_contact_list_help_tab'                       => array(
569
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
570
-                        'filename' => 'registrations_contact_list',
571
-                    ),
572
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
573
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
574
-                        'filename' => 'registrations_contact_list_table_column_headings',
575
-                    ),
576
-                    'registrations_contact_list_views_help_tab'                 => array(
577
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
578
-                        'filename' => 'registrations_contact_list_views',
579
-                    ),
580
-                    'registrations_contact_list_other_help_tab'                 => array(
581
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
582
-                        'filename' => 'registrations_contact_list_other',
583
-                    ),
584
-                ),
585
-                'help_tour'     => array('Contact_List_Help_Tour'),
586
-                'metaboxes'     => array(),
587
-                'require_nonce' => false,
588
-            ),
589
-            // override default cpt routes
590
-            'create_new'        => '',
591
-            'edit'              => '',
592
-        );
593
-    }
594
-
595
-
596
-    /**
597
-     * The below methods aren't used by this class currently
598
-     */
599
-    protected function _add_screen_options()
600
-    {
601
-    }
602
-
603
-
604
-    protected function _add_feature_pointers()
605
-    {
606
-    }
607
-
608
-
609
-    public function admin_init()
610
-    {
611
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
612
-            'click "Update Registration Questions" to save your changes',
613
-            'event_espresso'
614
-        );
615
-    }
616
-
617
-
618
-    public function admin_notices()
619
-    {
620
-    }
621
-
622
-
623
-    public function admin_footer_scripts()
624
-    {
625
-    }
626
-
627
-
628
-    /**
629
-     *        get list of registration statuses
630
-     *
631
-     * @access private
632
-     * @return void
633
-     * @throws EE_Error
634
-     */
635
-    private function _get_registration_status_array()
636
-    {
637
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
638
-    }
639
-
640
-
641
-    protected function _add_screen_options_default()
642
-    {
643
-        $this->_per_page_screen_option();
644
-    }
645
-
646
-
647
-    protected function _add_screen_options_contact_list()
648
-    {
649
-        $page_title = $this->_admin_page_title;
650
-        $this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
651
-        $this->_per_page_screen_option();
652
-        $this->_admin_page_title = $page_title;
653
-    }
654
-
655
-
656
-    public function load_scripts_styles()
657
-    {
658
-        // style
659
-        wp_register_style(
660
-            'espresso_reg',
661
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
662
-            array('ee-admin-css'),
663
-            EVENT_ESPRESSO_VERSION
664
-        );
665
-        wp_enqueue_style('espresso_reg');
666
-        // script
667
-        wp_register_script(
668
-            'espresso_reg',
669
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
670
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671
-            EVENT_ESPRESSO_VERSION,
672
-            true
673
-        );
674
-        wp_enqueue_script('espresso_reg');
675
-    }
676
-
677
-
678
-    public function load_scripts_styles_edit_attendee()
679
-    {
680
-        // stuff to only show up on our attendee edit details page.
681
-        $attendee_details_translations = array(
682
-            'att_publish_text' => sprintf(
683
-                esc_html__('Created on: <b>%1$s</b>', 'event_espresso'),
684
-                $this->_cpt_model_obj->get_datetime('ATT_created')
685
-            ),
686
-        );
687
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
688
-        wp_enqueue_script('jquery-validate');
689
-    }
690
-
691
-
692
-    public function load_scripts_styles_view_registration()
693
-    {
694
-        // styles
695
-        wp_enqueue_style('espresso-ui-theme');
696
-        // scripts
697
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
698
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
699
-    }
700
-
701
-
702
-    public function load_scripts_styles_contact_list()
703
-    {
704
-        wp_dequeue_style('espresso_reg');
705
-        wp_register_style(
706
-            'espresso_att',
707
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
708
-            array('ee-admin-css'),
709
-            EVENT_ESPRESSO_VERSION
710
-        );
711
-        wp_enqueue_style('espresso_att');
712
-    }
713
-
714
-
715
-    public function load_scripts_styles_new_registration()
716
-    {
717
-        wp_register_script(
718
-            'ee-spco-for-admin',
719
-            REG_ASSETS_URL . 'spco_for_admin.js',
720
-            array('underscore', 'jquery'),
721
-            EVENT_ESPRESSO_VERSION,
722
-            true
723
-        );
724
-        wp_enqueue_script('ee-spco-for-admin');
725
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
726
-        EE_Form_Section_Proper::wp_enqueue_scripts();
727
-        EED_Ticket_Selector::load_tckt_slctr_assets();
728
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
729
-    }
730
-
731
-
732
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
733
-    {
734
-        add_filter('FHEE_load_EE_messages', '__return_true');
735
-    }
736
-
737
-
738
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
739
-    {
740
-        add_filter('FHEE_load_EE_messages', '__return_true');
741
-    }
742
-
743
-
744
-    protected function _set_list_table_views_default()
745
-    {
746
-        // for notification related bulk actions we need to make sure only active messengers have an option.
747
-        EED_Messages::set_autoloaders();
748
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
749
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
750
-        $active_mts = $message_resource_manager->list_of_active_message_types();
751
-        // key= bulk_action_slug, value= message type.
752
-        $match_array = array(
753
-            'approve_registrations'    => 'registration',
754
-            'decline_registrations'    => 'declined_registration',
755
-            'pending_registrations'    => 'pending_approval',
756
-            'no_approve_registrations' => 'not_approved_registration',
757
-            'cancel_registrations'     => 'cancelled_registration',
758
-        );
759
-        $can_send = EE_Registry::instance()->CAP->current_user_can(
760
-            'ee_send_message',
761
-            'batch_send_messages'
762
-        );
763
-        /** setup reg status bulk actions **/
764
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
765
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
766
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
767
-                'Approve and Notify Registrations',
768
-                'event_espresso'
769
-            );
770
-        }
771
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
772
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
773
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
774
-                'Decline and Notify Registrations',
775
-                'event_espresso'
776
-            );
777
-        }
778
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
779
-            'Set Registrations to Pending Payment',
780
-            'event_espresso'
781
-        );
782
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
783
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
784
-                'Set Registrations to Pending Payment and Notify',
785
-                'event_espresso'
786
-            );
787
-        }
788
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
789
-            'Set Registrations to Not Approved',
790
-            'event_espresso'
791
-        );
792
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
793
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
794
-                'Set Registrations to Not Approved and Notify',
795
-                'event_espresso'
796
-            );
797
-        }
798
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
799
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
800
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
801
-                'Cancel Registrations and Notify',
802
-                'event_espresso'
803
-            );
804
-        }
805
-        $def_reg_status_actions = apply_filters(
806
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
807
-            $def_reg_status_actions,
808
-            $active_mts,
809
-            $can_send
810
-        );
811
-
812
-        $this->_views = array(
813
-            'all'   => array(
814
-                'slug'        => 'all',
815
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
816
-                'count'       => 0,
817
-                'bulk_action' => array_merge(
818
-                    $def_reg_status_actions,
819
-                    array(
820
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
821
-                    )
822
-                ),
823
-            ),
824
-            'month' => array(
825
-                'slug'        => 'month',
826
-                'label'       => esc_html__('This Month', 'event_espresso'),
827
-                'count'       => 0,
828
-                'bulk_action' => array_merge(
829
-                    $def_reg_status_actions,
830
-                    array(
831
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
832
-                    )
833
-                ),
834
-            ),
835
-            'today' => array(
836
-                'slug'        => 'today',
837
-                'label'       => sprintf(
838
-                    esc_html__('Today - %s', 'event_espresso'),
839
-                    date('M d, Y', current_time('timestamp'))
840
-                ),
841
-                'count'       => 0,
842
-                'bulk_action' => array_merge(
843
-                    $def_reg_status_actions,
844
-                    array(
845
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
846
-                    )
847
-                ),
848
-            ),
849
-        );
850
-        if (EE_Registry::instance()->CAP->current_user_can(
851
-            'ee_delete_registrations',
852
-            'espresso_registrations_delete_registration'
853
-        )) {
854
-            $this->_views['incomplete'] = array(
855
-                'slug'        => 'incomplete',
856
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
857
-                'count'       => 0,
858
-                'bulk_action' => array(
859
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
860
-                ),
861
-            );
862
-            $this->_views['trash'] = array(
863
-                'slug'        => 'trash',
864
-                'label'       => esc_html__('Trash', 'event_espresso'),
865
-                'count'       => 0,
866
-                'bulk_action' => array(
867
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
868
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
869
-                ),
870
-            );
871
-        }
872
-    }
873
-
874
-
875
-    protected function _set_list_table_views_contact_list()
876
-    {
877
-        $this->_views = array(
878
-            'in_use' => array(
879
-                'slug'        => 'in_use',
880
-                'label'       => esc_html__('In Use', 'event_espresso'),
881
-                'count'       => 0,
882
-                'bulk_action' => array(
883
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
884
-                ),
885
-            ),
886
-        );
887
-        if (EE_Registry::instance()->CAP->current_user_can(
888
-            'ee_delete_contacts',
889
-            'espresso_registrations_trash_attendees'
890
-        )
891
-        ) {
892
-            $this->_views['trash'] = array(
893
-                'slug'        => 'trash',
894
-                'label'       => esc_html__('Trash', 'event_espresso'),
895
-                'count'       => 0,
896
-                'bulk_action' => array(
897
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
898
-                ),
899
-            );
900
-        }
901
-    }
902
-
903
-
904
-    protected function _registration_legend_items()
905
-    {
906
-        $fc_items = array(
907
-            'star-icon'        => array(
908
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
909
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
910
-            ),
911
-            'view_details'     => array(
912
-                'class' => 'dashicons dashicons-clipboard',
913
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
914
-            ),
915
-            'edit_attendee'    => array(
916
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
917
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
918
-            ),
919
-            'view_transaction' => array(
920
-                'class' => 'dashicons dashicons-cart',
921
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
922
-            ),
923
-            'view_invoice'     => array(
924
-                'class' => 'dashicons dashicons-media-spreadsheet',
925
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
926
-            ),
927
-        );
928
-        if (EE_Registry::instance()->CAP->current_user_can(
929
-            'ee_send_message',
930
-            'espresso_registrations_resend_registration'
931
-        )) {
932
-            $fc_items['resend_registration'] = array(
933
-                'class' => 'dashicons dashicons-email-alt',
934
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
935
-            );
936
-        } else {
937
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
938
-        }
939
-        if (EE_Registry::instance()->CAP->current_user_can(
940
-            'ee_read_global_messages',
941
-            'view_filtered_messages'
942
-        )) {
943
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
944
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
945
-                $fc_items['view_related_messages'] = array(
946
-                    'class' => $related_for_icon['css_class'],
947
-                    'desc'  => $related_for_icon['label'],
948
-                );
949
-            }
950
-        }
951
-        $sc_items = array(
952
-            'approved_status'   => array(
953
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
-                'desc'  => EEH_Template::pretty_status(
955
-                    EEM_Registration::status_id_approved,
956
-                    false,
957
-                    'sentence'
958
-                ),
959
-            ),
960
-            'pending_status'    => array(
961
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
-                'desc'  => EEH_Template::pretty_status(
963
-                    EEM_Registration::status_id_pending_payment,
964
-                    false,
965
-                    'sentence'
966
-                ),
967
-            ),
968
-            'wait_list'         => array(
969
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
-                'desc'  => EEH_Template::pretty_status(
971
-                    EEM_Registration::status_id_wait_list,
972
-                    false,
973
-                    'sentence'
974
-                ),
975
-            ),
976
-            'incomplete_status' => array(
977
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
-                'desc'  => EEH_Template::pretty_status(
979
-                    EEM_Registration::status_id_incomplete,
980
-                    false,
981
-                    'sentence'
982
-                ),
983
-            ),
984
-            'not_approved'      => array(
985
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
-                'desc'  => EEH_Template::pretty_status(
987
-                    EEM_Registration::status_id_not_approved,
988
-                    false,
989
-                    'sentence'
990
-                ),
991
-            ),
992
-            'declined_status'   => array(
993
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
-                'desc'  => EEH_Template::pretty_status(
995
-                    EEM_Registration::status_id_declined,
996
-                    false,
997
-                    'sentence'
998
-                ),
999
-            ),
1000
-            'cancelled_status'  => array(
1001
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
-                'desc'  => EEH_Template::pretty_status(
1003
-                    EEM_Registration::status_id_cancelled,
1004
-                    false,
1005
-                    'sentence'
1006
-                ),
1007
-            ),
1008
-        );
1009
-        return array_merge($fc_items, $sc_items);
1010
-    }
1011
-
1012
-
1013
-
1014
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1015
-    /**
1016
-     * @throws \EE_Error
1017
-     */
1018
-    protected function _registrations_overview_list_table()
1019
-    {
1020
-        $this->_template_args['admin_page_header'] = '';
1021
-        $EVT_ID = ! empty($this->_req_data['event_id'])
1022
-            ? absint($this->_req_data['event_id'])
1023
-            : 0;
1024
-        $ATT_ID = ! empty($this->_req_data['ATT_ID'])
1025
-            ? absint($this->_req_data['ATT_ID'])
1026
-            : 0;
1027
-        if ($ATT_ID) {
1028
-            $attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1029
-            if ($attendee instanceof EE_Attendee) {
1030
-                $this->_template_args['admin_page_header'] = sprintf(
1031
-                    esc_html__(
1032
-                        '%1$s Viewing registrations for %2$s%3$s',
1033
-                        'event_espresso'
1034
-                    ),
1035
-                    '<h3 style="line-height:1.5em;">',
1036
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
-                        array(
1038
-                            'action' => 'edit_attendee',
1039
-                            'post'   => $ATT_ID,
1040
-                        ),
1041
-                        REG_ADMIN_URL
1042
-                    ) . '">' . $attendee->full_name() . '</a>',
1043
-                    '</h3>'
1044
-                );
1045
-            }
1046
-        }
1047
-        if ($EVT_ID) {
1048
-            if (EE_Registry::instance()->CAP->current_user_can(
1049
-                'ee_edit_registrations',
1050
-                'espresso_registrations_new_registration',
1051
-                $EVT_ID
1052
-            )) {
1053
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
-                    'new_registration',
1055
-                    'add-registrant',
1056
-                    array('event_id' => $EVT_ID),
1057
-                    'add-new-h2'
1058
-                );
1059
-            }
1060
-            $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1061
-            if ($event instanceof EE_Event) {
1062
-                $this->_template_args['admin_page_header'] = sprintf(
1063
-                    esc_html__(
1064
-                        '%s Viewing registrations for the event: %s%s',
1065
-                        'event_espresso'
1066
-                    ),
1067
-                    '<h3 style="line-height:1.5em;">',
1068
-                    '<br /><a href="'
1069
-                    . EE_Admin_Page::add_query_args_and_nonce(
1070
-                        array(
1071
-                            'action' => 'edit',
1072
-                            'post'   => $event->ID(),
1073
-                        ),
1074
-                        EVENTS_ADMIN_URL
1075
-                    )
1076
-                    . '">&nbsp;'
1077
-                    . $event->get('EVT_name')
1078
-                    . '&nbsp;</a>&nbsp;',
1079
-                    '</h3>'
1080
-                );
1081
-            }
1082
-            $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1083
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1084
-            if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1085
-                $this->_template_args['admin_page_header'] = substr(
1086
-                    $this->_template_args['admin_page_header'],
1087
-                    0,
1088
-                    -5
1089
-                );
1090
-                $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091
-                $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092
-                $this->_template_args['admin_page_header'] .= $datetime->name();
1093
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
-                $this->_template_args['admin_page_header'] .= '</span></h3>';
1095
-            }
1096
-        }
1097
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1098
-        $this->display_admin_list_table_page_with_no_sidebar();
1099
-    }
1100
-
1101
-
1102
-    /**
1103
-     * This sets the _registration property for the registration details screen
1104
-     *
1105
-     * @access private
1106
-     * @return bool
1107
-     * @throws EE_Error
1108
-     * @throws InvalidArgumentException
1109
-     * @throws InvalidDataTypeException
1110
-     * @throws InvalidInterfaceException
1111
-     */
1112
-    private function _set_registration_object()
1113
-    {
1114
-        // get out if we've already set the object
1115
-        if ($this->_registration instanceof EE_Registration) {
1116
-            return true;
1117
-        }
1118
-        $REG = EEM_Registration::instance();
1119
-        $REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
-        if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121
-            return true;
1122
-        } else {
1123
-            $error_msg = sprintf(
1124
-                esc_html__(
1125
-                    'An error occurred and the details for Registration ID #%s could not be retrieved.',
1126
-                    'event_espresso'
1127
-                ),
1128
-                $REG_ID
1129
-            );
1130
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1131
-            $this->_registration = null;
1132
-            return false;
1133
-        }
1134
-    }
1135
-
1136
-
1137
-    /**
1138
-     * Used to retrieve registrations for the list table.
1139
-     *
1140
-     * @param int  $per_page
1141
-     * @param bool $count
1142
-     * @param bool $this_month
1143
-     * @param bool $today
1144
-     * @return EE_Registration[]|int
1145
-     * @throws EE_Error
1146
-     * @throws InvalidArgumentException
1147
-     * @throws InvalidDataTypeException
1148
-     * @throws InvalidInterfaceException
1149
-     */
1150
-    public function get_registrations(
1151
-        $per_page = 10,
1152
-        $count = false,
1153
-        $this_month = false,
1154
-        $today = false
1155
-    ) {
1156
-        if ($this_month) {
1157
-            $this->_req_data['status'] = 'month';
1158
-        }
1159
-        if ($today) {
1160
-            $this->_req_data['status'] = 'today';
1161
-        }
1162
-        $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1163
-        /**
1164
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1165
-         *
1166
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1167
-         * @see  EEM_Base::get_all()
1168
-         */
1169
-        $query_params['group_by'] = '';
1170
-
1171
-        return $count
1172
-            ? EEM_Registration::instance()->count($query_params)
1173
-            /** @type EE_Registration[] */
1174
-            : EEM_Registration::instance()->get_all($query_params);
1175
-    }
1176
-
1177
-
1178
-    /**
1179
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1180
-     * Note: this listens to values on the request for some of the query parameters.
1181
-     *
1182
-     * @param array $request
1183
-     * @param int   $per_page
1184
-     * @param bool  $count
1185
-     * @return array
1186
-     * @throws EE_Error
1187
-     */
1188
-    protected function _get_registration_query_parameters(
1189
-        $request = array(),
1190
-        $per_page = 10,
1191
-        $count = false
1192
-    ) {
1193
-
1194
-        $query_params = array(
1195
-            0                          => $this->_get_where_conditions_for_registrations_query(
1196
-                $request
1197
-            ),
1198
-            'caps'                     => EEM_Registration::caps_read_admin,
1199
-            'default_where_conditions' => 'this_model_only',
1200
-        );
1201
-        if (! $count) {
1202
-            $query_params = array_merge(
1203
-                $query_params,
1204
-                $this->_get_orderby_for_registrations_query(),
1205
-                $this->_get_limit($per_page)
1206
-            );
1207
-        }
1208
-
1209
-        return $query_params;
1210
-    }
1211
-
1212
-
1213
-    /**
1214
-     * This will add ATT_ID to the provided $where array for EE model query parameters.
1215
-     *
1216
-     * @param array $request usually the same as $this->_req_data but not necessarily
1217
-     * @return array
1218
-     */
1219
-    protected function addAttendeeIdToWhereConditions(array $request)
1220
-    {
1221
-        $where = array();
1222
-        if (! empty($request['ATT_ID'])) {
1223
-            $where['ATT_ID'] = absint($request['ATT_ID']);
1224
-        }
1225
-        return $where;
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * This will add EVT_ID to the provided $where array for EE model query parameters.
1231
-     *
1232
-     * @param array $request usually the same as $this->_req_data but not necessarily
1233
-     * @return array
1234
-     */
1235
-    protected function _add_event_id_to_where_conditions(array $request)
1236
-    {
1237
-        $where = array();
1238
-        if (! empty($request['event_id'])) {
1239
-            $where['EVT_ID'] = absint($request['event_id']);
1240
-        }
1241
-        return $where;
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
1247
-     *
1248
-     * @param array $request usually the same as $this->_req_data but not necessarily
1249
-     * @return array
1250
-     */
1251
-    protected function _add_category_id_to_where_conditions(array $request)
1252
-    {
1253
-        $where = array();
1254
-        if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1255
-            $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1256
-        }
1257
-        return $where;
1258
-    }
1259
-
1260
-
1261
-    /**
1262
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1263
-     *
1264
-     * @param array $request usually the same as $this->_req_data but not necessarily
1265
-     * @return array
1266
-     */
1267
-    protected function _add_datetime_id_to_where_conditions(array $request)
1268
-    {
1269
-        $where = array();
1270
-        if (! empty($request['datetime_id'])) {
1271
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1272
-        }
1273
-        if (! empty($request['DTT_ID'])) {
1274
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1275
-        }
1276
-        return $where;
1277
-    }
1278
-
1279
-
1280
-    /**
1281
-     * Adds the correct registration status to the where conditions for the registrations query.
1282
-     *
1283
-     * @param array $request usually the same as $this->_req_data but not necessarily
1284
-     * @return array
1285
-     */
1286
-    protected function _add_registration_status_to_where_conditions(array $request)
1287
-    {
1288
-        $where = array();
1289
-        $view = EEH_Array::is_set($request, 'status', '');
1290
-        $registration_status = ! empty($request['_reg_status'])
1291
-            ? sanitize_text_field($request['_reg_status'])
1292
-            : '';
1293
-
1294
-        /*
22
+	/**
23
+	 * @var EE_Registration
24
+	 */
25
+	private $_registration;
26
+
27
+	/**
28
+	 * @var EE_Event
29
+	 */
30
+	private $_reg_event;
31
+
32
+	/**
33
+	 * @var EE_Session
34
+	 */
35
+	private $_session;
36
+
37
+	private static $_reg_status;
38
+
39
+	/**
40
+	 * Form for displaying the custom questions for this registration.
41
+	 * This gets used a few times throughout the request so its best to cache it
42
+	 *
43
+	 * @var EE_Registration_Custom_Questions_Form
44
+	 */
45
+	protected $_reg_custom_questions_form = null;
46
+
47
+
48
+	/**
49
+	 *        constructor
50
+	 *
51
+	 * @Constructor
52
+	 * @access public
53
+	 * @param bool $routing
54
+	 * @return Registrations_Admin_Page
55
+	 */
56
+	public function __construct($routing = true)
57
+	{
58
+		parent::__construct($routing);
59
+		add_action('wp_loaded', array($this, 'wp_loaded'));
60
+	}
61
+
62
+
63
+	public function wp_loaded()
64
+	{
65
+		// when adding a new registration...
66
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67
+			EE_System::do_not_cache();
68
+			if (! isset($this->_req_data['processing_registration'])
69
+				|| absint($this->_req_data['processing_registration']) !== 1
70
+			) {
71
+				// and it's NOT the attendee information reg step
72
+				// force cookie expiration by setting time to last week
73
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
74
+				// and update the global
75
+				$_COOKIE['ee_registration_added'] = 0;
76
+			}
77
+		}
78
+	}
79
+
80
+
81
+	protected function _init_page_props()
82
+	{
83
+		$this->page_slug = REG_PG_SLUG;
84
+		$this->_admin_base_url = REG_ADMIN_URL;
85
+		$this->_admin_base_path = REG_ADMIN;
86
+		$this->page_label = esc_html__('Registrations', 'event_espresso');
87
+		$this->_cpt_routes = array(
88
+			'add_new_attendee' => 'espresso_attendees',
89
+			'edit_attendee'    => 'espresso_attendees',
90
+			'insert_attendee'  => 'espresso_attendees',
91
+			'update_attendee'  => 'espresso_attendees',
92
+		);
93
+		$this->_cpt_model_names = array(
94
+			'add_new_attendee' => 'EEM_Attendee',
95
+			'edit_attendee'    => 'EEM_Attendee',
96
+		);
97
+		$this->_cpt_edit_routes = array(
98
+			'espresso_attendees' => 'edit_attendee',
99
+		);
100
+		$this->_pagenow_map = array(
101
+			'add_new_attendee' => 'post-new.php',
102
+			'edit_attendee'    => 'post.php',
103
+			'trash'            => 'post.php',
104
+		);
105
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
106
+		// add filters so that the comment urls don't take users to a confusing 404 page
107
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
108
+	}
109
+
110
+
111
+	public function clear_comment_link($link, $comment, $args)
112
+	{
113
+		// gotta make sure this only happens on this route
114
+		$post_type = get_post_type($comment->comment_post_ID);
115
+		if ($post_type === 'espresso_attendees') {
116
+			return '#commentsdiv';
117
+		}
118
+		return $link;
119
+	}
120
+
121
+
122
+	protected function _ajax_hooks()
123
+	{
124
+		// todo: all hooks for registrations ajax goes in here
125
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
126
+	}
127
+
128
+
129
+	protected function _define_page_props()
130
+	{
131
+		$this->_admin_page_title = $this->page_label;
132
+		$this->_labels = array(
133
+			'buttons'                      => array(
134
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
135
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
136
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
137
+				'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
138
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
139
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
140
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
141
+				'contact_list_export' => esc_html__("Export Data", "event_espresso"),
142
+			),
143
+			'publishbox'                   => array(
144
+				'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
145
+				'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
146
+			),
147
+			'hide_add_button_on_cpt_route' => array(
148
+				'edit_attendee' => true,
149
+			),
150
+		);
151
+	}
152
+
153
+
154
+	/**
155
+	 *        grab url requests and route them
156
+	 *
157
+	 * @access private
158
+	 * @return void
159
+	 */
160
+	public function _set_page_routes()
161
+	{
162
+		$this->_get_registration_status_array();
163
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
164
+			? $this->_req_data['_REG_ID'] : 0;
165
+		$reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
166
+			? $this->_req_data['reg_status_change_form']['REG_ID']
167
+			: $reg_id;
168
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
169
+			? $this->_req_data['ATT_ID'] : 0;
170
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
171
+			? $this->_req_data['post']
172
+			: $att_id;
173
+		$this->_page_routes = array(
174
+			'default'                             => array(
175
+				'func'       => '_registrations_overview_list_table',
176
+				'capability' => 'ee_read_registrations',
177
+			),
178
+			'view_registration'                   => array(
179
+				'func'       => '_registration_details',
180
+				'capability' => 'ee_read_registration',
181
+				'obj_id'     => $reg_id,
182
+			),
183
+			'edit_registration'                   => array(
184
+				'func'               => '_update_attendee_registration_form',
185
+				'noheader'           => true,
186
+				'headers_sent_route' => 'view_registration',
187
+				'capability'         => 'ee_edit_registration',
188
+				'obj_id'             => $reg_id,
189
+				'_REG_ID'            => $reg_id,
190
+			),
191
+			'trash_registrations'                 => array(
192
+				'func'       => '_trash_or_restore_registrations',
193
+				'args'       => array('trash' => true),
194
+				'noheader'   => true,
195
+				'capability' => 'ee_delete_registrations',
196
+			),
197
+			'restore_registrations'               => array(
198
+				'func'       => '_trash_or_restore_registrations',
199
+				'args'       => array('trash' => false),
200
+				'noheader'   => true,
201
+				'capability' => 'ee_delete_registrations',
202
+			),
203
+			'delete_registrations'                => array(
204
+				'func'       => '_delete_registrations',
205
+				'noheader'   => true,
206
+				'capability' => 'ee_delete_registrations',
207
+			),
208
+			'new_registration'                    => array(
209
+				'func'       => 'new_registration',
210
+				'capability' => 'ee_edit_registrations',
211
+			),
212
+			'process_reg_step'                    => array(
213
+				'func'       => 'process_reg_step',
214
+				'noheader'   => true,
215
+				'capability' => 'ee_edit_registrations',
216
+			),
217
+			'redirect_to_txn'                     => array(
218
+				'func'       => 'redirect_to_txn',
219
+				'noheader'   => true,
220
+				'capability' => 'ee_edit_registrations',
221
+			),
222
+			'change_reg_status'                   => array(
223
+				'func'       => '_change_reg_status',
224
+				'noheader'   => true,
225
+				'capability' => 'ee_edit_registration',
226
+				'obj_id'     => $reg_id,
227
+			),
228
+			'approve_registration'                => array(
229
+				'func'       => 'approve_registration',
230
+				'noheader'   => true,
231
+				'capability' => 'ee_edit_registration',
232
+				'obj_id'     => $reg_id,
233
+			),
234
+			'approve_and_notify_registration'     => array(
235
+				'func'       => 'approve_registration',
236
+				'noheader'   => true,
237
+				'args'       => array(true),
238
+				'capability' => 'ee_edit_registration',
239
+				'obj_id'     => $reg_id,
240
+			),
241
+			'approve_registrations'               => array(
242
+				'func'       => 'bulk_action_on_registrations',
243
+				'noheader'   => true,
244
+				'capability' => 'ee_edit_registrations',
245
+				'args'       => array('approve'),
246
+			),
247
+			'approve_and_notify_registrations'    => array(
248
+				'func'       => 'bulk_action_on_registrations',
249
+				'noheader'   => true,
250
+				'capability' => 'ee_edit_registrations',
251
+				'args'       => array('approve', true),
252
+			),
253
+			'decline_registration'                => array(
254
+				'func'       => 'decline_registration',
255
+				'noheader'   => true,
256
+				'capability' => 'ee_edit_registration',
257
+				'obj_id'     => $reg_id,
258
+			),
259
+			'decline_and_notify_registration'     => array(
260
+				'func'       => 'decline_registration',
261
+				'noheader'   => true,
262
+				'args'       => array(true),
263
+				'capability' => 'ee_edit_registration',
264
+				'obj_id'     => $reg_id,
265
+			),
266
+			'decline_registrations'               => array(
267
+				'func'       => 'bulk_action_on_registrations',
268
+				'noheader'   => true,
269
+				'capability' => 'ee_edit_registrations',
270
+				'args'       => array('decline'),
271
+			),
272
+			'decline_and_notify_registrations'    => array(
273
+				'func'       => 'bulk_action_on_registrations',
274
+				'noheader'   => true,
275
+				'capability' => 'ee_edit_registrations',
276
+				'args'       => array('decline', true),
277
+			),
278
+			'pending_registration'                => array(
279
+				'func'       => 'pending_registration',
280
+				'noheader'   => true,
281
+				'capability' => 'ee_edit_registration',
282
+				'obj_id'     => $reg_id,
283
+			),
284
+			'pending_and_notify_registration'     => array(
285
+				'func'       => 'pending_registration',
286
+				'noheader'   => true,
287
+				'args'       => array(true),
288
+				'capability' => 'ee_edit_registration',
289
+				'obj_id'     => $reg_id,
290
+			),
291
+			'pending_registrations'               => array(
292
+				'func'       => 'bulk_action_on_registrations',
293
+				'noheader'   => true,
294
+				'capability' => 'ee_edit_registrations',
295
+				'args'       => array('pending'),
296
+			),
297
+			'pending_and_notify_registrations'    => array(
298
+				'func'       => 'bulk_action_on_registrations',
299
+				'noheader'   => true,
300
+				'capability' => 'ee_edit_registrations',
301
+				'args'       => array('pending', true),
302
+			),
303
+			'no_approve_registration'             => array(
304
+				'func'       => 'not_approve_registration',
305
+				'noheader'   => true,
306
+				'capability' => 'ee_edit_registration',
307
+				'obj_id'     => $reg_id,
308
+			),
309
+			'no_approve_and_notify_registration'  => array(
310
+				'func'       => 'not_approve_registration',
311
+				'noheader'   => true,
312
+				'args'       => array(true),
313
+				'capability' => 'ee_edit_registration',
314
+				'obj_id'     => $reg_id,
315
+			),
316
+			'no_approve_registrations'            => array(
317
+				'func'       => 'bulk_action_on_registrations',
318
+				'noheader'   => true,
319
+				'capability' => 'ee_edit_registrations',
320
+				'args'       => array('not_approve'),
321
+			),
322
+			'no_approve_and_notify_registrations' => array(
323
+				'func'       => 'bulk_action_on_registrations',
324
+				'noheader'   => true,
325
+				'capability' => 'ee_edit_registrations',
326
+				'args'       => array('not_approve', true),
327
+			),
328
+			'cancel_registration'                 => array(
329
+				'func'       => 'cancel_registration',
330
+				'noheader'   => true,
331
+				'capability' => 'ee_edit_registration',
332
+				'obj_id'     => $reg_id,
333
+			),
334
+			'cancel_and_notify_registration'      => array(
335
+				'func'       => 'cancel_registration',
336
+				'noheader'   => true,
337
+				'args'       => array(true),
338
+				'capability' => 'ee_edit_registration',
339
+				'obj_id'     => $reg_id,
340
+			),
341
+			'cancel_registrations'                => array(
342
+				'func'       => 'bulk_action_on_registrations',
343
+				'noheader'   => true,
344
+				'capability' => 'ee_edit_registrations',
345
+				'args'       => array('cancel'),
346
+			),
347
+			'cancel_and_notify_registrations'     => array(
348
+				'func'       => 'bulk_action_on_registrations',
349
+				'noheader'   => true,
350
+				'capability' => 'ee_edit_registrations',
351
+				'args'       => array('cancel', true),
352
+			),
353
+			'wait_list_registration'              => array(
354
+				'func'       => 'wait_list_registration',
355
+				'noheader'   => true,
356
+				'capability' => 'ee_edit_registration',
357
+				'obj_id'     => $reg_id,
358
+			),
359
+			'wait_list_and_notify_registration'   => array(
360
+				'func'       => 'wait_list_registration',
361
+				'noheader'   => true,
362
+				'args'       => array(true),
363
+				'capability' => 'ee_edit_registration',
364
+				'obj_id'     => $reg_id,
365
+			),
366
+			'contact_list'                        => array(
367
+				'func'       => '_attendee_contact_list_table',
368
+				'capability' => 'ee_read_contacts',
369
+			),
370
+			'add_new_attendee'                    => array(
371
+				'func' => '_create_new_cpt_item',
372
+				'args' => array(
373
+					'new_attendee' => true,
374
+					'capability'   => 'ee_edit_contacts',
375
+				),
376
+			),
377
+			'edit_attendee'                       => array(
378
+				'func'       => '_edit_cpt_item',
379
+				'capability' => 'ee_edit_contacts',
380
+				'obj_id'     => $att_id,
381
+			),
382
+			'duplicate_attendee'                  => array(
383
+				'func'       => '_duplicate_attendee',
384
+				'noheader'   => true,
385
+				'capability' => 'ee_edit_contacts',
386
+				'obj_id'     => $att_id,
387
+			),
388
+			'insert_attendee'                     => array(
389
+				'func'       => '_insert_or_update_attendee',
390
+				'args'       => array(
391
+					'new_attendee' => true,
392
+				),
393
+				'noheader'   => true,
394
+				'capability' => 'ee_edit_contacts',
395
+			),
396
+			'update_attendee'                     => array(
397
+				'func'       => '_insert_or_update_attendee',
398
+				'args'       => array(
399
+					'new_attendee' => false,
400
+				),
401
+				'noheader'   => true,
402
+				'capability' => 'ee_edit_contacts',
403
+				'obj_id'     => $att_id,
404
+			),
405
+			'trash_attendees'                     => array(
406
+				'func'       => '_trash_or_restore_attendees',
407
+				'args'       => array(
408
+					'trash' => 'true',
409
+				),
410
+				'noheader'   => true,
411
+				'capability' => 'ee_delete_contacts',
412
+			),
413
+			'trash_attendee'                      => array(
414
+				'func'       => '_trash_or_restore_attendees',
415
+				'args'       => array(
416
+					'trash' => true,
417
+				),
418
+				'noheader'   => true,
419
+				'capability' => 'ee_delete_contacts',
420
+				'obj_id'     => $att_id,
421
+			),
422
+			'restore_attendees'                   => array(
423
+				'func'       => '_trash_or_restore_attendees',
424
+				'args'       => array(
425
+					'trash' => false,
426
+				),
427
+				'noheader'   => true,
428
+				'capability' => 'ee_delete_contacts',
429
+				'obj_id'     => $att_id,
430
+			),
431
+			'resend_registration'                 => array(
432
+				'func'       => '_resend_registration',
433
+				'noheader'   => true,
434
+				'capability' => 'ee_send_message',
435
+			),
436
+			'registrations_report'                => array(
437
+				'func'       => '_registrations_report',
438
+				'noheader'   => true,
439
+				'capability' => 'ee_read_registrations',
440
+			),
441
+			'contact_list_export'                 => array(
442
+				'func'       => '_contact_list_export',
443
+				'noheader'   => true,
444
+				'capability' => 'export',
445
+			),
446
+			'contact_list_report'                 => array(
447
+				'func'       => '_contact_list_report',
448
+				'noheader'   => true,
449
+				'capability' => 'ee_read_contacts',
450
+			),
451
+		);
452
+	}
453
+
454
+
455
+	protected function _set_page_config()
456
+	{
457
+		$this->_page_config = array(
458
+			'default'           => array(
459
+				'nav'           => array(
460
+					'label' => esc_html__('Overview', 'event_espresso'),
461
+					'order' => 5,
462
+				),
463
+				'help_tabs'     => array(
464
+					'registrations_overview_help_tab'                       => array(
465
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
466
+						'filename' => 'registrations_overview',
467
+					),
468
+					'registrations_overview_table_column_headings_help_tab' => array(
469
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
470
+						'filename' => 'registrations_overview_table_column_headings',
471
+					),
472
+					'registrations_overview_filters_help_tab'               => array(
473
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
474
+						'filename' => 'registrations_overview_filters',
475
+					),
476
+					'registrations_overview_views_help_tab'                 => array(
477
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
478
+						'filename' => 'registrations_overview_views',
479
+					),
480
+					'registrations_regoverview_other_help_tab'              => array(
481
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
482
+						'filename' => 'registrations_overview_other',
483
+					),
484
+				),
485
+				'help_tour'     => array('Registration_Overview_Help_Tour'),
486
+				'qtips'         => array('Registration_List_Table_Tips'),
487
+				'list_table'    => 'EE_Registrations_List_Table',
488
+				'require_nonce' => false,
489
+			),
490
+			'view_registration' => array(
491
+				'nav'           => array(
492
+					'label'      => esc_html__('REG Details', 'event_espresso'),
493
+					'order'      => 15,
494
+					'url'        => isset($this->_req_data['_REG_ID'])
495
+						? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
496
+						: $this->_admin_base_url,
497
+					'persistent' => false,
498
+				),
499
+				'help_tabs'     => array(
500
+					'registrations_details_help_tab'                    => array(
501
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
502
+						'filename' => 'registrations_details',
503
+					),
504
+					'registrations_details_table_help_tab'              => array(
505
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
506
+						'filename' => 'registrations_details_table',
507
+					),
508
+					'registrations_details_form_answers_help_tab'       => array(
509
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
510
+						'filename' => 'registrations_details_form_answers',
511
+					),
512
+					'registrations_details_registrant_details_help_tab' => array(
513
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
514
+						'filename' => 'registrations_details_registrant_details',
515
+					),
516
+				),
517
+				'help_tour'     => array('Registration_Details_Help_Tour'),
518
+				'metaboxes'     => array_merge(
519
+					$this->_default_espresso_metaboxes,
520
+					array('_registration_details_metaboxes')
521
+				),
522
+				'require_nonce' => false,
523
+			),
524
+			'new_registration'  => array(
525
+				'nav'           => array(
526
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
527
+					'url'        => '#',
528
+					'order'      => 15,
529
+					'persistent' => false,
530
+				),
531
+				'metaboxes'     => $this->_default_espresso_metaboxes,
532
+				'labels'        => array(
533
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
534
+				),
535
+				'require_nonce' => false,
536
+			),
537
+			'add_new_attendee'  => array(
538
+				'nav'           => array(
539
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
540
+					'order'      => 15,
541
+					'persistent' => false,
542
+				),
543
+				'metaboxes'     => array_merge(
544
+					$this->_default_espresso_metaboxes,
545
+					array('_publish_post_box', 'attendee_editor_metaboxes')
546
+				),
547
+				'require_nonce' => false,
548
+			),
549
+			'edit_attendee'     => array(
550
+				'nav'           => array(
551
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
552
+					'order'      => 15,
553
+					'persistent' => false,
554
+					'url'        => isset($this->_req_data['ATT_ID'])
555
+						? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
556
+						: $this->_admin_base_url,
557
+				),
558
+				'metaboxes'     => array('attendee_editor_metaboxes'),
559
+				'require_nonce' => false,
560
+			),
561
+			'contact_list'      => array(
562
+				'nav'           => array(
563
+					'label' => esc_html__('Contact List', 'event_espresso'),
564
+					'order' => 20,
565
+				),
566
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
567
+				'help_tabs'     => array(
568
+					'registrations_contact_list_help_tab'                       => array(
569
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
570
+						'filename' => 'registrations_contact_list',
571
+					),
572
+					'registrations_contact-list_table_column_headings_help_tab' => array(
573
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
574
+						'filename' => 'registrations_contact_list_table_column_headings',
575
+					),
576
+					'registrations_contact_list_views_help_tab'                 => array(
577
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
578
+						'filename' => 'registrations_contact_list_views',
579
+					),
580
+					'registrations_contact_list_other_help_tab'                 => array(
581
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
582
+						'filename' => 'registrations_contact_list_other',
583
+					),
584
+				),
585
+				'help_tour'     => array('Contact_List_Help_Tour'),
586
+				'metaboxes'     => array(),
587
+				'require_nonce' => false,
588
+			),
589
+			// override default cpt routes
590
+			'create_new'        => '',
591
+			'edit'              => '',
592
+		);
593
+	}
594
+
595
+
596
+	/**
597
+	 * The below methods aren't used by this class currently
598
+	 */
599
+	protected function _add_screen_options()
600
+	{
601
+	}
602
+
603
+
604
+	protected function _add_feature_pointers()
605
+	{
606
+	}
607
+
608
+
609
+	public function admin_init()
610
+	{
611
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
612
+			'click "Update Registration Questions" to save your changes',
613
+			'event_espresso'
614
+		);
615
+	}
616
+
617
+
618
+	public function admin_notices()
619
+	{
620
+	}
621
+
622
+
623
+	public function admin_footer_scripts()
624
+	{
625
+	}
626
+
627
+
628
+	/**
629
+	 *        get list of registration statuses
630
+	 *
631
+	 * @access private
632
+	 * @return void
633
+	 * @throws EE_Error
634
+	 */
635
+	private function _get_registration_status_array()
636
+	{
637
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
638
+	}
639
+
640
+
641
+	protected function _add_screen_options_default()
642
+	{
643
+		$this->_per_page_screen_option();
644
+	}
645
+
646
+
647
+	protected function _add_screen_options_contact_list()
648
+	{
649
+		$page_title = $this->_admin_page_title;
650
+		$this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
651
+		$this->_per_page_screen_option();
652
+		$this->_admin_page_title = $page_title;
653
+	}
654
+
655
+
656
+	public function load_scripts_styles()
657
+	{
658
+		// style
659
+		wp_register_style(
660
+			'espresso_reg',
661
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
662
+			array('ee-admin-css'),
663
+			EVENT_ESPRESSO_VERSION
664
+		);
665
+		wp_enqueue_style('espresso_reg');
666
+		// script
667
+		wp_register_script(
668
+			'espresso_reg',
669
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
670
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671
+			EVENT_ESPRESSO_VERSION,
672
+			true
673
+		);
674
+		wp_enqueue_script('espresso_reg');
675
+	}
676
+
677
+
678
+	public function load_scripts_styles_edit_attendee()
679
+	{
680
+		// stuff to only show up on our attendee edit details page.
681
+		$attendee_details_translations = array(
682
+			'att_publish_text' => sprintf(
683
+				esc_html__('Created on: <b>%1$s</b>', 'event_espresso'),
684
+				$this->_cpt_model_obj->get_datetime('ATT_created')
685
+			),
686
+		);
687
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
688
+		wp_enqueue_script('jquery-validate');
689
+	}
690
+
691
+
692
+	public function load_scripts_styles_view_registration()
693
+	{
694
+		// styles
695
+		wp_enqueue_style('espresso-ui-theme');
696
+		// scripts
697
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
698
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
699
+	}
700
+
701
+
702
+	public function load_scripts_styles_contact_list()
703
+	{
704
+		wp_dequeue_style('espresso_reg');
705
+		wp_register_style(
706
+			'espresso_att',
707
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
708
+			array('ee-admin-css'),
709
+			EVENT_ESPRESSO_VERSION
710
+		);
711
+		wp_enqueue_style('espresso_att');
712
+	}
713
+
714
+
715
+	public function load_scripts_styles_new_registration()
716
+	{
717
+		wp_register_script(
718
+			'ee-spco-for-admin',
719
+			REG_ASSETS_URL . 'spco_for_admin.js',
720
+			array('underscore', 'jquery'),
721
+			EVENT_ESPRESSO_VERSION,
722
+			true
723
+		);
724
+		wp_enqueue_script('ee-spco-for-admin');
725
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
726
+		EE_Form_Section_Proper::wp_enqueue_scripts();
727
+		EED_Ticket_Selector::load_tckt_slctr_assets();
728
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
729
+	}
730
+
731
+
732
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
733
+	{
734
+		add_filter('FHEE_load_EE_messages', '__return_true');
735
+	}
736
+
737
+
738
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
739
+	{
740
+		add_filter('FHEE_load_EE_messages', '__return_true');
741
+	}
742
+
743
+
744
+	protected function _set_list_table_views_default()
745
+	{
746
+		// for notification related bulk actions we need to make sure only active messengers have an option.
747
+		EED_Messages::set_autoloaders();
748
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
749
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
750
+		$active_mts = $message_resource_manager->list_of_active_message_types();
751
+		// key= bulk_action_slug, value= message type.
752
+		$match_array = array(
753
+			'approve_registrations'    => 'registration',
754
+			'decline_registrations'    => 'declined_registration',
755
+			'pending_registrations'    => 'pending_approval',
756
+			'no_approve_registrations' => 'not_approved_registration',
757
+			'cancel_registrations'     => 'cancelled_registration',
758
+		);
759
+		$can_send = EE_Registry::instance()->CAP->current_user_can(
760
+			'ee_send_message',
761
+			'batch_send_messages'
762
+		);
763
+		/** setup reg status bulk actions **/
764
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
765
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
766
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
767
+				'Approve and Notify Registrations',
768
+				'event_espresso'
769
+			);
770
+		}
771
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
772
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
773
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
774
+				'Decline and Notify Registrations',
775
+				'event_espresso'
776
+			);
777
+		}
778
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
779
+			'Set Registrations to Pending Payment',
780
+			'event_espresso'
781
+		);
782
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
783
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
784
+				'Set Registrations to Pending Payment and Notify',
785
+				'event_espresso'
786
+			);
787
+		}
788
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
789
+			'Set Registrations to Not Approved',
790
+			'event_espresso'
791
+		);
792
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
793
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
794
+				'Set Registrations to Not Approved and Notify',
795
+				'event_espresso'
796
+			);
797
+		}
798
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
799
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
800
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
801
+				'Cancel Registrations and Notify',
802
+				'event_espresso'
803
+			);
804
+		}
805
+		$def_reg_status_actions = apply_filters(
806
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
807
+			$def_reg_status_actions,
808
+			$active_mts,
809
+			$can_send
810
+		);
811
+
812
+		$this->_views = array(
813
+			'all'   => array(
814
+				'slug'        => 'all',
815
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
816
+				'count'       => 0,
817
+				'bulk_action' => array_merge(
818
+					$def_reg_status_actions,
819
+					array(
820
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
821
+					)
822
+				),
823
+			),
824
+			'month' => array(
825
+				'slug'        => 'month',
826
+				'label'       => esc_html__('This Month', 'event_espresso'),
827
+				'count'       => 0,
828
+				'bulk_action' => array_merge(
829
+					$def_reg_status_actions,
830
+					array(
831
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
832
+					)
833
+				),
834
+			),
835
+			'today' => array(
836
+				'slug'        => 'today',
837
+				'label'       => sprintf(
838
+					esc_html__('Today - %s', 'event_espresso'),
839
+					date('M d, Y', current_time('timestamp'))
840
+				),
841
+				'count'       => 0,
842
+				'bulk_action' => array_merge(
843
+					$def_reg_status_actions,
844
+					array(
845
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
846
+					)
847
+				),
848
+			),
849
+		);
850
+		if (EE_Registry::instance()->CAP->current_user_can(
851
+			'ee_delete_registrations',
852
+			'espresso_registrations_delete_registration'
853
+		)) {
854
+			$this->_views['incomplete'] = array(
855
+				'slug'        => 'incomplete',
856
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
857
+				'count'       => 0,
858
+				'bulk_action' => array(
859
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
860
+				),
861
+			);
862
+			$this->_views['trash'] = array(
863
+				'slug'        => 'trash',
864
+				'label'       => esc_html__('Trash', 'event_espresso'),
865
+				'count'       => 0,
866
+				'bulk_action' => array(
867
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
868
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
869
+				),
870
+			);
871
+		}
872
+	}
873
+
874
+
875
+	protected function _set_list_table_views_contact_list()
876
+	{
877
+		$this->_views = array(
878
+			'in_use' => array(
879
+				'slug'        => 'in_use',
880
+				'label'       => esc_html__('In Use', 'event_espresso'),
881
+				'count'       => 0,
882
+				'bulk_action' => array(
883
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
884
+				),
885
+			),
886
+		);
887
+		if (EE_Registry::instance()->CAP->current_user_can(
888
+			'ee_delete_contacts',
889
+			'espresso_registrations_trash_attendees'
890
+		)
891
+		) {
892
+			$this->_views['trash'] = array(
893
+				'slug'        => 'trash',
894
+				'label'       => esc_html__('Trash', 'event_espresso'),
895
+				'count'       => 0,
896
+				'bulk_action' => array(
897
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
898
+				),
899
+			);
900
+		}
901
+	}
902
+
903
+
904
+	protected function _registration_legend_items()
905
+	{
906
+		$fc_items = array(
907
+			'star-icon'        => array(
908
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
909
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
910
+			),
911
+			'view_details'     => array(
912
+				'class' => 'dashicons dashicons-clipboard',
913
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
914
+			),
915
+			'edit_attendee'    => array(
916
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
917
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
918
+			),
919
+			'view_transaction' => array(
920
+				'class' => 'dashicons dashicons-cart',
921
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
922
+			),
923
+			'view_invoice'     => array(
924
+				'class' => 'dashicons dashicons-media-spreadsheet',
925
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
926
+			),
927
+		);
928
+		if (EE_Registry::instance()->CAP->current_user_can(
929
+			'ee_send_message',
930
+			'espresso_registrations_resend_registration'
931
+		)) {
932
+			$fc_items['resend_registration'] = array(
933
+				'class' => 'dashicons dashicons-email-alt',
934
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
935
+			);
936
+		} else {
937
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
938
+		}
939
+		if (EE_Registry::instance()->CAP->current_user_can(
940
+			'ee_read_global_messages',
941
+			'view_filtered_messages'
942
+		)) {
943
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
944
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
945
+				$fc_items['view_related_messages'] = array(
946
+					'class' => $related_for_icon['css_class'],
947
+					'desc'  => $related_for_icon['label'],
948
+				);
949
+			}
950
+		}
951
+		$sc_items = array(
952
+			'approved_status'   => array(
953
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
+				'desc'  => EEH_Template::pretty_status(
955
+					EEM_Registration::status_id_approved,
956
+					false,
957
+					'sentence'
958
+				),
959
+			),
960
+			'pending_status'    => array(
961
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
+				'desc'  => EEH_Template::pretty_status(
963
+					EEM_Registration::status_id_pending_payment,
964
+					false,
965
+					'sentence'
966
+				),
967
+			),
968
+			'wait_list'         => array(
969
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
+				'desc'  => EEH_Template::pretty_status(
971
+					EEM_Registration::status_id_wait_list,
972
+					false,
973
+					'sentence'
974
+				),
975
+			),
976
+			'incomplete_status' => array(
977
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
+				'desc'  => EEH_Template::pretty_status(
979
+					EEM_Registration::status_id_incomplete,
980
+					false,
981
+					'sentence'
982
+				),
983
+			),
984
+			'not_approved'      => array(
985
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
+				'desc'  => EEH_Template::pretty_status(
987
+					EEM_Registration::status_id_not_approved,
988
+					false,
989
+					'sentence'
990
+				),
991
+			),
992
+			'declined_status'   => array(
993
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
+				'desc'  => EEH_Template::pretty_status(
995
+					EEM_Registration::status_id_declined,
996
+					false,
997
+					'sentence'
998
+				),
999
+			),
1000
+			'cancelled_status'  => array(
1001
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
+				'desc'  => EEH_Template::pretty_status(
1003
+					EEM_Registration::status_id_cancelled,
1004
+					false,
1005
+					'sentence'
1006
+				),
1007
+			),
1008
+		);
1009
+		return array_merge($fc_items, $sc_items);
1010
+	}
1011
+
1012
+
1013
+
1014
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1015
+	/**
1016
+	 * @throws \EE_Error
1017
+	 */
1018
+	protected function _registrations_overview_list_table()
1019
+	{
1020
+		$this->_template_args['admin_page_header'] = '';
1021
+		$EVT_ID = ! empty($this->_req_data['event_id'])
1022
+			? absint($this->_req_data['event_id'])
1023
+			: 0;
1024
+		$ATT_ID = ! empty($this->_req_data['ATT_ID'])
1025
+			? absint($this->_req_data['ATT_ID'])
1026
+			: 0;
1027
+		if ($ATT_ID) {
1028
+			$attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1029
+			if ($attendee instanceof EE_Attendee) {
1030
+				$this->_template_args['admin_page_header'] = sprintf(
1031
+					esc_html__(
1032
+						'%1$s Viewing registrations for %2$s%3$s',
1033
+						'event_espresso'
1034
+					),
1035
+					'<h3 style="line-height:1.5em;">',
1036
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
+						array(
1038
+							'action' => 'edit_attendee',
1039
+							'post'   => $ATT_ID,
1040
+						),
1041
+						REG_ADMIN_URL
1042
+					) . '">' . $attendee->full_name() . '</a>',
1043
+					'</h3>'
1044
+				);
1045
+			}
1046
+		}
1047
+		if ($EVT_ID) {
1048
+			if (EE_Registry::instance()->CAP->current_user_can(
1049
+				'ee_edit_registrations',
1050
+				'espresso_registrations_new_registration',
1051
+				$EVT_ID
1052
+			)) {
1053
+				$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
+					'new_registration',
1055
+					'add-registrant',
1056
+					array('event_id' => $EVT_ID),
1057
+					'add-new-h2'
1058
+				);
1059
+			}
1060
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1061
+			if ($event instanceof EE_Event) {
1062
+				$this->_template_args['admin_page_header'] = sprintf(
1063
+					esc_html__(
1064
+						'%s Viewing registrations for the event: %s%s',
1065
+						'event_espresso'
1066
+					),
1067
+					'<h3 style="line-height:1.5em;">',
1068
+					'<br /><a href="'
1069
+					. EE_Admin_Page::add_query_args_and_nonce(
1070
+						array(
1071
+							'action' => 'edit',
1072
+							'post'   => $event->ID(),
1073
+						),
1074
+						EVENTS_ADMIN_URL
1075
+					)
1076
+					. '">&nbsp;'
1077
+					. $event->get('EVT_name')
1078
+					. '&nbsp;</a>&nbsp;',
1079
+					'</h3>'
1080
+				);
1081
+			}
1082
+			$DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1083
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1084
+			if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1085
+				$this->_template_args['admin_page_header'] = substr(
1086
+					$this->_template_args['admin_page_header'],
1087
+					0,
1088
+					-5
1089
+				);
1090
+				$this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091
+				$this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092
+				$this->_template_args['admin_page_header'] .= $datetime->name();
1093
+				$this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
+				$this->_template_args['admin_page_header'] .= '</span></h3>';
1095
+			}
1096
+		}
1097
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1098
+		$this->display_admin_list_table_page_with_no_sidebar();
1099
+	}
1100
+
1101
+
1102
+	/**
1103
+	 * This sets the _registration property for the registration details screen
1104
+	 *
1105
+	 * @access private
1106
+	 * @return bool
1107
+	 * @throws EE_Error
1108
+	 * @throws InvalidArgumentException
1109
+	 * @throws InvalidDataTypeException
1110
+	 * @throws InvalidInterfaceException
1111
+	 */
1112
+	private function _set_registration_object()
1113
+	{
1114
+		// get out if we've already set the object
1115
+		if ($this->_registration instanceof EE_Registration) {
1116
+			return true;
1117
+		}
1118
+		$REG = EEM_Registration::instance();
1119
+		$REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121
+			return true;
1122
+		} else {
1123
+			$error_msg = sprintf(
1124
+				esc_html__(
1125
+					'An error occurred and the details for Registration ID #%s could not be retrieved.',
1126
+					'event_espresso'
1127
+				),
1128
+				$REG_ID
1129
+			);
1130
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1131
+			$this->_registration = null;
1132
+			return false;
1133
+		}
1134
+	}
1135
+
1136
+
1137
+	/**
1138
+	 * Used to retrieve registrations for the list table.
1139
+	 *
1140
+	 * @param int  $per_page
1141
+	 * @param bool $count
1142
+	 * @param bool $this_month
1143
+	 * @param bool $today
1144
+	 * @return EE_Registration[]|int
1145
+	 * @throws EE_Error
1146
+	 * @throws InvalidArgumentException
1147
+	 * @throws InvalidDataTypeException
1148
+	 * @throws InvalidInterfaceException
1149
+	 */
1150
+	public function get_registrations(
1151
+		$per_page = 10,
1152
+		$count = false,
1153
+		$this_month = false,
1154
+		$today = false
1155
+	) {
1156
+		if ($this_month) {
1157
+			$this->_req_data['status'] = 'month';
1158
+		}
1159
+		if ($today) {
1160
+			$this->_req_data['status'] = 'today';
1161
+		}
1162
+		$query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1163
+		/**
1164
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1165
+		 *
1166
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1167
+		 * @see  EEM_Base::get_all()
1168
+		 */
1169
+		$query_params['group_by'] = '';
1170
+
1171
+		return $count
1172
+			? EEM_Registration::instance()->count($query_params)
1173
+			/** @type EE_Registration[] */
1174
+			: EEM_Registration::instance()->get_all($query_params);
1175
+	}
1176
+
1177
+
1178
+	/**
1179
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1180
+	 * Note: this listens to values on the request for some of the query parameters.
1181
+	 *
1182
+	 * @param array $request
1183
+	 * @param int   $per_page
1184
+	 * @param bool  $count
1185
+	 * @return array
1186
+	 * @throws EE_Error
1187
+	 */
1188
+	protected function _get_registration_query_parameters(
1189
+		$request = array(),
1190
+		$per_page = 10,
1191
+		$count = false
1192
+	) {
1193
+
1194
+		$query_params = array(
1195
+			0                          => $this->_get_where_conditions_for_registrations_query(
1196
+				$request
1197
+			),
1198
+			'caps'                     => EEM_Registration::caps_read_admin,
1199
+			'default_where_conditions' => 'this_model_only',
1200
+		);
1201
+		if (! $count) {
1202
+			$query_params = array_merge(
1203
+				$query_params,
1204
+				$this->_get_orderby_for_registrations_query(),
1205
+				$this->_get_limit($per_page)
1206
+			);
1207
+		}
1208
+
1209
+		return $query_params;
1210
+	}
1211
+
1212
+
1213
+	/**
1214
+	 * This will add ATT_ID to the provided $where array for EE model query parameters.
1215
+	 *
1216
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1217
+	 * @return array
1218
+	 */
1219
+	protected function addAttendeeIdToWhereConditions(array $request)
1220
+	{
1221
+		$where = array();
1222
+		if (! empty($request['ATT_ID'])) {
1223
+			$where['ATT_ID'] = absint($request['ATT_ID']);
1224
+		}
1225
+		return $where;
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * This will add EVT_ID to the provided $where array for EE model query parameters.
1231
+	 *
1232
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1233
+	 * @return array
1234
+	 */
1235
+	protected function _add_event_id_to_where_conditions(array $request)
1236
+	{
1237
+		$where = array();
1238
+		if (! empty($request['event_id'])) {
1239
+			$where['EVT_ID'] = absint($request['event_id']);
1240
+		}
1241
+		return $where;
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
1247
+	 *
1248
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1249
+	 * @return array
1250
+	 */
1251
+	protected function _add_category_id_to_where_conditions(array $request)
1252
+	{
1253
+		$where = array();
1254
+		if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1255
+			$where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1256
+		}
1257
+		return $where;
1258
+	}
1259
+
1260
+
1261
+	/**
1262
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1263
+	 *
1264
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1265
+	 * @return array
1266
+	 */
1267
+	protected function _add_datetime_id_to_where_conditions(array $request)
1268
+	{
1269
+		$where = array();
1270
+		if (! empty($request['datetime_id'])) {
1271
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1272
+		}
1273
+		if (! empty($request['DTT_ID'])) {
1274
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1275
+		}
1276
+		return $where;
1277
+	}
1278
+
1279
+
1280
+	/**
1281
+	 * Adds the correct registration status to the where conditions for the registrations query.
1282
+	 *
1283
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1284
+	 * @return array
1285
+	 */
1286
+	protected function _add_registration_status_to_where_conditions(array $request)
1287
+	{
1288
+		$where = array();
1289
+		$view = EEH_Array::is_set($request, 'status', '');
1290
+		$registration_status = ! empty($request['_reg_status'])
1291
+			? sanitize_text_field($request['_reg_status'])
1292
+			: '';
1293
+
1294
+		/*
1295 1295
          * If filtering by registration status, then we show registrations matching that status.
1296 1296
          * If not filtering by specified status, then we show all registrations excluding incomplete registrations
1297 1297
          * UNLESS viewing trashed registrations.
1298 1298
          */
1299
-        if (! empty($registration_status)) {
1300
-            $where['STS_ID'] = $registration_status;
1301
-        } else {
1302
-            // make sure we exclude incomplete registrations, but only if not trashed.
1303
-            if ($view === 'trash') {
1304
-                $where['REG_deleted'] = true;
1305
-            } elseif ($view === 'incomplete') {
1306
-                $where['STS_ID'] = EEM_Registration::status_id_incomplete;
1307
-            } else {
1308
-                $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1309
-            }
1310
-        }
1311
-        return $where;
1312
-    }
1313
-
1314
-
1315
-    /**
1316
-     * Adds any provided date restraints to the where conditions for the registrations query.
1317
-     *
1318
-     * @param array $request usually the same as $this->_req_data but not necessarily
1319
-     * @return array
1320
-     * @throws EE_Error
1321
-     * @throws InvalidArgumentException
1322
-     * @throws InvalidDataTypeException
1323
-     * @throws InvalidInterfaceException
1324
-     */
1325
-    protected function _add_date_to_where_conditions(array $request)
1326
-    {
1327
-        $where = array();
1328
-        $view = EEH_Array::is_set($request, 'status', '');
1329
-        $month_range = ! empty($request['month_range'])
1330
-            ? sanitize_text_field($request['month_range'])
1331
-            : '';
1332
-        $retrieve_for_today = $view === 'today';
1333
-        $retrieve_for_this_month = $view === 'month';
1334
-
1335
-        if ($retrieve_for_today) {
1336
-            $now = date('Y-m-d', current_time('timestamp'));
1337
-            $where['REG_date'] = array(
1338
-                'BETWEEN',
1339
-                array(
1340
-                    EEM_Registration::instance()->convert_datetime_for_query(
1341
-                        'REG_date',
1342
-                        $now . ' 00:00:00',
1343
-                        'Y-m-d H:i:s'
1344
-                    ),
1345
-                    EEM_Registration::instance()->convert_datetime_for_query(
1346
-                        'REG_date',
1347
-                        $now . ' 23:59:59',
1348
-                        'Y-m-d H:i:s'
1349
-                    ),
1350
-                ),
1351
-            );
1352
-        } elseif ($retrieve_for_this_month) {
1353
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
1354
-            $days_this_month = date('t', current_time('timestamp'));
1355
-            $where['REG_date'] = array(
1356
-                'BETWEEN',
1357
-                array(
1358
-                    EEM_Registration::instance()->convert_datetime_for_query(
1359
-                        'REG_date',
1360
-                        $current_year_and_month . '-01 00:00:00',
1361
-                        'Y-m-d H:i:s'
1362
-                    ),
1363
-                    EEM_Registration::instance()->convert_datetime_for_query(
1364
-                        'REG_date',
1365
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1366
-                        'Y-m-d H:i:s'
1367
-                    ),
1368
-                ),
1369
-            );
1370
-        } elseif ($month_range) {
1371
-            $pieces = explode(' ', $month_range, 3);
1372
-            $month_requested = ! empty($pieces[0])
1373
-                ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1374
-                : '';
1375
-            $year_requested = ! empty($pieces[1])
1376
-                ? $pieces[1]
1377
-                : '';
1378
-            // if there is not a month or year then we can't go further
1379
-            if ($month_requested && $year_requested) {
1380
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1381
-                $where['REG_date'] = array(
1382
-                    'BETWEEN',
1383
-                    array(
1384
-                        EEM_Registration::instance()->convert_datetime_for_query(
1385
-                            'REG_date',
1386
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
1387
-                            'Y-m-d H:i:s'
1388
-                        ),
1389
-                        EEM_Registration::instance()->convert_datetime_for_query(
1390
-                            'REG_date',
1391
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1392
-                            'Y-m-d H:i:s'
1393
-                        ),
1394
-                    ),
1395
-                );
1396
-            }
1397
-        }
1398
-        return $where;
1399
-    }
1400
-
1401
-
1402
-    /**
1403
-     * Adds any provided search restraints to the where conditions for the registrations query
1404
-     *
1405
-     * @param array $request usually the same as $this->_req_data but not necessarily
1406
-     * @return array
1407
-     */
1408
-    protected function _add_search_to_where_conditions(array $request)
1409
-    {
1410
-        $where = array();
1411
-        if (! empty($request['s'])) {
1412
-            $search_string = '%' . sanitize_text_field($request['s']) . '%';
1413
-            $where['OR*search_conditions'] = array(
1414
-                'Event.EVT_name'                          => array('LIKE', $search_string),
1415
-                'Event.EVT_desc'                          => array('LIKE', $search_string),
1416
-                'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1417
-                'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1418
-                'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1419
-                'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1420
-                'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1421
-                'Attendee.ATT_email'                      => array('LIKE', $search_string),
1422
-                'Attendee.ATT_address'                    => array('LIKE', $search_string),
1423
-                'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1424
-                'Attendee.ATT_city'                       => array('LIKE', $search_string),
1425
-                'REG_final_price'                         => array('LIKE', $search_string),
1426
-                'REG_code'                                => array('LIKE', $search_string),
1427
-                'REG_count'                               => array('LIKE', $search_string),
1428
-                'REG_group_size'                          => array('LIKE', $search_string),
1429
-                'Ticket.TKT_name'                         => array('LIKE', $search_string),
1430
-                'Ticket.TKT_description'                  => array('LIKE', $search_string),
1431
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1432
-            );
1433
-        }
1434
-        return $where;
1435
-    }
1436
-
1437
-
1438
-    /**
1439
-     * Sets up the where conditions for the registrations query.
1440
-     *
1441
-     * @param array $request
1442
-     * @return array
1443
-     * @throws EE_Error
1444
-     */
1445
-    protected function _get_where_conditions_for_registrations_query($request)
1446
-    {
1447
-        return apply_filters(
1448
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1449
-            array_merge(
1450
-                $this->addAttendeeIdToWhereConditions($request),
1451
-                $this->_add_event_id_to_where_conditions($request),
1452
-                $this->_add_category_id_to_where_conditions($request),
1453
-                $this->_add_datetime_id_to_where_conditions($request),
1454
-                $this->_add_registration_status_to_where_conditions($request),
1455
-                $this->_add_date_to_where_conditions($request),
1456
-                $this->_add_search_to_where_conditions($request)
1457
-            ),
1458
-            $request
1459
-        );
1460
-    }
1461
-
1462
-
1463
-    /**
1464
-     * Sets up the orderby for the registrations query.
1465
-     *
1466
-     * @return array
1467
-     */
1468
-    protected function _get_orderby_for_registrations_query()
1469
-    {
1470
-        $orderby_field = ! empty($this->_req_data['orderby'])
1471
-            ? sanitize_text_field($this->_req_data['orderby'])
1472
-            : '_REG_date';
1473
-        switch ($orderby_field) {
1474
-            case '_REG_ID':
1475
-                $orderby = array('REG_ID');
1476
-                break;
1477
-            case '_Reg_status':
1478
-                $orderby = array('STS_ID');
1479
-                break;
1480
-            case 'ATT_fname':
1481
-                $orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1482
-                break;
1483
-            case 'ATT_lname':
1484
-                $orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1485
-                break;
1486
-            case 'event_name':
1487
-                $orderby = array('Event.EVT_name');
1488
-                break;
1489
-            case 'DTT_EVT_start':
1490
-                $orderby = array('Event.Datetime.DTT_EVT_start');
1491
-                break;
1492
-            case '_REG_date':
1493
-                $orderby = array('REG_date');
1494
-                break;
1495
-            default:
1496
-                $orderby = array($orderby_field);
1497
-                break;
1498
-        }
1499
-
1500
-        // order
1501
-        $order = ! empty($this->_req_data['order'])
1502
-            ? sanitize_text_field($this->_req_data['order'])
1503
-            : 'DESC';
1504
-        $orderby = array_combine(
1505
-            $orderby,
1506
-            array_fill(0, count($orderby), $order)
1507
-        );
1508
-        // because there are many registrations with the same date, define
1509
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
1510
-        if (empty($orderby['REG_ID'])) {
1511
-            $orderby['REG_ID'] = $order;
1512
-        }
1513
-
1514
-        $orderby = apply_filters(
1515
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
1516
-            $orderby,
1517
-            $this->_req_data
1518
-        );
1519
-
1520
-        return array('order_by' => $orderby);
1521
-    }
1522
-
1523
-
1524
-    /**
1525
-     * Sets up the limit for the registrations query.
1526
-     *
1527
-     * @param $per_page
1528
-     * @return array
1529
-     */
1530
-    protected function _get_limit($per_page)
1531
-    {
1532
-        $current_page = ! empty($this->_req_data['paged'])
1533
-            ? absint($this->_req_data['paged'])
1534
-            : 1;
1535
-        $per_page = ! empty($this->_req_data['perpage'])
1536
-            ? $this->_req_data['perpage']
1537
-            : $per_page;
1538
-
1539
-        // -1 means return all results so get out if that's set.
1540
-        if ((int) $per_page === -1) {
1541
-            return array();
1542
-        }
1543
-        $per_page = absint($per_page);
1544
-        $offset = ($current_page - 1) * $per_page;
1545
-        return array('limit' => array($offset, $per_page));
1546
-    }
1547
-
1548
-
1549
-    public function get_registration_status_array()
1550
-    {
1551
-        return self::$_reg_status;
1552
-    }
1553
-
1554
-
1555
-
1556
-
1557
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1558
-    /**
1559
-     *        generates HTML for the View Registration Details Admin page
1560
-     *
1561
-     * @access protected
1562
-     * @return void
1563
-     * @throws DomainException
1564
-     * @throws EE_Error
1565
-     * @throws InvalidArgumentException
1566
-     * @throws InvalidDataTypeException
1567
-     * @throws InvalidInterfaceException
1568
-     * @throws EntityNotFoundException
1569
-     */
1570
-    protected function _registration_details()
1571
-    {
1572
-        $this->_template_args = array();
1573
-        $this->_set_registration_object();
1574
-        if (is_object($this->_registration)) {
1575
-            $transaction = $this->_registration->transaction()
1576
-                ? $this->_registration->transaction()
1577
-                : EE_Transaction::new_instance();
1578
-            $this->_session = $transaction->session_data();
1579
-            $event_id = $this->_registration->event_ID();
1580
-            $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1581
-            $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1582
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1583
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1584
-            $this->_template_args['grand_total'] = $transaction->total();
1585
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1586
-            // link back to overview
1587
-            $this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1588
-            $this->_template_args['registration'] = $this->_registration;
1589
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1590
-                array(
1591
-                    'action'   => 'default',
1592
-                    'event_id' => $event_id,
1593
-                ),
1594
-                REG_ADMIN_URL
1595
-            );
1596
-            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1597
-                array(
1598
-                    'action' => 'default',
1599
-                    'EVT_ID' => $event_id,
1600
-                    'page'   => 'espresso_transactions',
1601
-                ),
1602
-                admin_url('admin.php')
1603
-            );
1604
-            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1605
-                array(
1606
-                    'page'   => 'espresso_events',
1607
-                    'action' => 'edit',
1608
-                    'post'   => $event_id,
1609
-                ),
1610
-                admin_url('admin.php')
1611
-            );
1612
-            // next and previous links
1613
-            $next_reg = $this->_registration->next(
1614
-                null,
1615
-                array(),
1616
-                'REG_ID'
1617
-            );
1618
-            $this->_template_args['next_registration'] = $next_reg
1619
-                ? $this->_next_link(
1620
-                    EE_Admin_Page::add_query_args_and_nonce(
1621
-                        array(
1622
-                            'action'  => 'view_registration',
1623
-                            '_REG_ID' => $next_reg['REG_ID'],
1624
-                        ),
1625
-                        REG_ADMIN_URL
1626
-                    ),
1627
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1628
-                )
1629
-                : '';
1630
-            $previous_reg = $this->_registration->previous(
1631
-                null,
1632
-                array(),
1633
-                'REG_ID'
1634
-            );
1635
-            $this->_template_args['previous_registration'] = $previous_reg
1636
-                ? $this->_previous_link(
1637
-                    EE_Admin_Page::add_query_args_and_nonce(
1638
-                        array(
1639
-                            'action'  => 'view_registration',
1640
-                            '_REG_ID' => $previous_reg['REG_ID'],
1641
-                        ),
1642
-                        REG_ADMIN_URL
1643
-                    ),
1644
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1645
-                )
1646
-                : '';
1647
-            // grab header
1648
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1649
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1650
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1651
-                $template_path,
1652
-                $this->_template_args,
1653
-                true
1654
-            );
1655
-        } else {
1656
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1657
-        }
1658
-        // the details template wrapper
1659
-        $this->display_admin_page_with_sidebar();
1660
-    }
1661
-
1662
-
1663
-    protected function _registration_details_metaboxes()
1664
-    {
1665
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1666
-        $this->_set_registration_object();
1667
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1668
-        add_meta_box(
1669
-            'edit-reg-status-mbox',
1670
-            esc_html__('Registration Status', 'event_espresso'),
1671
-            array($this, 'set_reg_status_buttons_metabox'),
1672
-            $this->wp_page_slug,
1673
-            'normal',
1674
-            'high'
1675
-        );
1676
-        add_meta_box(
1677
-            'edit-reg-details-mbox',
1678
-            esc_html__('Registration Details', 'event_espresso'),
1679
-            array($this, '_reg_details_meta_box'),
1680
-            $this->wp_page_slug,
1681
-            'normal',
1682
-            'high'
1683
-        );
1684
-        if ($attendee instanceof EE_Attendee
1685
-            && EE_Registry::instance()->CAP->current_user_can(
1686
-                'ee_read_registration',
1687
-                'edit-reg-questions-mbox',
1688
-                $this->_registration->ID()
1689
-            )
1690
-        ) {
1691
-            add_meta_box(
1692
-                'edit-reg-questions-mbox',
1693
-                esc_html__('Registration Form Answers', 'event_espresso'),
1694
-                array($this, '_reg_questions_meta_box'),
1695
-                $this->wp_page_slug,
1696
-                'normal',
1697
-                'high'
1698
-            );
1699
-        }
1700
-        add_meta_box(
1701
-            'edit-reg-registrant-mbox',
1702
-            esc_html__('Contact Details', 'event_espresso'),
1703
-            array($this, '_reg_registrant_side_meta_box'),
1704
-            $this->wp_page_slug,
1705
-            'side',
1706
-            'high'
1707
-        );
1708
-        if ($this->_registration->group_size() > 1) {
1709
-            add_meta_box(
1710
-                'edit-reg-attendees-mbox',
1711
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1712
-                array($this, '_reg_attendees_meta_box'),
1713
-                $this->wp_page_slug,
1714
-                'normal',
1715
-                'high'
1716
-            );
1717
-        }
1718
-    }
1719
-
1720
-
1721
-    /**
1722
-     * set_reg_status_buttons_metabox
1723
-     *
1724
-     * @access protected
1725
-     * @return string
1726
-     * @throws \EE_Error
1727
-     */
1728
-    public function set_reg_status_buttons_metabox()
1729
-    {
1730
-        $this->_set_registration_object();
1731
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1732
-        echo $change_reg_status_form->form_open(
1733
-            self::add_query_args_and_nonce(
1734
-                array(
1735
-                    'action' => 'change_reg_status',
1736
-                ),
1737
-                REG_ADMIN_URL
1738
-            )
1739
-        );
1740
-        echo $change_reg_status_form->get_html();
1741
-        echo $change_reg_status_form->form_close();
1742
-    }
1743
-
1744
-
1745
-    /**
1746
-     * @return EE_Form_Section_Proper
1747
-     * @throws EE_Error
1748
-     * @throws InvalidArgumentException
1749
-     * @throws InvalidDataTypeException
1750
-     * @throws InvalidInterfaceException
1751
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1752
-     */
1753
-    protected function _generate_reg_status_change_form()
1754
-    {
1755
-        $reg_status_change_form_array = array(
1756
-            'name'            => 'reg_status_change_form',
1757
-            'html_id'         => 'reg-status-change-form',
1758
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1759
-            'subsections'     => array(
1760
-                'return'             => new EE_Hidden_Input(
1761
-                    array(
1762
-                        'name'    => 'return',
1763
-                        'default' => 'view_registration',
1764
-                    )
1765
-                ),
1766
-                'REG_ID'             => new EE_Hidden_Input(
1767
-                    array(
1768
-                        'name'    => 'REG_ID',
1769
-                        'default' => $this->_registration->ID(),
1770
-                    )
1771
-                ),
1772
-                'current_status'     => new EE_Form_Section_HTML(
1773
-                    EEH_HTML::tr(
1774
-                        EEH_HTML::th(
1775
-                            EEH_HTML::label(
1776
-                                EEH_HTML::strong(
1777
-                                    esc_html__('Current Registration Status', 'event_espresso')
1778
-                                )
1779
-                            )
1780
-                        )
1781
-                        . EEH_HTML::td(
1782
-                            EEH_HTML::strong(
1783
-                                $this->_registration->pretty_status(),
1784
-                                '',
1785
-                                'status-' . $this->_registration->status_ID(),
1786
-                                'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1787
-                            )
1788
-                        )
1789
-                    )
1790
-                )
1791
-            )
1792
-        );
1793
-        if (EE_Registry::instance()->CAP->current_user_can(
1794
-            'ee_edit_registration',
1795
-            'toggle_registration_status',
1796
-            $this->_registration->ID()
1797
-        )) {
1798
-            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1799
-                $this->_get_reg_statuses(),
1800
-                array(
1801
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1802
-                    'default'         => $this->_registration->status_ID(),
1803
-                )
1804
-            );
1805
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1806
-                array(
1807
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1808
-                    'default'         => false,
1809
-                    'html_help_text'  => esc_html__(
1810
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1811
-                        'event_espresso'
1812
-                    )
1813
-                )
1814
-            );
1815
-            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1816
-                array(
1817
-                    'html_class'      => 'button-primary',
1818
-                    'html_label_text' => '&nbsp;',
1819
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1820
-                )
1821
-            );
1822
-        }
1823
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1824
-    }
1825
-
1826
-
1827
-    /**
1828
-     * Returns an array of all the buttons for the various statuses and switch status actions
1829
-     *
1830
-     * @return array
1831
-     * @throws EE_Error
1832
-     * @throws InvalidArgumentException
1833
-     * @throws InvalidDataTypeException
1834
-     * @throws InvalidInterfaceException
1835
-     * @throws EntityNotFoundException
1836
-     */
1837
-    protected function _get_reg_statuses()
1838
-    {
1839
-        $reg_status_array = EEM_Registration::instance()->reg_status_array();
1840
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1841
-        // get current reg status
1842
-        $current_status = $this->_registration->status_ID();
1843
-        // is registration for free event? This will determine whether to display the pending payment option
1844
-        if ($current_status !== EEM_Registration::status_id_pending_payment
1845
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1846
-        ) {
1847
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1848
-        }
1849
-        return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1850
-    }
1851
-
1852
-
1853
-    /**
1854
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1855
-     *
1856
-     * @param bool $status REG status given for changing registrations to.
1857
-     * @param bool $notify Whether to send messages notifications or not.
1858
-     * @return array (array with reg_id(s) updated and whether update was successful.
1859
-     * @throws EE_Error
1860
-     * @throws InvalidArgumentException
1861
-     * @throws InvalidDataTypeException
1862
-     * @throws InvalidInterfaceException
1863
-     * @throws ReflectionException
1864
-     * @throws RuntimeException
1865
-     * @throws EntityNotFoundException
1866
-     */
1867
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1868
-    {
1869
-        if (isset($this->_req_data['reg_status_change_form'])) {
1870
-            $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1871
-                ? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1872
-                : array();
1873
-        } else {
1874
-            $REG_IDs = isset($this->_req_data['_REG_ID'])
1875
-                ? (array) $this->_req_data['_REG_ID']
1876
-                : array();
1877
-        }
1878
-        // sanitize $REG_IDs
1879
-        $REG_IDs = array_map('absint', $REG_IDs);
1880
-        // and remove empty entries
1881
-        $REG_IDs = array_filter($REG_IDs);
1882
-
1883
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1884
-
1885
-        /**
1886
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1887
-         * Currently this value is used downstream by the _process_resend_registration method.
1888
-         *
1889
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1890
-         * @param bool                     $status           The status registrations were changed to.
1891
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1892
-         * @param Registrations_Admin_Page $admin_page_object
1893
-         */
1894
-        $this->_req_data['_REG_ID'] = apply_filters(
1895
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1896
-            $result['REG_ID'],
1897
-            $status,
1898
-            $result['success'],
1899
-            $this
1900
-        );
1901
-
1902
-        // notify?
1903
-        if ($notify
1904
-            && $result['success']
1905
-            && ! empty($this->_req_data['_REG_ID'])
1906
-            && EE_Registry::instance()->CAP->current_user_can(
1907
-                'ee_send_message',
1908
-                'espresso_registrations_resend_registration'
1909
-            )
1910
-        ) {
1911
-            $this->_process_resend_registration();
1912
-        }
1913
-        return $result;
1914
-    }
1915
-
1916
-
1917
-    /**
1918
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1919
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1920
-     *
1921
-     * @param array  $REG_IDs
1922
-     * @param string $status
1923
-     * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1924
-     *                        slug sent with setting the registration status.
1925
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1926
-     * @throws EE_Error
1927
-     * @throws InvalidArgumentException
1928
-     * @throws InvalidDataTypeException
1929
-     * @throws InvalidInterfaceException
1930
-     * @throws ReflectionException
1931
-     * @throws RuntimeException
1932
-     * @throws EntityNotFoundException
1933
-     */
1934
-    protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1935
-    {
1936
-        $success = false;
1937
-        // typecast $REG_IDs
1938
-        $REG_IDs = (array) $REG_IDs;
1939
-        if (! empty($REG_IDs)) {
1940
-            $success = true;
1941
-            // set default status if none is passed
1942
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1943
-            $status_context = $notify
1944
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1945
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1946
-            // loop through REG_ID's and change status
1947
-            foreach ($REG_IDs as $REG_ID) {
1948
-                $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1949
-                if ($registration instanceof EE_Registration) {
1950
-                    $registration->set_status(
1951
-                        $status,
1952
-                        false,
1953
-                        new Context(
1954
-                            $status_context,
1955
-                            esc_html__(
1956
-                                'Manually triggered status change on a Registration Admin Page route.',
1957
-                                'event_espresso'
1958
-                            )
1959
-                        )
1960
-                    );
1961
-                    $result = $registration->save();
1962
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1963
-                    $success = $result !== false ? $success : false;
1964
-                }
1965
-            }
1966
-        }
1967
-
1968
-        // return $success and processed registrations
1969
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1970
-    }
1971
-
1972
-
1973
-    /**
1974
-     * Common logic for setting up success message and redirecting to appropriate route
1975
-     *
1976
-     * @param  string $STS_ID status id for the registration changed to
1977
-     * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1978
-     * @return void
1979
-     * @throws EE_Error
1980
-     */
1981
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1982
-    {
1983
-        $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1984
-            : array('success' => false);
1985
-        $success = isset($result['success']) && $result['success'];
1986
-        // setup success message
1987
-        if ($success) {
1988
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1989
-                $msg = sprintf(
1990
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1991
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1992
-                );
1993
-            } else {
1994
-                $msg = sprintf(
1995
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1996
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1997
-                );
1998
-            }
1999
-            EE_Error::add_success($msg);
2000
-        } else {
2001
-            EE_Error::add_error(
2002
-                esc_html__(
2003
-                    'Something went wrong, and the status was not changed',
2004
-                    'event_espresso'
2005
-                ),
2006
-                __FILE__,
2007
-                __LINE__,
2008
-                __FUNCTION__
2009
-            );
2010
-        }
2011
-        if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
2012
-            $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
2013
-        } else {
2014
-            $route = array('action' => 'default');
2015
-        }
2016
-        // unset nonces
2017
-        foreach ($this->_req_data as $ref => $value) {
2018
-            if (strpos($ref, 'nonce') !== false) {
2019
-                unset($this->_req_data[ $ref ]);
2020
-                continue;
2021
-            }
2022
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
2023
-            $this->_req_data[ $ref ] = $value;
2024
-        }
2025
-        // merge request vars so that the reloaded list table contains any existing filter query params
2026
-        $route = array_merge($this->_req_data, $route);
2027
-        $this->_redirect_after_action($success, '', '', $route, true);
2028
-    }
2029
-
2030
-
2031
-    /**
2032
-     * incoming reg status change from reg details page.
2033
-     *
2034
-     * @return void
2035
-     */
2036
-    protected function _change_reg_status()
2037
-    {
2038
-        $this->_req_data['return'] = 'view_registration';
2039
-        // set notify based on whether the send notifications toggle is set or not
2040
-        $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
2041
-        // $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2042
-        $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2043
-            ? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2044
-        switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2045
-            case EEM_Registration::status_id_approved:
2046
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
2047
-                $this->approve_registration($notify);
2048
-                break;
2049
-            case EEM_Registration::status_id_pending_payment:
2050
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
2051
-                $this->pending_registration($notify);
2052
-                break;
2053
-            case EEM_Registration::status_id_not_approved:
2054
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
2055
-                $this->not_approve_registration($notify);
2056
-                break;
2057
-            case EEM_Registration::status_id_declined:
2058
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
2059
-                $this->decline_registration($notify);
2060
-                break;
2061
-            case EEM_Registration::status_id_cancelled:
2062
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
2063
-                $this->cancel_registration($notify);
2064
-                break;
2065
-            case EEM_Registration::status_id_wait_list:
2066
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
2067
-                $this->wait_list_registration($notify);
2068
-                break;
2069
-            case EEM_Registration::status_id_incomplete:
2070
-            default:
2071
-                $result['success'] = false;
2072
-                unset($this->_req_data['return']);
2073
-                $this->_reg_status_change_return('', false);
2074
-                break;
2075
-        }
2076
-    }
2077
-
2078
-
2079
-    /**
2080
-     * Callback for bulk action routes.
2081
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2082
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
2083
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2084
-     * when an action is happening on just a single registration).
2085
-     *
2086
-     * @param      $action
2087
-     * @param bool $notify
2088
-     */
2089
-    protected function bulk_action_on_registrations($action, $notify = false)
2090
-    {
2091
-        do_action(
2092
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2093
-            $this,
2094
-            $action,
2095
-            $notify
2096
-        );
2097
-        $method = $action . '_registration';
2098
-        if (method_exists($this, $method)) {
2099
-            $this->$method($notify);
2100
-        }
2101
-    }
2102
-
2103
-
2104
-    /**
2105
-     * approve_registration
2106
-     *
2107
-     * @access protected
2108
-     * @param bool $notify whether or not to notify the registrant about their approval.
2109
-     * @return void
2110
-     */
2111
-    protected function approve_registration($notify = false)
2112
-    {
2113
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2114
-    }
2115
-
2116
-
2117
-    /**
2118
-     *        decline_registration
2119
-     *
2120
-     * @access protected
2121
-     * @param bool $notify whether or not to notify the registrant about their status change.
2122
-     * @return void
2123
-     */
2124
-    protected function decline_registration($notify = false)
2125
-    {
2126
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2127
-    }
2128
-
2129
-
2130
-    /**
2131
-     *        cancel_registration
2132
-     *
2133
-     * @access protected
2134
-     * @param bool $notify whether or not to notify the registrant about their status change.
2135
-     * @return void
2136
-     */
2137
-    protected function cancel_registration($notify = false)
2138
-    {
2139
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2140
-    }
2141
-
2142
-
2143
-    /**
2144
-     *        not_approve_registration
2145
-     *
2146
-     * @access protected
2147
-     * @param bool $notify whether or not to notify the registrant about their status change.
2148
-     * @return void
2149
-     */
2150
-    protected function not_approve_registration($notify = false)
2151
-    {
2152
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2153
-    }
2154
-
2155
-
2156
-    /**
2157
-     *        decline_registration
2158
-     *
2159
-     * @access protected
2160
-     * @param bool $notify whether or not to notify the registrant about their status change.
2161
-     * @return void
2162
-     */
2163
-    protected function pending_registration($notify = false)
2164
-    {
2165
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2166
-    }
2167
-
2168
-
2169
-    /**
2170
-     * waitlist_registration
2171
-     *
2172
-     * @access protected
2173
-     * @param bool $notify whether or not to notify the registrant about their status change.
2174
-     * @return void
2175
-     */
2176
-    protected function wait_list_registration($notify = false)
2177
-    {
2178
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2179
-    }
2180
-
2181
-
2182
-    /**
2183
-     *        generates HTML for the Registration main meta box
2184
-     *
2185
-     * @access public
2186
-     * @return void
2187
-     * @throws DomainException
2188
-     * @throws EE_Error
2189
-     * @throws InvalidArgumentException
2190
-     * @throws InvalidDataTypeException
2191
-     * @throws InvalidInterfaceException
2192
-     * @throws ReflectionException
2193
-     * @throws EntityNotFoundException
2194
-     */
2195
-    public function _reg_details_meta_box()
2196
-    {
2197
-        EEH_Autoloader::register_line_item_display_autoloaders();
2198
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2199
-        EE_Registry::instance()->load_helper('Line_Item');
2200
-        $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2201
-            : EE_Transaction::new_instance();
2202
-        $this->_session = $transaction->session_data();
2203
-        $filters = new EE_Line_Item_Filter_Collection();
2204
-        // $filters->add( new EE_Non_Zero_Line_Item_Filter() );
2205
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2206
-        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2207
-            $filters,
2208
-            $transaction->total_line_item()
2209
-        );
2210
-        $filtered_line_item_tree = $line_item_filter_processor->process();
2211
-        $line_item_display = new EE_Line_Item_Display(
2212
-            'reg_admin_table',
2213
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2214
-        );
2215
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2216
-            $filtered_line_item_tree,
2217
-            array('EE_Registration' => $this->_registration)
2218
-        );
2219
-        $attendee = $this->_registration->attendee();
2220
-        if (EE_Registry::instance()->CAP->current_user_can(
2221
-            'ee_read_transaction',
2222
-            'espresso_transactions_view_transaction'
2223
-        )) {
2224
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2225
-                EE_Admin_Page::add_query_args_and_nonce(
2226
-                    array(
2227
-                        'action' => 'view_transaction',
2228
-                        'TXN_ID' => $transaction->ID(),
2229
-                    ),
2230
-                    TXN_ADMIN_URL
2231
-                ),
2232
-                esc_html__(' View Transaction', 'event_espresso'),
2233
-                'button secondary-button right',
2234
-                'dashicons dashicons-cart'
2235
-            );
2236
-        } else {
2237
-            $this->_template_args['view_transaction_button'] = '';
2238
-        }
2239
-        if ($attendee instanceof EE_Attendee
2240
-            && EE_Registry::instance()->CAP->current_user_can(
2241
-                'ee_send_message',
2242
-                'espresso_registrations_resend_registration'
2243
-            )
2244
-        ) {
2245
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2246
-                EE_Admin_Page::add_query_args_and_nonce(
2247
-                    array(
2248
-                        'action'      => 'resend_registration',
2249
-                        '_REG_ID'     => $this->_registration->ID(),
2250
-                        'redirect_to' => 'view_registration',
2251
-                    ),
2252
-                    REG_ADMIN_URL
2253
-                ),
2254
-                esc_html__(' Resend Registration', 'event_espresso'),
2255
-                'button secondary-button right',
2256
-                'dashicons dashicons-email-alt'
2257
-            );
2258
-        } else {
2259
-            $this->_template_args['resend_registration_button'] = '';
2260
-        }
2261
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2262
-        $payment = $transaction->get_first_related('Payment');
2263
-        $payment = ! $payment instanceof EE_Payment
2264
-            ? EE_Payment::new_instance()
2265
-            : $payment;
2266
-        $payment_method = $payment->get_first_related('Payment_Method');
2267
-        $payment_method = ! $payment_method instanceof EE_Payment_Method
2268
-            ? EE_Payment_Method::new_instance()
2269
-            : $payment_method;
2270
-        $reg_details = array(
2271
-            'payment_method'       => $payment_method->name(),
2272
-            'response_msg'         => $payment->gateway_response(),
2273
-            'registration_id'      => $this->_registration->get('REG_code'),
2274
-            'registration_session' => $this->_registration->session_ID(),
2275
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2276
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2277
-        );
2278
-        if (isset($reg_details['registration_id'])) {
2279
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2280
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2281
-                'Registration ID',
2282
-                'event_espresso'
2283
-            );
2284
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2285
-        }
2286
-        if (isset($reg_details['payment_method'])) {
2287
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2288
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2289
-                'Most Recent Payment Method',
2290
-                'event_espresso'
2291
-            );
2292
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2293
-            $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2294
-            $this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2295
-                'Payment method response',
2296
-                'event_espresso'
2297
-            );
2298
-            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2299
-        }
2300
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2301
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2302
-            'Registration Session',
2303
-            'event_espresso'
2304
-        );
2305
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2306
-        $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2307
-        $this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2308
-            'Registration placed from IP',
2309
-            'event_espresso'
2310
-        );
2311
-        $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2312
-        $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2313
-        $this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2314
-            'Registrant User Agent',
2315
-            'event_espresso'
2316
-        );
2317
-        $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2318
-        $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2319
-            array(
2320
-                'action'   => 'default',
2321
-                'event_id' => $this->_registration->event_ID(),
2322
-            ),
2323
-            REG_ADMIN_URL
2324
-        );
2325
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2326
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2327
-        $template_path =
2328
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2329
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2330
-    }
2331
-
2332
-
2333
-    /**
2334
-     * generates HTML for the Registration Questions meta box.
2335
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2336
-     * otherwise uses new forms system
2337
-     *
2338
-     * @access public
2339
-     * @return void
2340
-     * @throws DomainException
2341
-     * @throws EE_Error
2342
-     */
2343
-    public function _reg_questions_meta_box()
2344
-    {
2345
-        // allow someone to override this method entirely
2346
-        if (apply_filters(
2347
-            'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2348
-            true,
2349
-            $this,
2350
-            $this->_registration
2351
-        )) {
2352
-            $form = $this->_get_reg_custom_questions_form(
2353
-                $this->_registration->ID()
2354
-            );
2355
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2356
-                ? $form->get_html_and_js()
2357
-                : '';
2358
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2359
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2360
-            $template_path =
2361
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2362
-            echo EEH_Template::display_template($template_path, $this->_template_args, true);
2363
-        }
2364
-    }
2365
-
2366
-
2367
-    /**
2368
-     * form_before_question_group
2369
-     *
2370
-     * @deprecated    as of 4.8.32.rc.000
2371
-     * @access        public
2372
-     * @param        string $output
2373
-     * @return        string
2374
-     */
2375
-    public function form_before_question_group($output)
2376
-    {
2377
-        EE_Error::doing_it_wrong(
2378
-            __CLASS__ . '::' . __FUNCTION__,
2379
-            esc_html__(
2380
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2381
-                'event_espresso'
2382
-            ),
2383
-            '4.8.32.rc.000'
2384
-        );
2385
-        return '
1299
+		if (! empty($registration_status)) {
1300
+			$where['STS_ID'] = $registration_status;
1301
+		} else {
1302
+			// make sure we exclude incomplete registrations, but only if not trashed.
1303
+			if ($view === 'trash') {
1304
+				$where['REG_deleted'] = true;
1305
+			} elseif ($view === 'incomplete') {
1306
+				$where['STS_ID'] = EEM_Registration::status_id_incomplete;
1307
+			} else {
1308
+				$where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1309
+			}
1310
+		}
1311
+		return $where;
1312
+	}
1313
+
1314
+
1315
+	/**
1316
+	 * Adds any provided date restraints to the where conditions for the registrations query.
1317
+	 *
1318
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1319
+	 * @return array
1320
+	 * @throws EE_Error
1321
+	 * @throws InvalidArgumentException
1322
+	 * @throws InvalidDataTypeException
1323
+	 * @throws InvalidInterfaceException
1324
+	 */
1325
+	protected function _add_date_to_where_conditions(array $request)
1326
+	{
1327
+		$where = array();
1328
+		$view = EEH_Array::is_set($request, 'status', '');
1329
+		$month_range = ! empty($request['month_range'])
1330
+			? sanitize_text_field($request['month_range'])
1331
+			: '';
1332
+		$retrieve_for_today = $view === 'today';
1333
+		$retrieve_for_this_month = $view === 'month';
1334
+
1335
+		if ($retrieve_for_today) {
1336
+			$now = date('Y-m-d', current_time('timestamp'));
1337
+			$where['REG_date'] = array(
1338
+				'BETWEEN',
1339
+				array(
1340
+					EEM_Registration::instance()->convert_datetime_for_query(
1341
+						'REG_date',
1342
+						$now . ' 00:00:00',
1343
+						'Y-m-d H:i:s'
1344
+					),
1345
+					EEM_Registration::instance()->convert_datetime_for_query(
1346
+						'REG_date',
1347
+						$now . ' 23:59:59',
1348
+						'Y-m-d H:i:s'
1349
+					),
1350
+				),
1351
+			);
1352
+		} elseif ($retrieve_for_this_month) {
1353
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
1354
+			$days_this_month = date('t', current_time('timestamp'));
1355
+			$where['REG_date'] = array(
1356
+				'BETWEEN',
1357
+				array(
1358
+					EEM_Registration::instance()->convert_datetime_for_query(
1359
+						'REG_date',
1360
+						$current_year_and_month . '-01 00:00:00',
1361
+						'Y-m-d H:i:s'
1362
+					),
1363
+					EEM_Registration::instance()->convert_datetime_for_query(
1364
+						'REG_date',
1365
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1366
+						'Y-m-d H:i:s'
1367
+					),
1368
+				),
1369
+			);
1370
+		} elseif ($month_range) {
1371
+			$pieces = explode(' ', $month_range, 3);
1372
+			$month_requested = ! empty($pieces[0])
1373
+				? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1374
+				: '';
1375
+			$year_requested = ! empty($pieces[1])
1376
+				? $pieces[1]
1377
+				: '';
1378
+			// if there is not a month or year then we can't go further
1379
+			if ($month_requested && $year_requested) {
1380
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1381
+				$where['REG_date'] = array(
1382
+					'BETWEEN',
1383
+					array(
1384
+						EEM_Registration::instance()->convert_datetime_for_query(
1385
+							'REG_date',
1386
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
1387
+							'Y-m-d H:i:s'
1388
+						),
1389
+						EEM_Registration::instance()->convert_datetime_for_query(
1390
+							'REG_date',
1391
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1392
+							'Y-m-d H:i:s'
1393
+						),
1394
+					),
1395
+				);
1396
+			}
1397
+		}
1398
+		return $where;
1399
+	}
1400
+
1401
+
1402
+	/**
1403
+	 * Adds any provided search restraints to the where conditions for the registrations query
1404
+	 *
1405
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1406
+	 * @return array
1407
+	 */
1408
+	protected function _add_search_to_where_conditions(array $request)
1409
+	{
1410
+		$where = array();
1411
+		if (! empty($request['s'])) {
1412
+			$search_string = '%' . sanitize_text_field($request['s']) . '%';
1413
+			$where['OR*search_conditions'] = array(
1414
+				'Event.EVT_name'                          => array('LIKE', $search_string),
1415
+				'Event.EVT_desc'                          => array('LIKE', $search_string),
1416
+				'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1417
+				'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1418
+				'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1419
+				'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1420
+				'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1421
+				'Attendee.ATT_email'                      => array('LIKE', $search_string),
1422
+				'Attendee.ATT_address'                    => array('LIKE', $search_string),
1423
+				'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1424
+				'Attendee.ATT_city'                       => array('LIKE', $search_string),
1425
+				'REG_final_price'                         => array('LIKE', $search_string),
1426
+				'REG_code'                                => array('LIKE', $search_string),
1427
+				'REG_count'                               => array('LIKE', $search_string),
1428
+				'REG_group_size'                          => array('LIKE', $search_string),
1429
+				'Ticket.TKT_name'                         => array('LIKE', $search_string),
1430
+				'Ticket.TKT_description'                  => array('LIKE', $search_string),
1431
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1432
+			);
1433
+		}
1434
+		return $where;
1435
+	}
1436
+
1437
+
1438
+	/**
1439
+	 * Sets up the where conditions for the registrations query.
1440
+	 *
1441
+	 * @param array $request
1442
+	 * @return array
1443
+	 * @throws EE_Error
1444
+	 */
1445
+	protected function _get_where_conditions_for_registrations_query($request)
1446
+	{
1447
+		return apply_filters(
1448
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1449
+			array_merge(
1450
+				$this->addAttendeeIdToWhereConditions($request),
1451
+				$this->_add_event_id_to_where_conditions($request),
1452
+				$this->_add_category_id_to_where_conditions($request),
1453
+				$this->_add_datetime_id_to_where_conditions($request),
1454
+				$this->_add_registration_status_to_where_conditions($request),
1455
+				$this->_add_date_to_where_conditions($request),
1456
+				$this->_add_search_to_where_conditions($request)
1457
+			),
1458
+			$request
1459
+		);
1460
+	}
1461
+
1462
+
1463
+	/**
1464
+	 * Sets up the orderby for the registrations query.
1465
+	 *
1466
+	 * @return array
1467
+	 */
1468
+	protected function _get_orderby_for_registrations_query()
1469
+	{
1470
+		$orderby_field = ! empty($this->_req_data['orderby'])
1471
+			? sanitize_text_field($this->_req_data['orderby'])
1472
+			: '_REG_date';
1473
+		switch ($orderby_field) {
1474
+			case '_REG_ID':
1475
+				$orderby = array('REG_ID');
1476
+				break;
1477
+			case '_Reg_status':
1478
+				$orderby = array('STS_ID');
1479
+				break;
1480
+			case 'ATT_fname':
1481
+				$orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1482
+				break;
1483
+			case 'ATT_lname':
1484
+				$orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1485
+				break;
1486
+			case 'event_name':
1487
+				$orderby = array('Event.EVT_name');
1488
+				break;
1489
+			case 'DTT_EVT_start':
1490
+				$orderby = array('Event.Datetime.DTT_EVT_start');
1491
+				break;
1492
+			case '_REG_date':
1493
+				$orderby = array('REG_date');
1494
+				break;
1495
+			default:
1496
+				$orderby = array($orderby_field);
1497
+				break;
1498
+		}
1499
+
1500
+		// order
1501
+		$order = ! empty($this->_req_data['order'])
1502
+			? sanitize_text_field($this->_req_data['order'])
1503
+			: 'DESC';
1504
+		$orderby = array_combine(
1505
+			$orderby,
1506
+			array_fill(0, count($orderby), $order)
1507
+		);
1508
+		// because there are many registrations with the same date, define
1509
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
1510
+		if (empty($orderby['REG_ID'])) {
1511
+			$orderby['REG_ID'] = $order;
1512
+		}
1513
+
1514
+		$orderby = apply_filters(
1515
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
1516
+			$orderby,
1517
+			$this->_req_data
1518
+		);
1519
+
1520
+		return array('order_by' => $orderby);
1521
+	}
1522
+
1523
+
1524
+	/**
1525
+	 * Sets up the limit for the registrations query.
1526
+	 *
1527
+	 * @param $per_page
1528
+	 * @return array
1529
+	 */
1530
+	protected function _get_limit($per_page)
1531
+	{
1532
+		$current_page = ! empty($this->_req_data['paged'])
1533
+			? absint($this->_req_data['paged'])
1534
+			: 1;
1535
+		$per_page = ! empty($this->_req_data['perpage'])
1536
+			? $this->_req_data['perpage']
1537
+			: $per_page;
1538
+
1539
+		// -1 means return all results so get out if that's set.
1540
+		if ((int) $per_page === -1) {
1541
+			return array();
1542
+		}
1543
+		$per_page = absint($per_page);
1544
+		$offset = ($current_page - 1) * $per_page;
1545
+		return array('limit' => array($offset, $per_page));
1546
+	}
1547
+
1548
+
1549
+	public function get_registration_status_array()
1550
+	{
1551
+		return self::$_reg_status;
1552
+	}
1553
+
1554
+
1555
+
1556
+
1557
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1558
+	/**
1559
+	 *        generates HTML for the View Registration Details Admin page
1560
+	 *
1561
+	 * @access protected
1562
+	 * @return void
1563
+	 * @throws DomainException
1564
+	 * @throws EE_Error
1565
+	 * @throws InvalidArgumentException
1566
+	 * @throws InvalidDataTypeException
1567
+	 * @throws InvalidInterfaceException
1568
+	 * @throws EntityNotFoundException
1569
+	 */
1570
+	protected function _registration_details()
1571
+	{
1572
+		$this->_template_args = array();
1573
+		$this->_set_registration_object();
1574
+		if (is_object($this->_registration)) {
1575
+			$transaction = $this->_registration->transaction()
1576
+				? $this->_registration->transaction()
1577
+				: EE_Transaction::new_instance();
1578
+			$this->_session = $transaction->session_data();
1579
+			$event_id = $this->_registration->event_ID();
1580
+			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1581
+			$this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1582
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1583
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1584
+			$this->_template_args['grand_total'] = $transaction->total();
1585
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1586
+			// link back to overview
1587
+			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1588
+			$this->_template_args['registration'] = $this->_registration;
1589
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1590
+				array(
1591
+					'action'   => 'default',
1592
+					'event_id' => $event_id,
1593
+				),
1594
+				REG_ADMIN_URL
1595
+			);
1596
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1597
+				array(
1598
+					'action' => 'default',
1599
+					'EVT_ID' => $event_id,
1600
+					'page'   => 'espresso_transactions',
1601
+				),
1602
+				admin_url('admin.php')
1603
+			);
1604
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1605
+				array(
1606
+					'page'   => 'espresso_events',
1607
+					'action' => 'edit',
1608
+					'post'   => $event_id,
1609
+				),
1610
+				admin_url('admin.php')
1611
+			);
1612
+			// next and previous links
1613
+			$next_reg = $this->_registration->next(
1614
+				null,
1615
+				array(),
1616
+				'REG_ID'
1617
+			);
1618
+			$this->_template_args['next_registration'] = $next_reg
1619
+				? $this->_next_link(
1620
+					EE_Admin_Page::add_query_args_and_nonce(
1621
+						array(
1622
+							'action'  => 'view_registration',
1623
+							'_REG_ID' => $next_reg['REG_ID'],
1624
+						),
1625
+						REG_ADMIN_URL
1626
+					),
1627
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1628
+				)
1629
+				: '';
1630
+			$previous_reg = $this->_registration->previous(
1631
+				null,
1632
+				array(),
1633
+				'REG_ID'
1634
+			);
1635
+			$this->_template_args['previous_registration'] = $previous_reg
1636
+				? $this->_previous_link(
1637
+					EE_Admin_Page::add_query_args_and_nonce(
1638
+						array(
1639
+							'action'  => 'view_registration',
1640
+							'_REG_ID' => $previous_reg['REG_ID'],
1641
+						),
1642
+						REG_ADMIN_URL
1643
+					),
1644
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1645
+				)
1646
+				: '';
1647
+			// grab header
1648
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1649
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1650
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1651
+				$template_path,
1652
+				$this->_template_args,
1653
+				true
1654
+			);
1655
+		} else {
1656
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1657
+		}
1658
+		// the details template wrapper
1659
+		$this->display_admin_page_with_sidebar();
1660
+	}
1661
+
1662
+
1663
+	protected function _registration_details_metaboxes()
1664
+	{
1665
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1666
+		$this->_set_registration_object();
1667
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1668
+		add_meta_box(
1669
+			'edit-reg-status-mbox',
1670
+			esc_html__('Registration Status', 'event_espresso'),
1671
+			array($this, 'set_reg_status_buttons_metabox'),
1672
+			$this->wp_page_slug,
1673
+			'normal',
1674
+			'high'
1675
+		);
1676
+		add_meta_box(
1677
+			'edit-reg-details-mbox',
1678
+			esc_html__('Registration Details', 'event_espresso'),
1679
+			array($this, '_reg_details_meta_box'),
1680
+			$this->wp_page_slug,
1681
+			'normal',
1682
+			'high'
1683
+		);
1684
+		if ($attendee instanceof EE_Attendee
1685
+			&& EE_Registry::instance()->CAP->current_user_can(
1686
+				'ee_read_registration',
1687
+				'edit-reg-questions-mbox',
1688
+				$this->_registration->ID()
1689
+			)
1690
+		) {
1691
+			add_meta_box(
1692
+				'edit-reg-questions-mbox',
1693
+				esc_html__('Registration Form Answers', 'event_espresso'),
1694
+				array($this, '_reg_questions_meta_box'),
1695
+				$this->wp_page_slug,
1696
+				'normal',
1697
+				'high'
1698
+			);
1699
+		}
1700
+		add_meta_box(
1701
+			'edit-reg-registrant-mbox',
1702
+			esc_html__('Contact Details', 'event_espresso'),
1703
+			array($this, '_reg_registrant_side_meta_box'),
1704
+			$this->wp_page_slug,
1705
+			'side',
1706
+			'high'
1707
+		);
1708
+		if ($this->_registration->group_size() > 1) {
1709
+			add_meta_box(
1710
+				'edit-reg-attendees-mbox',
1711
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1712
+				array($this, '_reg_attendees_meta_box'),
1713
+				$this->wp_page_slug,
1714
+				'normal',
1715
+				'high'
1716
+			);
1717
+		}
1718
+	}
1719
+
1720
+
1721
+	/**
1722
+	 * set_reg_status_buttons_metabox
1723
+	 *
1724
+	 * @access protected
1725
+	 * @return string
1726
+	 * @throws \EE_Error
1727
+	 */
1728
+	public function set_reg_status_buttons_metabox()
1729
+	{
1730
+		$this->_set_registration_object();
1731
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1732
+		echo $change_reg_status_form->form_open(
1733
+			self::add_query_args_and_nonce(
1734
+				array(
1735
+					'action' => 'change_reg_status',
1736
+				),
1737
+				REG_ADMIN_URL
1738
+			)
1739
+		);
1740
+		echo $change_reg_status_form->get_html();
1741
+		echo $change_reg_status_form->form_close();
1742
+	}
1743
+
1744
+
1745
+	/**
1746
+	 * @return EE_Form_Section_Proper
1747
+	 * @throws EE_Error
1748
+	 * @throws InvalidArgumentException
1749
+	 * @throws InvalidDataTypeException
1750
+	 * @throws InvalidInterfaceException
1751
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1752
+	 */
1753
+	protected function _generate_reg_status_change_form()
1754
+	{
1755
+		$reg_status_change_form_array = array(
1756
+			'name'            => 'reg_status_change_form',
1757
+			'html_id'         => 'reg-status-change-form',
1758
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1759
+			'subsections'     => array(
1760
+				'return'             => new EE_Hidden_Input(
1761
+					array(
1762
+						'name'    => 'return',
1763
+						'default' => 'view_registration',
1764
+					)
1765
+				),
1766
+				'REG_ID'             => new EE_Hidden_Input(
1767
+					array(
1768
+						'name'    => 'REG_ID',
1769
+						'default' => $this->_registration->ID(),
1770
+					)
1771
+				),
1772
+				'current_status'     => new EE_Form_Section_HTML(
1773
+					EEH_HTML::tr(
1774
+						EEH_HTML::th(
1775
+							EEH_HTML::label(
1776
+								EEH_HTML::strong(
1777
+									esc_html__('Current Registration Status', 'event_espresso')
1778
+								)
1779
+							)
1780
+						)
1781
+						. EEH_HTML::td(
1782
+							EEH_HTML::strong(
1783
+								$this->_registration->pretty_status(),
1784
+								'',
1785
+								'status-' . $this->_registration->status_ID(),
1786
+								'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1787
+							)
1788
+						)
1789
+					)
1790
+				)
1791
+			)
1792
+		);
1793
+		if (EE_Registry::instance()->CAP->current_user_can(
1794
+			'ee_edit_registration',
1795
+			'toggle_registration_status',
1796
+			$this->_registration->ID()
1797
+		)) {
1798
+			$reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1799
+				$this->_get_reg_statuses(),
1800
+				array(
1801
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1802
+					'default'         => $this->_registration->status_ID(),
1803
+				)
1804
+			);
1805
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1806
+				array(
1807
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1808
+					'default'         => false,
1809
+					'html_help_text'  => esc_html__(
1810
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1811
+						'event_espresso'
1812
+					)
1813
+				)
1814
+			);
1815
+			$reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1816
+				array(
1817
+					'html_class'      => 'button-primary',
1818
+					'html_label_text' => '&nbsp;',
1819
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1820
+				)
1821
+			);
1822
+		}
1823
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1824
+	}
1825
+
1826
+
1827
+	/**
1828
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1829
+	 *
1830
+	 * @return array
1831
+	 * @throws EE_Error
1832
+	 * @throws InvalidArgumentException
1833
+	 * @throws InvalidDataTypeException
1834
+	 * @throws InvalidInterfaceException
1835
+	 * @throws EntityNotFoundException
1836
+	 */
1837
+	protected function _get_reg_statuses()
1838
+	{
1839
+		$reg_status_array = EEM_Registration::instance()->reg_status_array();
1840
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1841
+		// get current reg status
1842
+		$current_status = $this->_registration->status_ID();
1843
+		// is registration for free event? This will determine whether to display the pending payment option
1844
+		if ($current_status !== EEM_Registration::status_id_pending_payment
1845
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1846
+		) {
1847
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1848
+		}
1849
+		return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1850
+	}
1851
+
1852
+
1853
+	/**
1854
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1855
+	 *
1856
+	 * @param bool $status REG status given for changing registrations to.
1857
+	 * @param bool $notify Whether to send messages notifications or not.
1858
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1859
+	 * @throws EE_Error
1860
+	 * @throws InvalidArgumentException
1861
+	 * @throws InvalidDataTypeException
1862
+	 * @throws InvalidInterfaceException
1863
+	 * @throws ReflectionException
1864
+	 * @throws RuntimeException
1865
+	 * @throws EntityNotFoundException
1866
+	 */
1867
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1868
+	{
1869
+		if (isset($this->_req_data['reg_status_change_form'])) {
1870
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1871
+				? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1872
+				: array();
1873
+		} else {
1874
+			$REG_IDs = isset($this->_req_data['_REG_ID'])
1875
+				? (array) $this->_req_data['_REG_ID']
1876
+				: array();
1877
+		}
1878
+		// sanitize $REG_IDs
1879
+		$REG_IDs = array_map('absint', $REG_IDs);
1880
+		// and remove empty entries
1881
+		$REG_IDs = array_filter($REG_IDs);
1882
+
1883
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1884
+
1885
+		/**
1886
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1887
+		 * Currently this value is used downstream by the _process_resend_registration method.
1888
+		 *
1889
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1890
+		 * @param bool                     $status           The status registrations were changed to.
1891
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1892
+		 * @param Registrations_Admin_Page $admin_page_object
1893
+		 */
1894
+		$this->_req_data['_REG_ID'] = apply_filters(
1895
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1896
+			$result['REG_ID'],
1897
+			$status,
1898
+			$result['success'],
1899
+			$this
1900
+		);
1901
+
1902
+		// notify?
1903
+		if ($notify
1904
+			&& $result['success']
1905
+			&& ! empty($this->_req_data['_REG_ID'])
1906
+			&& EE_Registry::instance()->CAP->current_user_can(
1907
+				'ee_send_message',
1908
+				'espresso_registrations_resend_registration'
1909
+			)
1910
+		) {
1911
+			$this->_process_resend_registration();
1912
+		}
1913
+		return $result;
1914
+	}
1915
+
1916
+
1917
+	/**
1918
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1919
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1920
+	 *
1921
+	 * @param array  $REG_IDs
1922
+	 * @param string $status
1923
+	 * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1924
+	 *                        slug sent with setting the registration status.
1925
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1926
+	 * @throws EE_Error
1927
+	 * @throws InvalidArgumentException
1928
+	 * @throws InvalidDataTypeException
1929
+	 * @throws InvalidInterfaceException
1930
+	 * @throws ReflectionException
1931
+	 * @throws RuntimeException
1932
+	 * @throws EntityNotFoundException
1933
+	 */
1934
+	protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1935
+	{
1936
+		$success = false;
1937
+		// typecast $REG_IDs
1938
+		$REG_IDs = (array) $REG_IDs;
1939
+		if (! empty($REG_IDs)) {
1940
+			$success = true;
1941
+			// set default status if none is passed
1942
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1943
+			$status_context = $notify
1944
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1945
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1946
+			// loop through REG_ID's and change status
1947
+			foreach ($REG_IDs as $REG_ID) {
1948
+				$registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1949
+				if ($registration instanceof EE_Registration) {
1950
+					$registration->set_status(
1951
+						$status,
1952
+						false,
1953
+						new Context(
1954
+							$status_context,
1955
+							esc_html__(
1956
+								'Manually triggered status change on a Registration Admin Page route.',
1957
+								'event_espresso'
1958
+							)
1959
+						)
1960
+					);
1961
+					$result = $registration->save();
1962
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1963
+					$success = $result !== false ? $success : false;
1964
+				}
1965
+			}
1966
+		}
1967
+
1968
+		// return $success and processed registrations
1969
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1970
+	}
1971
+
1972
+
1973
+	/**
1974
+	 * Common logic for setting up success message and redirecting to appropriate route
1975
+	 *
1976
+	 * @param  string $STS_ID status id for the registration changed to
1977
+	 * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1978
+	 * @return void
1979
+	 * @throws EE_Error
1980
+	 */
1981
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1982
+	{
1983
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1984
+			: array('success' => false);
1985
+		$success = isset($result['success']) && $result['success'];
1986
+		// setup success message
1987
+		if ($success) {
1988
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1989
+				$msg = sprintf(
1990
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1991
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1992
+				);
1993
+			} else {
1994
+				$msg = sprintf(
1995
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1996
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1997
+				);
1998
+			}
1999
+			EE_Error::add_success($msg);
2000
+		} else {
2001
+			EE_Error::add_error(
2002
+				esc_html__(
2003
+					'Something went wrong, and the status was not changed',
2004
+					'event_espresso'
2005
+				),
2006
+				__FILE__,
2007
+				__LINE__,
2008
+				__FUNCTION__
2009
+			);
2010
+		}
2011
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
2012
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
2013
+		} else {
2014
+			$route = array('action' => 'default');
2015
+		}
2016
+		// unset nonces
2017
+		foreach ($this->_req_data as $ref => $value) {
2018
+			if (strpos($ref, 'nonce') !== false) {
2019
+				unset($this->_req_data[ $ref ]);
2020
+				continue;
2021
+			}
2022
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
2023
+			$this->_req_data[ $ref ] = $value;
2024
+		}
2025
+		// merge request vars so that the reloaded list table contains any existing filter query params
2026
+		$route = array_merge($this->_req_data, $route);
2027
+		$this->_redirect_after_action($success, '', '', $route, true);
2028
+	}
2029
+
2030
+
2031
+	/**
2032
+	 * incoming reg status change from reg details page.
2033
+	 *
2034
+	 * @return void
2035
+	 */
2036
+	protected function _change_reg_status()
2037
+	{
2038
+		$this->_req_data['return'] = 'view_registration';
2039
+		// set notify based on whether the send notifications toggle is set or not
2040
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
2041
+		// $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2042
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2043
+			? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2044
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2045
+			case EEM_Registration::status_id_approved:
2046
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
2047
+				$this->approve_registration($notify);
2048
+				break;
2049
+			case EEM_Registration::status_id_pending_payment:
2050
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
2051
+				$this->pending_registration($notify);
2052
+				break;
2053
+			case EEM_Registration::status_id_not_approved:
2054
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
2055
+				$this->not_approve_registration($notify);
2056
+				break;
2057
+			case EEM_Registration::status_id_declined:
2058
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
2059
+				$this->decline_registration($notify);
2060
+				break;
2061
+			case EEM_Registration::status_id_cancelled:
2062
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
2063
+				$this->cancel_registration($notify);
2064
+				break;
2065
+			case EEM_Registration::status_id_wait_list:
2066
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
2067
+				$this->wait_list_registration($notify);
2068
+				break;
2069
+			case EEM_Registration::status_id_incomplete:
2070
+			default:
2071
+				$result['success'] = false;
2072
+				unset($this->_req_data['return']);
2073
+				$this->_reg_status_change_return('', false);
2074
+				break;
2075
+		}
2076
+	}
2077
+
2078
+
2079
+	/**
2080
+	 * Callback for bulk action routes.
2081
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2082
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
2083
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2084
+	 * when an action is happening on just a single registration).
2085
+	 *
2086
+	 * @param      $action
2087
+	 * @param bool $notify
2088
+	 */
2089
+	protected function bulk_action_on_registrations($action, $notify = false)
2090
+	{
2091
+		do_action(
2092
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2093
+			$this,
2094
+			$action,
2095
+			$notify
2096
+		);
2097
+		$method = $action . '_registration';
2098
+		if (method_exists($this, $method)) {
2099
+			$this->$method($notify);
2100
+		}
2101
+	}
2102
+
2103
+
2104
+	/**
2105
+	 * approve_registration
2106
+	 *
2107
+	 * @access protected
2108
+	 * @param bool $notify whether or not to notify the registrant about their approval.
2109
+	 * @return void
2110
+	 */
2111
+	protected function approve_registration($notify = false)
2112
+	{
2113
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2114
+	}
2115
+
2116
+
2117
+	/**
2118
+	 *        decline_registration
2119
+	 *
2120
+	 * @access protected
2121
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2122
+	 * @return void
2123
+	 */
2124
+	protected function decline_registration($notify = false)
2125
+	{
2126
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2127
+	}
2128
+
2129
+
2130
+	/**
2131
+	 *        cancel_registration
2132
+	 *
2133
+	 * @access protected
2134
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2135
+	 * @return void
2136
+	 */
2137
+	protected function cancel_registration($notify = false)
2138
+	{
2139
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2140
+	}
2141
+
2142
+
2143
+	/**
2144
+	 *        not_approve_registration
2145
+	 *
2146
+	 * @access protected
2147
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2148
+	 * @return void
2149
+	 */
2150
+	protected function not_approve_registration($notify = false)
2151
+	{
2152
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2153
+	}
2154
+
2155
+
2156
+	/**
2157
+	 *        decline_registration
2158
+	 *
2159
+	 * @access protected
2160
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2161
+	 * @return void
2162
+	 */
2163
+	protected function pending_registration($notify = false)
2164
+	{
2165
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2166
+	}
2167
+
2168
+
2169
+	/**
2170
+	 * waitlist_registration
2171
+	 *
2172
+	 * @access protected
2173
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2174
+	 * @return void
2175
+	 */
2176
+	protected function wait_list_registration($notify = false)
2177
+	{
2178
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2179
+	}
2180
+
2181
+
2182
+	/**
2183
+	 *        generates HTML for the Registration main meta box
2184
+	 *
2185
+	 * @access public
2186
+	 * @return void
2187
+	 * @throws DomainException
2188
+	 * @throws EE_Error
2189
+	 * @throws InvalidArgumentException
2190
+	 * @throws InvalidDataTypeException
2191
+	 * @throws InvalidInterfaceException
2192
+	 * @throws ReflectionException
2193
+	 * @throws EntityNotFoundException
2194
+	 */
2195
+	public function _reg_details_meta_box()
2196
+	{
2197
+		EEH_Autoloader::register_line_item_display_autoloaders();
2198
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2199
+		EE_Registry::instance()->load_helper('Line_Item');
2200
+		$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2201
+			: EE_Transaction::new_instance();
2202
+		$this->_session = $transaction->session_data();
2203
+		$filters = new EE_Line_Item_Filter_Collection();
2204
+		// $filters->add( new EE_Non_Zero_Line_Item_Filter() );
2205
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2206
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2207
+			$filters,
2208
+			$transaction->total_line_item()
2209
+		);
2210
+		$filtered_line_item_tree = $line_item_filter_processor->process();
2211
+		$line_item_display = new EE_Line_Item_Display(
2212
+			'reg_admin_table',
2213
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2214
+		);
2215
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2216
+			$filtered_line_item_tree,
2217
+			array('EE_Registration' => $this->_registration)
2218
+		);
2219
+		$attendee = $this->_registration->attendee();
2220
+		if (EE_Registry::instance()->CAP->current_user_can(
2221
+			'ee_read_transaction',
2222
+			'espresso_transactions_view_transaction'
2223
+		)) {
2224
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2225
+				EE_Admin_Page::add_query_args_and_nonce(
2226
+					array(
2227
+						'action' => 'view_transaction',
2228
+						'TXN_ID' => $transaction->ID(),
2229
+					),
2230
+					TXN_ADMIN_URL
2231
+				),
2232
+				esc_html__(' View Transaction', 'event_espresso'),
2233
+				'button secondary-button right',
2234
+				'dashicons dashicons-cart'
2235
+			);
2236
+		} else {
2237
+			$this->_template_args['view_transaction_button'] = '';
2238
+		}
2239
+		if ($attendee instanceof EE_Attendee
2240
+			&& EE_Registry::instance()->CAP->current_user_can(
2241
+				'ee_send_message',
2242
+				'espresso_registrations_resend_registration'
2243
+			)
2244
+		) {
2245
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2246
+				EE_Admin_Page::add_query_args_and_nonce(
2247
+					array(
2248
+						'action'      => 'resend_registration',
2249
+						'_REG_ID'     => $this->_registration->ID(),
2250
+						'redirect_to' => 'view_registration',
2251
+					),
2252
+					REG_ADMIN_URL
2253
+				),
2254
+				esc_html__(' Resend Registration', 'event_espresso'),
2255
+				'button secondary-button right',
2256
+				'dashicons dashicons-email-alt'
2257
+			);
2258
+		} else {
2259
+			$this->_template_args['resend_registration_button'] = '';
2260
+		}
2261
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2262
+		$payment = $transaction->get_first_related('Payment');
2263
+		$payment = ! $payment instanceof EE_Payment
2264
+			? EE_Payment::new_instance()
2265
+			: $payment;
2266
+		$payment_method = $payment->get_first_related('Payment_Method');
2267
+		$payment_method = ! $payment_method instanceof EE_Payment_Method
2268
+			? EE_Payment_Method::new_instance()
2269
+			: $payment_method;
2270
+		$reg_details = array(
2271
+			'payment_method'       => $payment_method->name(),
2272
+			'response_msg'         => $payment->gateway_response(),
2273
+			'registration_id'      => $this->_registration->get('REG_code'),
2274
+			'registration_session' => $this->_registration->session_ID(),
2275
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2276
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2277
+		);
2278
+		if (isset($reg_details['registration_id'])) {
2279
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2280
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2281
+				'Registration ID',
2282
+				'event_espresso'
2283
+			);
2284
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2285
+		}
2286
+		if (isset($reg_details['payment_method'])) {
2287
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2288
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2289
+				'Most Recent Payment Method',
2290
+				'event_espresso'
2291
+			);
2292
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2293
+			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2294
+			$this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2295
+				'Payment method response',
2296
+				'event_espresso'
2297
+			);
2298
+			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2299
+		}
2300
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2301
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2302
+			'Registration Session',
2303
+			'event_espresso'
2304
+		);
2305
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2306
+		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2307
+		$this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2308
+			'Registration placed from IP',
2309
+			'event_espresso'
2310
+		);
2311
+		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2312
+		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2313
+		$this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2314
+			'Registrant User Agent',
2315
+			'event_espresso'
2316
+		);
2317
+		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2318
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2319
+			array(
2320
+				'action'   => 'default',
2321
+				'event_id' => $this->_registration->event_ID(),
2322
+			),
2323
+			REG_ADMIN_URL
2324
+		);
2325
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2326
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2327
+		$template_path =
2328
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2329
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2330
+	}
2331
+
2332
+
2333
+	/**
2334
+	 * generates HTML for the Registration Questions meta box.
2335
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2336
+	 * otherwise uses new forms system
2337
+	 *
2338
+	 * @access public
2339
+	 * @return void
2340
+	 * @throws DomainException
2341
+	 * @throws EE_Error
2342
+	 */
2343
+	public function _reg_questions_meta_box()
2344
+	{
2345
+		// allow someone to override this method entirely
2346
+		if (apply_filters(
2347
+			'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2348
+			true,
2349
+			$this,
2350
+			$this->_registration
2351
+		)) {
2352
+			$form = $this->_get_reg_custom_questions_form(
2353
+				$this->_registration->ID()
2354
+			);
2355
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2356
+				? $form->get_html_and_js()
2357
+				: '';
2358
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2359
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2360
+			$template_path =
2361
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2362
+			echo EEH_Template::display_template($template_path, $this->_template_args, true);
2363
+		}
2364
+	}
2365
+
2366
+
2367
+	/**
2368
+	 * form_before_question_group
2369
+	 *
2370
+	 * @deprecated    as of 4.8.32.rc.000
2371
+	 * @access        public
2372
+	 * @param        string $output
2373
+	 * @return        string
2374
+	 */
2375
+	public function form_before_question_group($output)
2376
+	{
2377
+		EE_Error::doing_it_wrong(
2378
+			__CLASS__ . '::' . __FUNCTION__,
2379
+			esc_html__(
2380
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2381
+				'event_espresso'
2382
+			),
2383
+			'4.8.32.rc.000'
2384
+		);
2385
+		return '
2386 2386
 	<table class="form-table ee-width-100">
2387 2387
 		<tbody>
2388 2388
 			';
2389
-    }
2390
-
2391
-
2392
-    /**
2393
-     * form_after_question_group
2394
-     *
2395
-     * @deprecated    as of 4.8.32.rc.000
2396
-     * @access        public
2397
-     * @param        string $output
2398
-     * @return        string
2399
-     */
2400
-    public function form_after_question_group($output)
2401
-    {
2402
-        EE_Error::doing_it_wrong(
2403
-            __CLASS__ . '::' . __FUNCTION__,
2404
-            esc_html__(
2405
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2406
-                'event_espresso'
2407
-            ),
2408
-            '4.8.32.rc.000'
2409
-        );
2410
-        return '
2389
+	}
2390
+
2391
+
2392
+	/**
2393
+	 * form_after_question_group
2394
+	 *
2395
+	 * @deprecated    as of 4.8.32.rc.000
2396
+	 * @access        public
2397
+	 * @param        string $output
2398
+	 * @return        string
2399
+	 */
2400
+	public function form_after_question_group($output)
2401
+	{
2402
+		EE_Error::doing_it_wrong(
2403
+			__CLASS__ . '::' . __FUNCTION__,
2404
+			esc_html__(
2405
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2406
+				'event_espresso'
2407
+			),
2408
+			'4.8.32.rc.000'
2409
+		);
2410
+		return '
2411 2411
 			<tr class="hide-if-no-js">
2412 2412
 				<th> </th>
2413 2413
 				<td class="reg-admin-edit-attendee-question-td">
2414 2414
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2415
-               . esc_attr__('click to edit question', 'event_espresso')
2416
-               . '">
2415
+			   . esc_attr__('click to edit question', 'event_espresso')
2416
+			   . '">
2417 2417
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2418
-               . esc_html__('edit the above question group', 'event_espresso')
2419
-               . '</span>
2418
+			   . esc_html__('edit the above question group', 'event_espresso')
2419
+			   . '</span>
2420 2420
 						<div class="dashicons dashicons-edit"></div>
2421 2421
 					</a>
2422 2422
 				</td>
@@ -2424,606 +2424,606 @@  discard block
 block discarded – undo
2424 2424
 		</tbody>
2425 2425
 	</table>
2426 2426
 ';
2427
-    }
2428
-
2429
-
2430
-    /**
2431
-     * form_form_field_label_wrap
2432
-     *
2433
-     * @deprecated    as of 4.8.32.rc.000
2434
-     * @access        public
2435
-     * @param        string $label
2436
-     * @return        string
2437
-     */
2438
-    public function form_form_field_label_wrap($label)
2439
-    {
2440
-        EE_Error::doing_it_wrong(
2441
-            __CLASS__ . '::' . __FUNCTION__,
2442
-            esc_html__(
2443
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2444
-                'event_espresso'
2445
-            ),
2446
-            '4.8.32.rc.000'
2447
-        );
2448
-        return '
2427
+	}
2428
+
2429
+
2430
+	/**
2431
+	 * form_form_field_label_wrap
2432
+	 *
2433
+	 * @deprecated    as of 4.8.32.rc.000
2434
+	 * @access        public
2435
+	 * @param        string $label
2436
+	 * @return        string
2437
+	 */
2438
+	public function form_form_field_label_wrap($label)
2439
+	{
2440
+		EE_Error::doing_it_wrong(
2441
+			__CLASS__ . '::' . __FUNCTION__,
2442
+			esc_html__(
2443
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2444
+				'event_espresso'
2445
+			),
2446
+			'4.8.32.rc.000'
2447
+		);
2448
+		return '
2449 2449
 			<tr>
2450 2450
 				<th>
2451 2451
 					' . $label . '
2452 2452
 				</th>';
2453
-    }
2454
-
2455
-
2456
-    /**
2457
-     * form_form_field_input__wrap
2458
-     *
2459
-     * @deprecated    as of 4.8.32.rc.000
2460
-     * @access        public
2461
-     * @param        string $input
2462
-     * @return        string
2463
-     */
2464
-    public function form_form_field_input__wrap($input)
2465
-    {
2466
-        EE_Error::doing_it_wrong(
2467
-            __CLASS__ . '::' . __FUNCTION__,
2468
-            esc_html__(
2469
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2470
-                'event_espresso'
2471
-            ),
2472
-            '4.8.32.rc.000'
2473
-        );
2474
-        return '
2453
+	}
2454
+
2455
+
2456
+	/**
2457
+	 * form_form_field_input__wrap
2458
+	 *
2459
+	 * @deprecated    as of 4.8.32.rc.000
2460
+	 * @access        public
2461
+	 * @param        string $input
2462
+	 * @return        string
2463
+	 */
2464
+	public function form_form_field_input__wrap($input)
2465
+	{
2466
+		EE_Error::doing_it_wrong(
2467
+			__CLASS__ . '::' . __FUNCTION__,
2468
+			esc_html__(
2469
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2470
+				'event_espresso'
2471
+			),
2472
+			'4.8.32.rc.000'
2473
+		);
2474
+		return '
2475 2475
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2476 2476
 					' . $input . '
2477 2477
 				</td>
2478 2478
 			</tr>';
2479
-    }
2480
-
2481
-
2482
-    /**
2483
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2484
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2485
-     * to display the page
2486
-     *
2487
-     * @access protected
2488
-     * @return void
2489
-     * @throws EE_Error
2490
-     */
2491
-    protected function _update_attendee_registration_form()
2492
-    {
2493
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2494
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2495
-            $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2496
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2497
-            if ($success) {
2498
-                $what = esc_html__('Registration Form', 'event_espresso');
2499
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2500
-                    : array('action' => 'default');
2501
-                $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2502
-            }
2503
-        }
2504
-    }
2505
-
2506
-
2507
-    /**
2508
-     * Gets the form for saving registrations custom questions (if done
2509
-     * previously retrieves the cached form object, which may have validation errors in it)
2510
-     *
2511
-     * @param int $REG_ID
2512
-     * @return EE_Registration_Custom_Questions_Form
2513
-     * @throws EE_Error
2514
-     * @throws InvalidArgumentException
2515
-     * @throws InvalidDataTypeException
2516
-     * @throws InvalidInterfaceException
2517
-     */
2518
-    protected function _get_reg_custom_questions_form($REG_ID)
2519
-    {
2520
-        if (! $this->_reg_custom_questions_form) {
2521
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2522
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2523
-                EEM_Registration::instance()->get_one_by_ID($REG_ID)
2524
-            );
2525
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2526
-        }
2527
-        return $this->_reg_custom_questions_form;
2528
-    }
2529
-
2530
-
2531
-    /**
2532
-     * Saves
2533
-     *
2534
-     * @access private
2535
-     * @param bool $REG_ID
2536
-     * @return bool
2537
-     * @throws EE_Error
2538
-     * @throws InvalidArgumentException
2539
-     * @throws InvalidDataTypeException
2540
-     * @throws InvalidInterfaceException
2541
-     */
2542
-    private function _save_reg_custom_questions_form($REG_ID = false)
2543
-    {
2544
-        if (! $REG_ID) {
2545
-            EE_Error::add_error(
2546
-                esc_html__(
2547
-                    'An error occurred. No registration ID was received.',
2548
-                    'event_espresso'
2549
-                ),
2550
-                __FILE__,
2551
-                __FUNCTION__,
2552
-                __LINE__
2553
-            );
2554
-        }
2555
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2556
-        $form->receive_form_submission($this->_req_data);
2557
-        $success = false;
2558
-        if ($form->is_valid()) {
2559
-            foreach ($form->subforms() as $question_group_id => $question_group_form) {
2560
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2561
-                    $where_conditions = array(
2562
-                        'QST_ID' => $question_id,
2563
-                        'REG_ID' => $REG_ID,
2564
-                    );
2565
-                    $possibly_new_values = array(
2566
-                        'ANS_value' => $input->normalized_value(),
2567
-                    );
2568
-                    $answer = EEM_Answer::instance()->get_one(array($where_conditions));
2569
-                    if ($answer instanceof EE_Answer) {
2570
-                        $success = $answer->save($possibly_new_values);
2571
-                    } else {
2572
-                        // insert it then
2573
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2574
-                        $answer = EE_Answer::new_instance($cols_n_vals);
2575
-                        $success = $answer->save();
2576
-                    }
2577
-                }
2578
-            }
2579
-        } else {
2580
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2581
-        }
2582
-        return $success;
2583
-    }
2584
-
2585
-
2586
-    /**
2587
-     *        generates HTML for the Registration main meta box
2588
-     *
2589
-     * @access public
2590
-     * @return void
2591
-     * @throws DomainException
2592
-     * @throws EE_Error
2593
-     * @throws InvalidArgumentException
2594
-     * @throws InvalidDataTypeException
2595
-     * @throws InvalidInterfaceException
2596
-     */
2597
-    public function _reg_attendees_meta_box()
2598
-    {
2599
-        $REG = EEM_Registration::instance();
2600
-        // get all other registrations on this transaction, and cache
2601
-        // the attendees for them so we don't have to run another query using force_join
2602
-        $registrations = $REG->get_all(
2603
-            array(
2604
-                array(
2605
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2606
-                    'REG_ID' => array('!=', $this->_registration->ID()),
2607
-                ),
2608
-                'force_join' => array('Attendee'),
2609
-            )
2610
-        );
2611
-        $this->_template_args['attendees'] = array();
2612
-        $this->_template_args['attendee_notice'] = '';
2613
-        if (empty($registrations)
2614
-            || (is_array($registrations)
2615
-                && ! EEH_Array::get_one_item_from_array($registrations))
2616
-        ) {
2617
-            EE_Error::add_error(
2618
-                esc_html__(
2619
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2620
-                    'event_espresso'
2621
-                ),
2622
-                __FILE__,
2623
-                __FUNCTION__,
2624
-                __LINE__
2625
-            );
2626
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2627
-        } else {
2628
-            $att_nmbr = 1;
2629
-            foreach ($registrations as $registration) {
2630
-                /* @var $registration EE_Registration */
2631
-                $attendee = $registration->attendee()
2632
-                    ? $registration->attendee()
2633
-                    : EEM_Attendee::instance()
2634
-                                  ->create_default_object();
2635
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2636
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2637
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2638
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2639
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2640
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2641
-                    ', ',
2642
-                    $attendee->full_address_as_array()
2643
-                );
2644
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2645
-                    array(
2646
-                        'action' => 'edit_attendee',
2647
-                        'post'   => $attendee->ID(),
2648
-                    ),
2649
-                    REG_ADMIN_URL
2650
-                );
2651
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name();
2652
-                $att_nmbr++;
2653
-            }
2654
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2655
-        }
2656
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2657
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2658
-    }
2659
-
2660
-
2661
-    /**
2662
-     *        generates HTML for the Edit Registration side meta box
2663
-     *
2664
-     * @access public
2665
-     * @return void
2666
-     * @throws DomainException
2667
-     * @throws EE_Error
2668
-     * @throws InvalidArgumentException
2669
-     * @throws InvalidDataTypeException
2670
-     * @throws InvalidInterfaceException
2671
-     */
2672
-    public function _reg_registrant_side_meta_box()
2673
-    {
2674
-        /*@var $attendee EE_Attendee */
2675
-        $att_check = $this->_registration->attendee();
2676
-        $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2677
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2678
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2679
-        // primary registration object (that way we know if we need to show create button or not)
2680
-        if (! $this->_registration->is_primary_registrant()) {
2681
-            $primary_registration = $this->_registration->get_primary_registration();
2682
-            $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2683
-                : null;
2684
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2685
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2686
-                // custom attendee object so let's not worry about the primary reg.
2687
-                $primary_registration = null;
2688
-            }
2689
-        } else {
2690
-            $primary_registration = null;
2691
-        }
2692
-        $this->_template_args['ATT_ID'] = $attendee->ID();
2693
-        $this->_template_args['fname'] = $attendee->fname();
2694
-        $this->_template_args['lname'] = $attendee->lname();
2695
-        $this->_template_args['email'] = $attendee->email();
2696
-        $this->_template_args['phone'] = $attendee->phone();
2697
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2698
-        // edit link
2699
-        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2700
-            array(
2701
-                'action' => 'edit_attendee',
2702
-                'post'   => $attendee->ID(),
2703
-            ),
2704
-            REG_ADMIN_URL
2705
-        );
2706
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2707
-        // create link
2708
-        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2709
-            ? EE_Admin_Page::add_query_args_and_nonce(
2710
-                array(
2711
-                    'action'  => 'duplicate_attendee',
2712
-                    '_REG_ID' => $this->_registration->ID(),
2713
-                ),
2714
-                REG_ADMIN_URL
2715
-            ) : '';
2716
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2717
-        $this->_template_args['att_check'] = $att_check;
2718
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2719
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2720
-    }
2721
-
2722
-
2723
-    /**
2724
-     * trash or restore registrations
2725
-     *
2726
-     * @param  boolean $trash whether to archive or restore
2727
-     * @return void
2728
-     * @throws EE_Error
2729
-     * @throws InvalidArgumentException
2730
-     * @throws InvalidDataTypeException
2731
-     * @throws InvalidInterfaceException
2732
-     * @throws RuntimeException
2733
-     * @access protected
2734
-     */
2735
-    protected function _trash_or_restore_registrations($trash = true)
2736
-    {
2737
-        // if empty _REG_ID then get out because there's nothing to do
2738
-        if (empty($this->_req_data['_REG_ID'])) {
2739
-            EE_Error::add_error(
2740
-                sprintf(
2741
-                    esc_html__(
2742
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2743
-                        'event_espresso'
2744
-                    ),
2745
-                    $trash ? 'trash' : 'restore'
2746
-                ),
2747
-                __FILE__,
2748
-                __LINE__,
2749
-                __FUNCTION__
2750
-            );
2751
-            $this->_redirect_after_action(false, '', '', array(), true);
2752
-        }
2753
-        $success = 0;
2754
-        $overwrite_msgs = false;
2755
-        // Checkboxes
2756
-        if (! is_array($this->_req_data['_REG_ID'])) {
2757
-            $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2758
-        }
2759
-        $reg_count = count($this->_req_data['_REG_ID']);
2760
-        // cycle thru checkboxes
2761
-        foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2762
-            /** @var EE_Registration $REG */
2763
-            $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2764
-            $payments = $REG->registration_payments();
2765
-            if (! empty($payments)) {
2766
-                $name = $REG->attendee() instanceof EE_Attendee
2767
-                    ? $REG->attendee()->full_name()
2768
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2769
-                $overwrite_msgs = true;
2770
-                EE_Error::add_error(
2771
-                    sprintf(
2772
-                        esc_html__(
2773
-                            '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.',
2774
-                            'event_espresso'
2775
-                        ),
2776
-                        $name
2777
-                    ),
2778
-                    __FILE__,
2779
-                    __FUNCTION__,
2780
-                    __LINE__
2781
-                );
2782
-                // can't trash this registration because it has payments.
2783
-                continue;
2784
-            }
2785
-            $updated = $trash ? $REG->delete() : $REG->restore();
2786
-            if ($updated) {
2787
-                $success++;
2788
-            }
2789
-        }
2790
-        $this->_redirect_after_action(
2791
-            $success === $reg_count, // were ALL registrations affected?
2792
-            $success > 1
2793
-                ? esc_html__('Registrations', 'event_espresso')
2794
-                : esc_html__('Registration', 'event_espresso'),
2795
-            $trash
2796
-                ? esc_html__('moved to the trash', 'event_espresso')
2797
-                : esc_html__('restored', 'event_espresso'),
2798
-            array('action' => 'default'),
2799
-            $overwrite_msgs
2800
-        );
2801
-    }
2802
-
2803
-
2804
-    /**
2805
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2806
-     * registration but also.
2807
-     * 1. Removing relations to EE_Attendee
2808
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2809
-     * ALSO trashed.
2810
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2811
-     * 4. Removing relationships between all tickets and the related registrations
2812
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2813
-     * 6. Deleting permanently any related Checkins.
2814
-     *
2815
-     * @return void
2816
-     * @throws EE_Error
2817
-     * @throws InvalidArgumentException
2818
-     * @throws InvalidDataTypeException
2819
-     * @throws InvalidInterfaceException
2820
-     */
2821
-    protected function _delete_registrations()
2822
-    {
2823
-        $REG_MDL = EEM_Registration::instance();
2824
-        $success = 1;
2825
-        // Checkboxes
2826
-        if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2827
-            // if array has more than one element than success message should be plural
2828
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2829
-            // cycle thru checkboxes
2830
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2831
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2832
-                if (! $REG instanceof EE_Registration) {
2833
-                    continue;
2834
-                }
2835
-                $deleted = $this->_delete_registration($REG);
2836
-                if (! $deleted) {
2837
-                    $success = 0;
2838
-                }
2839
-            }
2840
-        } else {
2841
-            // grab single id and delete
2842
-            $REG_ID = $this->_req_data['_REG_ID'];
2843
-            $REG = $REG_MDL->get_one_by_ID($REG_ID);
2844
-            $deleted = $this->_delete_registration($REG);
2845
-            if (! $deleted) {
2846
-                $success = 0;
2847
-            }
2848
-        }
2849
-        $what = $success > 1
2850
-            ? esc_html__('Registrations', 'event_espresso')
2851
-            : esc_html__('Registration', 'event_espresso');
2852
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2853
-        $this->_redirect_after_action(
2854
-            $success,
2855
-            $what,
2856
-            $action_desc,
2857
-            array('action' => 'default'),
2858
-            true
2859
-        );
2860
-    }
2861
-
2862
-
2863
-    /**
2864
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2865
-     * models get affected.
2866
-     *
2867
-     * @param  EE_Registration $REG registration to be deleted permenantly
2868
-     * @return bool true = successful deletion, false = fail.
2869
-     * @throws EE_Error
2870
-     */
2871
-    protected function _delete_registration(EE_Registration $REG)
2872
-    {
2873
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2874
-        // registrations on the transaction that are NOT trashed.
2875
-        $TXN = $REG->get_first_related('Transaction');
2876
-        $REGS = $TXN->get_many_related('Registration');
2877
-        $all_trashed = true;
2878
-        foreach ($REGS as $registration) {
2879
-            if (! $registration->get('REG_deleted')) {
2880
-                $all_trashed = false;
2881
-            }
2882
-        }
2883
-        if (! $all_trashed) {
2884
-            EE_Error::add_error(
2885
-                esc_html__(
2886
-                    '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.',
2887
-                    'event_espresso'
2888
-                ),
2889
-                __FILE__,
2890
-                __FUNCTION__,
2891
-                __LINE__
2892
-            );
2893
-            return false;
2894
-        }
2895
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2896
-        // separately from THIS one).
2897
-        foreach ($REGS as $registration) {
2898
-            // delete related answers
2899
-            $registration->delete_related_permanently('Answer');
2900
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2901
-            $attendee = $registration->get_first_related('Attendee');
2902
-            if ($attendee instanceof EE_Attendee) {
2903
-                $registration->_remove_relation_to($attendee, 'Attendee');
2904
-            }
2905
-            // now remove relationships to tickets on this registration.
2906
-            $registration->_remove_relations('Ticket');
2907
-            // now delete permanently the checkins related to this registration.
2908
-            $registration->delete_related_permanently('Checkin');
2909
-            if ($registration->ID() === $REG->ID()) {
2910
-                continue;
2911
-            } //we don't want to delete permanently the existing registration just yet.
2912
-            // remove relation to transaction for these registrations if NOT the existing registrations
2913
-            $registration->_remove_relations('Transaction');
2914
-            // delete permanently any related messages.
2915
-            $registration->delete_related_permanently('Message');
2916
-            // now delete this registration permanently
2917
-            $registration->delete_permanently();
2918
-        }
2919
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2920
-        // (the transaction and line items should be all that's left).
2921
-        // delete the line items related to the transaction for this registration.
2922
-        $TXN->delete_related_permanently('Line_Item');
2923
-        // we need to remove all the relationships on the transaction
2924
-        $TXN->delete_related_permanently('Payment');
2925
-        $TXN->delete_related_permanently('Extra_Meta');
2926
-        $TXN->delete_related_permanently('Message');
2927
-        // now we can delete this REG permanently (and the transaction of course)
2928
-        $REG->delete_related_permanently('Transaction');
2929
-        return $REG->delete_permanently();
2930
-    }
2931
-
2932
-
2933
-    /**
2934
-     *    generates HTML for the Register New Attendee Admin page
2935
-     *
2936
-     * @access private
2937
-     * @throws DomainException
2938
-     * @throws EE_Error
2939
-     */
2940
-    public function new_registration()
2941
-    {
2942
-        if (! $this->_set_reg_event()) {
2943
-            throw new EE_Error(
2944
-                esc_html__(
2945
-                    'Unable to continue with registering because there is no Event ID in the request',
2946
-                    'event_espresso'
2947
-                )
2948
-            );
2949
-        }
2950
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2951
-        // gotta start with a clean slate if we're not coming here via ajax
2952
-        if (! defined('DOING_AJAX')
2953
-            && (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2954
-        ) {
2955
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2956
-        }
2957
-        $this->_template_args['event_name'] = '';
2958
-        // event name
2959
-        if ($this->_reg_event) {
2960
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2961
-            $edit_event_url = self::add_query_args_and_nonce(
2962
-                array(
2963
-                    'action' => 'edit',
2964
-                    'post'   => $this->_reg_event->ID(),
2965
-                ),
2966
-                EVENTS_ADMIN_URL
2967
-            );
2968
-            $edit_event_lnk = '<a href="'
2969
-                              . $edit_event_url
2970
-                              . '" title="'
2971
-                              . esc_attr__('Edit ', 'event_espresso')
2972
-                              . $this->_reg_event->name()
2973
-                              . '">'
2974
-                              . esc_html__('Edit Event', 'event_espresso')
2975
-                              . '</a>';
2976
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2977
-                                                   . $edit_event_lnk
2978
-                                                   . '</span>';
2979
-        }
2980
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2981
-        if (defined('DOING_AJAX')) {
2982
-            $this->_return_json();
2983
-        }
2984
-        // grab header
2985
-        $template_path =
2986
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2987
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2988
-            $template_path,
2989
-            $this->_template_args,
2990
-            true
2991
-        );
2992
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2993
-        // the details template wrapper
2994
-        $this->display_admin_page_with_sidebar();
2995
-    }
2996
-
2997
-
2998
-    /**
2999
-     * This returns the content for a registration step
3000
-     *
3001
-     * @access protected
3002
-     * @return string html
3003
-     * @throws DomainException
3004
-     * @throws EE_Error
3005
-     * @throws InvalidArgumentException
3006
-     * @throws InvalidDataTypeException
3007
-     * @throws InvalidInterfaceException
3008
-     */
3009
-    protected function _get_registration_step_content()
3010
-    {
3011
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
3012
-            $warning_msg = sprintf(
3013
-                esc_html__(
3014
-                    '%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',
3015
-                    'event_espresso'
3016
-                ),
3017
-                '<br />',
3018
-                '<h3 class="important-notice">',
3019
-                '</h3>',
3020
-                '<div class="float-right">',
3021
-                '<span id="redirect_timer" class="important-notice">30</span>',
3022
-                '</div>',
3023
-                '<b>',
3024
-                '</b>'
3025
-            );
3026
-            return '
2479
+	}
2480
+
2481
+
2482
+	/**
2483
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2484
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2485
+	 * to display the page
2486
+	 *
2487
+	 * @access protected
2488
+	 * @return void
2489
+	 * @throws EE_Error
2490
+	 */
2491
+	protected function _update_attendee_registration_form()
2492
+	{
2493
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2494
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2495
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2496
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2497
+			if ($success) {
2498
+				$what = esc_html__('Registration Form', 'event_espresso');
2499
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2500
+					: array('action' => 'default');
2501
+				$this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2502
+			}
2503
+		}
2504
+	}
2505
+
2506
+
2507
+	/**
2508
+	 * Gets the form for saving registrations custom questions (if done
2509
+	 * previously retrieves the cached form object, which may have validation errors in it)
2510
+	 *
2511
+	 * @param int $REG_ID
2512
+	 * @return EE_Registration_Custom_Questions_Form
2513
+	 * @throws EE_Error
2514
+	 * @throws InvalidArgumentException
2515
+	 * @throws InvalidDataTypeException
2516
+	 * @throws InvalidInterfaceException
2517
+	 */
2518
+	protected function _get_reg_custom_questions_form($REG_ID)
2519
+	{
2520
+		if (! $this->_reg_custom_questions_form) {
2521
+			require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2522
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2523
+				EEM_Registration::instance()->get_one_by_ID($REG_ID)
2524
+			);
2525
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2526
+		}
2527
+		return $this->_reg_custom_questions_form;
2528
+	}
2529
+
2530
+
2531
+	/**
2532
+	 * Saves
2533
+	 *
2534
+	 * @access private
2535
+	 * @param bool $REG_ID
2536
+	 * @return bool
2537
+	 * @throws EE_Error
2538
+	 * @throws InvalidArgumentException
2539
+	 * @throws InvalidDataTypeException
2540
+	 * @throws InvalidInterfaceException
2541
+	 */
2542
+	private function _save_reg_custom_questions_form($REG_ID = false)
2543
+	{
2544
+		if (! $REG_ID) {
2545
+			EE_Error::add_error(
2546
+				esc_html__(
2547
+					'An error occurred. No registration ID was received.',
2548
+					'event_espresso'
2549
+				),
2550
+				__FILE__,
2551
+				__FUNCTION__,
2552
+				__LINE__
2553
+			);
2554
+		}
2555
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2556
+		$form->receive_form_submission($this->_req_data);
2557
+		$success = false;
2558
+		if ($form->is_valid()) {
2559
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
2560
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2561
+					$where_conditions = array(
2562
+						'QST_ID' => $question_id,
2563
+						'REG_ID' => $REG_ID,
2564
+					);
2565
+					$possibly_new_values = array(
2566
+						'ANS_value' => $input->normalized_value(),
2567
+					);
2568
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
2569
+					if ($answer instanceof EE_Answer) {
2570
+						$success = $answer->save($possibly_new_values);
2571
+					} else {
2572
+						// insert it then
2573
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2574
+						$answer = EE_Answer::new_instance($cols_n_vals);
2575
+						$success = $answer->save();
2576
+					}
2577
+				}
2578
+			}
2579
+		} else {
2580
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2581
+		}
2582
+		return $success;
2583
+	}
2584
+
2585
+
2586
+	/**
2587
+	 *        generates HTML for the Registration main meta box
2588
+	 *
2589
+	 * @access public
2590
+	 * @return void
2591
+	 * @throws DomainException
2592
+	 * @throws EE_Error
2593
+	 * @throws InvalidArgumentException
2594
+	 * @throws InvalidDataTypeException
2595
+	 * @throws InvalidInterfaceException
2596
+	 */
2597
+	public function _reg_attendees_meta_box()
2598
+	{
2599
+		$REG = EEM_Registration::instance();
2600
+		// get all other registrations on this transaction, and cache
2601
+		// the attendees for them so we don't have to run another query using force_join
2602
+		$registrations = $REG->get_all(
2603
+			array(
2604
+				array(
2605
+					'TXN_ID' => $this->_registration->transaction_ID(),
2606
+					'REG_ID' => array('!=', $this->_registration->ID()),
2607
+				),
2608
+				'force_join' => array('Attendee'),
2609
+			)
2610
+		);
2611
+		$this->_template_args['attendees'] = array();
2612
+		$this->_template_args['attendee_notice'] = '';
2613
+		if (empty($registrations)
2614
+			|| (is_array($registrations)
2615
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2616
+		) {
2617
+			EE_Error::add_error(
2618
+				esc_html__(
2619
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2620
+					'event_espresso'
2621
+				),
2622
+				__FILE__,
2623
+				__FUNCTION__,
2624
+				__LINE__
2625
+			);
2626
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2627
+		} else {
2628
+			$att_nmbr = 1;
2629
+			foreach ($registrations as $registration) {
2630
+				/* @var $registration EE_Registration */
2631
+				$attendee = $registration->attendee()
2632
+					? $registration->attendee()
2633
+					: EEM_Attendee::instance()
2634
+								  ->create_default_object();
2635
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2636
+				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2637
+				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2638
+				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2639
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2640
+				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2641
+					', ',
2642
+					$attendee->full_address_as_array()
2643
+				);
2644
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2645
+					array(
2646
+						'action' => 'edit_attendee',
2647
+						'post'   => $attendee->ID(),
2648
+					),
2649
+					REG_ADMIN_URL
2650
+				);
2651
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name();
2652
+				$att_nmbr++;
2653
+			}
2654
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2655
+		}
2656
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2657
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2658
+	}
2659
+
2660
+
2661
+	/**
2662
+	 *        generates HTML for the Edit Registration side meta box
2663
+	 *
2664
+	 * @access public
2665
+	 * @return void
2666
+	 * @throws DomainException
2667
+	 * @throws EE_Error
2668
+	 * @throws InvalidArgumentException
2669
+	 * @throws InvalidDataTypeException
2670
+	 * @throws InvalidInterfaceException
2671
+	 */
2672
+	public function _reg_registrant_side_meta_box()
2673
+	{
2674
+		/*@var $attendee EE_Attendee */
2675
+		$att_check = $this->_registration->attendee();
2676
+		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2677
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2678
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2679
+		// primary registration object (that way we know if we need to show create button or not)
2680
+		if (! $this->_registration->is_primary_registrant()) {
2681
+			$primary_registration = $this->_registration->get_primary_registration();
2682
+			$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2683
+				: null;
2684
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2685
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2686
+				// custom attendee object so let's not worry about the primary reg.
2687
+				$primary_registration = null;
2688
+			}
2689
+		} else {
2690
+			$primary_registration = null;
2691
+		}
2692
+		$this->_template_args['ATT_ID'] = $attendee->ID();
2693
+		$this->_template_args['fname'] = $attendee->fname();
2694
+		$this->_template_args['lname'] = $attendee->lname();
2695
+		$this->_template_args['email'] = $attendee->email();
2696
+		$this->_template_args['phone'] = $attendee->phone();
2697
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2698
+		// edit link
2699
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2700
+			array(
2701
+				'action' => 'edit_attendee',
2702
+				'post'   => $attendee->ID(),
2703
+			),
2704
+			REG_ADMIN_URL
2705
+		);
2706
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2707
+		// create link
2708
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2709
+			? EE_Admin_Page::add_query_args_and_nonce(
2710
+				array(
2711
+					'action'  => 'duplicate_attendee',
2712
+					'_REG_ID' => $this->_registration->ID(),
2713
+				),
2714
+				REG_ADMIN_URL
2715
+			) : '';
2716
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2717
+		$this->_template_args['att_check'] = $att_check;
2718
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2719
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2720
+	}
2721
+
2722
+
2723
+	/**
2724
+	 * trash or restore registrations
2725
+	 *
2726
+	 * @param  boolean $trash whether to archive or restore
2727
+	 * @return void
2728
+	 * @throws EE_Error
2729
+	 * @throws InvalidArgumentException
2730
+	 * @throws InvalidDataTypeException
2731
+	 * @throws InvalidInterfaceException
2732
+	 * @throws RuntimeException
2733
+	 * @access protected
2734
+	 */
2735
+	protected function _trash_or_restore_registrations($trash = true)
2736
+	{
2737
+		// if empty _REG_ID then get out because there's nothing to do
2738
+		if (empty($this->_req_data['_REG_ID'])) {
2739
+			EE_Error::add_error(
2740
+				sprintf(
2741
+					esc_html__(
2742
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2743
+						'event_espresso'
2744
+					),
2745
+					$trash ? 'trash' : 'restore'
2746
+				),
2747
+				__FILE__,
2748
+				__LINE__,
2749
+				__FUNCTION__
2750
+			);
2751
+			$this->_redirect_after_action(false, '', '', array(), true);
2752
+		}
2753
+		$success = 0;
2754
+		$overwrite_msgs = false;
2755
+		// Checkboxes
2756
+		if (! is_array($this->_req_data['_REG_ID'])) {
2757
+			$this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2758
+		}
2759
+		$reg_count = count($this->_req_data['_REG_ID']);
2760
+		// cycle thru checkboxes
2761
+		foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2762
+			/** @var EE_Registration $REG */
2763
+			$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2764
+			$payments = $REG->registration_payments();
2765
+			if (! empty($payments)) {
2766
+				$name = $REG->attendee() instanceof EE_Attendee
2767
+					? $REG->attendee()->full_name()
2768
+					: esc_html__('Unknown Attendee', 'event_espresso');
2769
+				$overwrite_msgs = true;
2770
+				EE_Error::add_error(
2771
+					sprintf(
2772
+						esc_html__(
2773
+							'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.',
2774
+							'event_espresso'
2775
+						),
2776
+						$name
2777
+					),
2778
+					__FILE__,
2779
+					__FUNCTION__,
2780
+					__LINE__
2781
+				);
2782
+				// can't trash this registration because it has payments.
2783
+				continue;
2784
+			}
2785
+			$updated = $trash ? $REG->delete() : $REG->restore();
2786
+			if ($updated) {
2787
+				$success++;
2788
+			}
2789
+		}
2790
+		$this->_redirect_after_action(
2791
+			$success === $reg_count, // were ALL registrations affected?
2792
+			$success > 1
2793
+				? esc_html__('Registrations', 'event_espresso')
2794
+				: esc_html__('Registration', 'event_espresso'),
2795
+			$trash
2796
+				? esc_html__('moved to the trash', 'event_espresso')
2797
+				: esc_html__('restored', 'event_espresso'),
2798
+			array('action' => 'default'),
2799
+			$overwrite_msgs
2800
+		);
2801
+	}
2802
+
2803
+
2804
+	/**
2805
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2806
+	 * registration but also.
2807
+	 * 1. Removing relations to EE_Attendee
2808
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2809
+	 * ALSO trashed.
2810
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2811
+	 * 4. Removing relationships between all tickets and the related registrations
2812
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2813
+	 * 6. Deleting permanently any related Checkins.
2814
+	 *
2815
+	 * @return void
2816
+	 * @throws EE_Error
2817
+	 * @throws InvalidArgumentException
2818
+	 * @throws InvalidDataTypeException
2819
+	 * @throws InvalidInterfaceException
2820
+	 */
2821
+	protected function _delete_registrations()
2822
+	{
2823
+		$REG_MDL = EEM_Registration::instance();
2824
+		$success = 1;
2825
+		// Checkboxes
2826
+		if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2827
+			// if array has more than one element than success message should be plural
2828
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2829
+			// cycle thru checkboxes
2830
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2831
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2832
+				if (! $REG instanceof EE_Registration) {
2833
+					continue;
2834
+				}
2835
+				$deleted = $this->_delete_registration($REG);
2836
+				if (! $deleted) {
2837
+					$success = 0;
2838
+				}
2839
+			}
2840
+		} else {
2841
+			// grab single id and delete
2842
+			$REG_ID = $this->_req_data['_REG_ID'];
2843
+			$REG = $REG_MDL->get_one_by_ID($REG_ID);
2844
+			$deleted = $this->_delete_registration($REG);
2845
+			if (! $deleted) {
2846
+				$success = 0;
2847
+			}
2848
+		}
2849
+		$what = $success > 1
2850
+			? esc_html__('Registrations', 'event_espresso')
2851
+			: esc_html__('Registration', 'event_espresso');
2852
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2853
+		$this->_redirect_after_action(
2854
+			$success,
2855
+			$what,
2856
+			$action_desc,
2857
+			array('action' => 'default'),
2858
+			true
2859
+		);
2860
+	}
2861
+
2862
+
2863
+	/**
2864
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2865
+	 * models get affected.
2866
+	 *
2867
+	 * @param  EE_Registration $REG registration to be deleted permenantly
2868
+	 * @return bool true = successful deletion, false = fail.
2869
+	 * @throws EE_Error
2870
+	 */
2871
+	protected function _delete_registration(EE_Registration $REG)
2872
+	{
2873
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2874
+		// registrations on the transaction that are NOT trashed.
2875
+		$TXN = $REG->get_first_related('Transaction');
2876
+		$REGS = $TXN->get_many_related('Registration');
2877
+		$all_trashed = true;
2878
+		foreach ($REGS as $registration) {
2879
+			if (! $registration->get('REG_deleted')) {
2880
+				$all_trashed = false;
2881
+			}
2882
+		}
2883
+		if (! $all_trashed) {
2884
+			EE_Error::add_error(
2885
+				esc_html__(
2886
+					'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.',
2887
+					'event_espresso'
2888
+				),
2889
+				__FILE__,
2890
+				__FUNCTION__,
2891
+				__LINE__
2892
+			);
2893
+			return false;
2894
+		}
2895
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2896
+		// separately from THIS one).
2897
+		foreach ($REGS as $registration) {
2898
+			// delete related answers
2899
+			$registration->delete_related_permanently('Answer');
2900
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2901
+			$attendee = $registration->get_first_related('Attendee');
2902
+			if ($attendee instanceof EE_Attendee) {
2903
+				$registration->_remove_relation_to($attendee, 'Attendee');
2904
+			}
2905
+			// now remove relationships to tickets on this registration.
2906
+			$registration->_remove_relations('Ticket');
2907
+			// now delete permanently the checkins related to this registration.
2908
+			$registration->delete_related_permanently('Checkin');
2909
+			if ($registration->ID() === $REG->ID()) {
2910
+				continue;
2911
+			} //we don't want to delete permanently the existing registration just yet.
2912
+			// remove relation to transaction for these registrations if NOT the existing registrations
2913
+			$registration->_remove_relations('Transaction');
2914
+			// delete permanently any related messages.
2915
+			$registration->delete_related_permanently('Message');
2916
+			// now delete this registration permanently
2917
+			$registration->delete_permanently();
2918
+		}
2919
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2920
+		// (the transaction and line items should be all that's left).
2921
+		// delete the line items related to the transaction for this registration.
2922
+		$TXN->delete_related_permanently('Line_Item');
2923
+		// we need to remove all the relationships on the transaction
2924
+		$TXN->delete_related_permanently('Payment');
2925
+		$TXN->delete_related_permanently('Extra_Meta');
2926
+		$TXN->delete_related_permanently('Message');
2927
+		// now we can delete this REG permanently (and the transaction of course)
2928
+		$REG->delete_related_permanently('Transaction');
2929
+		return $REG->delete_permanently();
2930
+	}
2931
+
2932
+
2933
+	/**
2934
+	 *    generates HTML for the Register New Attendee Admin page
2935
+	 *
2936
+	 * @access private
2937
+	 * @throws DomainException
2938
+	 * @throws EE_Error
2939
+	 */
2940
+	public function new_registration()
2941
+	{
2942
+		if (! $this->_set_reg_event()) {
2943
+			throw new EE_Error(
2944
+				esc_html__(
2945
+					'Unable to continue with registering because there is no Event ID in the request',
2946
+					'event_espresso'
2947
+				)
2948
+			);
2949
+		}
2950
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2951
+		// gotta start with a clean slate if we're not coming here via ajax
2952
+		if (! defined('DOING_AJAX')
2953
+			&& (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2954
+		) {
2955
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2956
+		}
2957
+		$this->_template_args['event_name'] = '';
2958
+		// event name
2959
+		if ($this->_reg_event) {
2960
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2961
+			$edit_event_url = self::add_query_args_and_nonce(
2962
+				array(
2963
+					'action' => 'edit',
2964
+					'post'   => $this->_reg_event->ID(),
2965
+				),
2966
+				EVENTS_ADMIN_URL
2967
+			);
2968
+			$edit_event_lnk = '<a href="'
2969
+							  . $edit_event_url
2970
+							  . '" title="'
2971
+							  . esc_attr__('Edit ', 'event_espresso')
2972
+							  . $this->_reg_event->name()
2973
+							  . '">'
2974
+							  . esc_html__('Edit Event', 'event_espresso')
2975
+							  . '</a>';
2976
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2977
+												   . $edit_event_lnk
2978
+												   . '</span>';
2979
+		}
2980
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2981
+		if (defined('DOING_AJAX')) {
2982
+			$this->_return_json();
2983
+		}
2984
+		// grab header
2985
+		$template_path =
2986
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2987
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2988
+			$template_path,
2989
+			$this->_template_args,
2990
+			true
2991
+		);
2992
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2993
+		// the details template wrapper
2994
+		$this->display_admin_page_with_sidebar();
2995
+	}
2996
+
2997
+
2998
+	/**
2999
+	 * This returns the content for a registration step
3000
+	 *
3001
+	 * @access protected
3002
+	 * @return string html
3003
+	 * @throws DomainException
3004
+	 * @throws EE_Error
3005
+	 * @throws InvalidArgumentException
3006
+	 * @throws InvalidDataTypeException
3007
+	 * @throws InvalidInterfaceException
3008
+	 */
3009
+	protected function _get_registration_step_content()
3010
+	{
3011
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
3012
+			$warning_msg = sprintf(
3013
+				esc_html__(
3014
+					'%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',
3015
+					'event_espresso'
3016
+				),
3017
+				'<br />',
3018
+				'<h3 class="important-notice">',
3019
+				'</h3>',
3020
+				'<div class="float-right">',
3021
+				'<span id="redirect_timer" class="important-notice">30</span>',
3022
+				'</div>',
3023
+				'<b>',
3024
+				'</b>'
3025
+			);
3026
+			return '
3027 3027
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
3028 3028
 	<script >
3029 3029
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -3036,857 +3036,857 @@  discard block
 block discarded – undo
3036 3036
 	        }
3037 3037
 	    }, 800 );
3038 3038
 	</script >';
3039
-        }
3040
-        $template_args = array(
3041
-            'title'                    => '',
3042
-            'content'                  => '',
3043
-            'step_button_text'         => '',
3044
-            'show_notification_toggle' => false,
3045
-        );
3046
-        // to indicate we're processing a new registration
3047
-        $hidden_fields = array(
3048
-            'processing_registration' => array(
3049
-                'type'  => 'hidden',
3050
-                'value' => 0,
3051
-            ),
3052
-            'event_id'                => array(
3053
-                'type'  => 'hidden',
3054
-                'value' => $this->_reg_event->ID(),
3055
-            ),
3056
-        );
3057
-        // if the cart is empty then we know we're at step one so we'll display ticket selector
3058
-        $cart = EE_Registry::instance()->SSN->cart();
3059
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3060
-        switch ($step) {
3061
-            case 'ticket':
3062
-                $hidden_fields['processing_registration']['value'] = 1;
3063
-                $template_args['title'] = esc_html__(
3064
-                    'Step One: Select the Ticket for this registration',
3065
-                    'event_espresso'
3066
-                );
3067
-                $template_args['content'] =
3068
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
3069
-                $template_args['step_button_text'] = esc_html__(
3070
-                    'Add Tickets and Continue to Registrant Details',
3071
-                    'event_espresso'
3072
-                );
3073
-                $template_args['show_notification_toggle'] = false;
3074
-                break;
3075
-            case 'questions':
3076
-                $hidden_fields['processing_registration']['value'] = 2;
3077
-                $template_args['title'] = esc_html__(
3078
-                    'Step Two: Add Registrant Details for this Registration',
3079
-                    'event_espresso'
3080
-                );
3081
-                // in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3082
-                // properly by the first process_reg_step run.
3083
-                $template_args['content'] =
3084
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
3085
-                $template_args['step_button_text'] = esc_html__(
3086
-                    'Save Registration and Continue to Details',
3087
-                    'event_espresso'
3088
-                );
3089
-                $template_args['show_notification_toggle'] = true;
3090
-                break;
3091
-        }
3092
-        // we come back to the process_registration_step route.
3093
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3094
-        return EEH_Template::display_template(
3095
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3096
-            $template_args,
3097
-            true
3098
-        );
3099
-    }
3100
-
3101
-
3102
-    /**
3103
-     *        set_reg_event
3104
-     *
3105
-     * @access private
3106
-     * @return bool
3107
-     * @throws EE_Error
3108
-     * @throws InvalidArgumentException
3109
-     * @throws InvalidDataTypeException
3110
-     * @throws InvalidInterfaceException
3111
-     */
3112
-    private function _set_reg_event()
3113
-    {
3114
-        if (is_object($this->_reg_event)) {
3115
-            return true;
3116
-        }
3117
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3118
-        if (! $EVT_ID) {
3119
-            return false;
3120
-        }
3121
-        $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3122
-        return true;
3123
-    }
3124
-
3125
-
3126
-    /**
3127
-     * process_reg_step
3128
-     *
3129
-     * @access        public
3130
-     * @return string
3131
-     * @throws DomainException
3132
-     * @throws EE_Error
3133
-     * @throws InvalidArgumentException
3134
-     * @throws InvalidDataTypeException
3135
-     * @throws InvalidInterfaceException
3136
-     * @throws ReflectionException
3137
-     * @throws RuntimeException
3138
-     */
3139
-    public function process_reg_step()
3140
-    {
3141
-        EE_System::do_not_cache();
3142
-        $this->_set_reg_event();
3143
-        EE_Registry::instance()->REQ->set_espresso_page(true);
3144
-        EE_Registry::instance()->REQ->set('uts', time());
3145
-        // what step are we on?
3146
-        $cart = EE_Registry::instance()->SSN->cart();
3147
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3148
-        // if doing ajax then we need to verify the nonce
3149
-        if (defined('DOING_AJAX')) {
3150
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
3151
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3152
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3153
-        }
3154
-        switch ($step) {
3155
-            case 'ticket':
3156
-                // process ticket selection
3157
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3158
-                if ($success) {
3159
-                    EE_Error::add_success(
3160
-                        esc_html__(
3161
-                            'Tickets Selected. Now complete the registration.',
3162
-                            'event_espresso'
3163
-                        )
3164
-                    );
3165
-                } else {
3166
-                    $query_args['step_error'] = $this->_req_data['step_error'] = true;
3167
-                }
3168
-                if (defined('DOING_AJAX')) {
3169
-                    $this->new_registration(); // display next step
3170
-                } else {
3171
-                    $query_args = array(
3172
-                        'action'                  => 'new_registration',
3173
-                        'processing_registration' => 1,
3174
-                        'event_id'                => $this->_reg_event->ID(),
3175
-                        'uts'                     => time(),
3176
-                    );
3177
-                    $this->_redirect_after_action(
3178
-                        false,
3179
-                        '',
3180
-                        '',
3181
-                        $query_args,
3182
-                        true
3183
-                    );
3184
-                }
3185
-                break;
3186
-            case 'questions':
3187
-                if (! isset(
3188
-                    $this->_req_data['txn_reg_status_change'],
3189
-                    $this->_req_data['txn_reg_status_change']['send_notifications']
3190
-                )
3191
-                ) {
3192
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3193
-                }
3194
-                // process registration
3195
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3196
-                if ($cart instanceof EE_Cart) {
3197
-                    $grand_total = $cart->get_cart_grand_total();
3198
-                    if ($grand_total instanceof EE_Line_Item) {
3199
-                        $grand_total->save_this_and_descendants_to_txn();
3200
-                    }
3201
-                }
3202
-                if (! $transaction instanceof EE_Transaction) {
3203
-                    $query_args = array(
3204
-                        'action'                  => 'new_registration',
3205
-                        'processing_registration' => 2,
3206
-                        'event_id'                => $this->_reg_event->ID(),
3207
-                        'uts'                     => time(),
3208
-                    );
3209
-                    if (defined('DOING_AJAX')) {
3210
-                        // display registration form again because there are errors (maybe validation?)
3211
-                        $this->new_registration();
3212
-                        return;
3213
-                    } else {
3214
-                        $this->_redirect_after_action(
3215
-                            false,
3216
-                            '',
3217
-                            '',
3218
-                            $query_args,
3219
-                            true
3220
-                        );
3221
-                        return;
3222
-                    }
3223
-                }
3224
-                // maybe update status, and make sure to save transaction if not done already
3225
-                if (! $transaction->update_status_based_on_total_paid()) {
3226
-                    $transaction->save();
3227
-                }
3228
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3229
-                $this->_req_data = array();
3230
-                $query_args = array(
3231
-                    'action'        => 'redirect_to_txn',
3232
-                    'TXN_ID'        => $transaction->ID(),
3233
-                    'EVT_ID'        => $this->_reg_event->ID(),
3234
-                    'event_name'    => urlencode($this->_reg_event->name()),
3235
-                    'redirect_from' => 'new_registration',
3236
-                );
3237
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3238
-                break;
3239
-        }
3240
-        // what are you looking here for?  Should be nothing to do at this point.
3241
-    }
3242
-
3243
-
3244
-    /**
3245
-     * redirect_to_txn
3246
-     *
3247
-     * @access public
3248
-     * @return void
3249
-     * @throws EE_Error
3250
-     * @throws InvalidArgumentException
3251
-     * @throws InvalidDataTypeException
3252
-     * @throws InvalidInterfaceException
3253
-     */
3254
-    public function redirect_to_txn()
3255
-    {
3256
-        EE_System::do_not_cache();
3257
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3258
-        $query_args = array(
3259
-            'action' => 'view_transaction',
3260
-            'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3261
-            'page'   => 'espresso_transactions',
3262
-        );
3263
-        if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3264
-            $query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3265
-            $query_args['event_name'] = urlencode($this->_req_data['event_name']);
3266
-            $query_args['redirect_from'] = $this->_req_data['redirect_from'];
3267
-        }
3268
-        EE_Error::add_success(
3269
-            esc_html__(
3270
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3271
-                'event_espresso'
3272
-            )
3273
-        );
3274
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3275
-    }
3276
-
3277
-
3278
-    /**
3279
-     *        generates HTML for the Attendee Contact List
3280
-     *
3281
-     * @access protected
3282
-     * @return void
3283
-     */
3284
-    protected function _attendee_contact_list_table()
3285
-    {
3286
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3287
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3288
-        $this->display_admin_list_table_page_with_no_sidebar();
3289
-    }
3290
-
3291
-
3292
-    /**
3293
-     *        get_attendees
3294
-     *
3295
-     * @param      $per_page
3296
-     * @param bool $count whether to return count or data.
3297
-     * @param bool $trash
3298
-     * @return array
3299
-     * @throws EE_Error
3300
-     * @throws InvalidArgumentException
3301
-     * @throws InvalidDataTypeException
3302
-     * @throws InvalidInterfaceException
3303
-     * @access public
3304
-     */
3305
-    public function get_attendees($per_page, $count = false, $trash = false)
3306
-    {
3307
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3308
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3309
-        $ATT_MDL = EEM_Attendee::instance();
3310
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3311
-        switch ($this->_req_data['orderby']) {
3312
-            case 'ATT_ID':
3313
-                $orderby = 'ATT_ID';
3314
-                break;
3315
-            case 'ATT_fname':
3316
-                $orderby = 'ATT_fname';
3317
-                break;
3318
-            case 'ATT_email':
3319
-                $orderby = 'ATT_email';
3320
-                break;
3321
-            case 'ATT_city':
3322
-                $orderby = 'ATT_city';
3323
-                break;
3324
-            case 'STA_ID':
3325
-                $orderby = 'STA_ID';
3326
-                break;
3327
-            case 'CNT_ID':
3328
-                $orderby = 'CNT_ID';
3329
-                break;
3330
-            case 'Registration_Count':
3331
-                $orderby = 'Registration_Count';
3332
-                break;
3333
-            default:
3334
-                $orderby = 'ATT_lname';
3335
-        }
3336
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3337
-            ? $this->_req_data['order']
3338
-            : 'ASC';
3339
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3340
-            ? $this->_req_data['paged']
3341
-            : 1;
3342
-        $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3343
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3344
-            ? $this->_req_data['perpage']
3345
-            : $per_page;
3346
-        $_where = array();
3347
-        if (! empty($this->_req_data['s'])) {
3348
-            $sstr = '%' . $this->_req_data['s'] . '%';
3349
-            $_where['OR'] = array(
3350
-                'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3351
-                'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3352
-                'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3353
-                'ATT_fname'                         => array('LIKE', $sstr),
3354
-                'ATT_lname'                         => array('LIKE', $sstr),
3355
-                'ATT_short_bio'                     => array('LIKE', $sstr),
3356
-                'ATT_email'                         => array('LIKE', $sstr),
3357
-                'ATT_address'                       => array('LIKE', $sstr),
3358
-                'ATT_address2'                      => array('LIKE', $sstr),
3359
-                'ATT_city'                          => array('LIKE', $sstr),
3360
-                'Country.CNT_name'                  => array('LIKE', $sstr),
3361
-                'State.STA_name'                    => array('LIKE', $sstr),
3362
-                'ATT_phone'                         => array('LIKE', $sstr),
3363
-                'Registration.REG_final_price'      => array('LIKE', $sstr),
3364
-                'Registration.REG_code'             => array('LIKE', $sstr),
3365
-                'Registration.REG_group_size'       => array('LIKE', $sstr),
3366
-            );
3367
-        }
3368
-        $offset = ($current_page - 1) * $per_page;
3369
-        $limit = $count ? null : array($offset, $per_page);
3370
-        $query_args = array(
3371
-            $_where,
3372
-            'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3373
-            'limit'         => $limit,
3374
-        );
3375
-        if (! $count) {
3376
-            $query_args['order_by'] = array($orderby => $sort);
3377
-        }
3378
-        if ($trash) {
3379
-            $query_args[0]['status'] = array('!=', 'publish');
3380
-            $all_attendees = $count
3381
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3382
-                : $ATT_MDL->get_all($query_args);
3383
-        } else {
3384
-            $query_args[0]['status'] = array('IN', array('publish'));
3385
-            $all_attendees = $count
3386
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3387
-                : $ATT_MDL->get_all($query_args);
3388
-        }
3389
-        return $all_attendees;
3390
-    }
3391
-
3392
-
3393
-    /**
3394
-     * This is just taking care of resending the registration confirmation
3395
-     *
3396
-     * @access protected
3397
-     * @return void
3398
-     */
3399
-    protected function _resend_registration()
3400
-    {
3401
-        $this->_process_resend_registration();
3402
-        $query_args = isset($this->_req_data['redirect_to'])
3403
-            ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3404
-            : array('action' => 'default');
3405
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3406
-    }
3407
-
3408
-    /**
3409
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3410
-     * to use when selecting registrations
3411
-     *
3412
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3413
-     *                                                     the query parameters from the request
3414
-     * @return void ends the request with a redirect or download
3415
-     */
3416
-    public function _registrations_report_base($method_name_for_getting_query_params)
3417
-    {
3418
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3419
-            wp_redirect(
3420
-                EE_Admin_Page::add_query_args_and_nonce(
3421
-                    array(
3422
-                        'page'        => 'espresso_batch',
3423
-                        'batch'       => 'file',
3424
-                        'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3425
-                        'filters'     => urlencode(
3426
-                            serialize(
3427
-                                call_user_func(
3428
-                                    array($this, $method_name_for_getting_query_params),
3429
-                                    EEH_Array::is_set(
3430
-                                        $this->_req_data,
3431
-                                        'filters',
3432
-                                        array()
3433
-                                    )
3434
-                                )
3435
-                            )
3436
-                        ),
3437
-                        'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3438
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3439
-                        'ee_return_url'  => urlencode($this->_req_data['ee_return_url']),
3440
-                    )
3441
-                )
3442
-            );
3443
-            die;
3444
-        } else {
3445
-            $new_request_args = array(
3446
-                'export' => 'report',
3447
-                'action' => 'registrations_report_for_event',
3448
-                'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3449
-            );
3450
-            $this->_req_data = array_merge($this->_req_data, $new_request_args);
3451
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3452
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3453
-                $EE_Export = EE_Export::instance($this->_req_data);
3454
-                $EE_Export->export();
3455
-            }
3456
-        }
3457
-    }
3458
-
3459
-
3460
-    /**
3461
-     * Creates a registration report using only query parameters in the request
3462
-     *
3463
-     * @return void
3464
-     */
3465
-    public function _registrations_report()
3466
-    {
3467
-        $this->_registrations_report_base('_get_registration_query_parameters');
3468
-    }
3469
-
3470
-
3471
-    public function _contact_list_export()
3472
-    {
3473
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3474
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3475
-            $EE_Export = EE_Export::instance($this->_req_data);
3476
-            $EE_Export->export_attendees();
3477
-        }
3478
-    }
3479
-
3480
-
3481
-    public function _contact_list_report()
3482
-    {
3483
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3484
-            wp_redirect(
3485
-                EE_Admin_Page::add_query_args_and_nonce(
3486
-                    array(
3487
-                        'page'        => 'espresso_batch',
3488
-                        'batch'       => 'file',
3489
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3490
-                        'ee_return_url'  => urlencode($this->_req_data['ee_return_url']),
3491
-                    )
3492
-                )
3493
-            );
3494
-            die;
3495
-        } else {
3496
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3497
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3498
-                $EE_Export = EE_Export::instance($this->_req_data);
3499
-                $EE_Export->report_attendees();
3500
-            }
3501
-        }
3502
-    }
3503
-
3504
-
3505
-
3506
-
3507
-
3508
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3509
-    /**
3510
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3511
-     *
3512
-     * @return void
3513
-     * @throws EE_Error
3514
-     * @throws InvalidArgumentException
3515
-     * @throws InvalidDataTypeException
3516
-     * @throws InvalidInterfaceException
3517
-     */
3518
-    protected function _duplicate_attendee()
3519
-    {
3520
-        $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3521
-        // verify we have necessary info
3522
-        if (empty($this->_req_data['_REG_ID'])) {
3523
-            EE_Error::add_error(
3524
-                esc_html__(
3525
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3526
-                    'event_espresso'
3527
-                ),
3528
-                __FILE__,
3529
-                __LINE__,
3530
-                __FUNCTION__
3531
-            );
3532
-            $query_args = array('action' => $action);
3533
-            $this->_redirect_after_action('', '', '', $query_args, true);
3534
-        }
3535
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3536
-        $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3537
-        $attendee = $registration->attendee();
3538
-        // remove relation of existing attendee on registration
3539
-        $registration->_remove_relation_to($attendee, 'Attendee');
3540
-        // new attendee
3541
-        $new_attendee = clone $attendee;
3542
-        $new_attendee->set('ATT_ID', 0);
3543
-        $new_attendee->save();
3544
-        // add new attendee to reg
3545
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3546
-        EE_Error::add_success(
3547
-            esc_html__(
3548
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3549
-                'event_espresso'
3550
-            )
3551
-        );
3552
-        // redirect to edit page for attendee
3553
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3554
-        $this->_redirect_after_action('', '', '', $query_args, true);
3555
-    }
3556
-
3557
-
3558
-    /**
3559
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3560
-     *
3561
-     * @param int     $post_id
3562
-     * @param WP_POST $post
3563
-     * @throws DomainException
3564
-     * @throws EE_Error
3565
-     * @throws InvalidArgumentException
3566
-     * @throws InvalidDataTypeException
3567
-     * @throws InvalidInterfaceException
3568
-     * @throws LogicException
3569
-     * @throws InvalidFormSubmissionException
3570
-     */
3571
-    protected function _insert_update_cpt_item($post_id, $post)
3572
-    {
3573
-        $success = true;
3574
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3575
-            ? EEM_Attendee::instance()->get_one_by_ID($post_id)
3576
-            : null;
3577
-        // for attendee updates
3578
-        if ($attendee instanceof EE_Attendee) {
3579
-            // note we should only be UPDATING attendees at this point.
3580
-            $updated_fields = array(
3581
-                'ATT_fname'     => $this->_req_data['ATT_fname'],
3582
-                'ATT_lname'     => $this->_req_data['ATT_lname'],
3583
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3584
-                'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3585
-                'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3586
-                'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3587
-                'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3588
-                'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3589
-                'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3590
-            );
3591
-            foreach ($updated_fields as $field => $value) {
3592
-                $attendee->set($field, $value);
3593
-            }
3594
-
3595
-            // process contact details metabox form handler (which will also save the attendee)
3596
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3597
-            $success = $contact_details_form->process($this->_req_data);
3598
-
3599
-            $attendee_update_callbacks = apply_filters(
3600
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3601
-                array()
3602
-            );
3603
-            foreach ($attendee_update_callbacks as $a_callback) {
3604
-                if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3605
-                    throw new EE_Error(
3606
-                        sprintf(
3607
-                            esc_html__(
3608
-                                '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.',
3609
-                                'event_espresso'
3610
-                            ),
3611
-                            $a_callback
3612
-                        )
3613
-                    );
3614
-                }
3615
-            }
3616
-        }
3617
-
3618
-        if ($success === false) {
3619
-            EE_Error::add_error(
3620
-                esc_html__(
3621
-                    'Something went wrong with updating the meta table data for the registration.',
3622
-                    'event_espresso'
3623
-                ),
3624
-                __FILE__,
3625
-                __FUNCTION__,
3626
-                __LINE__
3627
-            );
3628
-        }
3629
-    }
3630
-
3631
-
3632
-    public function trash_cpt_item($post_id)
3633
-    {
3634
-    }
3635
-
3636
-
3637
-    public function delete_cpt_item($post_id)
3638
-    {
3639
-    }
3640
-
3641
-
3642
-    public function restore_cpt_item($post_id)
3643
-    {
3644
-    }
3645
-
3646
-
3647
-    protected function _restore_cpt_item($post_id, $revision_id)
3648
-    {
3649
-    }
3650
-
3651
-
3652
-    public function attendee_editor_metaboxes()
3653
-    {
3654
-        $this->verify_cpt_object();
3655
-        remove_meta_box(
3656
-            'postexcerpt',
3657
-            esc_html__('Excerpt', 'event_espresso'),
3658
-            'post_excerpt_meta_box',
3659
-            $this->_cpt_routes[ $this->_req_action ],
3660
-            'normal',
3661
-            'core'
3662
-        );
3663
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3664
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3665
-            add_meta_box(
3666
-                'postexcerpt',
3667
-                esc_html__('Short Biography', 'event_espresso'),
3668
-                'post_excerpt_meta_box',
3669
-                $this->_cpt_routes[ $this->_req_action ],
3670
-                'normal'
3671
-            );
3672
-        }
3673
-        if (post_type_supports('espresso_attendees', 'comments')) {
3674
-            add_meta_box(
3675
-                'commentsdiv',
3676
-                esc_html__('Notes on the Contact', 'event_espresso'),
3677
-                'post_comment_meta_box',
3678
-                $this->_cpt_routes[ $this->_req_action ],
3679
-                'normal',
3680
-                'core'
3681
-            );
3682
-        }
3683
-        add_meta_box(
3684
-            'attendee_contact_info',
3685
-            esc_html__('Contact Info', 'event_espresso'),
3686
-            array($this, 'attendee_contact_info'),
3687
-            $this->_cpt_routes[ $this->_req_action ],
3688
-            'side',
3689
-            'core'
3690
-        );
3691
-        add_meta_box(
3692
-            'attendee_details_address',
3693
-            esc_html__('Address Details', 'event_espresso'),
3694
-            array($this, 'attendee_address_details'),
3695
-            $this->_cpt_routes[ $this->_req_action ],
3696
-            'normal',
3697
-            'core'
3698
-        );
3699
-        add_meta_box(
3700
-            'attendee_registrations',
3701
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3702
-            array($this, 'attendee_registrations_meta_box'),
3703
-            $this->_cpt_routes[ $this->_req_action ],
3704
-            'normal',
3705
-            'high'
3706
-        );
3707
-    }
3708
-
3709
-
3710
-    /**
3711
-     * Metabox for attendee contact info
3712
-     *
3713
-     * @param  WP_Post $post wp post object
3714
-     * @return string attendee contact info ( and form )
3715
-     * @throws EE_Error
3716
-     * @throws InvalidArgumentException
3717
-     * @throws InvalidDataTypeException
3718
-     * @throws InvalidInterfaceException
3719
-     * @throws LogicException
3720
-     * @throws DomainException
3721
-     */
3722
-    public function attendee_contact_info($post)
3723
-    {
3724
-        // get attendee object ( should already have it )
3725
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3726
-        $form->enqueueStylesAndScripts();
3727
-        echo $form->display();
3728
-    }
3729
-
3730
-
3731
-    /**
3732
-     * Return form handler for the contact details metabox
3733
-     *
3734
-     * @param EE_Attendee $attendee
3735
-     * @return AttendeeContactDetailsMetaboxFormHandler
3736
-     * @throws DomainException
3737
-     * @throws InvalidArgumentException
3738
-     * @throws InvalidDataTypeException
3739
-     * @throws InvalidInterfaceException
3740
-     */
3741
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3742
-    {
3743
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3744
-    }
3745
-
3746
-
3747
-    /**
3748
-     * Metabox for attendee details
3749
-     *
3750
-     * @param  WP_Post $post wp post object
3751
-     * @throws DomainException
3752
-     */
3753
-    public function attendee_address_details($post)
3754
-    {
3755
-        // get attendee object (should already have it)
3756
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3757
-        $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3758
-            new EE_Question_Form_Input(
3759
-                EE_Question::new_instance(
3760
-                    array(
3761
-                        'QST_ID'           => 0,
3762
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3763
-                        'QST_system'       => 'admin-state',
3764
-                    )
3765
-                ),
3766
-                EE_Answer::new_instance(
3767
-                    array(
3768
-                        'ANS_ID'    => 0,
3769
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3770
-                    )
3771
-                ),
3772
-                array(
3773
-                    'input_id'       => 'STA_ID',
3774
-                    'input_name'     => 'STA_ID',
3775
-                    'input_prefix'   => '',
3776
-                    'append_qstn_id' => false,
3777
-                )
3778
-            )
3779
-        );
3780
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3781
-            new EE_Question_Form_Input(
3782
-                EE_Question::new_instance(
3783
-                    array(
3784
-                        'QST_ID'           => 0,
3785
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3786
-                        'QST_system'       => 'admin-country',
3787
-                    )
3788
-                ),
3789
-                EE_Answer::new_instance(
3790
-                    array(
3791
-                        'ANS_ID'    => 0,
3792
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3793
-                    )
3794
-                ),
3795
-                array(
3796
-                    'input_id'       => 'CNT_ISO',
3797
-                    'input_name'     => 'CNT_ISO',
3798
-                    'input_prefix'   => '',
3799
-                    'append_qstn_id' => false,
3800
-                )
3801
-            )
3802
-        );
3803
-        $template =
3804
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3805
-        EEH_Template::display_template($template, $this->_template_args);
3806
-    }
3807
-
3808
-
3809
-    /**
3810
-     *        _attendee_details
3811
-     *
3812
-     * @access protected
3813
-     * @param $post
3814
-     * @return void
3815
-     * @throws DomainException
3816
-     * @throws EE_Error
3817
-     */
3818
-    public function attendee_registrations_meta_box($post)
3819
-    {
3820
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3821
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3822
-        $template =
3823
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3824
-        EEH_Template::display_template($template, $this->_template_args);
3825
-    }
3826
-
3827
-
3828
-    /**
3829
-     * add in the form fields for the attendee edit
3830
-     *
3831
-     * @param  WP_Post $post wp post object
3832
-     * @return string html for new form.
3833
-     * @throws DomainException
3834
-     */
3835
-    public function after_title_form_fields($post)
3836
-    {
3837
-        if ($post->post_type == 'espresso_attendees') {
3838
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3839
-            $template_args['attendee'] = $this->_cpt_model_obj;
3840
-            EEH_Template::display_template($template, $template_args);
3841
-        }
3842
-    }
3843
-
3844
-
3845
-    /**
3846
-     *        _trash_or_restore_attendee
3847
-     *
3848
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3849
-     * @return void
3850
-     * @throws EE_Error
3851
-     * @throws InvalidArgumentException
3852
-     * @throws InvalidDataTypeException
3853
-     * @throws InvalidInterfaceException
3854
-     * @access protected
3855
-     */
3856
-    protected function _trash_or_restore_attendees($trash = true)
3857
-    {
3858
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3859
-        $ATT_MDL = EEM_Attendee::instance();
3860
-        $success = 1;
3861
-        // Checkboxes
3862
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3863
-            // if array has more than one element than success message should be plural
3864
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3865
-            // cycle thru checkboxes
3866
-            while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3867
-                $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3868
-                    : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3869
-                if (! $updated) {
3870
-                    $success = 0;
3871
-                }
3872
-            }
3873
-        } else {
3874
-            // grab single id and delete
3875
-            $ATT_ID = absint($this->_req_data['ATT_ID']);
3876
-            // get attendee
3877
-            $att = $ATT_MDL->get_one_by_ID($ATT_ID);
3878
-            $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3879
-            $updated = $att->save();
3880
-            if (! $updated) {
3881
-                $success = 0;
3882
-            }
3883
-        }
3884
-        $what = $success > 1
3885
-            ? esc_html__('Contacts', 'event_espresso')
3886
-            : esc_html__('Contact', 'event_espresso');
3887
-        $action_desc = $trash
3888
-            ? esc_html__('moved to the trash', 'event_espresso')
3889
-            : esc_html__('restored', 'event_espresso');
3890
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3891
-    }
3039
+		}
3040
+		$template_args = array(
3041
+			'title'                    => '',
3042
+			'content'                  => '',
3043
+			'step_button_text'         => '',
3044
+			'show_notification_toggle' => false,
3045
+		);
3046
+		// to indicate we're processing a new registration
3047
+		$hidden_fields = array(
3048
+			'processing_registration' => array(
3049
+				'type'  => 'hidden',
3050
+				'value' => 0,
3051
+			),
3052
+			'event_id'                => array(
3053
+				'type'  => 'hidden',
3054
+				'value' => $this->_reg_event->ID(),
3055
+			),
3056
+		);
3057
+		// if the cart is empty then we know we're at step one so we'll display ticket selector
3058
+		$cart = EE_Registry::instance()->SSN->cart();
3059
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3060
+		switch ($step) {
3061
+			case 'ticket':
3062
+				$hidden_fields['processing_registration']['value'] = 1;
3063
+				$template_args['title'] = esc_html__(
3064
+					'Step One: Select the Ticket for this registration',
3065
+					'event_espresso'
3066
+				);
3067
+				$template_args['content'] =
3068
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
3069
+				$template_args['step_button_text'] = esc_html__(
3070
+					'Add Tickets and Continue to Registrant Details',
3071
+					'event_espresso'
3072
+				);
3073
+				$template_args['show_notification_toggle'] = false;
3074
+				break;
3075
+			case 'questions':
3076
+				$hidden_fields['processing_registration']['value'] = 2;
3077
+				$template_args['title'] = esc_html__(
3078
+					'Step Two: Add Registrant Details for this Registration',
3079
+					'event_espresso'
3080
+				);
3081
+				// in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3082
+				// properly by the first process_reg_step run.
3083
+				$template_args['content'] =
3084
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
3085
+				$template_args['step_button_text'] = esc_html__(
3086
+					'Save Registration and Continue to Details',
3087
+					'event_espresso'
3088
+				);
3089
+				$template_args['show_notification_toggle'] = true;
3090
+				break;
3091
+		}
3092
+		// we come back to the process_registration_step route.
3093
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3094
+		return EEH_Template::display_template(
3095
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3096
+			$template_args,
3097
+			true
3098
+		);
3099
+	}
3100
+
3101
+
3102
+	/**
3103
+	 *        set_reg_event
3104
+	 *
3105
+	 * @access private
3106
+	 * @return bool
3107
+	 * @throws EE_Error
3108
+	 * @throws InvalidArgumentException
3109
+	 * @throws InvalidDataTypeException
3110
+	 * @throws InvalidInterfaceException
3111
+	 */
3112
+	private function _set_reg_event()
3113
+	{
3114
+		if (is_object($this->_reg_event)) {
3115
+			return true;
3116
+		}
3117
+		$EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3118
+		if (! $EVT_ID) {
3119
+			return false;
3120
+		}
3121
+		$this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3122
+		return true;
3123
+	}
3124
+
3125
+
3126
+	/**
3127
+	 * process_reg_step
3128
+	 *
3129
+	 * @access        public
3130
+	 * @return string
3131
+	 * @throws DomainException
3132
+	 * @throws EE_Error
3133
+	 * @throws InvalidArgumentException
3134
+	 * @throws InvalidDataTypeException
3135
+	 * @throws InvalidInterfaceException
3136
+	 * @throws ReflectionException
3137
+	 * @throws RuntimeException
3138
+	 */
3139
+	public function process_reg_step()
3140
+	{
3141
+		EE_System::do_not_cache();
3142
+		$this->_set_reg_event();
3143
+		EE_Registry::instance()->REQ->set_espresso_page(true);
3144
+		EE_Registry::instance()->REQ->set('uts', time());
3145
+		// what step are we on?
3146
+		$cart = EE_Registry::instance()->SSN->cart();
3147
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3148
+		// if doing ajax then we need to verify the nonce
3149
+		if (defined('DOING_AJAX')) {
3150
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
3151
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3152
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3153
+		}
3154
+		switch ($step) {
3155
+			case 'ticket':
3156
+				// process ticket selection
3157
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3158
+				if ($success) {
3159
+					EE_Error::add_success(
3160
+						esc_html__(
3161
+							'Tickets Selected. Now complete the registration.',
3162
+							'event_espresso'
3163
+						)
3164
+					);
3165
+				} else {
3166
+					$query_args['step_error'] = $this->_req_data['step_error'] = true;
3167
+				}
3168
+				if (defined('DOING_AJAX')) {
3169
+					$this->new_registration(); // display next step
3170
+				} else {
3171
+					$query_args = array(
3172
+						'action'                  => 'new_registration',
3173
+						'processing_registration' => 1,
3174
+						'event_id'                => $this->_reg_event->ID(),
3175
+						'uts'                     => time(),
3176
+					);
3177
+					$this->_redirect_after_action(
3178
+						false,
3179
+						'',
3180
+						'',
3181
+						$query_args,
3182
+						true
3183
+					);
3184
+				}
3185
+				break;
3186
+			case 'questions':
3187
+				if (! isset(
3188
+					$this->_req_data['txn_reg_status_change'],
3189
+					$this->_req_data['txn_reg_status_change']['send_notifications']
3190
+				)
3191
+				) {
3192
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3193
+				}
3194
+				// process registration
3195
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3196
+				if ($cart instanceof EE_Cart) {
3197
+					$grand_total = $cart->get_cart_grand_total();
3198
+					if ($grand_total instanceof EE_Line_Item) {
3199
+						$grand_total->save_this_and_descendants_to_txn();
3200
+					}
3201
+				}
3202
+				if (! $transaction instanceof EE_Transaction) {
3203
+					$query_args = array(
3204
+						'action'                  => 'new_registration',
3205
+						'processing_registration' => 2,
3206
+						'event_id'                => $this->_reg_event->ID(),
3207
+						'uts'                     => time(),
3208
+					);
3209
+					if (defined('DOING_AJAX')) {
3210
+						// display registration form again because there are errors (maybe validation?)
3211
+						$this->new_registration();
3212
+						return;
3213
+					} else {
3214
+						$this->_redirect_after_action(
3215
+							false,
3216
+							'',
3217
+							'',
3218
+							$query_args,
3219
+							true
3220
+						);
3221
+						return;
3222
+					}
3223
+				}
3224
+				// maybe update status, and make sure to save transaction if not done already
3225
+				if (! $transaction->update_status_based_on_total_paid()) {
3226
+					$transaction->save();
3227
+				}
3228
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3229
+				$this->_req_data = array();
3230
+				$query_args = array(
3231
+					'action'        => 'redirect_to_txn',
3232
+					'TXN_ID'        => $transaction->ID(),
3233
+					'EVT_ID'        => $this->_reg_event->ID(),
3234
+					'event_name'    => urlencode($this->_reg_event->name()),
3235
+					'redirect_from' => 'new_registration',
3236
+				);
3237
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3238
+				break;
3239
+		}
3240
+		// what are you looking here for?  Should be nothing to do at this point.
3241
+	}
3242
+
3243
+
3244
+	/**
3245
+	 * redirect_to_txn
3246
+	 *
3247
+	 * @access public
3248
+	 * @return void
3249
+	 * @throws EE_Error
3250
+	 * @throws InvalidArgumentException
3251
+	 * @throws InvalidDataTypeException
3252
+	 * @throws InvalidInterfaceException
3253
+	 */
3254
+	public function redirect_to_txn()
3255
+	{
3256
+		EE_System::do_not_cache();
3257
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3258
+		$query_args = array(
3259
+			'action' => 'view_transaction',
3260
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3261
+			'page'   => 'espresso_transactions',
3262
+		);
3263
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3264
+			$query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3265
+			$query_args['event_name'] = urlencode($this->_req_data['event_name']);
3266
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
3267
+		}
3268
+		EE_Error::add_success(
3269
+			esc_html__(
3270
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3271
+				'event_espresso'
3272
+			)
3273
+		);
3274
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3275
+	}
3276
+
3277
+
3278
+	/**
3279
+	 *        generates HTML for the Attendee Contact List
3280
+	 *
3281
+	 * @access protected
3282
+	 * @return void
3283
+	 */
3284
+	protected function _attendee_contact_list_table()
3285
+	{
3286
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3287
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3288
+		$this->display_admin_list_table_page_with_no_sidebar();
3289
+	}
3290
+
3291
+
3292
+	/**
3293
+	 *        get_attendees
3294
+	 *
3295
+	 * @param      $per_page
3296
+	 * @param bool $count whether to return count or data.
3297
+	 * @param bool $trash
3298
+	 * @return array
3299
+	 * @throws EE_Error
3300
+	 * @throws InvalidArgumentException
3301
+	 * @throws InvalidDataTypeException
3302
+	 * @throws InvalidInterfaceException
3303
+	 * @access public
3304
+	 */
3305
+	public function get_attendees($per_page, $count = false, $trash = false)
3306
+	{
3307
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3308
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3309
+		$ATT_MDL = EEM_Attendee::instance();
3310
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3311
+		switch ($this->_req_data['orderby']) {
3312
+			case 'ATT_ID':
3313
+				$orderby = 'ATT_ID';
3314
+				break;
3315
+			case 'ATT_fname':
3316
+				$orderby = 'ATT_fname';
3317
+				break;
3318
+			case 'ATT_email':
3319
+				$orderby = 'ATT_email';
3320
+				break;
3321
+			case 'ATT_city':
3322
+				$orderby = 'ATT_city';
3323
+				break;
3324
+			case 'STA_ID':
3325
+				$orderby = 'STA_ID';
3326
+				break;
3327
+			case 'CNT_ID':
3328
+				$orderby = 'CNT_ID';
3329
+				break;
3330
+			case 'Registration_Count':
3331
+				$orderby = 'Registration_Count';
3332
+				break;
3333
+			default:
3334
+				$orderby = 'ATT_lname';
3335
+		}
3336
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3337
+			? $this->_req_data['order']
3338
+			: 'ASC';
3339
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3340
+			? $this->_req_data['paged']
3341
+			: 1;
3342
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3343
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3344
+			? $this->_req_data['perpage']
3345
+			: $per_page;
3346
+		$_where = array();
3347
+		if (! empty($this->_req_data['s'])) {
3348
+			$sstr = '%' . $this->_req_data['s'] . '%';
3349
+			$_where['OR'] = array(
3350
+				'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3351
+				'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3352
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3353
+				'ATT_fname'                         => array('LIKE', $sstr),
3354
+				'ATT_lname'                         => array('LIKE', $sstr),
3355
+				'ATT_short_bio'                     => array('LIKE', $sstr),
3356
+				'ATT_email'                         => array('LIKE', $sstr),
3357
+				'ATT_address'                       => array('LIKE', $sstr),
3358
+				'ATT_address2'                      => array('LIKE', $sstr),
3359
+				'ATT_city'                          => array('LIKE', $sstr),
3360
+				'Country.CNT_name'                  => array('LIKE', $sstr),
3361
+				'State.STA_name'                    => array('LIKE', $sstr),
3362
+				'ATT_phone'                         => array('LIKE', $sstr),
3363
+				'Registration.REG_final_price'      => array('LIKE', $sstr),
3364
+				'Registration.REG_code'             => array('LIKE', $sstr),
3365
+				'Registration.REG_group_size'       => array('LIKE', $sstr),
3366
+			);
3367
+		}
3368
+		$offset = ($current_page - 1) * $per_page;
3369
+		$limit = $count ? null : array($offset, $per_page);
3370
+		$query_args = array(
3371
+			$_where,
3372
+			'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3373
+			'limit'         => $limit,
3374
+		);
3375
+		if (! $count) {
3376
+			$query_args['order_by'] = array($orderby => $sort);
3377
+		}
3378
+		if ($trash) {
3379
+			$query_args[0]['status'] = array('!=', 'publish');
3380
+			$all_attendees = $count
3381
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3382
+				: $ATT_MDL->get_all($query_args);
3383
+		} else {
3384
+			$query_args[0]['status'] = array('IN', array('publish'));
3385
+			$all_attendees = $count
3386
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3387
+				: $ATT_MDL->get_all($query_args);
3388
+		}
3389
+		return $all_attendees;
3390
+	}
3391
+
3392
+
3393
+	/**
3394
+	 * This is just taking care of resending the registration confirmation
3395
+	 *
3396
+	 * @access protected
3397
+	 * @return void
3398
+	 */
3399
+	protected function _resend_registration()
3400
+	{
3401
+		$this->_process_resend_registration();
3402
+		$query_args = isset($this->_req_data['redirect_to'])
3403
+			? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3404
+			: array('action' => 'default');
3405
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3406
+	}
3407
+
3408
+	/**
3409
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3410
+	 * to use when selecting registrations
3411
+	 *
3412
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3413
+	 *                                                     the query parameters from the request
3414
+	 * @return void ends the request with a redirect or download
3415
+	 */
3416
+	public function _registrations_report_base($method_name_for_getting_query_params)
3417
+	{
3418
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3419
+			wp_redirect(
3420
+				EE_Admin_Page::add_query_args_and_nonce(
3421
+					array(
3422
+						'page'        => 'espresso_batch',
3423
+						'batch'       => 'file',
3424
+						'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3425
+						'filters'     => urlencode(
3426
+							serialize(
3427
+								call_user_func(
3428
+									array($this, $method_name_for_getting_query_params),
3429
+									EEH_Array::is_set(
3430
+										$this->_req_data,
3431
+										'filters',
3432
+										array()
3433
+									)
3434
+								)
3435
+							)
3436
+						),
3437
+						'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3438
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3439
+						'ee_return_url'  => urlencode($this->_req_data['ee_return_url']),
3440
+					)
3441
+				)
3442
+			);
3443
+			die;
3444
+		} else {
3445
+			$new_request_args = array(
3446
+				'export' => 'report',
3447
+				'action' => 'registrations_report_for_event',
3448
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3449
+			);
3450
+			$this->_req_data = array_merge($this->_req_data, $new_request_args);
3451
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3452
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3453
+				$EE_Export = EE_Export::instance($this->_req_data);
3454
+				$EE_Export->export();
3455
+			}
3456
+		}
3457
+	}
3458
+
3459
+
3460
+	/**
3461
+	 * Creates a registration report using only query parameters in the request
3462
+	 *
3463
+	 * @return void
3464
+	 */
3465
+	public function _registrations_report()
3466
+	{
3467
+		$this->_registrations_report_base('_get_registration_query_parameters');
3468
+	}
3469
+
3470
+
3471
+	public function _contact_list_export()
3472
+	{
3473
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3474
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3475
+			$EE_Export = EE_Export::instance($this->_req_data);
3476
+			$EE_Export->export_attendees();
3477
+		}
3478
+	}
3479
+
3480
+
3481
+	public function _contact_list_report()
3482
+	{
3483
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3484
+			wp_redirect(
3485
+				EE_Admin_Page::add_query_args_and_nonce(
3486
+					array(
3487
+						'page'        => 'espresso_batch',
3488
+						'batch'       => 'file',
3489
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3490
+						'ee_return_url'  => urlencode($this->_req_data['ee_return_url']),
3491
+					)
3492
+				)
3493
+			);
3494
+			die;
3495
+		} else {
3496
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3497
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3498
+				$EE_Export = EE_Export::instance($this->_req_data);
3499
+				$EE_Export->report_attendees();
3500
+			}
3501
+		}
3502
+	}
3503
+
3504
+
3505
+
3506
+
3507
+
3508
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3509
+	/**
3510
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3511
+	 *
3512
+	 * @return void
3513
+	 * @throws EE_Error
3514
+	 * @throws InvalidArgumentException
3515
+	 * @throws InvalidDataTypeException
3516
+	 * @throws InvalidInterfaceException
3517
+	 */
3518
+	protected function _duplicate_attendee()
3519
+	{
3520
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3521
+		// verify we have necessary info
3522
+		if (empty($this->_req_data['_REG_ID'])) {
3523
+			EE_Error::add_error(
3524
+				esc_html__(
3525
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3526
+					'event_espresso'
3527
+				),
3528
+				__FILE__,
3529
+				__LINE__,
3530
+				__FUNCTION__
3531
+			);
3532
+			$query_args = array('action' => $action);
3533
+			$this->_redirect_after_action('', '', '', $query_args, true);
3534
+		}
3535
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3536
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3537
+		$attendee = $registration->attendee();
3538
+		// remove relation of existing attendee on registration
3539
+		$registration->_remove_relation_to($attendee, 'Attendee');
3540
+		// new attendee
3541
+		$new_attendee = clone $attendee;
3542
+		$new_attendee->set('ATT_ID', 0);
3543
+		$new_attendee->save();
3544
+		// add new attendee to reg
3545
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3546
+		EE_Error::add_success(
3547
+			esc_html__(
3548
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3549
+				'event_espresso'
3550
+			)
3551
+		);
3552
+		// redirect to edit page for attendee
3553
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3554
+		$this->_redirect_after_action('', '', '', $query_args, true);
3555
+	}
3556
+
3557
+
3558
+	/**
3559
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3560
+	 *
3561
+	 * @param int     $post_id
3562
+	 * @param WP_POST $post
3563
+	 * @throws DomainException
3564
+	 * @throws EE_Error
3565
+	 * @throws InvalidArgumentException
3566
+	 * @throws InvalidDataTypeException
3567
+	 * @throws InvalidInterfaceException
3568
+	 * @throws LogicException
3569
+	 * @throws InvalidFormSubmissionException
3570
+	 */
3571
+	protected function _insert_update_cpt_item($post_id, $post)
3572
+	{
3573
+		$success = true;
3574
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3575
+			? EEM_Attendee::instance()->get_one_by_ID($post_id)
3576
+			: null;
3577
+		// for attendee updates
3578
+		if ($attendee instanceof EE_Attendee) {
3579
+			// note we should only be UPDATING attendees at this point.
3580
+			$updated_fields = array(
3581
+				'ATT_fname'     => $this->_req_data['ATT_fname'],
3582
+				'ATT_lname'     => $this->_req_data['ATT_lname'],
3583
+				'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3584
+				'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3585
+				'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3586
+				'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3587
+				'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3588
+				'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3589
+				'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3590
+			);
3591
+			foreach ($updated_fields as $field => $value) {
3592
+				$attendee->set($field, $value);
3593
+			}
3594
+
3595
+			// process contact details metabox form handler (which will also save the attendee)
3596
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3597
+			$success = $contact_details_form->process($this->_req_data);
3598
+
3599
+			$attendee_update_callbacks = apply_filters(
3600
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3601
+				array()
3602
+			);
3603
+			foreach ($attendee_update_callbacks as $a_callback) {
3604
+				if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3605
+					throw new EE_Error(
3606
+						sprintf(
3607
+							esc_html__(
3608
+								'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.',
3609
+								'event_espresso'
3610
+							),
3611
+							$a_callback
3612
+						)
3613
+					);
3614
+				}
3615
+			}
3616
+		}
3617
+
3618
+		if ($success === false) {
3619
+			EE_Error::add_error(
3620
+				esc_html__(
3621
+					'Something went wrong with updating the meta table data for the registration.',
3622
+					'event_espresso'
3623
+				),
3624
+				__FILE__,
3625
+				__FUNCTION__,
3626
+				__LINE__
3627
+			);
3628
+		}
3629
+	}
3630
+
3631
+
3632
+	public function trash_cpt_item($post_id)
3633
+	{
3634
+	}
3635
+
3636
+
3637
+	public function delete_cpt_item($post_id)
3638
+	{
3639
+	}
3640
+
3641
+
3642
+	public function restore_cpt_item($post_id)
3643
+	{
3644
+	}
3645
+
3646
+
3647
+	protected function _restore_cpt_item($post_id, $revision_id)
3648
+	{
3649
+	}
3650
+
3651
+
3652
+	public function attendee_editor_metaboxes()
3653
+	{
3654
+		$this->verify_cpt_object();
3655
+		remove_meta_box(
3656
+			'postexcerpt',
3657
+			esc_html__('Excerpt', 'event_espresso'),
3658
+			'post_excerpt_meta_box',
3659
+			$this->_cpt_routes[ $this->_req_action ],
3660
+			'normal',
3661
+			'core'
3662
+		);
3663
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3664
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3665
+			add_meta_box(
3666
+				'postexcerpt',
3667
+				esc_html__('Short Biography', 'event_espresso'),
3668
+				'post_excerpt_meta_box',
3669
+				$this->_cpt_routes[ $this->_req_action ],
3670
+				'normal'
3671
+			);
3672
+		}
3673
+		if (post_type_supports('espresso_attendees', 'comments')) {
3674
+			add_meta_box(
3675
+				'commentsdiv',
3676
+				esc_html__('Notes on the Contact', 'event_espresso'),
3677
+				'post_comment_meta_box',
3678
+				$this->_cpt_routes[ $this->_req_action ],
3679
+				'normal',
3680
+				'core'
3681
+			);
3682
+		}
3683
+		add_meta_box(
3684
+			'attendee_contact_info',
3685
+			esc_html__('Contact Info', 'event_espresso'),
3686
+			array($this, 'attendee_contact_info'),
3687
+			$this->_cpt_routes[ $this->_req_action ],
3688
+			'side',
3689
+			'core'
3690
+		);
3691
+		add_meta_box(
3692
+			'attendee_details_address',
3693
+			esc_html__('Address Details', 'event_espresso'),
3694
+			array($this, 'attendee_address_details'),
3695
+			$this->_cpt_routes[ $this->_req_action ],
3696
+			'normal',
3697
+			'core'
3698
+		);
3699
+		add_meta_box(
3700
+			'attendee_registrations',
3701
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3702
+			array($this, 'attendee_registrations_meta_box'),
3703
+			$this->_cpt_routes[ $this->_req_action ],
3704
+			'normal',
3705
+			'high'
3706
+		);
3707
+	}
3708
+
3709
+
3710
+	/**
3711
+	 * Metabox for attendee contact info
3712
+	 *
3713
+	 * @param  WP_Post $post wp post object
3714
+	 * @return string attendee contact info ( and form )
3715
+	 * @throws EE_Error
3716
+	 * @throws InvalidArgumentException
3717
+	 * @throws InvalidDataTypeException
3718
+	 * @throws InvalidInterfaceException
3719
+	 * @throws LogicException
3720
+	 * @throws DomainException
3721
+	 */
3722
+	public function attendee_contact_info($post)
3723
+	{
3724
+		// get attendee object ( should already have it )
3725
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3726
+		$form->enqueueStylesAndScripts();
3727
+		echo $form->display();
3728
+	}
3729
+
3730
+
3731
+	/**
3732
+	 * Return form handler for the contact details metabox
3733
+	 *
3734
+	 * @param EE_Attendee $attendee
3735
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3736
+	 * @throws DomainException
3737
+	 * @throws InvalidArgumentException
3738
+	 * @throws InvalidDataTypeException
3739
+	 * @throws InvalidInterfaceException
3740
+	 */
3741
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3742
+	{
3743
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3744
+	}
3745
+
3746
+
3747
+	/**
3748
+	 * Metabox for attendee details
3749
+	 *
3750
+	 * @param  WP_Post $post wp post object
3751
+	 * @throws DomainException
3752
+	 */
3753
+	public function attendee_address_details($post)
3754
+	{
3755
+		// get attendee object (should already have it)
3756
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3757
+		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3758
+			new EE_Question_Form_Input(
3759
+				EE_Question::new_instance(
3760
+					array(
3761
+						'QST_ID'           => 0,
3762
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3763
+						'QST_system'       => 'admin-state',
3764
+					)
3765
+				),
3766
+				EE_Answer::new_instance(
3767
+					array(
3768
+						'ANS_ID'    => 0,
3769
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3770
+					)
3771
+				),
3772
+				array(
3773
+					'input_id'       => 'STA_ID',
3774
+					'input_name'     => 'STA_ID',
3775
+					'input_prefix'   => '',
3776
+					'append_qstn_id' => false,
3777
+				)
3778
+			)
3779
+		);
3780
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3781
+			new EE_Question_Form_Input(
3782
+				EE_Question::new_instance(
3783
+					array(
3784
+						'QST_ID'           => 0,
3785
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3786
+						'QST_system'       => 'admin-country',
3787
+					)
3788
+				),
3789
+				EE_Answer::new_instance(
3790
+					array(
3791
+						'ANS_ID'    => 0,
3792
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3793
+					)
3794
+				),
3795
+				array(
3796
+					'input_id'       => 'CNT_ISO',
3797
+					'input_name'     => 'CNT_ISO',
3798
+					'input_prefix'   => '',
3799
+					'append_qstn_id' => false,
3800
+				)
3801
+			)
3802
+		);
3803
+		$template =
3804
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3805
+		EEH_Template::display_template($template, $this->_template_args);
3806
+	}
3807
+
3808
+
3809
+	/**
3810
+	 *        _attendee_details
3811
+	 *
3812
+	 * @access protected
3813
+	 * @param $post
3814
+	 * @return void
3815
+	 * @throws DomainException
3816
+	 * @throws EE_Error
3817
+	 */
3818
+	public function attendee_registrations_meta_box($post)
3819
+	{
3820
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3821
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3822
+		$template =
3823
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3824
+		EEH_Template::display_template($template, $this->_template_args);
3825
+	}
3826
+
3827
+
3828
+	/**
3829
+	 * add in the form fields for the attendee edit
3830
+	 *
3831
+	 * @param  WP_Post $post wp post object
3832
+	 * @return string html for new form.
3833
+	 * @throws DomainException
3834
+	 */
3835
+	public function after_title_form_fields($post)
3836
+	{
3837
+		if ($post->post_type == 'espresso_attendees') {
3838
+			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3839
+			$template_args['attendee'] = $this->_cpt_model_obj;
3840
+			EEH_Template::display_template($template, $template_args);
3841
+		}
3842
+	}
3843
+
3844
+
3845
+	/**
3846
+	 *        _trash_or_restore_attendee
3847
+	 *
3848
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3849
+	 * @return void
3850
+	 * @throws EE_Error
3851
+	 * @throws InvalidArgumentException
3852
+	 * @throws InvalidDataTypeException
3853
+	 * @throws InvalidInterfaceException
3854
+	 * @access protected
3855
+	 */
3856
+	protected function _trash_or_restore_attendees($trash = true)
3857
+	{
3858
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3859
+		$ATT_MDL = EEM_Attendee::instance();
3860
+		$success = 1;
3861
+		// Checkboxes
3862
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3863
+			// if array has more than one element than success message should be plural
3864
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3865
+			// cycle thru checkboxes
3866
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3867
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3868
+					: $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3869
+				if (! $updated) {
3870
+					$success = 0;
3871
+				}
3872
+			}
3873
+		} else {
3874
+			// grab single id and delete
3875
+			$ATT_ID = absint($this->_req_data['ATT_ID']);
3876
+			// get attendee
3877
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
3878
+			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3879
+			$updated = $att->save();
3880
+			if (! $updated) {
3881
+				$success = 0;
3882
+			}
3883
+		}
3884
+		$what = $success > 1
3885
+			? esc_html__('Contacts', 'event_espresso')
3886
+			: esc_html__('Contact', 'event_espresso');
3887
+		$action_desc = $trash
3888
+			? esc_html__('moved to the trash', 'event_espresso')
3889
+			: esc_html__('restored', 'event_espresso');
3890
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3891
+	}
3892 3892
 }
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         // when adding a new registration...
66 66
         if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67 67
             EE_System::do_not_cache();
68
-            if (! isset($this->_req_data['processing_registration'])
68
+            if ( ! isset($this->_req_data['processing_registration'])
69 69
                 || absint($this->_req_data['processing_registration']) !== 1
70 70
             ) {
71 71
                 // and it's NOT the attendee information reg step
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         // style
659 659
         wp_register_style(
660 660
             'espresso_reg',
661
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
661
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
662 662
             array('ee-admin-css'),
663 663
             EVENT_ESPRESSO_VERSION
664 664
         );
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
         // script
667 667
         wp_register_script(
668 668
             'espresso_reg',
669
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
669
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
670 670
             array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671 671
             EVENT_ESPRESSO_VERSION,
672 672
             true
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         wp_dequeue_style('espresso_reg');
705 705
         wp_register_style(
706 706
             'espresso_att',
707
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
707
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
708 708
             array('ee-admin-css'),
709 709
             EVENT_ESPRESSO_VERSION
710 710
         );
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
     {
717 717
         wp_register_script(
718 718
             'ee-spco-for-admin',
719
-            REG_ASSETS_URL . 'spco_for_admin.js',
719
+            REG_ASSETS_URL.'spco_for_admin.js',
720 720
             array('underscore', 'jquery'),
721 721
             EVENT_ESPRESSO_VERSION,
722 722
             true
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
         }
951 951
         $sc_items = array(
952 952
             'approved_status'   => array(
953
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
953
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
954 954
                 'desc'  => EEH_Template::pretty_status(
955 955
                     EEM_Registration::status_id_approved,
956 956
                     false,
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
                 ),
959 959
             ),
960 960
             'pending_status'    => array(
961
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
961
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
962 962
                 'desc'  => EEH_Template::pretty_status(
963 963
                     EEM_Registration::status_id_pending_payment,
964 964
                     false,
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
                 ),
967 967
             ),
968 968
             'wait_list'         => array(
969
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
969
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
970 970
                 'desc'  => EEH_Template::pretty_status(
971 971
                     EEM_Registration::status_id_wait_list,
972 972
                     false,
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
                 ),
975 975
             ),
976 976
             'incomplete_status' => array(
977
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
977
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
978 978
                 'desc'  => EEH_Template::pretty_status(
979 979
                     EEM_Registration::status_id_incomplete,
980 980
                     false,
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
                 ),
983 983
             ),
984 984
             'not_approved'      => array(
985
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
985
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
986 986
                 'desc'  => EEH_Template::pretty_status(
987 987
                     EEM_Registration::status_id_not_approved,
988 988
                     false,
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
                 ),
991 991
             ),
992 992
             'declined_status'   => array(
993
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
993
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
994 994
                 'desc'  => EEH_Template::pretty_status(
995 995
                     EEM_Registration::status_id_declined,
996 996
                     false,
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
                 ),
999 999
             ),
1000 1000
             'cancelled_status'  => array(
1001
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1001
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1002 1002
                 'desc'  => EEH_Template::pretty_status(
1003 1003
                     EEM_Registration::status_id_cancelled,
1004 1004
                     false,
@@ -1033,13 +1033,13 @@  discard block
 block discarded – undo
1033 1033
                         'event_espresso'
1034 1034
                     ),
1035 1035
                     '<h3 style="line-height:1.5em;">',
1036
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1036
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
1037 1037
                         array(
1038 1038
                             'action' => 'edit_attendee',
1039 1039
                             'post'   => $ATT_ID,
1040 1040
                         ),
1041 1041
                         REG_ADMIN_URL
1042
-                    ) . '">' . $attendee->full_name() . '</a>',
1042
+                    ).'">'.$attendee->full_name().'</a>',
1043 1043
                     '</h3>'
1044 1044
                 );
1045 1045
             }
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
                 'espresso_registrations_new_registration',
1051 1051
                 $EVT_ID
1052 1052
             )) {
1053
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1053
+                $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1054 1054
                     'new_registration',
1055 1055
                     'add-registrant',
1056 1056
                     array('event_id' => $EVT_ID),
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
                 $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091 1091
                 $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092 1092
                 $this->_template_args['admin_page_header'] .= $datetime->name();
1093
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1093
+                $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )';
1094 1094
                 $this->_template_args['admin_page_header'] .= '</span></h3>';
1095 1095
             }
1096 1096
         }
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
             return true;
1117 1117
         }
1118 1118
         $REG = EEM_Registration::instance();
1119
-        $REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1119
+        $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120 1120
         if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121 1121
             return true;
1122 1122
         } else {
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
             'caps'                     => EEM_Registration::caps_read_admin,
1199 1199
             'default_where_conditions' => 'this_model_only',
1200 1200
         );
1201
-        if (! $count) {
1201
+        if ( ! $count) {
1202 1202
             $query_params = array_merge(
1203 1203
                 $query_params,
1204 1204
                 $this->_get_orderby_for_registrations_query(),
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
     protected function addAttendeeIdToWhereConditions(array $request)
1220 1220
     {
1221 1221
         $where = array();
1222
-        if (! empty($request['ATT_ID'])) {
1222
+        if ( ! empty($request['ATT_ID'])) {
1223 1223
             $where['ATT_ID'] = absint($request['ATT_ID']);
1224 1224
         }
1225 1225
         return $where;
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
     protected function _add_event_id_to_where_conditions(array $request)
1236 1236
     {
1237 1237
         $where = array();
1238
-        if (! empty($request['event_id'])) {
1238
+        if ( ! empty($request['event_id'])) {
1239 1239
             $where['EVT_ID'] = absint($request['event_id']);
1240 1240
         }
1241 1241
         return $where;
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
     protected function _add_category_id_to_where_conditions(array $request)
1252 1252
     {
1253 1253
         $where = array();
1254
-        if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1254
+        if ( ! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1255 1255
             $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1256 1256
         }
1257 1257
         return $where;
@@ -1267,10 +1267,10 @@  discard block
 block discarded – undo
1267 1267
     protected function _add_datetime_id_to_where_conditions(array $request)
1268 1268
     {
1269 1269
         $where = array();
1270
-        if (! empty($request['datetime_id'])) {
1270
+        if ( ! empty($request['datetime_id'])) {
1271 1271
             $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1272 1272
         }
1273
-        if (! empty($request['DTT_ID'])) {
1273
+        if ( ! empty($request['DTT_ID'])) {
1274 1274
             $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1275 1275
         }
1276 1276
         return $where;
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
          * If not filtering by specified status, then we show all registrations excluding incomplete registrations
1297 1297
          * UNLESS viewing trashed registrations.
1298 1298
          */
1299
-        if (! empty($registration_status)) {
1299
+        if ( ! empty($registration_status)) {
1300 1300
             $where['STS_ID'] = $registration_status;
1301 1301
         } else {
1302 1302
             // make sure we exclude incomplete registrations, but only if not trashed.
@@ -1339,12 +1339,12 @@  discard block
 block discarded – undo
1339 1339
                 array(
1340 1340
                     EEM_Registration::instance()->convert_datetime_for_query(
1341 1341
                         'REG_date',
1342
-                        $now . ' 00:00:00',
1342
+                        $now.' 00:00:00',
1343 1343
                         'Y-m-d H:i:s'
1344 1344
                     ),
1345 1345
                     EEM_Registration::instance()->convert_datetime_for_query(
1346 1346
                         'REG_date',
1347
-                        $now . ' 23:59:59',
1347
+                        $now.' 23:59:59',
1348 1348
                         'Y-m-d H:i:s'
1349 1349
                     ),
1350 1350
                 ),
@@ -1357,12 +1357,12 @@  discard block
 block discarded – undo
1357 1357
                 array(
1358 1358
                     EEM_Registration::instance()->convert_datetime_for_query(
1359 1359
                         'REG_date',
1360
-                        $current_year_and_month . '-01 00:00:00',
1360
+                        $current_year_and_month.'-01 00:00:00',
1361 1361
                         'Y-m-d H:i:s'
1362 1362
                     ),
1363 1363
                     EEM_Registration::instance()->convert_datetime_for_query(
1364 1364
                         'REG_date',
1365
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1365
+                        $current_year_and_month.'-'.$days_this_month.' 23:59:59',
1366 1366
                         'Y-m-d H:i:s'
1367 1367
                     ),
1368 1368
                 ),
@@ -1377,18 +1377,18 @@  discard block
 block discarded – undo
1377 1377
                 : '';
1378 1378
             // if there is not a month or year then we can't go further
1379 1379
             if ($month_requested && $year_requested) {
1380
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1380
+                $days_in_month = date('t', strtotime($year_requested.'-'.$month_requested.'-'.'01'));
1381 1381
                 $where['REG_date'] = array(
1382 1382
                     'BETWEEN',
1383 1383
                     array(
1384 1384
                         EEM_Registration::instance()->convert_datetime_for_query(
1385 1385
                             'REG_date',
1386
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
1386
+                            $year_requested.'-'.$month_requested.'-01 00:00:00',
1387 1387
                             'Y-m-d H:i:s'
1388 1388
                         ),
1389 1389
                         EEM_Registration::instance()->convert_datetime_for_query(
1390 1390
                             'REG_date',
1391
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1391
+                            $year_requested.'-'.$month_requested.'-'.$days_in_month.' 23:59:59',
1392 1392
                             'Y-m-d H:i:s'
1393 1393
                         ),
1394 1394
                     ),
@@ -1408,8 +1408,8 @@  discard block
 block discarded – undo
1408 1408
     protected function _add_search_to_where_conditions(array $request)
1409 1409
     {
1410 1410
         $where = array();
1411
-        if (! empty($request['s'])) {
1412
-            $search_string = '%' . sanitize_text_field($request['s']) . '%';
1411
+        if ( ! empty($request['s'])) {
1412
+            $search_string = '%'.sanitize_text_field($request['s']).'%';
1413 1413
             $where['OR*search_conditions'] = array(
1414 1414
                 'Event.EVT_name'                          => array('LIKE', $search_string),
1415 1415
                 'Event.EVT_desc'                          => array('LIKE', $search_string),
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
                 )
1646 1646
                 : '';
1647 1647
             // grab header
1648
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1648
+            $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1649 1649
             $this->_template_args['REG_ID'] = $this->_registration->ID();
1650 1650
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1651 1651
                 $template_path,
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
                             EEH_HTML::strong(
1783 1783
                                 $this->_registration->pretty_status(),
1784 1784
                                 '',
1785
-                                'status-' . $this->_registration->status_ID(),
1785
+                                'status-'.$this->_registration->status_ID(),
1786 1786
                                 'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1787 1787
                             )
1788 1788
                         )
@@ -1837,14 +1837,14 @@  discard block
 block discarded – undo
1837 1837
     protected function _get_reg_statuses()
1838 1838
     {
1839 1839
         $reg_status_array = EEM_Registration::instance()->reg_status_array();
1840
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1840
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1841 1841
         // get current reg status
1842 1842
         $current_status = $this->_registration->status_ID();
1843 1843
         // is registration for free event? This will determine whether to display the pending payment option
1844 1844
         if ($current_status !== EEM_Registration::status_id_pending_payment
1845 1845
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1846 1846
         ) {
1847
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1847
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1848 1848
         }
1849 1849
         return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1850 1850
     }
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
         $success = false;
1937 1937
         // typecast $REG_IDs
1938 1938
         $REG_IDs = (array) $REG_IDs;
1939
-        if (! empty($REG_IDs)) {
1939
+        if ( ! empty($REG_IDs)) {
1940 1940
             $success = true;
1941 1941
             // set default status if none is passed
1942 1942
             $status = $status ? $status : EEM_Registration::status_id_pending_payment;
@@ -2016,11 +2016,11 @@  discard block
 block discarded – undo
2016 2016
         // unset nonces
2017 2017
         foreach ($this->_req_data as $ref => $value) {
2018 2018
             if (strpos($ref, 'nonce') !== false) {
2019
-                unset($this->_req_data[ $ref ]);
2019
+                unset($this->_req_data[$ref]);
2020 2020
                 continue;
2021 2021
             }
2022 2022
             $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
2023
-            $this->_req_data[ $ref ] = $value;
2023
+            $this->_req_data[$ref] = $value;
2024 2024
         }
2025 2025
         // merge request vars so that the reloaded list table contains any existing filter query params
2026 2026
         $route = array_merge($this->_req_data, $route);
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
             $action,
2095 2095
             $notify
2096 2096
         );
2097
-        $method = $action . '_registration';
2097
+        $method = $action.'_registration';
2098 2098
         if (method_exists($this, $method)) {
2099 2099
             $this->$method($notify);
2100 2100
         }
@@ -2325,7 +2325,7 @@  discard block
 block discarded – undo
2325 2325
         $this->_template_args['REG_ID'] = $this->_registration->ID();
2326 2326
         $this->_template_args['event_id'] = $this->_registration->event_ID();
2327 2327
         $template_path =
2328
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2328
+            REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2329 2329
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2330 2330
     }
2331 2331
 
@@ -2358,7 +2358,7 @@  discard block
 block discarded – undo
2358 2358
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2359 2359
             $this->_template_args['REG_ID'] = $this->_registration->ID();
2360 2360
             $template_path =
2361
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2361
+                REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2362 2362
             echo EEH_Template::display_template($template_path, $this->_template_args, true);
2363 2363
         }
2364 2364
     }
@@ -2375,7 +2375,7 @@  discard block
 block discarded – undo
2375 2375
     public function form_before_question_group($output)
2376 2376
     {
2377 2377
         EE_Error::doing_it_wrong(
2378
-            __CLASS__ . '::' . __FUNCTION__,
2378
+            __CLASS__.'::'.__FUNCTION__,
2379 2379
             esc_html__(
2380 2380
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2381 2381
                 'event_espresso'
@@ -2400,7 +2400,7 @@  discard block
 block discarded – undo
2400 2400
     public function form_after_question_group($output)
2401 2401
     {
2402 2402
         EE_Error::doing_it_wrong(
2403
-            __CLASS__ . '::' . __FUNCTION__,
2403
+            __CLASS__.'::'.__FUNCTION__,
2404 2404
             esc_html__(
2405 2405
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2406 2406
                 'event_espresso'
@@ -2438,7 +2438,7 @@  discard block
 block discarded – undo
2438 2438
     public function form_form_field_label_wrap($label)
2439 2439
     {
2440 2440
         EE_Error::doing_it_wrong(
2441
-            __CLASS__ . '::' . __FUNCTION__,
2441
+            __CLASS__.'::'.__FUNCTION__,
2442 2442
             esc_html__(
2443 2443
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2444 2444
                 'event_espresso'
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
         return '
2449 2449
 			<tr>
2450 2450
 				<th>
2451
-					' . $label . '
2451
+					' . $label.'
2452 2452
 				</th>';
2453 2453
     }
2454 2454
 
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
     public function form_form_field_input__wrap($input)
2465 2465
     {
2466 2466
         EE_Error::doing_it_wrong(
2467
-            __CLASS__ . '::' . __FUNCTION__,
2467
+            __CLASS__.'::'.__FUNCTION__,
2468 2468
             esc_html__(
2469 2469
                 'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2470 2470
                 'event_espresso'
@@ -2473,7 +2473,7 @@  discard block
 block discarded – undo
2473 2473
         );
2474 2474
         return '
2475 2475
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2476
-					' . $input . '
2476
+					' . $input.'
2477 2477
 				</td>
2478 2478
 			</tr>';
2479 2479
     }
@@ -2517,8 +2517,8 @@  discard block
 block discarded – undo
2517 2517
      */
2518 2518
     protected function _get_reg_custom_questions_form($REG_ID)
2519 2519
     {
2520
-        if (! $this->_reg_custom_questions_form) {
2521
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2520
+        if ( ! $this->_reg_custom_questions_form) {
2521
+            require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php');
2522 2522
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2523 2523
                 EEM_Registration::instance()->get_one_by_ID($REG_ID)
2524 2524
             );
@@ -2541,7 +2541,7 @@  discard block
 block discarded – undo
2541 2541
      */
2542 2542
     private function _save_reg_custom_questions_form($REG_ID = false)
2543 2543
     {
2544
-        if (! $REG_ID) {
2544
+        if ( ! $REG_ID) {
2545 2545
             EE_Error::add_error(
2546 2546
                 esc_html__(
2547 2547
                     'An error occurred. No registration ID was received.',
@@ -2632,28 +2632,28 @@  discard block
 block discarded – undo
2632 2632
                     ? $registration->attendee()
2633 2633
                     : EEM_Attendee::instance()
2634 2634
                                   ->create_default_object();
2635
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2636
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2637
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2638
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2639
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2640
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2635
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID();
2636
+                $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();
2637
+                $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();
2638
+                $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();
2639
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2640
+                $this->_template_args['attendees'][$att_nmbr]['address'] = implode(
2641 2641
                     ', ',
2642 2642
                     $attendee->full_address_as_array()
2643 2643
                 );
2644
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2644
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2645 2645
                     array(
2646 2646
                         'action' => 'edit_attendee',
2647 2647
                         'post'   => $attendee->ID(),
2648 2648
                     ),
2649 2649
                     REG_ADMIN_URL
2650 2650
                 );
2651
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name();
2651
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name();
2652 2652
                 $att_nmbr++;
2653 2653
             }
2654 2654
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2655 2655
         }
2656
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2656
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2657 2657
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2658 2658
     }
2659 2659
 
@@ -2677,11 +2677,11 @@  discard block
 block discarded – undo
2677 2677
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2678 2678
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2679 2679
         // primary registration object (that way we know if we need to show create button or not)
2680
-        if (! $this->_registration->is_primary_registrant()) {
2680
+        if ( ! $this->_registration->is_primary_registrant()) {
2681 2681
             $primary_registration = $this->_registration->get_primary_registration();
2682 2682
             $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2683 2683
                 : null;
2684
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2684
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2685 2685
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2686 2686
                 // custom attendee object so let's not worry about the primary reg.
2687 2687
                 $primary_registration = null;
@@ -2715,7 +2715,7 @@  discard block
 block discarded – undo
2715 2715
             ) : '';
2716 2716
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2717 2717
         $this->_template_args['att_check'] = $att_check;
2718
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2718
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2719 2719
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2720 2720
     }
2721 2721
 
@@ -2753,7 +2753,7 @@  discard block
 block discarded – undo
2753 2753
         $success = 0;
2754 2754
         $overwrite_msgs = false;
2755 2755
         // Checkboxes
2756
-        if (! is_array($this->_req_data['_REG_ID'])) {
2756
+        if ( ! is_array($this->_req_data['_REG_ID'])) {
2757 2757
             $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2758 2758
         }
2759 2759
         $reg_count = count($this->_req_data['_REG_ID']);
@@ -2762,7 +2762,7 @@  discard block
 block discarded – undo
2762 2762
             /** @var EE_Registration $REG */
2763 2763
             $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2764 2764
             $payments = $REG->registration_payments();
2765
-            if (! empty($payments)) {
2765
+            if ( ! empty($payments)) {
2766 2766
                 $name = $REG->attendee() instanceof EE_Attendee
2767 2767
                     ? $REG->attendee()->full_name()
2768 2768
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2823,17 +2823,17 @@  discard block
 block discarded – undo
2823 2823
         $REG_MDL = EEM_Registration::instance();
2824 2824
         $success = 1;
2825 2825
         // Checkboxes
2826
-        if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2826
+        if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2827 2827
             // if array has more than one element than success message should be plural
2828 2828
             $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2829 2829
             // cycle thru checkboxes
2830 2830
             while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2831 2831
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2832
-                if (! $REG instanceof EE_Registration) {
2832
+                if ( ! $REG instanceof EE_Registration) {
2833 2833
                     continue;
2834 2834
                 }
2835 2835
                 $deleted = $this->_delete_registration($REG);
2836
-                if (! $deleted) {
2836
+                if ( ! $deleted) {
2837 2837
                     $success = 0;
2838 2838
                 }
2839 2839
             }
@@ -2842,7 +2842,7 @@  discard block
 block discarded – undo
2842 2842
             $REG_ID = $this->_req_data['_REG_ID'];
2843 2843
             $REG = $REG_MDL->get_one_by_ID($REG_ID);
2844 2844
             $deleted = $this->_delete_registration($REG);
2845
-            if (! $deleted) {
2845
+            if ( ! $deleted) {
2846 2846
                 $success = 0;
2847 2847
             }
2848 2848
         }
@@ -2876,11 +2876,11 @@  discard block
 block discarded – undo
2876 2876
         $REGS = $TXN->get_many_related('Registration');
2877 2877
         $all_trashed = true;
2878 2878
         foreach ($REGS as $registration) {
2879
-            if (! $registration->get('REG_deleted')) {
2879
+            if ( ! $registration->get('REG_deleted')) {
2880 2880
                 $all_trashed = false;
2881 2881
             }
2882 2882
         }
2883
-        if (! $all_trashed) {
2883
+        if ( ! $all_trashed) {
2884 2884
             EE_Error::add_error(
2885 2885
                 esc_html__(
2886 2886
                     '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.',
@@ -2939,7 +2939,7 @@  discard block
 block discarded – undo
2939 2939
      */
2940 2940
     public function new_registration()
2941 2941
     {
2942
-        if (! $this->_set_reg_event()) {
2942
+        if ( ! $this->_set_reg_event()) {
2943 2943
             throw new EE_Error(
2944 2944
                 esc_html__(
2945 2945
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2949,8 +2949,8 @@  discard block
 block discarded – undo
2949 2949
         }
2950 2950
         EE_Registry::instance()->REQ->set_espresso_page(true);
2951 2951
         // gotta start with a clean slate if we're not coming here via ajax
2952
-        if (! defined('DOING_AJAX')
2953
-            && (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2952
+        if ( ! defined('DOING_AJAX')
2953
+            && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2954 2954
         ) {
2955 2955
             EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2956 2956
         }
@@ -2983,7 +2983,7 @@  discard block
 block discarded – undo
2983 2983
         }
2984 2984
         // grab header
2985 2985
         $template_path =
2986
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2986
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2987 2987
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2988 2988
             $template_path,
2989 2989
             $this->_template_args,
@@ -3024,7 +3024,7 @@  discard block
 block discarded – undo
3024 3024
                 '</b>'
3025 3025
             );
3026 3026
             return '
3027
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
3027
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
3028 3028
 	<script >
3029 3029
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
3030 3030
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -3092,7 +3092,7 @@  discard block
 block discarded – undo
3092 3092
         // we come back to the process_registration_step route.
3093 3093
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3094 3094
         return EEH_Template::display_template(
3095
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3095
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
3096 3096
             $template_args,
3097 3097
             true
3098 3098
         );
@@ -3114,8 +3114,8 @@  discard block
 block discarded – undo
3114 3114
         if (is_object($this->_reg_event)) {
3115 3115
             return true;
3116 3116
         }
3117
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3118
-        if (! $EVT_ID) {
3117
+        $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3118
+        if ( ! $EVT_ID) {
3119 3119
             return false;
3120 3120
         }
3121 3121
         $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
@@ -3147,8 +3147,8 @@  discard block
 block discarded – undo
3147 3147
         $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3148 3148
         // if doing ajax then we need to verify the nonce
3149 3149
         if (defined('DOING_AJAX')) {
3150
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
3151
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3150
+            $nonce = isset($this->_req_data[$this->_req_nonce])
3151
+                ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
3152 3152
             $this->_verify_nonce($nonce, $this->_req_nonce);
3153 3153
         }
3154 3154
         switch ($step) {
@@ -3184,7 +3184,7 @@  discard block
 block discarded – undo
3184 3184
                 }
3185 3185
                 break;
3186 3186
             case 'questions':
3187
-                if (! isset(
3187
+                if ( ! isset(
3188 3188
                     $this->_req_data['txn_reg_status_change'],
3189 3189
                     $this->_req_data['txn_reg_status_change']['send_notifications']
3190 3190
                 )
@@ -3199,7 +3199,7 @@  discard block
 block discarded – undo
3199 3199
                         $grand_total->save_this_and_descendants_to_txn();
3200 3200
                     }
3201 3201
                 }
3202
-                if (! $transaction instanceof EE_Transaction) {
3202
+                if ( ! $transaction instanceof EE_Transaction) {
3203 3203
                     $query_args = array(
3204 3204
                         'action'                  => 'new_registration',
3205 3205
                         'processing_registration' => 2,
@@ -3222,7 +3222,7 @@  discard block
 block discarded – undo
3222 3222
                     }
3223 3223
                 }
3224 3224
                 // maybe update status, and make sure to save transaction if not done already
3225
-                if (! $transaction->update_status_based_on_total_paid()) {
3225
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3226 3226
                     $transaction->save();
3227 3227
                 }
3228 3228
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3305,7 +3305,7 @@  discard block
 block discarded – undo
3305 3305
     public function get_attendees($per_page, $count = false, $trash = false)
3306 3306
     {
3307 3307
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3308
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3308
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3309 3309
         $ATT_MDL = EEM_Attendee::instance();
3310 3310
         $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3311 3311
         switch ($this->_req_data['orderby']) {
@@ -3344,8 +3344,8 @@  discard block
 block discarded – undo
3344 3344
             ? $this->_req_data['perpage']
3345 3345
             : $per_page;
3346 3346
         $_where = array();
3347
-        if (! empty($this->_req_data['s'])) {
3348
-            $sstr = '%' . $this->_req_data['s'] . '%';
3347
+        if ( ! empty($this->_req_data['s'])) {
3348
+            $sstr = '%'.$this->_req_data['s'].'%';
3349 3349
             $_where['OR'] = array(
3350 3350
                 'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3351 3351
                 'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
@@ -3372,7 +3372,7 @@  discard block
 block discarded – undo
3372 3372
             'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3373 3373
             'limit'         => $limit,
3374 3374
         );
3375
-        if (! $count) {
3375
+        if ( ! $count) {
3376 3376
             $query_args['order_by'] = array($orderby => $sort);
3377 3377
         }
3378 3378
         if ($trash) {
@@ -3415,7 +3415,7 @@  discard block
 block discarded – undo
3415 3415
      */
3416 3416
     public function _registrations_report_base($method_name_for_getting_query_params)
3417 3417
     {
3418
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3418
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3419 3419
             wp_redirect(
3420 3420
                 EE_Admin_Page::add_query_args_and_nonce(
3421 3421
                     array(
@@ -3448,8 +3448,8 @@  discard block
 block discarded – undo
3448 3448
                 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3449 3449
             );
3450 3450
             $this->_req_data = array_merge($this->_req_data, $new_request_args);
3451
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3452
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3451
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3452
+                require_once(EE_CLASSES.'EE_Export.class.php');
3453 3453
                 $EE_Export = EE_Export::instance($this->_req_data);
3454 3454
                 $EE_Export->export();
3455 3455
             }
@@ -3470,8 +3470,8 @@  discard block
 block discarded – undo
3470 3470
 
3471 3471
     public function _contact_list_export()
3472 3472
     {
3473
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3474
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3473
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3474
+            require_once(EE_CLASSES.'EE_Export.class.php');
3475 3475
             $EE_Export = EE_Export::instance($this->_req_data);
3476 3476
             $EE_Export->export_attendees();
3477 3477
         }
@@ -3480,7 +3480,7 @@  discard block
 block discarded – undo
3480 3480
 
3481 3481
     public function _contact_list_report()
3482 3482
     {
3483
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3483
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3484 3484
             wp_redirect(
3485 3485
                 EE_Admin_Page::add_query_args_and_nonce(
3486 3486
                     array(
@@ -3493,8 +3493,8 @@  discard block
 block discarded – undo
3493 3493
             );
3494 3494
             die;
3495 3495
         } else {
3496
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3497
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3496
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3497
+                require_once(EE_CLASSES.'EE_Export.class.php');
3498 3498
                 $EE_Export = EE_Export::instance($this->_req_data);
3499 3499
                 $EE_Export->report_attendees();
3500 3500
             }
@@ -3580,7 +3580,7 @@  discard block
 block discarded – undo
3580 3580
             $updated_fields = array(
3581 3581
                 'ATT_fname'     => $this->_req_data['ATT_fname'],
3582 3582
                 'ATT_lname'     => $this->_req_data['ATT_lname'],
3583
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3583
+                'ATT_full_name' => $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'],
3584 3584
                 'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3585 3585
                 'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3586 3586
                 'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
@@ -3656,17 +3656,17 @@  discard block
 block discarded – undo
3656 3656
             'postexcerpt',
3657 3657
             esc_html__('Excerpt', 'event_espresso'),
3658 3658
             'post_excerpt_meta_box',
3659
-            $this->_cpt_routes[ $this->_req_action ],
3659
+            $this->_cpt_routes[$this->_req_action],
3660 3660
             'normal',
3661 3661
             'core'
3662 3662
         );
3663
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3663
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
3664 3664
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3665 3665
             add_meta_box(
3666 3666
                 'postexcerpt',
3667 3667
                 esc_html__('Short Biography', 'event_espresso'),
3668 3668
                 'post_excerpt_meta_box',
3669
-                $this->_cpt_routes[ $this->_req_action ],
3669
+                $this->_cpt_routes[$this->_req_action],
3670 3670
                 'normal'
3671 3671
             );
3672 3672
         }
@@ -3675,7 +3675,7 @@  discard block
 block discarded – undo
3675 3675
                 'commentsdiv',
3676 3676
                 esc_html__('Notes on the Contact', 'event_espresso'),
3677 3677
                 'post_comment_meta_box',
3678
-                $this->_cpt_routes[ $this->_req_action ],
3678
+                $this->_cpt_routes[$this->_req_action],
3679 3679
                 'normal',
3680 3680
                 'core'
3681 3681
             );
@@ -3684,7 +3684,7 @@  discard block
 block discarded – undo
3684 3684
             'attendee_contact_info',
3685 3685
             esc_html__('Contact Info', 'event_espresso'),
3686 3686
             array($this, 'attendee_contact_info'),
3687
-            $this->_cpt_routes[ $this->_req_action ],
3687
+            $this->_cpt_routes[$this->_req_action],
3688 3688
             'side',
3689 3689
             'core'
3690 3690
         );
@@ -3692,7 +3692,7 @@  discard block
 block discarded – undo
3692 3692
             'attendee_details_address',
3693 3693
             esc_html__('Address Details', 'event_espresso'),
3694 3694
             array($this, 'attendee_address_details'),
3695
-            $this->_cpt_routes[ $this->_req_action ],
3695
+            $this->_cpt_routes[$this->_req_action],
3696 3696
             'normal',
3697 3697
             'core'
3698 3698
         );
@@ -3700,7 +3700,7 @@  discard block
 block discarded – undo
3700 3700
             'attendee_registrations',
3701 3701
             esc_html__('Registrations for this Contact', 'event_espresso'),
3702 3702
             array($this, 'attendee_registrations_meta_box'),
3703
-            $this->_cpt_routes[ $this->_req_action ],
3703
+            $this->_cpt_routes[$this->_req_action],
3704 3704
             'normal',
3705 3705
             'high'
3706 3706
         );
@@ -3801,7 +3801,7 @@  discard block
 block discarded – undo
3801 3801
             )
3802 3802
         );
3803 3803
         $template =
3804
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3804
+            REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3805 3805
         EEH_Template::display_template($template, $this->_template_args);
3806 3806
     }
3807 3807
 
@@ -3820,7 +3820,7 @@  discard block
 block discarded – undo
3820 3820
         $this->_template_args['attendee'] = $this->_cpt_model_obj;
3821 3821
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3822 3822
         $template =
3823
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3823
+            REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3824 3824
         EEH_Template::display_template($template, $this->_template_args);
3825 3825
     }
3826 3826
 
@@ -3835,7 +3835,7 @@  discard block
 block discarded – undo
3835 3835
     public function after_title_form_fields($post)
3836 3836
     {
3837 3837
         if ($post->post_type == 'espresso_attendees') {
3838
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3838
+            $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3839 3839
             $template_args['attendee'] = $this->_cpt_model_obj;
3840 3840
             EEH_Template::display_template($template, $template_args);
3841 3841
         }
@@ -3859,14 +3859,14 @@  discard block
 block discarded – undo
3859 3859
         $ATT_MDL = EEM_Attendee::instance();
3860 3860
         $success = 1;
3861 3861
         // Checkboxes
3862
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3862
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3863 3863
             // if array has more than one element than success message should be plural
3864 3864
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3865 3865
             // cycle thru checkboxes
3866 3866
             while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3867 3867
                 $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3868 3868
                     : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3869
-                if (! $updated) {
3869
+                if ( ! $updated) {
3870 3870
                     $success = 0;
3871 3871
                 }
3872 3872
             }
@@ -3877,7 +3877,7 @@  discard block
 block discarded – undo
3877 3877
             $att = $ATT_MDL->get_one_by_ID($ATT_ID);
3878 3878
             $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3879 3879
             $updated = $att->save();
3880
-            if (! $updated) {
3880
+            if ( ! $updated) {
3881 3881
                 $success = 0;
3882 3882
             }
3883 3883
         }
Please login to merge, or discard this patch.