Completed
Push — master ( 10354b...44551c )
by Devin
29:37 queued 13:08
created

customers.php ➔ give_customers_view()   F

Complexity

Conditions 18
Paths 1152

Size

Total Lines 287
Code Lines 177

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 18
eloc 177
nc 1152
nop 1
dl 0
loc 287
rs 2

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 25 and the first side effect is on line 14.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Customer (Donors)
4
 *
5
 * @package     Give
6
 * @subpackage  Admin/Customers
7
 * @copyright   Copyright (c) 2016, WordImpress
8
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
 * @since       1.0
10
 */
11
12
// Exit if accessed directly
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Customers Page
19
 *
20
 * Renders the customers page contents.
21
 *
22
 * @since  1.0
23
 * @return void
24
 */
25
function give_customers_page() {
26
	$default_views  = give_customer_views();
27
	$requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'customers';
28
	if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) {
29
		give_render_customer_view( $requested_view, $default_views );
30
	} else {
31
		give_customers_list();
32
	}
33
}
34
35
/**
36
 * Register the views for customer management
37
 *
38
 * @since  1.0
39
 * @return array Array of views and their callbacks
40
 */
41
function give_customer_views() {
42
43
	$views = array();
44
45
	return apply_filters( 'give_customer_views', $views );
46
47
}
48
49
/**
50
 * Register the tabs for customer management
51
 *
52
 * @since  1.0
53
 * @return array Array of tabs for the customer
54
 */
55
function give_customer_tabs() {
56
57
	$tabs = array();
58
59
	return apply_filters( 'give_customer_tabs', $tabs );
60
61
}
62
63
/**
64
 * List table of customers
65
 *
66
 * @since  1.0
67
 * @return void
68
 */
69
function give_customers_list() {
70
	include( dirname( __FILE__ ) . '/class-customer-table.php' );
71
72
	$customers_table = new Give_Customer_Reports_Table();
73
	$customers_table->prepare_items();
74
	?>
75
	<div class="wrap">
76
		<h2><?php _e( 'Donors', 'give' ); ?></h2>
77
		<?php do_action( 'give_donors_table_top' ); ?>
78
		<form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>">
79
			<?php
80
			$customers_table->search_box( __( 'Search Donors', 'give' ), 'give-donors' );
81
			$customers_table->display();
82
			?>
83
			<input type="hidden" name="post_type" value="give_forms" />
84
			<input type="hidden" name="page" value="give-donors" />
85
			<input type="hidden" name="view" value="customers" />
86
		</form>
87
		<?php do_action( 'give_donors_table_bottom' ); ?>
88
	</div>
89
	<?php
90
}
91
92
/**
93
 * Renders the customer view wrapper
94
 *
95
 * @since  1.0
96
 *
97
 * @param  string $view      The View being requested
98
 * @param  array  $callbacks The Registered views and their callback functions
99
 *
100
 * @return void
101
 */
102
function give_render_customer_view( $view, $callbacks ) {
103
104
	$render = true;
105
106
	$customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' );
107
108
	if ( ! current_user_can( $customer_view_role ) ) {
109
		give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) );
110
		$render = false;
111
	}
112
 
113
	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
114
		give_set_error( 'give-invalid_customer', __( 'Invalid Donor ID Provided.', 'give' ) );
115
		$render = false;
116
	}
117
118
	$customer_id = (int) $_GET['id'];
119
	$customer    = new Give_Customer( $customer_id );
120
121
	if ( empty( $customer->id ) ) {
122
		give_set_error( 'give-invalid_customer', __( 'Invalid Donor ID Provided.', 'give' ) );
123
		$render = false;
124
	}
125
126
	$customer_tabs = give_customer_tabs();
127
	?>
128
129
	<div class='wrap'>
130
131
		<?php if ( give_get_errors() ) : ?>
132
			<div class="error settings-error">
133
				<?php give_print_errors( 0 ); ?>
134
			</div>
135
		<?php endif; ?>
136
137
		<?php if ( $customer && $render ) : ?>
138
139
			<div id="customer-tab-wrapper">
140
				<ul id="customer-tab-wrapper-list" class="nav-tab-wrapper">
