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