PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.9.6
Subscriptions for WooCommerce with Stripe Recurring Payments v1.9.6
2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / includes / Admin / views / subscription-list.php

subscription-list.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.9.6, at includes/Admin/views/subscription-list.php

277 lines 12.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Subscription admin list view.
4 *
5 * @package SpringDevs\Subscription\Admin
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 if ( ! isset( $date_filter ) ) {
14 $date_filter = '';
15 }
16
17 // Determine if filters are active
18 $filters_active = ! empty( $status ) || ! empty( $date_filter ) || ! empty( $search );
19 $months = array();
20 for ( $i = 0; $i < 12; $i++ ) {
21 $month = strtotime( "-$i month" );
22 $months[ date( 'Y-m', $month ) ] = date( 'F Y', $month );
23 }
24 ?>
25 <div class="wp-subscription-admin-content list-page">
26 <div class="wp-subscription-list-title"><h1 class="wp-heading-inline">Subscriptions</h1></div>
27
28 <form method="post" id="subscriptions-form">
29 <div class="wp-subscription-list-header">
30 <div class="wp-subscription-filters">
31 <?php wp_nonce_field( 'subscrpt_list_action' ); ?>
32 <input type="hidden" name="page" value="wp-subscription" />
33 <select name="subscrpt_status" value="<?php echo esc_attr( $status ); ?>">
34 <option value=""><?php esc_html_e( 'All Status', 'subscription' ); ?></option>
35 <option value="active" <?php selected( $status, 'active' ); ?>><?php esc_html_e( 'Active', 'subscription' ); ?></option>
36 <option value="pending" <?php selected( $status, 'pending' ); ?>><?php esc_html_e( 'Pending', 'subscription' ); ?></option>
37 <option value="cancelled" <?php selected( $status, 'cancelled' ); ?>><?php esc_html_e( 'Cancelled', 'subscription' ); ?></option>
38 <option value="expired" <?php selected( $status, 'expired' ); ?>><?php esc_html_e( 'Expired', 'subscription' ); ?></option>
39 <option value="draft" <?php selected( $status, 'draft' ); ?>><?php esc_html_e( 'Draft', 'subscription' ); ?></option>
40 <option value="trash" <?php selected( $status, 'trash' ); ?>><?php esc_html_e( 'Trash', 'subscription' ); ?></option>
41 </select>
42 <select name="date_filter" value="<?php echo esc_attr( $date_filter ); ?>">
43 <option value=""><?php esc_html_e( 'All Dates', 'subscription' ); ?></option>
44 <?php foreach ( $months as $val => $label ) : ?>
45 <option value="<?php echo esc_attr( $val ); ?>" <?php selected( $date_filter, $val ); ?>><?php echo esc_html( $label ); ?></option>
46 <?php endforeach; ?>
47 </select>
48 <input type="search" name="s" value="<?php echo esc_attr( $search ); ?>" placeholder="<?php esc_attr_e( 'Search by subscription ID...', 'subscription' ); ?>" />
49 <select name="per_page">
50 <?php foreach ( array( 10, 20, 50, 100 ) as $n ) : ?>
51 <option value="<?php echo (int) $n; ?>" <?php selected( isset( $_GET['per_page'] ) ? intval( wp_unslash( $_GET['per_page'] ) ) : 20, $n ); ?>><?php echo (int) $n; ?> per page</option>
52 <?php endforeach; ?>
53 </select>
54 <button type="submit" name="filter_action" value="filter" class="button">Search</button>
55 <?php if ( $filters_active ) : ?>
56 <a href="<?php echo esc_url( remove_query_arg( array( 'subscrpt_status', 'date_filter', 's', 'title', 'paged' ) ) ); ?>" class="button">Reset</a>
57 <?php endif; ?>
58 <?php if ( $filters_active ) : ?>
59 <span>Filters applied</span>
60 <?php endif; ?>
61 </div>
62
63 <?php if ( ! empty( $subscriptions ) ) : ?>
64 <div class="wp-subscription-bulk-actions">
65 <select name="action">
66 <option value="-1"><?php esc_html_e( 'Bulk Actions', 'subscription' ); ?></option>
67 <?php if ( $status === 'trash' ) : ?>
68 <option value="restore"><?php esc_html_e( 'Restore', 'subscription' ); ?></option>
69 <option value="delete"><?php esc_html_e( 'Delete Permanently', 'subscription' ); ?></option>
70 <?php else : ?>
71 <option value="trash"><?php esc_html_e( 'Move to Trash', 'subscription' ); ?></option>
72 <?php endif; ?>
73 </select>
74 <input type="submit" name="bulk_action" value="<?php esc_attr_e( 'Apply', 'subscription' ); ?>" class="button action">
75 <?php if ( $status === 'trash' && ! empty( $subscriptions ) ) : ?>
76 <?php
77 $nonce_action = 'wpsubs_action_clean_trash';
78 $empty_trash_url = wp_nonce_url( admin_url( 'admin.php?page=wp-subscription&action=clean_trash&sub_id=all' ), $nonce_action );
79 ?>
80 <a href="<?php echo esc_url( $empty_trash_url ); ?>"
81 class="button button-link-delete"
82 onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to permanently delete all items in trash? This action cannot be undone.', 'subscription' ); ?>')">
83 <?php esc_html_e( 'Empty Trash', 'subscription' ); ?>
84 </a>
85 <?php endif; ?>
86 </div>
87 <?php endif; ?>
88 </div>
89
90 <h2 class="screen-reader-text">Subscriptions list</h2>
91 <table class="wp-list-table widefat fixed striped wp-subscription-modern-table">
92 <thead>
93 <tr>
94 <th style="width:20px;"><input type="checkbox" id="cb-select-all-1"></th>
95 <th style="width:180px;">ID</th>
96 <th style="min-width:320px;">Title</th>
97 <th style="width:180px;">Customer</th>
98 <th style="width:100px;">Start Date</th>
99 <th style="width:100px;">Renewal Date</th>
100 <th style="width:100px;">Status</th>
101 <th style="width:80px;">Actions</th>
102 </tr>
103 </thead>
104 <tbody>
105 <?php if ( ! empty( $subscriptions ) ) : ?>
106 <?php
107 foreach ( $subscriptions as $subscription ) :
108 $subscription_id = $subscription->ID;
109 $subscription_data = SpringDevs\Subscription\Illuminate\Helper::get_subscription_data( $subscription_id );
110
111 $subscrpt_status = $subscription_data['status'] ?? '';
112 $subscrpt_status = empty( $subscrpt_status ) ? get_post_status( $subscription_id ) : $subscrpt_status;
113
114 $order_id = $subscription_data['order']['order_id'] ?? 0;
115 $order_item_id = $subscription_data['order']['order_item_id'] ?? 0;
116 $order = $order_id ? wc_get_order( $order_id ) : null;
117 $order_item = $order ? $order->get_item( $order_item_id ) : null;
118 $product_name = $order_item ? $order_item->get_name() : '-';
119
120 $customer = $order ? $order->get_formatted_billing_full_name() : '-';
121 $customer_id = $order ? $order->get_customer_id() : 0;
122 $customer_url = $customer_id ? admin_url( 'user-edit.php?user_id=' . $customer_id ) : '';
123 $customer_email = $order ? $order->get_billing_email() : '';
124
125 $start_date = $subscription_data['start_date'] ? strtotime( $subscription_data['start_date'] ) : 0;
126 $renewal_date = $subscription_data['next_date'] ? strtotime( $subscription_data['next_date'] ) : 0;
127 $status_obj = get_post_status_object( get_post_status( $subscription->ID ) );
128
129 $is_trash = $subscription->post_status === 'trash';
130
131 $is_grace_period = isset( $subscription_data['grace_period'] );
132 $grace_remaining = $subscription_data['grace_period']['remaining_days'] ?? 0;
133
134 // Build URLs
135 $nonce_action = 'wpsubs_action_' . $subscription->ID;
136 $view_subs_url = get_edit_post_link( $subscription->ID );
137 $duplicate_subs_url = wp_nonce_url( admin_url( 'admin.php?page=wp-subscription&action=duplicate&sub_id=' . $subscription->ID ), $nonce_action );
138 $trash_subs_url = wp_nonce_url( admin_url( 'admin.php?page=wp-subscription&action=trash&sub_id=' . $subscription->ID ), $nonce_action );
139 $del_per_subs_url = wp_nonce_url( admin_url( 'admin.php?page=wp-subscription&action=delete&sub_id=' . $subscription->ID ), $nonce_action );
140 $restore_subs_url = wp_nonce_url( admin_url( 'admin.php?page=wp-subscription&action=restore&sub_id=' . $subscription->ID ), $nonce_action );
141 ?>
142 <tr>
143 <td><input type="checkbox" name="subscription_ids[]" value="<?php echo esc_attr( $subscription->ID ); ?>"></td>
144 <td>
145 <div class="wp-subscription-title-wrap">
146 <a href="<?php echo esc_url( $view_subs_url ); ?>" class="subscrpt-id-link">
147 #<?php echo esc_html( get_the_title( $subscription->ID ) ); ?>
148 </a>
149
150 <div class="wp-subscription-row-actions">
151 <?php if ( ! $is_trash ) : ?>
152 <a href="<?php echo esc_url( $view_subs_url ); ?>">View</a>
153
154 <!-- <a href="<?php echo esc_url( $duplicate_subs_url ); ?>">Duplicate</a> -->
155
156 <a href="<?php echo esc_url( $trash_subs_url ); ?>" onclick="return confirm('<?php esc_attr_e( 'Move this subscription to trash?', 'subscription' ); ?>')">Trash</a>
157
158 <?php else : ?>
159 <a href="<?php echo esc_url( $restore_subs_url ); ?>">Restore</a>
160
161 <a href="<?php echo esc_url( $del_per_subs_url ); ?>" onclick="return confirm('<?php esc_attr_e( 'Delete this subscription permanently? This action cannot be undone.', 'subscription' ); ?>')" style="color:#d93025;">Delete Permanently</a>
162 <?php endif; ?>
163 </div>
164 </div>
165 </td>
166 <td style="min-width:320px;">
167 <span><?php echo esc_html( $product_name ); ?></span>
168 </td>
169 <td>
170 <?php if ( $customer_url ) : ?>
171 <a href="<?php echo esc_url( $customer_url ); ?>" target="_blank"><?php echo esc_html( $customer ); ?></a>
172 <?php else : ?>
173 <?php echo esc_html( $customer ); ?>
174 <?php endif; ?>
175 <?php if ( $customer_email ) : ?>
176 <div class="wp-subscription-customer-email"><?php echo esc_html( $customer_email ); ?></div>
177 <?php endif; ?>
178 </td>
179 <td><?php echo $start_date ? esc_html( wp_date( 'F d, Y', $start_date ) ) : '-'; ?></td>
180 <td><?php echo $renewal_date ? esc_html( wp_date( 'F d, Y', $renewal_date ) ) : '-'; ?></td>
181 <td>
182 <?php if ( $is_grace_period && $grace_remaining > 0 ) : ?>
183 <span class="subscrpt-active grace-active">
184 Active
185
186 <?php
187 $grace_remaining_text = sprintf(
188 // translators: Number of days remaining in grace period.
189 __( '%d days remaining!', 'subscription' ),
190 $grace_remaining
191 );
192 ?>
193 <span class="grace-icon" data-tooltip="<?php echo esc_attr( $grace_remaining_text ); ?>">
194 <span class="dashicons dashicons-warning"></span>
195 </span>
196 </span>
197 <?php else : ?>
198 <span class="subscrpt-<?php echo esc_attr( strtolower( $subscrpt_status ) ); ?>">
199 <?php
200 $verbose_status = SpringDevs\Subscription\Illuminate\Helper::get_verbose_status( $subscrpt_status );
201 echo esc_html( strlen( $verbose_status ) > 9 ? substr( $verbose_status, 0, 9 ) . '...' : $verbose_status );
202 ?>
203 </span>
204 <?php endif; ?>
205 </td>
206 <td>
207 <a href="<?php echo esc_url( get_edit_post_link( $subscription->ID ) ); ?>" class="button button-small"><?php esc_html_e( 'Edit', 'subscription' ); ?></a>
208 </td>
209 </tr>
210 <?php endforeach; ?>
211 <?php else : ?>
212 <tr>
213 <td colspan="8" class="wp-subscription-list-empty">
214 <?php esc_html_e( 'No subscriptions found.', 'subscription' ); ?>
215 </td>
216 </tr>
217 <?php endif; ?>
218 </tbody>
219 </table>
220
221 <?php if ( ! empty( $subscriptions ) ) : ?>
222 <div class="tablenav bottom">
223 <div class="alignleft actions bulkactions">
224 <select name="action2">
225 <option value="-1"><?php esc_html_e( 'Bulk Actions', 'subscription' ); ?></option>
226 <?php if ( $status === 'trash' ) : ?>
227 <option value="restore"><?php esc_html_e( 'Restore', 'subscription' ); ?></option>
228 <option value="delete"><?php esc_html_e( 'Delete Permanently', 'subscription' ); ?></option>
229 <?php else : ?>
230 <option value="trash"><?php esc_html_e( 'Move to Trash', 'subscription' ); ?></option>
231 <?php endif; ?>
232 </select>
233 <input type="submit" name="bulk_action2" value="<?php esc_attr_e( 'Apply', 'subscription' ); ?>" class="button action">
234 </div>
235 </div>
236 <?php endif; ?>
237 </form>
238
239 <?php if ( $max_num_pages > 1 ) : ?>
240 <div class="wp-subscription-pagination">
241 <span class="total">Total <?php echo (int) $total; ?></span>
242 <?php
243 $base_url = remove_query_arg( 'paged' );
244 $show_pages = $max_num_pages > 1 || $max_num_pages == 1;
245 for ( $i = 1; $i <= $max_num_pages; $i++ ) :
246 $url = add_query_arg(
247 array(
248 'paged' => $i,
249 'per_page' => $per_page,
250 ),
251 $base_url
252 );
253 $is_current = $i == $paged;
254 ?>
255 <a href="<?php echo esc_url( $url ); ?>" class="button
256 <?php
257 if ( $is_current ) {
258 echo ' button-primary';}
259 ?>
260 "
261 <?php
262 if ( $is_current ) {
263 echo 'disabled';}
264 ?>
265 ><?php echo (int) $i; ?></a>
266 <?php endfor; ?>
267 <span class="goto-label">Go to</span>
268 <form method="get">
269 <input type="hidden" name="page" value="wp-subscription" />
270 <input type="number" name="paged" min="1" max="<?php echo (int) $max_num_pages; ?>" value="<?php echo (int) $paged; ?>" />
271 <input type="hidden" name="per_page" value="<?php echo (int) $per_page; ?>" />
272 <button type="submit" class="button">OK</button>
273 </form>
274 </div>
275 <?php endif; ?>
276 </div>
277