141
					<?php foreach ( $customer_tabs as $key => $tab ) : ?>
142
						<?php $active = $key === $view ? true : false; ?>
143
						<?php $class = $active ? 'active' : 'inactive'; ?>
144
145
						<li class="<?php echo sanitize_html_class( $class ); ?>">
146
							<?php if ( ! $active ) : ?>
147
							<a title="<?php echo esc_attr( $tab['title'] ); ?>" aria-label="<?php echo esc_attr( $tab['title'] ); ?>" href="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ); ?>">
148
								<?php endif; ?>
149
150
								<span class="dashicons <?php echo sanitize_html_class( $tab['dashicon'] ); ?>"></span> <?php echo esc_attr( $tab['title'] ); ?>
151
								<?php if ( ! $active ) : ?>
152
							</a>
153
						<?php endif; ?>
154
155
						</li>
156
157
158
					<?php endforeach; ?>
159
				</ul>
160
			</div>
161
162
			<div id="give-customer-card-wrapper">
163
				<?php $callbacks[ $view ]( $customer ) ?>
164
			</div>
165
166
		<?php endif; ?>
167
168
	</div>
169
	<?php
170
171
}
172
173
174
/**
175
 * View a customer
176
 *
177
 * @since  1.0
178
 *
179
 * @param  $customer The Customer object being displayed
180
 *
181
 * @return void
182
 */
183
function give_customers_view( $customer ) {
184
185
	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
186
187
	?>
188
189
	<?php do_action( 'give_donor_card_top', $customer ); ?>
190
191
	<div id="donor-summary" class="info-wrapper customer-section postbox">
192
193
		<form id="edit-customer-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>">
194
195
			<div class="customer-info">
196
197
198
				<div class="donor-bio-header clearfix">
199
200
					<div class="avatar-wrap left" id="customer-avatar">
201
						<?php echo get_avatar( $customer->email ); ?>
202
					</div>
203
204
					<div class="customer-id" class="left">
205
						#<?php echo $customer->id; ?>
206
					</div>
207
					<div id="customer-name-wrap" class="left">
208
						<span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $customer->name ); ?>" placeholder="<?php _e( 'Donor Name', 'give' ); ?>" /></span>
209
						<span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span>
210
					</div>
211
					<p class="customer-since info-item">
212
						<?php _e( 'Donor since', 'give' ); ?>
213
						<?php echo date_i18n( get_option( 'date_format' ), strtotime( $customer->date_created ) ) ?>
214
					</p>
215
					<?php if ( current_user_can( $customer_edit_role ) ): ?>
216
						<a title="<?php _e( 'Edit Donor', 'give' ); ?>" href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php _e( 'Edit Donor', 'give' ); ?></a>
217
					<?php endif; ?>
218
				</div>
219
				<!-- /donor-bio-header -->
220
221
				<div class="customer-main-wrapper">
222
223
					<table class="widefat">
224
						<tbody>
225
						<tr>
226
							<td><label for="tablecell"><?php esc_attr_e( 'Email', 'give' ); ?></label>:</td>
227
							<td class="row-title">
228
								<span class="customer-name info-item edit-item"><input size="20" data-key="email" name="customerinfo[email]" type="text" value="<?php echo $customer->email; ?>" placeholder="<?php _e( 'Donor Email', 'give' ); ?>" /></span>
229
								<span class="customer-email info-item editable" data-key="email"><?php echo $customer->email; ?></span>
230
							</td>
231
						</tr>
232
						<tr class="alternate">
233
							<td><label for="tablecell"><?php esc_attr_e( 'User ID', 'give' ); ?></label>:</td>
234
							<td class="row-title">
235
								<span class="customer-user-id info-item edit-item">
236
									<?php
237
238
									$user_id   = $customer->user_id > 0 ? $customer->user_id : '';
239
									$data_atts = array(
240
										'key'     => 'user_login',
241
										'exclude' => $user_id
242
									);
243
									$user_args = array(
244
										'name'  => 'customerinfo[user_login]',
245
										'class' => 'give-user-dropdown',
246
										'data'  => $data_atts,
247
									);
