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