示例#1
0
 /**
  * Prepare body for withdraw email
  *
  * @param string $body
  * @param WP_User $user
  * @param float $amount
  * @param string $method
  * @param string $note
  * @return string
  */
 function prepare_withdraw($body, $user, $amount, $method, $note = '')
 {
     $find = array('%username%', '%amount%', '%method%', '%profile_url%', '%withdraw_page%', '%site_name%', '%site_url%', '%notes%');
     $replace = array($user->user_login, $this->currency_symbol($amount), dokan_withdraw_get_method_title($method), admin_url('user-edit.php?user_id=' . $user->ID), admin_url('admin.php?page=dokan-withdraw'), $this->get_from_name(), home_url(), $note);
     $body = str_replace($find, $replace, $body);
     return $body;
 }
    /**
     * Print the approved user withdraw requests
     *
     * @param  int  $user_id
     *
     * @return void
     */
    function user_approved_withdraws($user_id)
    {
        $requests = $this->get_withdraw_requests($user_id, 1, 100);
        if ($requests) {
            ?>
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th><?php 
            _e('Amount', 'dokan');
            ?>
</th>
                        <th><?php 
            _e('Method', 'dokan');
            ?>
</th>
                        <th><?php 
            _e('Date', 'dokan');
            ?>
</th>
                    </tr>
                </thead>
                <tbody>

                <?php 
            foreach ($requests as $row) {
                ?>
                    <tr>
                        <td><?php 
                echo wc_price($row->amount);
                ?>
</td>
                        <td><?php 
                echo dokan_withdraw_get_method_title($row->method);
                ?>
</td>
                        <td><?php 
                echo date_i18n('M j, Y g:ia', strtotime($row->date));
                ?>
</td>
                    </tr>
                <?php 
            }
            ?>

                </tbody>
            </table>

        <?php 
        } else {
            ?>
            <div class="dokan-alert dokan-alert-warning">
                <strong><?php 
            _e('Err!', 'dokan');
            ?>
</strong> <?php 
            _e('Sorry, no transactions found!', 'dokan');
            ?>
            </div>
            <?php 
        }
    }
    /**
     * Withdraw listing for admin
     *
     * @param  string  $status
     *
     * @return void admin
     */
    function admin_withdraw_list($status)
    {
        $pagenum = isset($_GET['paged']) ? absint($_GET['paged']) : 1;
        $limit = 20;
        $offset = ($pagenum - 1) * $limit;
        $result = $this->get_withdraw_requests('', $this->get_status_code($status), $limit, $offset);
        ?>

        <?php 
        if (isset($_GET['message'])) {
            $message = '';
            switch ($_GET['message']) {
                case 'trashed':
                    $message = __('Requests DELETED!', 'dokan');
                    break;
                case 'cancelled':
                    $message = __('Requests CANCELLED!', 'dokan');
                    break;
                case 'approved':
                    $message = __('Requests APPROVED!', 'dokan');
                    break;
            }
            if (!empty($message)) {
                ?>
                <div class="updated">
                    <p><strong><?php 
                echo $message;
                ?>
</strong></p>
                </div>
                <?php 
            }
        }
        ?>
        <form method="post" action="" id="dokan-admin-withdraw-action">
            <?php 
        wp_nonce_field('dokan_withdraw_admin_bulk_action', 'dokan_withdraw_admin_bulk_action_nonce');
        ?>

            <table class="widefat withdraw-table">
                <thead>
                    <tr>
                        <th class="check-column">
                            <input type="checkbox" class="dokan-withdraw-allcheck">
                        </th>
                        <th><?php 
        _e('User Name', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Amount', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Method', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Method Details', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Note', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('IP', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Date', 'dokan');
        ?>
</th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th class="check-column">
                            <input type="checkbox" class="dokan-withdraw-allcheck">
                        </th>
                        <th><?php 
        _e('User Name', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Amount', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Method', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Method Details', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Note', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('IP', 'dokan');
        ?>
</th>
                        <th><?php 
        _e('Date', 'dokan');
        ?>
</th>
                    </tr>
                </tfoot>

            <?php 
        if ($result) {
            $count = 0;
            foreach ($result as $key => $row) {
                $user_data = get_userdata($row->user_id);
                $store_info = dokan_get_store_info($row->user_id);
                ?>
                    <tr class="<?php 
                echo $count % 2 == 0 ? 'alternate' : 'odd';
                ?>
">

                        <th class="check-column">
                            <input type="checkbox" name="id[<?php 
                echo $row->id;
                ?>
]" value="<?php 
                echo $row->id;
                ?>
">
                            <input type="hidden" name="user_id[<?php 
                echo $row->id;
                ?>
]" value="<?php 
                echo $row->user_id;
                ?>
">
                            <input type="hidden" name="method[<?php 
                echo $row->id;
                ?>
]" value="<?php 
                echo esc_attr($row->method);
                ?>
">
                            <input type="hidden" name="amount[<?php 
                echo $row->id;
                ?>
]" value="<?php 
                echo esc_attr($row->amount);
                ?>
">
                        </th>
                        <td>
                            <strong><a href="<?php 
                echo admin_url('user-edit.php?user_id=' . $user_data->ID);
                ?>
"><?php 
                echo $user_data->user_login;
                ?>
</a></strong>
                            <div class="row-actions">
                                <?php 
                if ($status == 'pending') {
                    ?>

                                    <span class="edit"><a href="#" class="dokan-withdraw-action" data-status="approve" data-withdraw_id = "<?php 
                    echo $row->id;
                    ?>
"><?php 
                    _e('Approve', 'dokan');
                    ?>
</a> | </span>
                                    <span class="edit"><a href="#" class="dokan-withdraw-action" data-status="cancel" data-withdraw_id = "<?php 
                    echo $row->id;
                    ?>
"><?php 
                    _e('Cancel', 'dokan');
                    ?>
</a></span>

                                <?php 
                } elseif ($status == 'completed') {
                    ?>

                                    <span class="edit"><a href="#" class="dokan-withdraw-action" data-status="cancel" data-withdraw_id = "<?php 
                    echo $row->id;
                    ?>
"><?php 
                    _e('Cancel', 'dokan');
                    ?>
</a> | </span>
                                    <span class="edit"><a href="#" class="dokan-withdraw-action" data-status="pending" data-withdraw_id = "<?php 
                    echo $row->id;
                    ?>
"><?php 
                    _e('Pending', 'dokan');
                    ?>
</a></span>

                                <?php 
                } elseif ($status == 'cancelled') {
                    ?>

                                    <span class="edit"><a href="#" class="dokan-withdraw-action" data-status="approve" data-withdraw_id = "<?php 
                    echo $row->id;
                    ?>
"><?php 
                    _e('Approve', 'dokan');
                    ?>
</a> | </span>
                                    <span class="edit"><a href="#" class="dokan-withdraw-action" data-status="pending" data-withdraw_id = "<?php 
                    echo $row->id;
                    ?>
"><?php 
                    _e('Pending', 'dokan');
                    ?>
</a></span>

                                <?php 
                }
                ?>

                                <?php 
                if ($result) {
                    ?>
                                    <span class="trash"> | <a href="#" class="dokan-withdraw-action" data-status="delete" data-withdraw_id = "<?php 
                    echo $row->id;
                    ?>
"><?php 
                    _e('Delete', 'dokan');
                    ?>
</a></span>

                                <?php 
                }
                ?>
                            </div>
                        </td>
                        <td><?php 
                echo wc_price($row->amount);
                ?>
</td>
                        <td><?php 
                echo dokan_withdraw_get_method_title($row->method);
                ?>
</td>
                        <td>
                            <?php 
                if ($row->method != 'bank') {
                    if (isset($store_info['payment'][$row->method])) {
                        echo $store_info['payment'][$row->method]['email'];
                    }
                } elseif ($row->method == 'bank') {
                    echo dokan_get_seller_bank_details($row->user_id);
                }
                ?>
                        </td>
                        <td>
                            <div class="dokan-add-note">
                                <div class="note-display">
                                    <p class="ajax_note"><?php 
                echo $row->note;
                ?>
</p>

                                    <div class="row-actions">
                                        <a href="#" class="dokan-note-field"><?php 
                _e('Add note', 'dokan');
                ?>
</a>
                                    </div>
                                </div>

                                <div class="note-form" style="display: none;">
                                    <p><input type="text" class="dokan-note-text" name="note[<?php 
                echo $row->id;
                ?>
]" value="<?php 
                echo esc_attr($row->note);
                ?>
"></p>
                                    <a class="dokan-note-submit button" data-id=<?php 
                echo $row->id;
                ?>
 href="#" ><?php 
                _e('Save', 'dokan');
                ?>
</a>
                                    <a href="#" class="dokan-note-cancel"><?php 
                _e('cancel', 'dokan');
                ?>
</a>
                                </div>
                            </div>

                        </td>
                        <td><?php 
                echo $row->ip;
                ?>
</td>
                        <td><?php 
                echo date_i18n('M j, Y g:ia', strtotime($row->date));
                ?>
</td>
                    </tr>
                    <?php 
                $count++;
            }
        } else {
            ?>
                <tr>
                    <td colspan="8">
                        <?php 
            _e('No results found', 'dokan');
            ?>
                    </td>
                </tr>
                <?php 
        }
        ?>
            </table>

            <div class="tablenav bottom">

                <div class="alignleft actions bulkactions">
                    <select name="dokan_withdraw_bulk">
                        <option value="-1" selected="selected"><?php 
        _e('Bulk Actions', 'dokan');
        ?>
