function admin_menu() { $menu_position = apply_filters('doakn_menu_position', 17); $capability = apply_filters('doakn_menu_capability', 'manage_options'); $withdraw = dokan_get_withdraw_count(); $withdraw_text = __('Withdraw', 'dokan'); if ($withdraw['pending']) { $withdraw_text = sprintf(__('Withdraw %s', 'dokan'), '<span class="awaiting-mod count-1"><span class="pending-count">' . $withdraw['pending'] . '</span></span>'); } $dashboard = add_menu_page(__('Dokan', 'dokan'), __('Dokan', 'dokan'), $capability, 'dokan', array($this, 'dashboard'), 'dashicons-vault', $menu_position); add_submenu_page('dokan', __('Dokan Dashboard', 'dokan'), __('Dashboard', 'dokan'), $capability, 'dokan', array($this, 'dashboard')); add_submenu_page('dokan', __('Withdraw', 'dokan'), $withdraw_text, $capability, 'dokan-withdraw', array($this, 'withdraw_page')); add_submenu_page('dokan', __('Sellers Listing', 'dokan'), __('All Sellers', 'dokan'), $capability, 'dokan-sellers', array($this, 'seller_listing')); $report = add_submenu_page('dokan', __('Earning Reports', 'dokan'), __('Earning Reports', 'dokan'), $capability, 'dokan-reports', array($this, 'report_page')); $announcement = add_submenu_page('dokan', __('Announcement', 'dokan'), __('Announcement', 'dokan'), $capability, 'edit.php?post_type=dokan_announcement'); do_action('dokan_admin_menu'); add_submenu_page('dokan', __('Tools', 'dokan'), __('Tools', 'dokan'), $capability, 'dokan-tools', array($this, 'tools_page')); add_submenu_page('dokan', __('Settings', 'dokan'), __('Settings', 'dokan'), $capability, 'dokan-settings', array($this, 'settings_page')); add_submenu_page('dokan', __('Add Ons', 'dokan'), __('Add-ons', 'dokan'), $capability, 'dokan-addons', array($this, 'addon_page')); add_action($dashboard, array($this, 'dashboard_script')); add_action($report, array($this, 'report_scripts')); // add_action( $announcement, array($this, 'announcement_scripts' ) ); add_action('admin_print_scripts-post-new.php', array($this, 'announcement_scripts'), 11); add_action('admin_print_scripts-post.php', array($this, 'announcement_scripts'), 11); }
function admin_menu() { $menu_position = apply_filters('doakn_menu_position', 17); $capability = apply_filters('doakn_menu_capability', 'manage_options'); $withdraw = dokan_get_withdraw_count(); $withdraw_text = __('Withdraw', 'dokan'); if ($withdraw['pending']) { $withdraw_text = sprintf(__('Withdraw %s', 'dokan'), '<span class="awaiting-mod count-1"><span class="pending-count">' . $withdraw['pending'] . '</span></span>'); } $dashboard = add_menu_page(__('Dokan', 'dokan'), __('Dokan', 'dokan'), $capability, 'dokan', array($this, 'dashboard'), 'dashicons-vault', $menu_position); add_submenu_page('dokan', __('Dokan Dashboard', 'dokan'), __('Dashboard', 'dokan'), $capability, 'dokan', array($this, 'dashboard')); add_submenu_page('dokan', __('Withdraw', 'dokan'), $withdraw_text, $capability, 'dokan-withdraw', array($this, 'withdraw_page')); do_action('dokan_admin_menu'); add_submenu_page('dokan', __('Settings', 'dokan'), __('Settings', 'dokan'), $capability, 'dokan-settings', array($this, 'settings_page')); add_submenu_page('dokan', __('Add Ons', 'dokan'), __('Add-ons', 'dokan'), $capability, 'dokan-addons', array($this, 'addon_page')); add_action($dashboard, array($this, 'dashboard_script')); }
function dokan_admin_dash_metabox_glance() { $user_count = count_users(); $withdraw_counts = dokan_get_withdraw_count(); $seller_counts = dokan_get_seller_count(); $total_seller = isset($user_count['avail_roles']['seller']) ? $user_count['avail_roles']['seller'] : 0; ?> <div class="dokan-left"> <h4><?php _e('Sellers', 'dokan'); ?> </h4> <ul> <li class="seller-count"> <div class="dashicons dashicons-businessman"></div> <a href="<?php echo admin_url('admin.php?page=dokan-sellers'); ?> "><?php printf(_n(__('%d Total Seller', 'dokan'), __('%d Total Sellers', 'dokan'), $total_seller, 'dokan'), $total_seller); ?> </a> </li> <li class="seller-count mark-green"> <div class="dashicons dashicons-awards"></div> <a href="<?php echo admin_url('admin.php?page=dokan-sellers'); ?> "> <?php if ($seller_counts['yes']) { printf(_n(__('%d Active Seller', 'dokan'), __('%d Active Sellers', 'dokan'), $seller_counts['yes'], 'dokan'), $seller_counts['yes']); } else { _e('No Active Seller', 'dokan'); } ?> </a> </li> <li class="seller-count <?php echo $seller_counts['no'] < 1 ? 'mark-green' : 'mark-red'; ?> "> <div class="dashicons dashicons-editor-help"></div> <a href="<?php echo admin_url('admin.php?page=dokan-sellers'); ?> "> <?php if ($seller_counts['no']) { printf(_n(__('%d Pending Seller', 'dokan'), __('%d Pending Sellers', 'dokan'), $seller_counts['no'], 'dokan'), $seller_counts['no']); } else { _e('No Pending Seller', 'dokan'); } ?> </a> </li> </ul> </div> <div class="dokan-right"> <h4><?php _e('Withdraw', 'dokan'); ?> </h4> <ul> <li class="withdraw-pending <?php echo $withdraw_counts['pending'] < 1 ? 'mark-green' : 'mark-red'; ?> "> <div class="dashicons dashicons-visibility"></div> <a href="<?php echo admin_url('admin.php?page=dokan-withdraw'); ?> "><?php printf(__('%d Pending Withdraw', 'dokan'), $withdraw_counts['pending']); ?> </a> </li> <li class="withdraw-completed mark-green"> <div class="dashicons dashicons-yes"></div> <a href="<?php echo admin_url('admin.php?page=dokan-withdraw&status=completed'); ?> "><?php printf(__('%d Completed Withdraw', 'dokan'), $withdraw_counts['completed']); ?> </a> </li> <li class="withdraw-cancelled"> <div class="dashicons dashicons-dismiss"></div> <a href="<?php echo admin_url('admin.php?page=dokan-withdraw&status=cancelled'); ?> "><?php printf(__('%d Cancelled Withdraw', 'dokan'), $withdraw_counts['cancelled']); ?> </a> </li> </ul> </div> <?php }
<?php $dokan_admin_withdraw = Dokan_Template_Withdraw::init(); $counts = dokan_get_withdraw_count(); $status = isset($_GET['status']) ? $_GET['status'] : 'pending'; ?> <div class="wrap"> <h2><?php _e('Withdraw Requests', 'dokan'); ?> </h2> <ul class="subsubsub" style="float: none;"> <li> <a href="admin.php?page=dokan-withdraw&status=pending" <?php if ($status == 'pending') { echo 'class="current"'; } ?> > <?php _e('Pending', 'dokan'); ?> <span class="count">(<?php echo $counts['pending']; ?> )</span> </a> | </li> <li> <a href="admin.php?page=dokan-withdraw&status=completed" <?php
/** * Withdraw listing for admin * * @param string $status * * @return void */ 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 result 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' => __('«', 'aag'), 'next_text' => __('»', '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( 'Somthig wrong...!!!' ); } }); }); }); })(jQuery) </script> <?php $this->add_note_script(); }
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'])) { if ($_GET['message'] == 'trashed') { ?> <div class="updated"> <p><strong><?php _e('Requests deleted!', 'dokan'); ?> </strong></p> </div> <?php } if ($_GET['message'] == 'cancelled') { ?> <div class="updated"> <p><strong><?php _e('Requests cancelled!', 'dokan'); ?> </strong></p> </div> <?php } if ($_GET['message'] == 'approved') { ?> <div class="updated"> <p><strong><?php _e('Requests approved!', 'dokan'); ?> </strong></p> </div> <?php } } ?> <form method="post" action=""> <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> </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 result 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' => __('«', 'aag'), 'next_text' => __('»', 'aag'), 'total' => $num_of_pages, 'current' => $pagenum)); if ($page_links) { echo '<div class="tablenav-pages">' . $page_links . '</div>'; } } ?> </div> </form> <style type="text/css"> .withdraw-table { margin-top: 10px; } .withdraw-table td, .withdraw-table th { vertical-align: top; } </style> <?php $this->add_note_script(); }