248
249
									if ( ! empty( $user_id ) ) {
250
										$userdata           = get_userdata( $user_id );
251
										$user_args['value'] = $userdata->user_login;
252
									}
253
254
									echo Give()->html->ajax_user_search( $user_args );
255
									?>
256
									<input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?>" />
257
								</span>
258
			
259
								<span class="customer-user-id info-item editable">
260
									<?php if ( intval( $customer->user_id ) > 0 ) : ?>
261
										<span data-key="user_id"><?php echo $customer->user_id; ?></span>
262
									<?php else : ?>
263
										<span data-key="user_id"><?php _e( 'none', 'give' ); ?></span>
264
									<?php endif; ?>
265
									<?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) : ?>
266
										<span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php _e( 'Disconnects the current user ID from this customer record', 'give' ); ?>"><?php _e( 'Disconnect User', 'give' ); ?></a></span>
267
									<?php endif; ?>
268
								</span>
269
							</td>
270
						</tr>
271
						<?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?>
272
273
							<tr>
274
								<td><?php esc_attr_e( 'Address', 'give' ); ?>:</td>
275
								<td class="row-title">
276
277
									<div class="customer-address-wrapper">
278
279
										<?php
280
										$address  = get_user_meta( $customer->user_id, '_give_user_address', true );
281
										$defaults = array(
282
											'line1'   => '',
283
											'line2'   => '',
284
											'city'    => '',
285
											'state'   => '',
286
											'country' => '',
287
											'zip'     => ''
288
										);
289
290
										$address = wp_parse_args( $address, $defaults );
291
										?>
292
293
										<?php if ( ! empty( $address ) ) { ?>
294
											<span class="customer-address info-item editable">
295
												<span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span>
296
												<span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span>
297
												<span class="info-item" data-key="city"><?php echo $address['city']; ?></span>
298
												<span class="info-item" data-key="state"><?php echo $address['state']; ?></span>
299
												<span class="info-item" data-key="country"><?php echo $address['country']; ?></span>
300
												<span class="info-item" data-key="zip"><?php echo $address['zip']; ?></span>
301
											</span>
302
										<?php } ?>
303
										<span class="customer-address info-item edit-item">
304
											<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php _e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" />
305
											<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php _e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" />
306
											<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php _e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" />
307
											<select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item">
308
												<?php
309
310
												$selected_country = $address['country'];
311
312
												$countries = give_get_country_list();
313
												foreach ( $countries as $country_code => $country ) {
314
													echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>';
315
												}
316
												?>
317
											</select>
318
											<?php
319
											$selected_state = give_get_state();
320
											$states         = give_get_states( $selected_country );
321
322
											$selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state;
323
324
											if ( ! empty( $states ) ) : ?>
325
												<select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item">
326
													<?php
327
													foreach ( $states as $state_code => $state ) {
328
														echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
329
													}
330
													?>
331
												</select>
332
											<?php else : ?>
333
												<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php _e( 'State / Province', 'give' ); ?>" />
334
											<?php endif; ?>
335
											<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e( 'Postal', 'give' ); ?>" value="<?php echo $address['zip']; ?>" />
336
													</span>
337
338
									</div>
339
								</td>
340
							</tr>
341
						<?php endif; ?>
342
						</tbody>
343
					</table>
344
345
346
				</div>
347
348
349
			</div>
350
351
			<span id="customer-edit-actions" class="edit-item">
352
				<input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" />
353
				<?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?>
354
				<input type="hidden" name="give_action" value="edit-customer" />
355
				<input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php _e( 'Update Donor', 'give' ); ?>" />
356
				<a id="give-edit-customer-cancel" href="" class="delete"><?php _e( 'Cancel', 'give' ); ?></a>
357
			</span>
358
359
		</form>
360
	</div>
361
362
	<?php do_action( 'give_donor_before_stats', $customer ); ?>
363
364
	<div id="customer-stats-wrapper" class="customer-section postbox clear">
365
		<ul>
366
			<li>
367
				<a title="<?php _e( 'View All Donations', 'give' ); ?>" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>">
368
					<span class="dashicons dashicons-heart"></span>
369
					<?php
