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