actions.php
3 years ago
class-payments-table.php
3 years ago
payments-history.php
4 years ago
view-payment-details.php
3 years ago
view-payment-details.php
993 lines
| 1 | <?php |
| 2 | /** |
| 3 | * View Donation Details |
| 4 | * |
| 5 | * @package Give |
| 6 | * @subpackage Admin/Payments |
| 7 | * @copyright Copyright (c) 2016, GiveWP |
| 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 | * @since 1.0 |
| 10 | */ |
| 11 | |
| 12 | // Exit if accessed directly. |
| 13 | use Give\Donations\ValueObjects\DonationMetaKeys; |
| 14 | |
| 15 | if (!defined('ABSPATH')) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | if (!current_user_can('view_give_payments')) { |
| 20 | wp_die( |
| 21 | __('Sorry, you are not allowed to access this page.', 'give'), |
| 22 | __('Error', 'give'), |
| 23 | array( |
| 24 | 'response' => 403, |
| 25 | ) |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * View donation details page |
| 31 | * |
| 32 | * @since 1.0 |
| 33 | * @return void |
| 34 | */ |
| 35 | if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
| 36 | wp_die( __( 'Donation ID not supplied. Please try again.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) ); |
| 37 | } |
| 38 | |
| 39 | // Setup the variables |
| 40 | $payment_id = absint( $_GET['id'] ); |
| 41 | $payment = new Give_Payment( $payment_id ); |
| 42 | |
| 43 | // Sanity check... fail if donation ID is invalid |
| 44 | $payment_exists = $payment->ID; |
| 45 | if ( empty( $payment_exists ) ) { |
| 46 | wp_die( __( 'The specified ID does not belong to a donation. Please try again.', 'give' ), __( 'Error', 'give' ), array( 'response' => 400 ) ); |
| 47 | } |
| 48 | |
| 49 | $number = $payment->number; |
| 50 | $payment_meta = $payment->get_meta(); |
| 51 | |
| 52 | $company_name = ! empty( $payment_meta['_give_donation_company'] ) ? esc_attr( $payment_meta['_give_donation_company'] ) : ''; |
| 53 | $transaction_id = esc_attr( $payment->transaction_id ); |
| 54 | $user_id = $payment->user_id; |
| 55 | $donor_id = $payment->customer_id; |
| 56 | $payment_date = strtotime( $payment->date ); |
| 57 | $user_info = give_get_payment_meta_user_info( $payment_id ); |
| 58 | $address = $payment->address; |
| 59 | $currency_code = $payment->currency; |
| 60 | $gateway = $payment->gateway; |
| 61 | $currency_code = $payment->currency; |
| 62 | $payment_mode = $payment->mode; |
| 63 | $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
| 64 | |
| 65 | ?> |
| 66 | <div class="wrap give-wrap"> |
| 67 | |
| 68 | <h1 id="transaction-details-heading" class="wp-heading-inline"> |
| 69 | <?php |
| 70 | printf( |
| 71 | /* translators: %s: donation number */ |
| 72 | esc_html__( 'Donation %s', 'give' ), |
| 73 | $number |
| 74 | ); |
| 75 | if ( $payment_mode == 'test' ) { |
| 76 | echo Give()->tooltips->render_span( |
| 77 | array( |
| 78 | 'label' => __( 'This donation was made in test mode.', 'give' ), |
| 79 | 'tag_content' => __( 'Test Donation', 'give' ), |
| 80 | 'position' => 'right', |
| 81 | 'attributes' => array( |
| 82 | 'id' => 'test-payment-label', |
| 83 | 'class' => 'give-item-label give-item-label-orange', |
| 84 | ), |
| 85 | ) |
| 86 | ); |
| 87 | } |
| 88 | ?> |
| 89 | </h1> |
| 90 | |
| 91 | <?php |
| 92 | /** |
| 93 | * Fires in donation details page, before the page content and after the H1 title output. |
| 94 | * |
| 95 | * @since 1.0 |
| 96 | * |
| 97 | * @param int $payment_id Payment id. |
| 98 | */ |
| 99 | do_action( 'give_view_donation_details_before', $payment_id ); |
| 100 | ?> |
| 101 | |
| 102 | <hr class="wp-header-end"> |
| 103 | |
| 104 | <form id="give-edit-order-form" method="post"> |
| 105 | <?php |
| 106 | /** |
| 107 | * Fires in donation details page, in the form before the order details. |
| 108 | * |
| 109 | * @since 1.0 |
| 110 | * |
| 111 | * @param int $payment_id Payment id. |
| 112 | */ |
| 113 | do_action( 'give_view_donation_details_form_top', $payment_id ); |
| 114 | ?> |
| 115 | <div id="poststuff" class="give-clearfix"> |
| 116 | <div id="give-dashboard-widgets-wrap"> |
| 117 | <div id="post-body" class="metabox-holder columns-2"> |
| 118 | <div id="postbox-container-1" class="postbox-container"> |
| 119 | <div id="side-sortables" class="meta-box-sortables ui-sortable"> |
| 120 | |
| 121 | <?php |
| 122 | /** |
| 123 | * Fires in donation details page, before the sidebar. |
| 124 | * |
| 125 | * @since 1.0 |
| 126 | * |
| 127 | * @param int $payment_id Payment id. |
| 128 | */ |
| 129 | do_action( 'give_view_donation_details_sidebar_before', $payment_id ); |
| 130 | ?> |
| 131 | |
| 132 | <div id="give-order-update" class="postbox give-order-data"> |
| 133 | |
| 134 | <div class="give-order-top"> |
| 135 | <h3 class="hndle"><?php _e( 'Update Donation', 'give' ); ?></h3> |
| 136 | |
| 137 | <?php |
| 138 | if ( current_user_can( 'view_give_payments' ) ) { |
| 139 | echo sprintf( |
| 140 | '<span class="delete-donation" id="delete-donation-%d"><a class="delete-single-donation delete-donation-button dashicons dashicons-trash" href="%s" aria-label="%s"></a></span>', |
| 141 | $payment_id, |
| 142 | esc_url( |
| 143 | wp_nonce_url( |
| 144 | add_query_arg( |
| 145 | array( |
| 146 | 'give-action' => 'delete_payment', |
| 147 | 'purchase_id' => $payment_id, |
| 148 | ), |
| 149 | $base_url |
| 150 | ), |
| 151 | 'give_donation_nonce' |
| 152 | ) |
| 153 | ), |
| 154 | sprintf( __( 'Delete Donation %s', 'give' ), $payment_id ) |
| 155 | ); |
| 156 | } |
| 157 | ?> |
| 158 | </div> |
| 159 | |
| 160 | <div class="inside"> |
| 161 | <div class="give-admin-box"> |
| 162 | |
| 163 | <?php |
| 164 | /** |
| 165 | * Fires in donation details page, before the sidebar update-payment metabox. |
| 166 | * |
| 167 | * @since 1.0 |
| 168 | * |
| 169 | * @param int $payment_id Payment id. |
| 170 | */ |
| 171 | do_action( 'give_view_donation_details_totals_before', $payment_id ); |
| 172 | ?> |
| 173 | |
| 174 | <div class="give-admin-box-inside"> |
| 175 | <p> |
| 176 | <label for="give-payment-status" class="strong"><?php _e( 'Status:', 'give' ); ?></label> |
| 177 | <select id="give-payment-status" name="give-payment-status" class="medium-text"> |
| 178 | <?php foreach ( give_get_payment_statuses() as $key => $status ) : ?> |
| 179 | <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $payment->status, $key, true ); ?>><?php echo esc_html( $status ); ?></option> |
| 180 | <?php endforeach; ?> |
| 181 | </select> |
| 182 | <span class="give-donation-status status-<?php echo sanitize_title( $payment->status ); ?>"><span class="give-donation-status-icon"></span></span> |
| 183 | </p> |
| 184 | </div> |
| 185 | |
| 186 | <div class="give-admin-box-inside"> |
| 187 | <?php $date_format = give_date_format(); ?> |
| 188 | <p> |
| 189 | <label for="give-payment-date" class="strong"><?php _e( 'Date:', 'give' ); ?></label> |
| 190 | <input type="text" id="give-payment-date" name="give-payment-date" data-standard-date="<?php echo esc_attr( date( 'Y-m-d', $payment_date ) ); ?>" value="<?php echo esc_attr( date_i18n( $date_format, $payment_date ) ); ?>" autocomplete="off" class="medium-text give_datepicker" placeholder="<?php _e( 'Date', 'give' ); ?>"/> |
| 191 | </p> |
| 192 | </div> |
| 193 | |
| 194 | <div class="give-admin-box-inside"> |
| 195 | <p> |
| 196 | <label for="give-payment-time-hour" class="strong"><?php _e( 'Time:', 'give' ); ?></label> |
| 197 | <input type="number" step="1" max="24" id="give-payment-time-hour" name="give-payment-time-hour" value="<?php echo esc_attr( date_i18n( 'H', $payment_date ) ); ?>" class="small-text give-payment-time-hour"/> : |
| 198 | <input type="number" step="1" max="59" id="give-payment-time-min" name="give-payment-time-min" value="<?php echo esc_attr( date( 'i', $payment_date ) ); ?>" class="small-text give-payment-time-min"/> |
| 199 | </p> |
| 200 | </div> |
| 201 | |
| 202 | <?php |
| 203 | /** |
| 204 | * Fires in donation details page, in the sidebar update-payment metabox. |
| 205 | * |
| 206 | * Allows you to add new inner items. |
| 207 | * |
| 208 | * @since 1.0 |
| 209 | * |
| 210 | * @param int $payment_id Payment id. |
| 211 | */ |
| 212 | do_action( 'give_view_donation_details_update_inner', $payment_id ); |
| 213 | ?> |
| 214 | |
| 215 | <div class="give-order-payment give-admin-box-inside"> |
| 216 | <p> |
| 217 | <label for="give-payment-total" class="strong"><?php _e( 'Total Donation:', 'give' ); ?></label> |
| 218 | <?php echo give_currency_symbol( $payment->currency ); ?> |
| 219 | <input id="give-payment-total" name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr( give_format_decimal( array( 'donation_id' => $payment_id ) ) ); ?>"/> |
| 220 | </p> |
| 221 | </div> |
| 222 | |
| 223 | <?php |
| 224 | /** |
| 225 | * Fires in donation details page, after the sidebar update-donation metabox. |
| 226 | * |
| 227 | * @since 1.0 |
| 228 | * |
| 229 | * @param int $payment_id Payment id. |
| 230 | */ |
| 231 | do_action( 'give_view_donation_details_totals_after', $payment_id ); |
| 232 | ?> |
| 233 | |
| 234 | </div> |
| 235 | <!-- /.give-admin-box --> |
| 236 | |
| 237 | </div> |
| 238 | <!-- /.inside --> |
| 239 | |
| 240 | <div class="give-order-update-box give-admin-box"> |
| 241 | <?php |
| 242 | /** |
| 243 | * Fires in donation details page, before the sidebar update-payment metabox actions buttons. |
| 244 | * |
| 245 | * @since 1.0 |
| 246 | * |
| 247 | * @param int $payment_id Payment id. |
| 248 | */ |
| 249 | do_action( 'give_view_donation_details_update_before', $payment_id ); |
| 250 | ?> |
| 251 | |
| 252 | <div id="major-publishing-actions"> |
| 253 | <div id="publishing-action"> |
| 254 | <input type="submit" class="button button-primary right" value="<?php esc_attr_e( 'Save Donation', 'give' ); ?>"/> |
| 255 | <?php |
| 256 | if ( give_is_payment_complete( $payment_id ) ) { |
| 257 | $url = add_query_arg( |
| 258 | array( |
| 259 | 'give-action' => 'email_links', |
| 260 | 'purchase_id' => $payment_id, |
| 261 | ), |
| 262 | admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ) |
| 263 | ); |
| 264 | |
| 265 | echo sprintf( |
| 266 | '<a href="%1$s" id="give-resend-receipt" class="button-secondary right">%2$s</a>', |
| 267 | esc_url( $url ), |
| 268 | esc_html__( 'Resend Receipt', 'give' ) |
| 269 | ); |
| 270 | } |
| 271 | ?> |
| 272 | </div> |
| 273 | <div class="clear"></div> |
| 274 | </div> |
| 275 | <?php |
| 276 | /** |
| 277 | * Fires in donation details page, after the sidebar update-payment metabox actions buttons. |
| 278 | * |
| 279 | * @since 1.0 |
| 280 | * |
| 281 | * @param int $payment_id Payment id. |
| 282 | */ |
| 283 | do_action( 'give_view_donation_details_update_after', $payment_id ); |
| 284 | ?> |
| 285 | |
| 286 | </div> |
| 287 | <!-- /.give-order-update-box --> |
| 288 | |
| 289 | </div> |
| 290 | <!-- /#give-order-data --> |
| 291 | |
| 292 | <div id="give-order-details" class="postbox give-order-data"> |
| 293 | |
| 294 | <h3 class="hndle"><?php _e( 'Donation Meta', 'give' ); ?></h3> |
| 295 | |
| 296 | <div class="inside"> |
| 297 | <div class="give-admin-box"> |
| 298 | |
| 299 | <?php |
| 300 | /** |
| 301 | * Fires in donation details page, before the donation-meta metabox. |
| 302 | * |
| 303 | * @since 1.0 |
| 304 | * |
| 305 | * @param int $payment_id Payment id. |
| 306 | */ |
| 307 | do_action( 'give_view_donation_details_payment_meta_before', $payment_id ); |
| 308 | |
| 309 | $gateway = give_get_payment_gateway( $payment_id ); |
| 310 | if ( $gateway ) : |
| 311 | ?> |
| 312 | <div class="give-order-gateway give-admin-box-inside"> |
| 313 | <p> |
| 314 | <strong><?php _e( 'Gateway:', 'give' ); ?></strong> |
| 315 | <?php echo give_get_gateway_admin_label( $gateway ); ?> |
| 316 | </p> |
| 317 | </div> |
| 318 | <?php endif; ?> |
| 319 | |
| 320 | <div class="give-order-payment-key give-admin-box-inside"> |
| 321 | <p> |
| 322 | <strong><?php _e( 'Key:', 'give' ); ?></strong> |
| 323 | <?php echo give_get_payment_key( $payment_id ); ?> |
| 324 | </p> |
| 325 | </div> |
| 326 | |
| 327 | <div class="give-order-ip give-admin-box-inside"> |
| 328 | <p> |
| 329 | <strong><?php _e( 'IP:', 'give' ); ?></strong> |
| 330 | <?php echo esc_html( give_get_payment_user_ip( $payment_id ) ); ?> |
| 331 | </p> |
| 332 | </div> |
| 333 | |
| 334 | <?php |
| 335 | // Display the transaction ID present. |
| 336 | // The transaction ID is the charge ID from the gateway. |
| 337 | // For instance, stripe "ch_BzvwYCchqOy5Nt". |
| 338 | if ( $transaction_id != $payment_id ) : |
| 339 | ?> |
| 340 | <div class="give-order-tx-id give-admin-box-inside"> |
| 341 | <p> |
| 342 | <strong><?php _e( 'Transaction ID:', 'give' ); ?> <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php echo sprintf( esc_attr__( 'The transaction ID within %s.', 'give' ), $gateway ); ?>"></span></strong> |
| 343 | <?php echo apply_filters( "give_payment_details_transaction_id-{$gateway}", $transaction_id, $payment_id ); ?> |
| 344 | </p> |
| 345 | </div> |
| 346 | <?php endif; ?> |
| 347 | |
| 348 | <?php |
| 349 | /** |
| 350 | * Fires in donation details page, after the donation-meta metabox. |
| 351 | * |
| 352 | * @since 1.0 |
| 353 | * |
| 354 | * @param int $payment_id Payment id. |
| 355 | */ |
| 356 | do_action( 'give_view_donation_details_payment_meta_after', $payment_id ); |
| 357 | ?> |
| 358 | |
| 359 | <div class="give-admin-box-inside"> |
| 360 | <p><?php $purchase_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( give_get_payment_donor_id( $payment_id ) ) ); ?> |
| 361 | <a href="<?php echo $purchase_url; ?>"><?php _e( 'View all donations for this donor »', 'give' ); ?></a> |
| 362 | </p> |
| 363 | </div> |
| 364 | |
| 365 | </div> |
| 366 | <!-- /.column-container --> |
| 367 | |
| 368 | </div> |
| 369 | <!-- /.inside --> |
| 370 | |
| 371 | </div> |
| 372 | <!-- /#give-order-data --> |
| 373 | |
| 374 | <?php |
| 375 | /** |
| 376 | * Fires in donation details page, after the sidebar. |
| 377 | * |
| 378 | * @since 1.0 |
| 379 | * |
| 380 | * @param int $payment_id Payment id. |
| 381 | */ |
| 382 | do_action( 'give_view_donation_details_sidebar_after', $payment_id ); |
| 383 | ?> |
| 384 | |
| 385 | </div> |
| 386 | <!-- /#side-sortables --> |
| 387 | </div> |
| 388 | <!-- /#postbox-container-1 --> |
| 389 | |
| 390 | <div id="postbox-container-2" class="postbox-container"> |
| 391 | |
| 392 | <div id="normal-sortables" class="meta-box-sortables ui-sortable"> |
| 393 | |
| 394 | <?php |
| 395 | /** |
| 396 | * Fires in donation details page, before the main area. |
| 397 | * |
| 398 | * @since 1.0 |
| 399 | * |
| 400 | * @param int $payment_id Payment id. |
| 401 | */ |
| 402 | do_action( 'give_view_donation_details_main_before', $payment_id ); |
| 403 | ?> |
| 404 | |
| 405 | <?php $column_count = 'columns-3'; ?> |
| 406 | <div id="give-donation-overview" class="postbox <?php echo $column_count; ?>"> |
| 407 | <h3 class="hndle"><?php _e( 'Donation Information', 'give' ); ?></h3> |
| 408 | |
| 409 | <div class="inside"> |
| 410 | |
| 411 | <div class="column-container"> |
| 412 | <div class="column"> |
| 413 | <p> |
| 414 | <strong><?php _e( 'Donation Form ID:', 'give' ); ?></strong><br> |
| 415 | <?php |
| 416 | if ( $payment->form_id ) : |
| 417 | printf( |
| 418 | '<a href="%1$s">%2$s</a>', |
| 419 | admin_url( 'post.php?action=edit&post=' . $payment->form_id ), |
| 420 | $payment->form_id |
| 421 | ); |
| 422 | endif; |
| 423 | ?> |
| 424 | </p> |
| 425 | <p> |
| 426 | <strong><?php esc_html_e( 'Donation Form Title:', 'give' ); ?></strong><br> |
| 427 | <?php |
| 428 | echo Give()->html->forms_dropdown( |
| 429 | array( |
| 430 | 'selected' => $payment->form_id, |
| 431 | 'name' => 'give-payment-form-select', |
| 432 | 'id' => 'give-payment-form-select', |
| 433 | 'chosen' => true, |
| 434 | 'placeholder' => '', |
| 435 | ) |
| 436 | ); |
| 437 | ?> |
| 438 | </p> |
| 439 | </div> |
| 440 | <div class="column"> |
| 441 | <p> |
| 442 | <strong><?php _e( 'Donation Date:', 'give' ); ?></strong><br> |
| 443 | <?php echo date_i18n( give_date_format(), $payment_date ); ?> |
| 444 | </p> |
| 445 | <p> |
| 446 | <strong><?php _e( 'Donation Level:', 'give' ); ?></strong><br> |
| 447 | <span class="give-donation-level"> |
| 448 | <?php |
| 449 | $var_prices = give_has_variable_prices( $payment->form_id ); |
| 450 | if ( empty( $var_prices ) ) { |
| 451 | _e( 'n/a', 'give' ); |
| 452 | } else { |
| 453 | $prices_atts = array(); |
| 454 | if ( $variable_prices = give_get_variable_prices( $payment->form_id ) ) { |
| 455 | foreach ( $variable_prices as $variable_price ) { |
| 456 | $prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ); |
| 457 | } |
| 458 | } |
| 459 | // Variable price dropdown options. |
| 460 | $variable_price_dropdown_option = array( |
| 461 | 'id' => $payment->form_id, |
| 462 | 'name' => 'give-variable-price', |
| 463 | 'chosen' => true, |
| 464 | 'show_option_all' => '', |
| 465 | 'show_option_none' => ( '' === $payment->price_id ? __( 'None', 'give' ) : '' ), |
| 466 | 'select_atts' => 'data-prices=' . esc_attr( wp_json_encode( $prices_atts ) ), |
| 467 | 'selected' => $payment->price_id, |
| 468 | ); |
| 469 | // Render variable prices select tag html. |
| 470 | give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
| 471 | } |
| 472 | ?> |
| 473 | </span> |
| 474 | </p> |
| 475 | </div> |
| 476 | <div class="column"> |
| 477 | <p> |
| 478 | <strong><?php esc_html_e( 'Total Donation:', 'give' ); ?></strong><br> |
| 479 | <?php echo give_donation_amount( $payment, true ); ?> |
| 480 | </p> |
| 481 | |
| 482 | <?php if ( give_is_anonymous_donation_field_enabled( $payment->form_id ) ) : ?> |
| 483 | <div> |
| 484 | <strong><?php esc_html_e( 'Anonymous Donation:', 'give' ); ?></strong> |
| 485 | <ul class="give-radio-inline"> |
| 486 | <li> |
| 487 | <label> |
| 488 | <input |
| 489 | name="give_anonymous_donation" |
| 490 | value="1" |
| 491 | type="radio" |
| 492 | <?php checked( 1, absint( give_get_meta( $payment_id, '_give_anonymous_donation', true ) ) ); ?> |
| 493 | ><?php _e( 'Yes', 'give' ); ?> |
| 494 | </label> |
| 495 | </li> |
| 496 | <li> |
| 497 | <label> |
| 498 | <input |
| 499 | name="give_anonymous_donation" |
| 500 | value="0" |
| 501 | type="radio" |
| 502 | <?php checked( 0, absint( give_get_meta( $payment_id, '_give_anonymous_donation', true ) ) ); ?> |
| 503 | ><?php _e( 'No', 'give' ); ?> |
| 504 | </label> |
| 505 | </li> |
| 506 | </ul> |
| 507 | </div> |
| 508 | <?php endif; ?> |
| 509 | <p> |
| 510 | <?php |
| 511 | /** |
| 512 | * Fires in donation details page, in the donation-information metabox, before the head elements. |
| 513 | * |
| 514 | * Allows you to add new TH elements at the beginning. |
| 515 | * |
| 516 | * @since 1.0 |
| 517 | * |
| 518 | * @param int $payment_id Payment id. |
| 519 | */ |
| 520 | do_action( 'give_donation_details_thead_before', $payment_id ); |
| 521 | |
| 522 | |
| 523 | /** |
| 524 | * Fires in donation details page, in the donation-information metabox, after the head elements. |
| 525 | * |
| 526 | * Allows you to add new TH elements at the end. |
| 527 | * |
| 528 | * @since 1.0 |
| 529 | * |
| 530 | * @param int $payment_id Payment id. |
| 531 | */ |
| 532 | do_action( 'give_donation_details_thead_after', $payment_id ); |
| 533 | |
| 534 | /** |
| 535 | * Fires in donation details page, in the donation-information metabox, before the body elements. |
| 536 | * |
| 537 | * Allows you to add new TD elements at the beginning. |
| 538 | * |
| 539 | * @since 1.0 |
| 540 | * |
| 541 | * @param int $payment_id Payment id. |
| 542 | */ |
| 543 | do_action( 'give_donation_details_tbody_before', $payment_id ); |
| 544 | |
| 545 | /** |
| 546 | * Fires in donation details page, in the donation-information metabox, after the body elements. |
| 547 | * |
| 548 | * Allows you to add new TD elements at the end. |
| 549 | * |
| 550 | * @since 1.0 |
| 551 | * |
| 552 | * @param int $payment_id Payment id. |
| 553 | */ |
| 554 | do_action( 'give_donation_details_tbody_after', $payment_id ); |
| 555 | ?> |
| 556 | </p> |
| 557 | </div> |
| 558 | </div> |
| 559 | |
| 560 | </div> |
| 561 | <!-- /.inside --> |
| 562 | |
| 563 | </div> |
| 564 | <!-- /#give-donation-overview --> |
| 565 | |
| 566 | <?php |
| 567 | /** |
| 568 | * Fires on the donation details page. |
| 569 | * |
| 570 | * @since 1.0 |
| 571 | * |
| 572 | * @param int $payment_id Payment id. |
| 573 | */ |
| 574 | do_action( 'give_view_donation_details_donor_detail_before', $payment_id ); |
| 575 | ?> |
| 576 | |
| 577 | <div id="give-donor-details" class="postbox"> |
| 578 | <h3 class="hndle"><?php _e( 'Donor Details', 'give' ); ?></h3> |
| 579 | |
| 580 | <div class="inside"> |
| 581 | |
| 582 | <?php $donor = new Give_Donor( $donor_id ); ?> |
| 583 | |
| 584 | <div class="column-container donor-info"> |
| 585 | <div class="column"> |
| 586 | <p> |
| 587 | <strong><?php esc_html_e( 'Donor ID:', 'give' ); ?></strong><br> |
| 588 | <?php |
| 589 | if ( ! empty( $donor->id ) ) { |
| 590 | printf( |
| 591 | '<a href="%1$s">%2$s</a>', |
| 592 | esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ), |
| 593 | intval( $donor->id ) |
| 594 | ); |
| 595 | } |
| 596 | ?> |
| 597 | <span>(<a href="#new" class="give-payment-new-donor"><?php esc_html_e( 'Create New Donor', 'give' ); ?></a>)</span> |
| 598 | </p> |
| 599 | <p> |
| 600 | <strong><?php esc_html_e( 'Donor Since:', 'give' ); ?></strong><br> |
| 601 | <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ); ?> |
| 602 | </p> |
| 603 | </div> |
| 604 | <div class="column"> |
| 605 | <p> |
| 606 | <strong><?php esc_html_e( 'Donor Name:', 'give' ); ?></strong><br> |
| 607 | <?php |
| 608 | $donor_billing_name = give_get_donor_name_by( $payment_id, 'donation' ); |
| 609 | $donor_name = give_get_donor_name_by( $donor_id, 'donor' ); |
| 610 | |
| 611 | // Check whether the donor name and WP_User name is same or not. |
| 612 | if ( $donor_billing_name !== $donor_name ) { |
| 613 | // Donors can be deleted by the user, but we can show the donor billing name from donation details. |
| 614 | if ( empty( $donor_name ) ) { |
| 615 | echo esc_html( $donor_billing_name ); |
| 616 | } else { |
| 617 | echo sprintf( |
| 618 | '%1$s (<a href="%2$s" target="_blank">%3$s</a>)', |
| 619 | esc_html( $donor_billing_name ), |
| 620 | esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}" ) ), |
| 621 | esc_html( $donor_name ) |
| 622 | ); |
| 623 | } |
| 624 | } else { |
| 625 | echo esc_html( $donor_name ); |
| 626 | } |
| 627 | ?> |
| 628 | </p> |
| 629 | <p> |
| 630 | <strong><?php esc_html_e( 'Donor Email:', 'give' ); ?></strong><br> |
| 631 | <?php |
| 632 | // Show Donor donation email first and Primary email on parenthesis if not match both email. |
| 633 | echo ( empty( $donor->email ) || hash_equals( $donor->email, $payment->email ) ) |
| 634 | ? $payment->email |
| 635 | : sprintf( |
| 636 | '%1$s (<a href="%2$s" target="_blank">%3$s</a>)', |
| 637 | $payment->email, |
| 638 | esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}" ) ), |
| 639 | $donor->email |
| 640 | ); |
| 641 | ?> |
| 642 | </p> |
| 643 | </div> |
| 644 | <div class="column"> |
| 645 | <p> |
| 646 | <strong><?php esc_html_e( 'Change Donor:', 'give' ); ?></strong><br> |
| 647 | <?php |
| 648 | echo Give()->html->donor_dropdown( |
| 649 | array( |
| 650 | 'selected' => $donor->id, |
| 651 | 'name' => 'donor-id', |
| 652 | ) |
| 653 | ); |
| 654 | ?> |
| 655 | </p> |
| 656 | <p> |
| 657 | <?php |
| 658 | if ( ! empty( $company_name ) ) { |
| 659 | ?> |
| 660 | <strong><?php esc_html_e( 'Company Name:', 'give' ); ?></strong><br> |
| 661 | <?php |
| 662 | echo $company_name; |
| 663 | } |
| 664 | ?> |
| 665 | </p> |
| 666 | </div> |
| 667 | </div> |
| 668 | |
| 669 | <div class="column-container new-donor" style="display: none"> |
| 670 | <div class="column"> |
| 671 | <p> |
| 672 | <label for="give-new-donor-first-name"><?php _e( 'New Donor First Name:', 'give' ); ?></label> |
| 673 | <input id="give-new-donor-first-name" type="text" name="give-new-donor-first-name" value="" class="medium-text"/> |
| 674 | </p> |
| 675 | </div> |
| 676 | <div class="column"> |
| 677 | <p> |
| 678 | <label for="give-new-donor-last-name"><?php _e( 'New Donor Last Name:', 'give' ); ?></label> |
| 679 | <input id="give-new-donor-last-name" type="text" name="give-new-donor-last-name" value="" class="medium-text"/> |
| 680 | </p> |
| 681 | </div> |
| 682 | <div class="column"> |
| 683 | <p> |
| 684 | <label for="give-new-donor-email"><?php _e( 'New Donor Email:', 'give' ); ?></label> |
| 685 | <input id="give-new-donor-email" type="email" name="give-new-donor-email" value="" class="medium-text"/> |
| 686 | </p> |
| 687 | </div> |
| 688 | <div class="column"> |
| 689 | <p> |
| 690 | <input type="hidden" name="give-current-donor" value="<?php echo $donor->id; ?>"/> |
| 691 | <input type="hidden" id="give-new-donor" name="give-new-donor" value="0"/> |
| 692 | <a href="#cancel" class="give-payment-new-donor-cancel give-delete"><?php _e( 'Cancel', 'give' ); ?></a> |
| 693 | <br> |
| 694 | <em><?php _e( 'Click "Save Donation" to create new donor.', 'give' ); ?></em> |
| 695 | </p> |
| 696 | </div> |
| 697 | </div> |
| 698 | <?php |
| 699 | /** |
| 700 | * Fires on the donation details page, in the donor-details metabox. |
| 701 | * |
| 702 | * The hook is left here for backwards compatibility. |
| 703 | * |
| 704 | * @since 1.7 |
| 705 | * |
| 706 | * @param array $payment_meta Payment meta. |
| 707 | * @param array $user_info User information. |
| 708 | */ |
| 709 | do_action( 'give_payment_personal_details_list', $payment_meta, $user_info ); |
| 710 | |
| 711 | /** |
| 712 | * Fires on the donation details page, in the donor-details metabox. |
| 713 | * |
| 714 | * @since 1.7 |
| 715 | * |
| 716 | * @param int $payment_id Payment id. |
| 717 | */ |
| 718 | do_action( 'give_payment_view_details', $payment_id ); |
| 719 | ?> |
| 720 | |
| 721 | </div> |
| 722 | <!-- /.inside --> |
| 723 | </div> |
| 724 | <!-- /#give-donor-details --> |
| 725 | |
| 726 | <?php |
| 727 | /** |
| 728 | * Fires on the donation details page, before the billing metabox. |
| 729 | * |
| 730 | * @since 1.0 |
| 731 | * |
| 732 | * @param int $payment_id Payment id. |
| 733 | */ |
| 734 | do_action( 'give_view_donation_details_billing_before', $payment_id ); |
| 735 | ?> |
| 736 | |
| 737 | <div id="give-billing-details" class="postbox"> |
| 738 | <h3 class="hndle"><?php _e( 'Billing Address', 'give' ); ?></h3> |
| 739 | |
| 740 | <div class="inside"> |
| 741 | |
| 742 | <div id="give-order-address"> |
| 743 | |
| 744 | <div class="order-data-address"> |
| 745 | <div class="data column-container"> |
| 746 | |
| 747 | <?php |
| 748 | $address['country'] = ( ! empty( $address['country'] ) ? $address['country'] : give_get_country() ); |
| 749 | |
| 750 | $address['state'] = ( ! empty( $address['state'] ) ? $address['state'] : '' ); |
| 751 | |
| 752 | // Get the country list that does not have any states init. |
| 753 | $no_states_country = give_no_states_country_list(); |
| 754 | ?> |
| 755 | |
| 756 | <div class="row"> |
| 757 | <div id="give-order-address-country-wrap"> |
| 758 | <label class="order-data-address-line"><?php _e( 'Country:', 'give' ); ?></label> |
| 759 | <?php |
| 760 | echo Give()->html->select( |
| 761 | array( |
| 762 | 'options' => give_get_country_list(), |
| 763 | 'name' => 'give-payment-address[0][country]', |
| 764 | 'selected' => $address['country'], |
| 765 | 'show_option_all' => false, |
| 766 | 'show_option_none' => false, |
| 767 | 'chosen' => true, |
| 768 | 'placeholder' => esc_attr__( 'Select a country', 'give' ), |
| 769 | 'data' => array( 'search-type' => 'no_ajax' ), |
| 770 | 'autocomplete' => 'country', |
| 771 | ) |
| 772 | ); |
| 773 | ?> |
| 774 | </div> |
| 775 | </div> |
| 776 | |
| 777 | <div class="row"> |
| 778 | <div class="give-wrap-address-line1"> |
| 779 | <label for="give-payment-address-line1" class="order-data-address"><?php _e( 'Address 1:', 'give' ); ?></label> |
| 780 | <input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr( $address['line1'] ); ?>" class="medium-text"/> |
| 781 | </div> |
| 782 | </div> |
| 783 | |
| 784 | <div class="row"> |
| 785 | <div class="give-wrap-address-line2"> |
| 786 | <label for="give-payment-address-line2" class="order-data-address-line"><?php _e( 'Address 2:', 'give' ); ?></label> |
| 787 | <input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr( $address['line2'] ); ?>" class="medium-text"/> |
| 788 | </div> |
| 789 | </div> |
| 790 | |
| 791 | <div class="row"> |
| 792 | <div class="give-wrap-address-city"> |
| 793 | <label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e( 'City:', 'give' ); ?></label> |
| 794 | <input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr( $address['city'] ); ?>" class="medium-text"/> |
| 795 | </div> |
| 796 | </div> |
| 797 | |
| 798 | <?php |
| 799 | $state_exists = ( ! empty( $address['country'] ) && array_key_exists( $address['country'], $no_states_country ) ? true : false ); |
| 800 | ?> |
| 801 | <div class="row"> |
| 802 | <div class="<?php echo( ! empty( $state_exists ) ? 'column-full' : 'column' ); ?> give-column give-column-state"> |
| 803 | <div id="give-order-address-state-wrap" class="<?php echo( ! empty( $state_exists ) ? 'give-hidden' : '' ); ?>"> |
| 804 | <label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label> |
| 805 | <?php |
| 806 | $states = give_get_states( $address['country'] ); |
| 807 | if ( ! empty( $states ) ) { |
| 808 | echo Give()->html->select( |
| 809 | array( |
| 810 | 'options' => $states, |
| 811 | 'name' => 'give-payment-address[0][state]', |
| 812 | 'selected' => $address['state'], |
| 813 | 'show_option_all' => false, |
| 814 | 'show_option_none' => false, |
| 815 | 'chosen' => true, |
| 816 | 'placeholder' => esc_attr__( 'Select a state', 'give' ), |
| 817 | 'data' => array( 'search-type' => 'no_ajax' ), |
| 818 | 'autocomplete' => 'address-level1', |
| 819 | ) |
| 820 | ); |
| 821 | } else { |
| 822 | ?> |
| 823 | <input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" autocomplete="address-line1" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/> |
| 824 | <?php |
| 825 | } |
| 826 | ?> |
| 827 | </div> |
| 828 | </div> |
| 829 | |
| 830 | <div class="<?php echo( ! empty( $state_exists ) ? 'column-full' : 'column' ); ?> give-column give-column-zip"> |
| 831 | <div class="give-wrap-address-zip"> |
| 832 | <label for="give-payment-address-zip" class="order-data-address-line"><?php _e( 'Zip / Postal Code:', 'give' ); ?></label> |
| 833 | <input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr( $address['zip'] ); ?>" class="medium-text"/> |
| 834 | </div> |
| 835 | </div> |
| 836 | </div> |
| 837 | </div> |
| 838 | </div> |
| 839 | </div> |
| 840 | <!-- /#give-order-address --> |
| 841 | |
| 842 | <?php |
| 843 | /** |
| 844 | * Fires in donation details page, in the billing metabox, after all the fields. |
| 845 | * |
| 846 | * Allows you to insert new billing address fields. |
| 847 | * |
| 848 | * @since 1.7 |
| 849 | * |
| 850 | * @param int $payment_id Payment id. |
| 851 | */ |
| 852 | do_action( 'give_payment_billing_details', $payment_id ); |
| 853 | ?> |
| 854 | |
| 855 | </div> |
| 856 | <!-- /.inside --> |
| 857 | </div> |
| 858 | <!-- /#give-billing-details --> |
| 859 | |
| 860 | <?php |
| 861 | /** |
| 862 | * Fires on the donation details page, after the billing metabox. |
| 863 | * |
| 864 | * @since 1.0 |
| 865 | * |
| 866 | * @param int $payment_id Payment id. |
| 867 | */ |
| 868 | do_action( 'give_view_donation_details_billing_after', $payment_id ); |
| 869 | ?> |
| 870 | |
| 871 | <div id="give-payment-notes" class="postbox"> |
| 872 | <h3 class="hndle"><?php _e( 'Donation Notes', 'give' ); ?></h3> |
| 873 | |
| 874 | <div class="inside"> |
| 875 | <div id="give-payment-notes-inner"> |
| 876 | <?php |
| 877 | $notes = give_get_payment_notes( $payment_id ); |
| 878 | if ( ! empty( $notes ) ) { |
| 879 | $no_notes_display = ' style="display:none;"'; |
| 880 | foreach ( $notes as $note ) : |
| 881 | |
| 882 | echo give_get_payment_note_html( $note, $payment_id ); |
| 883 | |
| 884 | endforeach; |
| 885 | } else { |
| 886 | $no_notes_display = ''; |
| 887 | } |
| 888 | |
| 889 | echo '<p class="give-no-payment-notes"' . $no_notes_display . '>' . esc_html__( 'No donation notes.', 'give' ) . '</p>'; |
| 890 | ?> |
| 891 | </div> |
| 892 | <textarea name="give-payment-note" id="give-payment-note" class="large-text"></textarea> |
| 893 | |
| 894 | <div class="give-clearfix"> |
| 895 | <p> |
| 896 | <label for="donation_note_type" class="screen-reader-text"><?php _e( 'Note type', 'give' ); ?></label> |
| 897 | <select name="donation_note_type" id="donation_note_type"> |
| 898 | <option value=""><?php _e( 'Private note', 'give' ); ?></option> |
| 899 | <option value="donor"><?php _e( 'Note to donor', 'give' ); ?></option> |
| 900 | </select> |
| 901 | <button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint( $payment_id ); ?>"><?php _e( 'Add Note', 'give' ); ?></button> |
| 902 | </p> |
| 903 | </div> |
| 904 | |
| 905 | </div> |
| 906 | <!-- /.inside --> |
| 907 | </div> |
| 908 | <!-- /#give-payment-notes --> |
| 909 | |
| 910 | <?php |
| 911 | /** |
| 912 | * Fires on the donation details page, after the main area. |
| 913 | * |
| 914 | * @since 2.27.0 Change to read comment from donations meta table |
| 915 | * @since 1.0 |
| 916 | * |
| 917 | * @param int $payment_id Payment id. |
| 918 | */ |
| 919 | do_action( 'give_view_donation_details_main_after', $payment_id ); |
| 920 | ?> |
| 921 | |
| 922 | <?php if ( give_is_donor_comment_field_enabled( $payment->form_id ) ) : ?> |
| 923 | <div id="give-payment-donor-comment" class="postbox"> |
| 924 | <h3 class="hndle"><?php _e( 'Donor Comment', 'give' ); ?></h3> |
| 925 | |
| 926 | <div class="inside"> |
| 927 | <div id="give-payment-donor-comment-inner"> |
| 928 | <p> |
| 929 | <?php |
| 930 | echo sprintf( |
| 931 | '<textarea name="give_comment" id="give_comment" placeholder="%s" class="large-text">%s</textarea>', |
| 932 | __( 'Add a comment', 'give' ), |
| 933 | $payment->get_meta(DonationMetaKeys::COMMENT) ?? '' |
| 934 | ); |
| 935 | ?> |
| 936 | </p> |
| 937 | </div> |
| 938 | |
| 939 | </div> |
| 940 | <!-- /.inside --> |
| 941 | </div> |
| 942 | <?php endif; ?> |
| 943 | <!-- /#give-payment-notes --> |
| 944 | |
| 945 | <?php |
| 946 | /** |
| 947 | * Fires on the donation details page, after the main area. |
| 948 | * |
| 949 | * @since 1.0 |
| 950 | * |
| 951 | * @param int $payment_id Payment id. |
| 952 | */ |
| 953 | do_action( 'give_view_donation_details_main_after', $payment_id ); |
| 954 | ?> |
| 955 | |
| 956 | </div> |
| 957 | <!-- /#normal-sortables --> |
| 958 | </div> |
| 959 | <!-- #postbox-container-2 --> |
| 960 | </div> |
| 961 | <!-- /#post-body --> |
| 962 | </div> |
| 963 | <!-- #give-dashboard-widgets-wrap --> |
| 964 | </div> |
| 965 | <!-- /#post-stuff --> |
| 966 | |
| 967 | <?php |
| 968 | /** |
| 969 | * Fires in donation details page, in the form after the order details. |
| 970 | * |
| 971 | * @since 1.0 |
| 972 | * |
| 973 | * @param int $payment_id Payment id. |
| 974 | */ |
| 975 | do_action( 'give_view_donation_details_form_bottom', $payment_id ); |
| 976 | |
| 977 | wp_nonce_field( 'give_update_payment_details_nonce' ); |
| 978 | ?> |
| 979 | <input type="hidden" name="give_payment_id" value="<?php echo esc_attr( $payment_id ); ?>"/> |
| 980 | <input type="hidden" name="give_action" value="update_payment_details"/> |
| 981 | </form> |
| 982 | <?php |
| 983 | /** |
| 984 | * Fires in donation details page, after the order form. |
| 985 | * |
| 986 | * @since 1.0 |
| 987 | * |
| 988 | * @param int $payment_id Payment id. |
| 989 | */ |
| 990 | do_action( 'give_view_donation_details_after', $payment_id ); |
| 991 | ?> |
| 992 | </div><!-- /.wrap --> |
| 993 |