370
					//Completed Donations
371
					$completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count );
372
					echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer );
373
					?>
374
				</a>
375
			</li>
376
			<li>
377
				<span class="dashicons dashicons-chart-area"></span>
378
				<?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?>
379
			</li>
380
			<?php do_action( 'give_donor_stats_list', $customer ); ?>
381
		</ul>
382
	</div>
383
384
	<?php do_action( 'give_donor_before_tables_wrapper', $customer ); ?>
385
386
	<div id="customer-tables-wrapper" class="customer-section">
387
388
		<?php do_action( 'give_donor_before_tables', $customer ); ?>
389
390
		<h3><?php _e( 'Recent Donations', 'give' ); ?></h3>
391
		<?php
392
		$payment_ids = explode( ',', $customer->payment_ids );
393
		$payments    = give_get_payments( array( 'post__in' => $payment_ids ) );
394
		$payments    = array_slice( $payments, 0, 10 );
395
		?>
396
		<table class="wp-list-table widefat striped payments">
397
			<thead>
398
			<tr>
399
				<th><?php _e( 'ID', 'give' ); ?></th>
400
				<th><?php _e( 'Amount', 'give' ); ?></th>
401
				<th><?php _e( 'Date', 'give' ); ?></th>
402
				<th><?php _e( 'Status', 'give' ); ?></th>
403
				<th><?php _e( 'Actions', 'give' ); ?></th>
404
			</tr>
405
			</thead>
406
			<tbody>
407
			<?php if ( ! empty( $payments ) ) : ?>
408
				<?php foreach ( $payments as $payment ) : ?>
409
					<tr>
410
						<td><?php echo $payment->ID; ?></td>
411
						<td><?php echo give_payment_amount( $payment->ID ); ?></td>
412
						<td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $payment->post_date ) ); ?></td>
413
						<td><?php echo give_get_payment_status( $payment, true ); ?></td>
414
						<td>
415
							<a title="<?php _e( 'View Details for Donation', 'give' );
416
							echo ' ' . $payment->ID; ?>" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ); ?>">
417
								<?php _e( 'View Details', 'give' ); ?>
418
							</a>
419
							<?php do_action( 'give_donor_recent_purchases_actions', $customer, $payment ); ?>
420
						</td>
421
					</tr>
422
				<?php endforeach; ?>
423
			<?php else: ?>
424
				<tr>
425
					<td colspan="5"><?php _e( 'No Donations Found', 'give' ); ?></td>
426
				</tr>
427
			<?php endif; ?>
428
			</tbody>
429
		</table>
430
431
		<h3><?php _e( 'Completed Donations', 'give' ); ?></h3>
432
		<?php
433
		$donations = give_get_users_completed_donations( $customer->email );
434
		?>
435
		<table class="wp-list-table widefat striped downloads">
436
			<thead>
437
			<tr>
438
				<th><?php echo give_get_forms_label_singular(); ?></th>
439
				<th width="120px"><?php _e( 'Actions', 'give' ); ?></th>
440
			</tr>
441
			</thead>
442
			<tbody>
443
			<?php if ( ! empty( $donations ) ) : ?>
444
				<?php foreach ( $donations as $donation ) : ?>
0 ignored issues
show
Bug introduced by
The expression $donations of type boolean|object is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
445
					<tr>
446
						<td><?php echo $donation->post_title; ?></td>
447
						<td>
448
							<a title="<?php echo esc_attr( sprintf( __( 'View %s', 'give' ), $donation->post_title ) ); ?>" href="<?php echo esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ); ?>">
449
								<?php printf( __( 'View %s', 'give' ), give_get_forms_label_singular() ); ?>
450
							</a>
451
						</td>
452
					</tr>
453
				<?php endforeach; ?>
454
			<?php else: ?>
455
				<tr>
456
					<td colspan="2"><?php _e( 'No Completed Donations Found', 'give' ); ?></td>
457
				</tr>
458
			<?php endif; ?>
459
			</tbody>
460
		</table>
461
462
		<?php do_action( 'give_donor_after_tables', $customer ); ?>
463
464
	</div>
