announcements
1 year ago
assignments
8 months ago
elements
1 year ago
enrolled-courses
3 years ago
instructor
2 years ago
my-courses
1 year ago
my-quiz-attempts
3 years ago
notifications
3 years ago
question-answer
1 year ago
quiz-attempts
3 years ago
reviews
3 years ago
settings
1 year ago
withdraw-method-fields
3 years ago
announcements.php
1 year ago
assignments.php
10 months ago
create-course.php
1 year ago
dashboard.php
8 months ago
enrolled-courses.php
8 months ago
index.php
3 years ago
logged-in.php
3 years ago
my-courses.php
8 months ago
my-profile.php
9 months ago
my-quiz-attempts.php
3 years ago
purchase_history.php
10 months ago
question-answer.php
11 months ago
quiz-attempts.php
1 year ago
registration.php
2 years ago
reviews.php
3 years ago
settings.php
1 year ago
wishlist.php
1 year ago
withdraw.php
1 year ago
withdraw.php
342 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Withdraw Page |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Dashboard |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @version 1.4.3 |
| 10 | */ |
| 11 | |
| 12 | use TUTOR\Input; |
| 13 | use Tutor\Models\WithdrawModel; |
| 14 | |
| 15 | //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 16 | $per_page = tutor_utils()->get_option( 'pagination_per_page', 20 ); |
| 17 | $current_page = max( 1, Input::get( 'current_page', 1, Input::TYPE_INT ) ); |
| 18 | $offset = ( $current_page - 1 ) * $per_page; |
| 19 | |
| 20 | $min_withdraw = tutor_utils()->get_option( 'min_withdraw_amount' ); |
| 21 | $formatted_min_withdraw_amount = tutor_utils()->tutor_price( $min_withdraw ); |
| 22 | |
| 23 | $saved_account = WithdrawModel::get_user_withdraw_method(); |
| 24 | $withdraw_method_name = tutor_utils()->avalue_dot( 'withdraw_method_name', $saved_account ); |
| 25 | |
| 26 | $user_id = get_current_user_id(); |
| 27 | $withdraw_status = array( WithdrawModel::STATUS_PENDING, WithdrawModel::STATUS_APPROVED, WithdrawModel::STATUS_REJECTED ); |
| 28 | $all_histories = WithdrawModel::get_withdrawals_history( $user_id, array( 'status' => $withdraw_status ), $offset, $per_page ); |
| 29 | $image_base = tutor()->url . '/assets/images/'; |
| 30 | |
| 31 | $method_icons = array( |
| 32 | 'bank_transfer_withdraw' => $image_base . 'icon-bank.svg', |
| 33 | 'echeck_withdraw' => $image_base . 'icon-echeck.svg', |
| 34 | 'paypal_withdraw' => $image_base . 'icon-paypal.svg', |
| 35 | ); |
| 36 | |
| 37 | $status_message = array( |
| 38 | 'rejected' => __( 'Please contact the site administrator for more information.', 'tutor' ), |
| 39 | 'pending' => __( 'Withdrawal request is pending for approval, please hold tight.', 'tutor' ), |
| 40 | ); |
| 41 | |
| 42 | $currency_symbol = ''; |
| 43 | if ( function_exists( 'get_woocommerce_currency_symbol' ) ) { |
| 44 | $currency_symbol = get_woocommerce_currency_symbol(); |
| 45 | } elseif ( function_exists( 'edd_currency_symbol' ) ) { |
| 46 | $currency_symbol = edd_currency_symbol(); |
| 47 | } |
| 48 | |
| 49 | $summary_data = WithdrawModel::get_withdraw_summary( $user_id ); |
| 50 | $available_for_withdraw = $summary_data->available_for_withdraw - $summary_data->total_pending; |
| 51 | $is_balance_sufficient = $available_for_withdraw >= $min_withdraw; |
| 52 | $available_for_withdraw_formatted = tutor_utils()->tutor_price( $available_for_withdraw ); |
| 53 | $current_balance_formated = tutor_utils()->tutor_price( $summary_data->current_balance ); |
| 54 | ?> |
| 55 | |
| 56 | <div class="tutor-dashboard-content-inner tutor-frontend-dashboard-withdrawal tutor-color-black"> |
| 57 | <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-24"><?php esc_html_e( 'Withdrawals', 'tutor' ); ?></div> |
| 58 | |
| 59 | <div class="tutor-card tutor-p-24"> |
| 60 | <div class="tutor-row tutor-align-lg-center"> |
| 61 | <div class="tutor-col-lg-auto tutor-mb-16 tutor-mb-lg-0"> |
| 62 | <div class="tutor-round-box tutor-p-8"> |
| 63 | <i class="tutor-icon-wallet" area-hidden="true"></i> |
| 64 | </div> |
| 65 | </div> |
| 66 | |
| 67 | <?php //phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment ?> |
| 68 | <div class="tutor-col tutor-mb-16 tutor-mb-lg-0"> |
| 69 | <div class="tutor-fs-6 tutor-color-muted tutor-mb-4"> |
| 70 | <?php |
| 71 | /* translators: %s: current balance */ |
| 72 | echo wp_kses_post( sprintf( esc_html__( 'Current Balance is %s', 'tutor' ), $current_balance_formated ) ); |
| 73 | ?> |
| 74 | </div> |
| 75 | <div class="tutor-fs-5 tutor-color-black"> |
| 76 | <?php |
| 77 | if ( $is_balance_sufficient ) { |
| 78 | /* translators: %s: available balance */ |
| 79 | echo wp_kses_post( sprintf( __( 'You have %s ready to withdraw now', 'tutor' ), "<strong class='available_balance'>" . $available_for_withdraw_formatted . '</strong>' ) ); |
| 80 | } else { |
| 81 | /* translators: %s: available balance */ |
| 82 | echo wp_kses_post( sprintf( __( 'You have %s and this is insufficient balance to withdraw', 'tutor' ), "<strong class='available_balance'>" . $available_for_withdraw_formatted . '</strong>' ) ); |
| 83 | } |
| 84 | ?> |
| 85 | </div> |
| 86 | <?php if ( $summary_data->total_pending > 0 ) : ?> |
| 87 | <div class="tutor-badge-label label-warning tutor-mt-4" style="display: inline-flex; gap: 3px"> |
| 88 | <?php |
| 89 | /* translators: %s: total pending withdrawal */ |
| 90 | echo wp_kses_post( sprintf( esc_html__( 'Total Pending Withdrawal %s', 'tutor' ), tutor_utils()->tutor_price( $summary_data->total_pending ) ) ); |
| 91 | ?> |
| 92 | </div> |
| 93 | <?php endif; ?> |
| 94 | </div> |
| 95 | |
| 96 | <?php |
| 97 | if ( $is_balance_sufficient && $withdraw_method_name ) { |
| 98 | ?> |
| 99 | <div class="tutor-col-lg-auto"> |
| 100 | <button class="tutor-btn tutor-btn-primary" data-tutor-modal-target="tutor-earning-withdraw-modal"> |
| 101 | <?php esc_html_e( 'Withdrawal Request', 'tutor' ); ?> |
| 102 | </button> |
| 103 | </div> |
| 104 | <?php |
| 105 | } |
| 106 | ?> |
| 107 | </div> |
| 108 | </div> |
| 109 | |
| 110 | <div class="current-withdraw-account-wrap tutor-d-flex tutor-mt-20"> |
| 111 | <span class="tutor-svg tutor-fs-4 tutor-mr-8"> |
| 112 | <?php echo tutor_utils()->get_svg_icon( 'infoCircle' );//phpcs:ignore ?> |
| 113 | </span> |
| 114 | <span class="tutor-fs-7 tutor-mt-4"> |
| 115 | <?php |
| 116 | $my_profile_url = tutor_utils()->get_tutor_dashboard_page_permalink( 'settings/withdraw-settings' ); |
| 117 | /* translators: %s: Withdraw Method Name */ |
| 118 | echo esc_html( $withdraw_method_name ? sprintf( __( 'The preferred payment method is selected as %s. ', 'tutor' ), $withdraw_method_name ) : '' ); |
| 119 | echo wp_kses( |
| 120 | /* translators: %1$s: a tag start, %2$s: a tag end */ |
| 121 | sprintf( __( 'You can change your %1$s Withdraw Preference %2$s', 'tutor' ), "<a href='{$my_profile_url}'>", '</a>' ), |
| 122 | array( |
| 123 | 'a' => array( 'href' => true ), |
| 124 | ) |
| 125 | ); |
| 126 | ?> |
| 127 | </span> |
| 128 | </div> |
| 129 | |
| 130 | <?php |
| 131 | if ( $is_balance_sufficient && $withdraw_method_name ) { |
| 132 | ?> |
| 133 | <div id="tutor-earning-withdraw-modal" class="tutor-modal"> |
| 134 | <div class="tutor-modal-overlay"></div> |
| 135 | <div class="tutor-modal-window"> |
| 136 | <div class="tutor-modal-content tutor-modal-content-white"> |
| 137 | <button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close> |
| 138 | <span class="tutor-icon-times" area-hidden="true"></span> |
| 139 | </button> |
| 140 | |
| 141 | <div class="tutor-modal-body"> |
| 142 | <div class="tutor-py-20 tutor-px-24"> |
| 143 | <div class="tutor-round-box tutor-round-box-lg tutor-mb-16"> |
| 144 | <span class="tutor-icon-wallet" area-hidden="true"></span> |
| 145 | </div> |
| 146 | |
| 147 | <div class="tutor-fs-4 tutor-fw-medium tutor-color-black tutor-mb-24"><?php esc_html_e( 'Withdrawal Request', 'tutor' ); ?></div> |
| 148 | <div class="tutor-fs-6 tutor-color-muted"><?php esc_html_e( 'Please check your transaction notification on your connected withdrawal method', 'tutor' ); ?></div> |
| 149 | |
| 150 | <div class="tutor-row tutor-mt-32"> |
| 151 | <div class="tutor-col"> |
| 152 | <div class="tutor-fs-6 tutor-color-secondary tutor-mb-4"><?php esc_html_e( 'Withdrawable Balance', 'tutor' ); ?></div> |
| 153 | <div class="tutor-fs-6 tutor-fw-bold tutor-color-black"><?php echo wp_kses_post( $available_for_withdraw_formatted ); ?></div> |
| 154 | </div> |
| 155 | |
| 156 | <div class="tutor-col"> |
| 157 | <div class="tutor-fs-6 tutor-color-secondary tutor-mb-4"><?php esc_html_e( 'Selected Payment Method', 'tutor' ); ?></div> |
| 158 | <div class="tutor-fs-6 tutor-fw-bold tutor-color-black"><?php echo esc_html( $withdraw_method_name ); ?></div> |
| 159 | </div> |
| 160 | </div> |
| 161 | </div> |
| 162 | |
| 163 | <div class="tutor-mx-n32 tutor-my-32"><div class="tutor-hr" area-hidden="true"></div></div> |
| 164 | |
| 165 | <form id="tutor-earning-withdraw-form" method="post"> |
| 166 | <div class="tutor-py-20 tutor-px-24"> |
| 167 | <div> |
| 168 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 169 | <input type="hidden" value="tutor_make_an_withdraw" name="action" /> |
| 170 | <?php do_action( 'tutor_withdraw_form_before' ); ?> |
| 171 | |
| 172 | <label class="tutor-form-label" for="tutor_withdraw_amount"><?php esc_html_e( 'Amount', 'tutor' ); ?></label> |
| 173 | <div class="tutor-form-wrap tutor-mb-16"> |
| 174 | <span class="tutor-form-icon"><?php echo esc_attr( $currency_symbol ); ?></span> |
| 175 | <input type="number" class="tutor-form-control" min="<?php echo esc_attr( $min_withdraw ); ?>" name="tutor_withdraw_amount" id="tutor_withdraw_amount" step=".01" required /> |
| 176 | </div> |
| 177 | |
| 178 | <div class="tutor-form-help tutor-d-flex tutor-align-center"> |
| 179 | <span class="tutor-icon-circle-question-mark tutor-mr-8" area-hidden="true"></span> |
| 180 | <span><?php echo wp_kses( __( 'Minimum withdraw amount is', 'tutor' ) . ' ' . $formatted_min_withdraw_amount, array() ); ?></span> |
| 181 | </div> |
| 182 | |
| 183 | <div class="tutor-withdraw-form-response"></div> |
| 184 | |
| 185 | <?php do_action( 'tutor_withdraw_form_after' ); ?> |
| 186 | </div> |
| 187 | |
| 188 | <div class="tutor-d-flex tutor-mt-48"> |
| 189 | <div> |
| 190 | <button class="tutor-btn tutor-btn-outline-primary" data-tutor-modal-close> |
| 191 | <?php esc_html_e( 'Cancel', 'tutor' ); ?> |
| 192 | </button> |
| 193 | </div> |
| 194 | |
| 195 | <div class="tutor-ml-auto"> |
| 196 | <button type="submit" name="withdraw-form-submit" id="tutor-earning-withdraw-btn" class="tutor-btn tutor-btn-primary tutor-modal-btn-edit tutor-ml-16"> |
| 197 | <?php esc_html_e( 'Submit Request', 'tutor' ); ?> |
| 198 | </button> |
| 199 | </div> |
| 200 | </div> |
| 201 | </form> |
| 202 | </div> |
| 203 | </div> |
| 204 | </div> |
| 205 | </div> |
| 206 | </div> |
| 207 | <?php |
| 208 | } |
| 209 | |
| 210 | if ( is_array( $all_histories->results ) && count( $all_histories->results ) ) { |
| 211 | ?> |
| 212 | <div class="withdraw-history-table-wrap tutor-tooltip-inside tutor-mt-40"> |
| 213 | <div class="withdraw-history-table-title"> |
| 214 | <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-24"> |
| 215 | <?php esc_html_e( 'Withdrawal History', 'tutor' ); ?> |
| 216 | </div> |
| 217 | </div> |
| 218 | |
| 219 | <div class="tutor-table-responsive"> |
| 220 | <table class="tutor-table tutor-table-middle"> |
| 221 | <thead> |
| 222 | <tr> |
| 223 | <th width="40%"> |
| 224 | <?php esc_html_e( 'Withdrawal Method', 'tutor' ); ?> |
| 225 | </th> |
| 226 | <th width="28%"> |
| 227 | <?php esc_html_e( 'Requested On', 'tutor' ); ?> |
| 228 | </th> |
| 229 | <th width="13%"> |
| 230 | <?php esc_html_e( 'Amount', 'tutor' ); ?> |
| 231 | </th> |
| 232 | <th width="13%"> |
| 233 | <?php esc_html_e( 'Status', 'tutor' ); ?> |
| 234 | </th> |
| 235 | <th></th> |
| 236 | </tr> |
| 237 | </thead> |
| 238 | |
| 239 | <tbody> |
| 240 | <?php foreach ( $all_histories->results as $withdraw_history ) : ?> |
| 241 | <tr> |
| 242 | <td> |
| 243 | <?php |
| 244 | $method_data = maybe_unserialize( $withdraw_history->method_data ); |
| 245 | $method_key = $method_data['withdraw_method_key']; |
| 246 | $method_title = ''; |
| 247 | |
| 248 | switch ( $method_key ) { |
| 249 | case 'bank_transfer_withdraw': |
| 250 | $method_title = $method_data['account_number']['value']; |
| 251 | $method_title = substr_replace( $method_title, '****', 2, strlen( $method_title ) - 4 ); |
| 252 | break; |
| 253 | case 'paypal_withdraw': |
| 254 | $method_title = $method_data['paypal_email']['value']; |
| 255 | $email_base = substr( $method_title, 0, strpos( $method_title, '@' ) ); |
| 256 | $method_title = substr_replace( $email_base, '****', 2, strlen( $email_base ) - 3 ) . substr( $method_title, strpos( $method_title, '@' ) ); |
| 257 | break; |
| 258 | } |
| 259 | ?> |
| 260 | <div class="tutor-withdrawals-method"> |
| 261 | <div class="tutor-withdrawals-method-icon"> |
| 262 | <img src="<?php echo esc_url( isset( $method_icons[ $method_key ] ) ? $method_icons[ $method_key ] : '' ); ?>" /> |
| 263 | </div> |
| 264 | <div class="tutor-withdrawals-method-name"> |
| 265 | <div class="withdraw-method-name tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 266 | <?php echo esc_html( tutor_utils()->avalue_dot( 'withdraw_method_name', $method_data ) ); ?> |
| 267 | </div> |
| 268 | <div class="tutor-fs-7 tutor-color-muted"> |
| 269 | <?php echo esc_html( $method_title ); ?> |
| 270 | </div> |
| 271 | </div> |
| 272 | </div> |
| 273 | </td> |
| 274 | <td> |
| 275 | <?php echo esc_attr( date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $withdraw_history->created_at ) ) ); ?> |
| 276 | </td> |
| 277 | <td> |
| 278 | <?php echo wp_kses_post( tutor_utils()->tutor_price( $withdraw_history->amount ) ); ?> |
| 279 | </td> |
| 280 | <td> |
| 281 | <span class="inline-image-text is-inline-block"> |
| 282 | <span class="tutor-badge-label |
| 283 | <?php |
| 284 | if ( 'approved' === $withdraw_history->status ) { |
| 285 | echo 'label-success'; |
| 286 | } |
| 287 | ?> |
| 288 | <?php |
| 289 | if ( 'pending' === $withdraw_history->status ) { |
| 290 | echo 'label-warning'; |
| 291 | } |
| 292 | ?> |
| 293 | <?php |
| 294 | if ( 'rejected' === $withdraw_history->status ) { |
| 295 | echo 'label-danger'; |
| 296 | } |
| 297 | ?> |
| 298 | "> |
| 299 | <?php esc_html_e( ucfirst( $withdraw_history->status ), 'tutor' ); //phpcs:ignore ?> |
| 300 | </span> |
| 301 | </span> |
| 302 | </td> |
| 303 | <td> |
| 304 | <?php if ( 'approved' !== $withdraw_history->status && isset( $status_message[ $withdraw_history->status ] ) ) : ?> |
| 305 | <span class="tool-tip-container"> |
| 306 | <div class="tooltip-wrap tooltip-icon"> |
| 307 | <span class="tooltip-txt tooltip-left"> |
| 308 | <?php echo esc_html( $status_message[ $withdraw_history->status ] ); ?> |
| 309 | </span> |
| 310 | </div> |
| 311 | </span> |
| 312 | <?php endif; ?> |
| 313 | </td> |
| 314 | </tr> |
| 315 | <?php endforeach; ?> |
| 316 | </tbody> |
| 317 | </table> |
| 318 | </div> |
| 319 | </div> |
| 320 | <?php |
| 321 | } else { |
| 322 | tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); |
| 323 | } |
| 324 | ?> |
| 325 | </div> |
| 326 | |
| 327 | <?php |
| 328 | if ( $all_histories->count >= $per_page ) { |
| 329 | $pagination_data = array( |
| 330 | 'total_items' => $all_histories->count, |
| 331 | 'per_page' => $per_page, |
| 332 | 'paged' => $current_page, |
| 333 | ); |
| 334 | |
| 335 | tutor_load_template_from_custom_path( |
| 336 | tutor()->path . 'templates/dashboard/elements/pagination.php', |
| 337 | $pagination_data |
| 338 | ); |
| 339 | } |
| 340 | //phpcs:enable WordPress.WP.I18n.MissingTranslatorsComment |
| 341 | ?> |
| 342 |