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.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / classes / Withdraw_Requests_List.php
tutor / classes Last commit date
Addons.php 5 years ago Admin.php 5 years ago Ajax.php 5 years ago Assets.php 5 years ago Course.php 5 years ago Course_Filter.php 5 years ago Course_Settings_Tabs.php 5 years ago Course_Widget.php 5 years ago Custom_Validation.php 5 years ago Dashboard.php 5 years ago Email.php 5 years ago FormHandler.php 5 years ago Frontend.php 5 years ago Gutenberg.php 5 years ago Instructor.php 5 years ago Instructors_List.php 5 years ago Lesson.php 5 years ago Options.php 5 years ago Post_types.php 5 years ago Private_Course_Access.php 5 years ago Q_and_A.php 5 years ago Question_Answers_List.php 5 years ago Quiz.php 5 years ago Quiz_Attempts_List.php 5 years ago RestAPI.php 5 years ago Rewrite_Rules.php 5 years ago Shortcode.php 5 years ago Student.php 5 years ago Students_List.php 5 years ago Taxonomies.php 5 years ago Template.php 5 years ago Theme_Compatibility.php 5 years ago Tools.php 5 years ago Tutor.php 5 years ago TutorEDD.php 5 years ago Tutor_Base.php 5 years ago Tutor_List_Table.php 5 years ago Tutor_Setup.php 5 years ago Upgrader.php 5 years ago User.php 5 years ago Utils.php 5 years ago Video_Stream.php 5 years ago Withdraw.php 5 years ago Withdraw_Requests_List.php 5 years ago WooCommerce.php 5 years ago
Withdraw_Requests_List.php
216 lines
1 <?php
2 namespace TUTOR;
3
4 if ( ! defined( 'ABSPATH' ) )
5 exit;
6
7 if (! class_exists('Tutor_List_Table')){
8 include_once tutor()->path.'classes/Tutor_List_Table.php';
9 }
10
11 class Withdraw_Requests_List extends \Tutor_List_Table {
12
13 const WITHDRAW_REQUEST_LIST_PAGE = 'tutor_withdraw_requests';
14
15 function __construct(){
16 global $status, $page;
17
18 //Set parent defaults
19 parent::__construct( array(
20 'singular' => 'withdraw', //singular name of the listed records
21 'plural' => 'withdraw', //plural name of the listed records
22 'ajax' => false //does this table support ajax?
23 ) );
24
25 $this->process_bulk_action();
26 }
27
28 function column_default($item, $column_name){
29 switch($column_name){
30 case 'testing_col':
31 return $item->$column_name;
32 default:
33 return print_r($item,true); //Show the whole array for troubleshooting purposes
34 }
35 }
36
37 function column_cb($item){
38 return sprintf(
39 '<input type="checkbox" name="%1$s[]" value="%2$s" />',
40 /*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("student")
41 /*$2%s*/ $item->withdraw_id //The value of the checkbox should be the record's id
42 );
43 }
44
45 function column_requested_user($item){
46 echo "<p>{$item->user_name}</p><p>{$item->user_email}</p>";
47
48 $actions = array();
49 switch ($item->status){
50 case 'pending':
51 $actions['approved'] = sprintf('<a href="?page=%s&action=%s&withdraw_id=%s">'.__('Approve', 'tutor').'</a>',self::WITHDRAW_REQUEST_LIST_PAGE,'approved',
52 $item->withdraw_id);
53 $actions['rejected'] = sprintf('<a href="?page=%s&action=%s&withdraw_id=%s">'.__('Rejected', 'tutor').'</a>',self::WITHDRAW_REQUEST_LIST_PAGE,'rejected',$item->withdraw_id);
54 break;
55 case 'approved':
56 $actions['rejected'] = sprintf('<a href="?page=%s&action=%s&withdraw_id=%s">'.__('Rejected', 'tutor').'</a>',self::WITHDRAW_REQUEST_LIST_PAGE,'rejected',$item->withdraw_id);
57 break;
58 case 'rejected':
59 $actions['approved'] = sprintf('<a href="?page=%s&action=%s&withdraw_id=%s">'.__('Approve', 'tutor').'</a>',self::WITHDRAW_REQUEST_LIST_PAGE,'approved',$item->withdraw_id);
60 break;
61 }
62
63 $actions['delete'] = sprintf('<a href="?page=%s&action=%s&withdraw_id=%s" onclick="return confirm(\'Are you Sure? It can not be undone\')">'.__('Delete', 'tutor').'</a>',self::WITHDRAW_REQUEST_LIST_PAGE,'delete',
64 $item->withdraw_id);
65
66 return "<div class='withdraw-list-row-actions'>". $this->row_actions($actions)."</div>";
67 }
68 function column_withdraw_method($item){
69 if ($item->method_data){
70 $data = maybe_unserialize($item->method_data);
71
72 $method_name = tutor_utils()->avalue_dot('withdraw_method_name', $data);
73
74 if ($method_name){
75 echo "<p><strong>{$method_name}</strong></p>";
76 }
77
78 unset($data['withdraw_method_key'], $data['withdraw_method_name']);
79
80 if (tutor_utils()->count($data)){
81 foreach ($data as $method_field){
82 $label = tutor_utils()->avalue_dot('label', $method_field);
83 $value = tutor_utils()->avalue_dot('value', $method_field);
84 echo "<p class='withdraw-method-data-row'> <span class='withdraw-method-label'>{$label}</span> : <span class='withdraw-method-value'>{$value}</span> </p>";
85 }
86 }
87
88 }
89 return '';
90 }
91
92 function column_requested_at($item){
93 echo "<p>".date_i18n(get_option('date_format').' '.get_option('time_format'), strtotime($item->created_at))."</p>";
94 }
95
96 function column_amount($item){
97 echo "<p>".tutor_utils()->tutor_price($item->amount)."</p>";
98 echo "<p><span class='withdraw-status withdraw-status-{$item->status}'>{$item->status}</span></p>";
99 }
100
101 function get_columns(){
102 $columns = array(
103 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
104 'requested_user' => __('Requested By', 'tutor'),
105 'amount' => __('Amount', 'tutor'),
106 'withdraw_method' => __('Withdrawal Method', 'tutor'),
107 'requested_at' => __('Requested Time', 'tutor'),
108 );
109 return $columns;
110 }
111
112 function get_bulk_actions() {
113 $actions = array(
114 //'delete' => 'Delete'
115 );
116 return $actions;
117 }
118
119 function process_bulk_action() {
120 global $wpdb;
121
122 $withdraw_page_url = admin_url('admin.php?page=' . self::WITHDRAW_REQUEST_LIST_PAGE);
123 $date = date("Y-m-d H:i:s", tutor_time());
124 $redirect = false;
125
126 //Detect when a bulk action is being triggered...
127 if( 'delete'===$this->current_action() ) {
128 $should_withdraw_delete = apply_filters('tutor_should_withdraw_delete', true);
129
130 if ($should_withdraw_delete){
131 $withdraw_id = (int) sanitize_text_field($_GET['withdraw_id']);
132
133 do_action('tutor_before_delete_withdraw', $withdraw_id);
134
135 $wpdb->delete($wpdb->prefix."tutor_withdraws",array('withdraw_id' =>$withdraw_id));
136
137 do_action('tutor_after_delete_withdraw', $withdraw_id);
138
139 $redirect = true;
140 }else{
141 wp_die('Items deleted (or they would be if we had items to delete)!');
142 }
143 }
144
145
146 /**
147 * Reject Withdraw
148 */
149 if( 'approved' === $this->current_action() ) {
150 $withdraw_id = (int) sanitize_text_field($_GET['withdraw_id']);
151 $withdraw = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}tutor_withdraws WHERE withdraw_id = %d ", $withdraw_id));
152 if ( ! $withdraw || $withdraw->status === 'approved'){
153 return;
154 }
155
156 do_action('tutor_before_approved_withdraw', $withdraw_id);
157
158 $wpdb->update($wpdb->prefix."tutor_withdraws", array('status' => 'approved', 'updated_at' => $date ), array('withdraw_id' =>$withdraw_id));
159
160 do_action('tutor_after_approved_withdraw', $withdraw_id);
161
162 $redirect = true;
163 }
164
165 /**
166 * Rejected
167 */
168 if( 'rejected' === $this->current_action() ) {
169 $withdraw_id = (int) sanitize_text_field($_GET['withdraw_id']);
170 $withdraw = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}tutor_withdraws WHERE withdraw_id = %d ", $withdraw_id));
171 if ( ! $withdraw || $withdraw->status === 'rejected'){
172 return;
173 }
174
175 do_action('tutor_before_rejected_withdraw', $withdraw_id);
176
177 $wpdb->update($wpdb->prefix."tutor_withdraws", array('status' => 'rejected', 'updated_at' => $date ), array('withdraw_id' =>$withdraw_id));
178
179 do_action('tutor_after_rejected_withdraw', $withdraw_id);
180
181 $redirect = true;
182 }
183
184
185 if ($redirect){
186 die("<script>location.href='{$withdraw_page_url}';</script>");
187 }
188 }
189
190 function prepare_items() {
191 $per_page = 20;
192
193 $search_term = '';
194 if (isset($_REQUEST['s'])){
195 $search_term = sanitize_text_field($_REQUEST['s']);
196 }
197
198 $columns = $this->get_columns();
199 $hidden = array();
200
201 $this->_column_headers = array($columns, $hidden);
202 $current_page = $this->get_pagenum();
203
204 $start = ($current_page-1)*$per_page;
205 $withdraw_requests = tutor_utils()->get_withdrawals_history(null, compact('start', 'per_page', 'search_term') );
206 $this->items = $withdraw_requests->results;
207 $count_result = $withdraw_requests->count;
208
209 $this->set_pagination_args( array(
210 'total_items' => $count_result,
211 'per_page' => $per_page,
212 'total_pages' => ceil($count_result/$per_page)
213 ) );
214 }
215 }
216