</option>

                        <?php 
        if ($status == 'pending') {
            ?>

                            <option value="approve"><?php 
            _e('Approve Requests', 'dokan');
            ?>
</option>
                            <option value="cancel"><?php 
            _e('Mark as Cancelled', 'dokan');
            ?>
</option>

                        <?php 
        } elseif ($status == 'completed') {
            ?>

                            <option value="cancel"><?php 
            _e('Mark as Cancelled', 'dokan');
            ?>
</option>
                            <option value="pending"><?php 
            _e('Mark Pending', 'dokan');
            ?>
</option>

                        <?php 
        } elseif ($status == 'cancelled') {
            ?>

                            <option value="approve"><?php 
            _e('Approve Requests', 'dokan');
            ?>
</option>
                            <option value="pending"><?php 
            _e('Mark Pending', 'dokan');
            ?>
</option>

                        <?php 
        }
        ?>

                        <?php 
        if ($result) {
            ?>
                            <option value="delete"><?php 
            _e('Delete', 'dokan');
            ?>
</option>
                            <option value="paypal"><?php 
            _e('Download PayPal mass payment file', 'dokan');
            ?>
</option>
                        <?php 
        }
        ?>
                    </select>

                    <input type="hidden" name="status_page" value="<?php 
        echo $status;
        ?>