465
466
	<?php do_action( 'give_donor_card_bottom', $customer ); ?>
467
468
	<?php
469
}
470
471
/**
472
 * View the notes of a customer
473
 *
474
 * @since  1.0
475
 *
476
 * @param  $customer The Donor being displayed
477
 *
478
 * @return void
479
 */
480
function give_customer_notes_view( $customer ) {
481
482
	$paged          = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1;
483
	$paged          = absint( $paged );
484
	$note_count     = $customer->get_notes_count();
485
	$per_page       = apply_filters( 'give_customer_notes_per_page', 20 );
486
	$total_pages    = ceil( $note_count / $per_page );
487
	$customer_notes = $customer->get_notes( $per_page, $paged );
488
	?>
489
490
	<div id="customer-notes-wrapper">
491
		<div class="customer-notes-header">
492
			<?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span>
493
		</div>
494
		<h3><?php _e( 'Notes', 'give' ); ?></h3>
495
496
		<?php if ( 1 == $paged ) : ?>
497
			<div style="display: block; margin-bottom: 55px;">
498
				<form id="give-add-customer-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $customer->id ); ?>">
499
					<textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea>
500
					<br />
501
					<input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" />
502
					<input type="hidden" name="give_action" value="add-customer-note" />
503
					<?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?>
504
					<input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" />
505
				</form>
506
			</div>
507
		<?php endif; ?>
508
509
		<?php
510
		$pagination_args = array(
511
			'base'     => '%_%',
512
			'format'   => '?paged=%#%',
513
			'total'    => $total_pages,
514
			'current'  => $paged,
515
			'show_all' => true
516
		);
517
518
		echo paginate_links( $pagination_args );
519
		?>
520
521
		<div id="give-customer-notes" class="postbox">
522
			<?php if ( count( $customer_notes ) > 0 ) : ?>
523
				<?php foreach ( $customer_notes as $key => $note ) : ?>
524
					<div class="customer-note-wrapper dashboard-comment-wrap comment-item">
525
					<span class="note-content-wrap">
526
						<?php echo stripslashes( $note ); ?>
527
					</span>
528
					</div>
529
				<?php endforeach; ?>
530
			<?php else: ?>
531
				<div class="give-no-customer-notes">
532
					<?php _e( 'No Donor Notes', 'give' ); ?>
533
				</div>
534
			<?php endif; ?>
535
		</div>
536
537
		<?php echo paginate_links( $pagination_args ); ?>
538
539
	</div>
540
541
	<?php
542
}
543
544
function give_customers_delete_view( $customer ) {
545
546
	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
547
548
	?>
549
550
	<?php do_action( 'give_customer_delete_top', $customer ); ?>
551
552
	<div class="info-wrapper customer-section">
553
554
		<form id="delete-customer" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id ); ?>">
555
556
			<div class="customer-notes-header">
557
				<?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span>
558
			</div>
559
560
561
			<div class="customer-info delete-customer">
562
563
				<span class="delete-customer-options">
564
					<p>
565
						<?php echo Give()->html->checkbox( array( 'name' => 'give-customer-delete-confirm' ) ); ?>
566
						<label for="give-customer-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label>
567
					</p>
568
569
					<p>
570
						<?php echo Give()->html->checkbox( array(
571
							'name'    => 'give-customer-delete-records',
572
							'options' => array( 'disabled' => true )
573
						) ); ?>
574
						<label for="give-customer-delete-records"><?php _e( 'Delete all associated payments and records?', 'give' ); ?></label>
575
					</p>
576
577
					<?php do_action( 'give_customer_delete_inputs', $customer ); ?>
578
				</span>
579
580
				<span id="customer-edit-actions">
581
					<input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" />
582
					<?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?>
583
					<input type="hidden" name="give_action" value="delete-customer" />
584
					<input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php _e( 'Delete Donor', 'give' ); ?>" />
585
					<a id="give-delete-customer-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>" class="delete"><?php _e( 'Cancel', 'give' ); ?></a>
586
				</span>
587
588
			</div>
589
590
		</form>
591
	</div>
592
593
	<?php
594
595
	do_action( 'give_customer_delete_bottom', $customer );
596
}
597