announcements
4 years ago
assignments
4 years ago
earning
4 years ago
enrolled-courses
4 years ago
instructor
4 years ago
my-quiz-attempts
4 years ago
notifications
4 years ago
question-answer
4 years ago
quiz-attempts
4 years ago
reviews
4 years ago
settings
4 years ago
withdraw-method-fields
4 years ago
announcements.php
4 years ago
assignments.php
4 years ago
create-course.php
4 years ago
dashboard-menu.php
4 years ago
dashboard.php
4 years ago
earning.php
4 years ago
enrolled-courses.php
4 years ago
index.php
4 years ago
logged-in.php
5 years ago
my-courses.php
4 years ago
my-profile.php
4 years ago
my-quiz-attempts.php
4 years ago
purchase_history.php
4 years ago
question-answer.php
4 years ago
quiz-attempts.php
4 years ago
registration.php
4 years ago
reviews.php
4 years ago
settings.php
4 years ago
wishlist.php
4 years ago
withdraw.php
4 years ago
withdraw.php
269 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package TutorLMS/Templates |
| 5 | * @version 1.4.3 |
| 6 | */ |
| 7 | |
| 8 | $earning_sum = tutor_utils()->get_earning_sum(); |
| 9 | $min_withdraw = tutor_utils()->get_option( 'min_withdraw_amount' ); |
| 10 | $formatted_min_withdraw_amount = tutor_utils()->tutor_price( $min_withdraw ); |
| 11 | |
| 12 | $saved_account = tutor_utils()->get_user_withdraw_method(); |
| 13 | $withdraw_method_name = tutor_utils()->avalue_dot( 'withdraw_method_name', $saved_account ); |
| 14 | |
| 15 | $user_id = get_current_user_id(); |
| 16 | $balance_formatted = tutor_utils()->tutor_price( $earning_sum->balance ); |
| 17 | $is_balance_sufficient = true; // $earning_sum->balance >= $min_withdraw; |
| 18 | $all_histories = tutor_utils()->get_withdrawals_history( $user_id, array( 'status' => array( 'pending', 'approved', 'rejected' ) ) ); |
| 19 | |
| 20 | $image_base = tutor()->url . '/assets/images/'; |
| 21 | $method_icons = array( |
| 22 | 'bank_transfer_withdraw' => $image_base . 'icon-bank.svg', |
| 23 | 'echeck_withdraw' => $image_base . 'icon-echeck.svg', |
| 24 | 'paypal_withdraw' => $image_base . 'icon-paypal.svg', |
| 25 | ); |
| 26 | |
| 27 | $status_message = array( |
| 28 | 'rejected' => __( 'Please contact the site administrator for more information.', 'tutor' ), |
| 29 | 'pending' => __( 'Withdrawal request is pending for approval, please hold tight.', 'tutor' ), |
| 30 | ); |
| 31 | |
| 32 | $currency_symbol = ''; |
| 33 | if ( function_exists( 'get_woocommerce_currency_symbol' ) ) { |
| 34 | $currency_symbol = get_woocommerce_currency_symbol(); |
| 35 | } elseif ( function_exists( 'edd_currency_symbol' ) ) { |
| 36 | $currency_symbol = edd_currency_symbol(); |
| 37 | } |
| 38 | |
| 39 | ?> |
| 40 | |
| 41 | <div class="tutor-dashboard-content-inner tutor-frontend-dashboard-withdrawal"> |
| 42 | <h4><?php echo __( 'Withdrawal', 'tutor' ); ?></h4> |
| 43 | |
| 44 | <div class="tutor-component-three-col-action"> |
| 45 | <img src="<?php echo esc_url( $image_base ); ?>wallet.svg" /> |
| 46 | |
| 47 | <div> |
| 48 | <small><?php _e( 'Current Balance', 'tutor' ); ?></small> |
| 49 | <p> |
| 50 | <?php |
| 51 | if ( $is_balance_sufficient ) { |
| 52 | echo sprintf( __( 'You currently have %1$s %2$s %3$s ready to withdraw', 'tutor' ), "<strong class='available_balance'>", $balance_formatted, '</strong>' ); |
| 53 | } else { |
| 54 | echo sprintf( __( 'You currently have %1$s %2$s %3$s and this is insufficient balance to withdraw', 'tutor' ), "<strong class='available_balance'>", $balance_formatted, '</strong>' ); |
| 55 | } |
| 56 | ?> |
| 57 | </p> |
| 58 | </div> |
| 59 | |
| 60 | <?php |
| 61 | if ( $is_balance_sufficient && $withdraw_method_name ) { |
| 62 | ?> |
| 63 | <button class="tutor-button tutor-button-primary open-withdraw-form-btn"> |
| 64 | <?php _e( 'Withdrawal Request', 'tutor' ); ?> |
| 65 | </button> |
| 66 | <?php |
| 67 | } |
| 68 | ?> |
| 69 | </div> |
| 70 | |
| 71 | <div class="current-withdraw-account-wrap withdrawal-preference inline-image-text"> |
| 72 | <img src="<?php echo esc_url( $image_base ); ?>info-icon-question.svg" /> |
| 73 | <span> |
| 74 | <?php |
| 75 | $my_profile_url = tutor_utils()->get_tutor_dashboard_page_permalink( 'settings/withdraw-settings' ); |
| 76 | echo $withdraw_method_name ? sprintf( __( 'The preferred payment method is selected as %s. ', 'tutor' ), $withdraw_method_name ) : ''; |
| 77 | echo sprintf( __( 'You can change your %1$s withdrawal preference %2$s', 'tutor' ), '<a href="' . esc_url( $my_profile_url ) . '">', '</a>' ); |
| 78 | ?> |
| 79 | </span> |
| 80 | </div> |
| 81 | |
| 82 | <?php |
| 83 | if ( $is_balance_sufficient && $withdraw_method_name ) { |
| 84 | ?> |
| 85 | |
| 86 | <div class="tutor-earning-withdraw-form-wrap"> |
| 87 | <div> |
| 88 | <div class="tutor-withdrawal-pop-up-success"> |
| 89 | <div> |
| 90 | <i class="tutor-icon-line-cross close-withdraw-form-btn" data-reload="yes"></i> |
| 91 | <br /> |
| 92 | <br /> |
| 93 | <div style="text-align:center"> |
| 94 | <img src="<?php echo esc_url( $image_base ); ?>icon-cheers.svg" /> |
| 95 | <h3><?php _e( 'Your withdrawal request has been successfully accepted', 'tutor' ); ?></h3> |
| 96 | <p><?php _e( 'Please check your transaction notification on your connected withdrawal method', 'tutor' ); ?></p> |
| 97 | </div> |
| 98 | <br /> |
| 99 | <br /> |
| 100 | <div class="tutor-withdraw-form-response"></div> |
| 101 | </div> |
| 102 | </div> |
| 103 | <div class="tutor-withdrawal-op-up-frorm"> |
| 104 | <div> |
| 105 | <i class="tutor-icon-line-cross close-withdraw-form-btn"></i> |
| 106 | <img src="<?php echo esc_url( $image_base ); ?>wallet.svg" /> |
| 107 | <h3><?php _e( 'Withdrawal Request', 'tutor' ); ?></h3> |
| 108 | <p><?php _e( 'Please enter withdrawal amount and click the submit request button', 'tutor' ); ?></p> |
| 109 | <table> |
| 110 | <tbody> |
| 111 | <tr> |
| 112 | <td> |
| 113 | <span><?php _e( 'Current Balance', 'tutor' ); ?></span><br /> |
| 114 | <b><?php echo $balance_formatted; ?></b> |
| 115 | </td> |
| 116 | <td> |
| 117 | <span><?php _e( 'Selected Payment Method', 'tutor' ); ?></span><br /> |
| 118 | <b><?php echo $withdraw_method_name; ?></b> |
| 119 | </td> |
| 120 | </tr> |
| 121 | </tbody> |
| 122 | </table> |
| 123 | </div> |
| 124 | <div> |
| 125 | <?php |
| 126 | /** |
| 127 | * @since 1.8.1 |
| 128 | * set min value for withdraw input field as per settings |
| 129 | * field req step .01 |
| 130 | */ |
| 131 | |
| 132 | ?> |
| 133 | <form id="tutor-earning-withdraw-form" action="" method="post"> |
| 134 | <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?> |
| 135 | <input type="hidden" value="tutor_make_an_withdraw" name="action" /> |
| 136 | <?php do_action( 'tutor_withdraw_form_before' ); ?> |
| 137 | <div class="withdraw-form-field-row"> |
| 138 | <label for="tutor_withdraw_amount"><?php _e( 'Amount', 'tutor' ); ?></label> |
| 139 | <div class="withdraw-form-field-amount"> |
| 140 | <span> |
| 141 | <span><?php echo $currency_symbol; ?></span> |
| 142 | </span> |
| 143 | <input type="number" min="<?php echo $min_withdraw; ?>" name="tutor_withdraw_amount" id="tutor_withdraw_amount" step=".01" required> |
| 144 | </div> |
| 145 | <div class="inline-image-text"> |
| 146 | <img src="<?php echo esc_url( $image_base ); ?>info-icon-question.svg" /> |
| 147 | <span> |
| 148 | <?php echo __( 'Minimum withdraw amount is', 'tutor' ) . ' ' . strip_tags( $formatted_min_withdraw_amount ); ?> |
| 149 | </span> |
| 150 | </div> |
| 151 | </div> |
| 152 | |
| 153 | <div class="tutor-withdraw-button-container"> |
| 154 | <button class="tutor-btn tutor-btn-secondary close-withdraw-form-btn"><?php _e( 'Cancel', 'tutor' ); ?></button> |
| 155 | <button class="tutor-btn" type="submit" id="tutor-earning-withdraw-btn" name="withdraw-form-submit"><?php _e( 'Submit Request', 'tutor' ); ?></button> |
| 156 | </div> |
| 157 | |
| 158 | <div class="tutor-withdraw-form-response"></div> |
| 159 | |
| 160 | <?php do_action( 'tutor_withdraw_form_after' ); ?> |
| 161 | </form> |
| 162 | </div> |
| 163 | </div> |
| 164 | </div> |
| 165 | </div> |
| 166 | |
| 167 | <?php |
| 168 | } |
| 169 | ?> |
| 170 | |
| 171 | <div class="withdraw-history-table-wrap tutor-tooltip-inside"> |
| 172 | <div class="withdraw-history-table-title"> |
| 173 | <h4> <?php _e( 'Withdrawal History', 'tutor' ); ?></h4> |
| 174 | </div> |
| 175 | |
| 176 | <?php |
| 177 | if ( tutor_utils()->count( $all_histories->results ) ) { |
| 178 | ?> |
| 179 | <table class="withdrawals-history tutor-table"> |
| 180 | <thead> |
| 181 | <tr> |
| 182 | <th><?php _e( 'Withdrawal Method', 'tutor' ); ?></th> |
| 183 | <th width="30%"><?php _e( 'Requested On', 'tutor' ); ?></th> |
| 184 | <th width="15%"><?php _e( 'Amount', 'tutor' ); ?></th> |
| 185 | <th width="15%"><?php _e( 'Status', 'tutor' ); ?></th> |
| 186 | <th></th> |
| 187 | </tr> |
| 188 | </thead> |
| 189 | <tbody> |
| 190 | <?php |
| 191 | foreach ( $all_histories->results as $withdraw_history ) { |
| 192 | ?> |
| 193 | <tr> |
| 194 | <td> |
| 195 | <?php |
| 196 | $method_data = maybe_unserialize( $withdraw_history->method_data ); |
| 197 | $method_key = $method_data['withdraw_method_key']; |
| 198 | $method_title = ''; |
| 199 | |
| 200 | switch ( $method_key ) { |
| 201 | case 'bank_transfer_withdraw': |
| 202 | $method_title = $method_data['account_number']['value']; |
| 203 | $method_title = substr_replace( $method_title, '****', 2, strlen( $method_title ) - 4 ); |
| 204 | break; |
| 205 | case 'paypal_withdraw': |
| 206 | $method_title = $method_data['paypal_email']['value']; |
| 207 | $email_base = substr( $method_title, 0, strpos( $method_title, '@' ) ); |
| 208 | $method_title = substr_replace( $email_base, '****', 2, strlen( $email_base ) - 3 ) . substr( $method_title, strpos( $method_title, '@' ) ); |
| 209 | break; |
| 210 | } |
| 211 | ?> |
| 212 | <div class="inline-image-text is-inline-block"> |
| 213 | <img src="<?php echo esc_url( isset( $method_icons[ $method_key ] ) ? $method_icons[ $method_key ] : '' ); ?>" /> |
| 214 | |
| 215 | <span> |
| 216 | <?php |
| 217 | echo '<strong class="withdraw-method-name">' . tutor_utils()->avalue_dot( 'withdraw_method_name', $method_data ) . '</strong>'; |
| 218 | echo '<small>' . $method_title . '</small>'; |
| 219 | ?> |
| 220 | </span> |
| 221 | </div> |
| 222 | </td> |
| 223 | <td> |
| 224 | <?php |
| 225 | echo date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $withdraw_history->created_at ) ); |
| 226 | ?> |
| 227 | </td> |
| 228 | <td> |
| 229 | <strong><?php echo tutor_utils()->tutor_price( $withdraw_history->amount ); ?></strong> |
| 230 | </td> |
| 231 | <td> |
| 232 | <span class="inline-image-text is-inline-block"> |
| 233 | <span class="tutor-status-text status-<?php echo $withdraw_history->status; ?>"> |
| 234 | <?php echo __( ucfirst( $withdraw_history->status ), 'tutor' ); ?> |
| 235 | </span> |
| 236 | </span> |
| 237 | </td> |
| 238 | <td> |
| 239 | <?php |
| 240 | if ( $withdraw_history->status !== 'approved' && isset( $status_message[ $withdraw_history->status ] ) ) { |
| 241 | ?> |
| 242 | <span class="tutor-status-text-container"> |
| 243 | <span class="tool-tip-container"> |
| 244 | <img src="<?php echo esc_url( $image_base ); ?>info-icon.svg" /> |
| 245 | <span class="tooltip tip-left" role="tooltip"> |
| 246 | <?php echo $status_message[ $withdraw_history->status ]; ?> |
| 247 | </span> |
| 248 | </span> |
| 249 | </span> |
| 250 | <?php |
| 251 | } |
| 252 | ?> |
| 253 | </td> |
| 254 | </tr> |
| 255 | <?php |
| 256 | } |
| 257 | ?> |
| 258 | </tbody> |
| 259 | </table> |
| 260 | <?php |
| 261 | } else { |
| 262 | ?> |
| 263 | <p><?php _e( 'No withdrawal yet', 'tutor' ); ?></p> |
| 264 | <?php |
| 265 | } |
| 266 | ?> |
| 267 | </div> |
| 268 | </div> |
| 269 |