">
                    <input type="submit" name="" id="doaction2" class="button button-primary" value="<?php 
        esc_attr_e('Apply', 'dokan');
        ?>
">
                </div>

                <?php 
        if ($result) {
            $counts = dokan_get_withdraw_count();
            $num_of_pages = ceil($counts[$status] / $limit);
            $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;', 'aag'), 'next_text' => __('&raquo;', 'aag'), 'total' => $num_of_pages, 'current' => $pagenum));
            if ($page_links) {
                echo '<div class="tablenav-pages">' . $page_links . '</div>';
            }
        }
        ?>
            </div>

        </form>
        <?php 
        $ajax_url = admin_url('admin-ajax.php');
        ?>
        <style type="text/css">
            .withdraw-table {
                margin-top: 10px;
            }

            .withdraw-table td, .withdraw-table th {
                vertical-align: top;
            }

            .custom-spinner {
                background: url('images/spinner-2x.gif') no-repeat;
                background-position: 43% 9px;
                background-size: 20px 20px;
                opacity: .4;
                filter: alpha(opacity=40);
                width: 20px;
                height: 20px;
            }
        </style>
        <script>
            (function($){
                $(document).ready(function(){
                    var url = "<?php 
        echo $ajax_url;
        ?>
";

                    $('#dokan-admin-withdraw-action').on('click', 'a.dokan-withdraw-action', function(e) {
                        e.preventDefault();
                        var self = $(this);

                        self.closest( 'tr' ).addClass('custom-spinner');
                        data = {
                            action: 'dokan_withdraw_form_action',
                            formData : $('#dokan-admin-withdraw-action').serialize(),
                            status: self.data('status') ,
                            withdraw_id : self.data( 'withdraw_id' )
                        }

                        $.post(url, data, function( resp ) {

                            if( resp.success ) {
                                self.closest( 'tr' ).removeClass('custom-spinner');
                                window.location = resp.data.url;
                            } else {
                                self.closest( 'tr' ).removeClass('custom-spinner');
                                alert( 'Error: ' + resp.data );
                            }
                        });

                    });
                });
            })(jQuery)
        </script>
        <?php 
        $this->add_note_script();
    }
示例#4
0
?>
        </label>

        <div class="dokan-w5 dokan-text-left">
            <select class="dokan-form-control" required name="withdraw_method" id="withdraw-method">
                <?php 
foreach ($payment_methods as $method_name) {
    ?>
                    <option <?php 
    selected($withdraw_method, $method_name);
    ?>
value="<?php 
    echo esc_attr($method_name);
    ?>
"><?php 
    echo dokan_withdraw_get_method_title($method_name);
    ?>
</option>
                <?php 
}
?>
            </select>
        </div>
    </div>

    <div class="dokan-form-group">
        <div class="dokan-w3 ajax_prev" style="margin-left:19%; width: 200px;">
            <?php 
wp_nonce_field('dokan_withdraw', 'dokan_withdraw_nonce');
?>
            <input type="submit" class="dokan-btn dokan-btn-theme" value="<?php 
_e('Date', 'dokan');
?>
</th>
        </tr>
    </thead>
    <tbody>

    <?php 
foreach ($requests as $row) {
    ?>
        <tr>
            <td><?php 
    echo wc_price($row->amount);
    ?>
</td>
            <td><?php 
    echo dokan_withdraw_get_method_title($row->method);
    ?>
</td>
            <td><?php 
    echo date_i18n('M j, Y g:ia', strtotime($row->date));
    ?>
</td>
        </tr>
    <?php 
}
?>

    </tbody>
</table>
    _e('Status', 'dokan');
    ?>
</th>
        </tr>

        <?php 
    foreach ($withdraw_requests as $request) {
        ?>

            <tr>
                <td><?php 
        echo wc_price($request->amount);
        ?>
</td>
                <td><?php 
        echo dokan_withdraw_get_method_title($request->method);
        ?>
</td>
                <td><?php 
        echo dokan_format_time($request->date);
        ?>
</td>
                <td>
                    <?php 
        $url = add_query_arg(array('action' => 'dokan_cancel_withdrow', 'id' => $request->id), dokan_get_navigation_url('withdraw'));
        ?>
                    <a href="<?php 
        echo wp_nonce_url($url, 'dokan_cancel_withdrow');
        ?>
">
                        <?php