dashboard.php
5 months ago
download-history.php
5 months ago
edit-profile.php
5 months ago
profile.php
5 months ago
download-history.php
231 lines
| 1 | <?php |
| 2 | /** |
| 3 | * User Dashboard - Download History |
| 4 | * Enterprise-grade design |
| 5 | */ |
| 6 | |
| 7 | use WPDM\__\__; |
| 8 | |
| 9 | if (!defined('ABSPATH')) die(); |
| 10 | |
| 11 | global $wpdb, $current_user, $wp_query; |
| 12 | |
| 13 | $items_per_page = 20; |
| 14 | $current_page = isset($_GET['pgd']) ? max(1, absint($_GET['pgd'])) : 1; |
| 15 | $start = ($current_page - 1) * $items_per_page; |
| 16 | |
| 17 | // Get total count for pagination |
| 18 | $total_items = (int) $wpdb->get_var($wpdb->prepare( |
| 19 | "SELECT COUNT(*) FROM {$wpdb->prefix}ahm_download_stats WHERE uid = %d", |
| 20 | $current_user->ID |
| 21 | )); |
| 22 | |
| 23 | // Get paginated results |
| 24 | $downloads = $wpdb->get_results($wpdb->prepare( |
| 25 | "SELECT p.post_title, s.* FROM {$wpdb->prefix}posts p, {$wpdb->prefix}ahm_download_stats s |
| 26 | WHERE s.uid = %d AND s.pid = p.ID |
| 27 | ORDER BY s.timestamp DESC |
| 28 | LIMIT %d, %d", |
| 29 | $current_user->ID, |
| 30 | $start, |
| 31 | $items_per_page |
| 32 | )); |
| 33 | |
| 34 | $total_pages = ceil($total_items / $items_per_page); |
| 35 | ?> |
| 36 | |
| 37 | <?php do_action("wpdm_before_download_history"); ?> |
| 38 | |
| 39 | <?php if (class_exists('\WPDM\AddOn\DownloadLimit')): ?> |
| 40 | <!-- Download Limit Info --> |
| 41 | <div class="row mb-3"> |
| 42 | <div class="col-md-6 mb-2"> |
| 43 | <div class="card h-100"> |
| 44 | <div class="card-body py-3"> |
| 45 | <div class="media"> |
| 46 | <div class="mr-3 text-info"> |
| 47 | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg> |
| 48 | </div> |
| 49 | <div class="media-body"> |
| 50 | <small class="text-muted d-block"><?php esc_html_e('Reset Timer', 'download-manager'); ?></small> |
| 51 | <strong><?php echo do_shortcode("[wpdm_download_limit_reset_timer]"); ?></strong> |
| 52 | </div> |
| 53 | </div> |
| 54 | </div> |
| 55 | </div> |
| 56 | </div> |
| 57 | <div class="col-md-6 mb-2"> |
| 58 | <div class="card h-100"> |
| 59 | <div class="card-body py-3"> |
| 60 | <div class="media"> |
| 61 | <div class="mr-3 text-warning"> |
| 62 | <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg> |
| 63 | </div> |
| 64 | <div class="media-body"> |
| 65 | <small class="text-muted d-block"><?php esc_html_e('Download Limit', 'download-manager'); ?></small> |
| 66 | <strong><?php echo do_shortcode("[wpdm_user_download_count]"); ?> / <?php echo do_shortcode("[wpdm_user_download_limit]"); ?></strong> |
| 67 | </div> |
| 68 | </div> |
| 69 | </div> |
| 70 | </div> |
| 71 | </div> |
| 72 | </div> |
| 73 | <?php endif; ?> |
| 74 | |
| 75 | <!-- Download History Card --> |
| 76 | <div class="wpdm-card"> |
| 77 | <div class="wpdm-card-header"> |
| 78 | <h3> |
| 79 | <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg> |
| 80 | <?php esc_html_e('Download History', 'download-manager'); ?> |
| 81 | </h3> |
| 82 | <?php if ($total_items > 0): ?> |
| 83 | <span class="wpdm-badge wpdm-badge--info"><?php echo number_format($total_items); ?> <?php esc_html_e('total', 'download-manager'); ?></span> |
| 84 | <?php endif; ?> |
| 85 | </div> |
| 86 | |
| 87 | <?php if (!empty($downloads)): ?> |
| 88 | <div class="wpdm-table-wrap"> |
| 89 | <table class="wpdm-table"> |
| 90 | <thead> |
| 91 | <tr> |
| 92 | <th><?php esc_html_e('Package / File', 'download-manager'); ?></th> |
| 93 | <th class="wpdm-hide-mobile"><?php esc_html_e('Download Time', 'download-manager'); ?></th> |
| 94 | <th class="wpdm-hide-mobile" style="width: 120px;"><?php esc_html_e('IP Address', 'download-manager'); ?></th> |
| 95 | </tr> |
| 96 | </thead> |
| 97 | <tbody> |
| 98 | <?php foreach ($downloads as $stat): ?> |
| 99 | <tr> |
| 100 | <td> |
| 101 | <div class="wpdm-product-cell"> |
| 102 | <a class="wpdm-table-link wpdm-product-name" href="<?php echo esc_url(get_permalink($stat->pid)); ?>"> |
| 103 | <?php echo esc_html($stat->post_title); ?> |
| 104 | </a> |
| 105 | <?php if (!empty($stat->filename)): ?> |
| 106 | <span class="wpdm-file-meta"> |
| 107 | <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg> |
| 108 | <?php echo esc_html(__::mask($stat->filename, '...', -25, false) ?: 'Package'); ?> |
| 109 | </span> |
| 110 | <?php endif; ?> |
| 111 | <span class="wpdm-mobile-meta wpdm-show-mobile"> |
| 112 | <?php echo date_i18n(get_option('date_format') . ' H:i', $stat->timestamp + __::timezoneOffset()); ?> |
| 113 | </span> |
| 114 | </div> |
| 115 | </td> |
| 116 | <td class="wpdm-hide-mobile"> |
| 117 | <span class="wpdm-date"><?php echo date_i18n(get_option('date_format') . ' H:i', $stat->timestamp + __::timezoneOffset()); ?></span> |
| 118 | </td> |
| 119 | <td class="wpdm-hide-mobile"> |
| 120 | <span class="wpdm-ip"><?php echo esc_html($stat->ip); ?></span> |
| 121 | </td> |
| 122 | </tr> |
| 123 | <?php endforeach; ?> |
| 124 | </tbody> |
| 125 | </table> |
| 126 | </div> |
| 127 | |
| 128 | <?php if ($total_pages > 1): ?> |
| 129 | <div class="wpdm-card-footer"> |
| 130 | <div class="wpdm-pagination"> |
| 131 | <?php |
| 132 | $pagination_args = array( |
| 133 | 'base' => add_query_arg('pgd', '%#%'), |
| 134 | 'format' => '', |
| 135 | 'total' => $total_pages, |
| 136 | 'current' => $current_page, |
| 137 | 'show_all' => false, |
| 138 | 'end_size' => 1, |
| 139 | 'mid_size' => 2, |
| 140 | 'prev_next' => true, |
| 141 | 'prev_text' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>', |
| 142 | 'next_text' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>', |
| 143 | 'type' => 'plain', |
| 144 | ); |
| 145 | echo paginate_links($pagination_args); |
| 146 | ?> |
| 147 | </div> |
| 148 | </div> |
| 149 | <?php endif; ?> |
| 150 | |
| 151 | <?php else: ?> |
| 152 | <div class="wpdm-card-body"> |
| 153 | <div class="wpdm-empty-state wpdm-empty-state--compact"> |
| 154 | <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg> |
| 155 | <h4><?php esc_html_e('No download history', 'download-manager'); ?></h4> |
| 156 | <p><?php esc_html_e("You haven't downloaded any files yet.", 'download-manager'); ?></p> |
| 157 | </div> |
| 158 | </div> |
| 159 | <?php endif; ?> |
| 160 | </div> |
| 161 | |
| 162 | <?php do_action("wpdm_after_download_history"); ?> |
| 163 | |
| 164 | <style> |
| 165 | .wpdm-file-meta { |
| 166 | display: inline-flex; |
| 167 | align-items: center; |
| 168 | gap: 0.375rem; |
| 169 | font-size: 0.8125rem; |
| 170 | color: #64748b; |
| 171 | } |
| 172 | .wpdm-file-meta svg { |
| 173 | color: #94a3b8; |
| 174 | } |
| 175 | .wpdm-mobile-meta { |
| 176 | display: none; |
| 177 | font-size: 0.75rem; |
| 178 | color: #94a3b8; |
| 179 | margin-top: 0.25rem; |
| 180 | } |
| 181 | @media (max-width: 768px) { |
| 182 | .wpdm-show-mobile { |
| 183 | display: block; |
| 184 | } |
| 185 | } |
| 186 | .wpdm-pagination { |
| 187 | display: flex; |
| 188 | justify-content: center; |
| 189 | align-items: center; |
| 190 | gap: 0.25rem; |
| 191 | flex-wrap: wrap; |
| 192 | } |
| 193 | .wpdm-pagination a, |
| 194 | .wpdm-pagination span { |
| 195 | display: inline-flex; |
| 196 | align-items: center; |
| 197 | justify-content: center; |
| 198 | min-width: 36px; |
| 199 | height: 36px; |
| 200 | padding: 0 0.75rem; |
| 201 | font-size: 0.875rem; |
| 202 | font-weight: 500; |
| 203 | color: #475569; |
| 204 | background: #fff; |
| 205 | border: 1px solid #e2e8f0; |
| 206 | border-radius: 0.5rem; |
| 207 | text-decoration: none; |
| 208 | transition: all 0.15s ease; |
| 209 | } |
| 210 | .wpdm-pagination a:hover { |
| 211 | background: #f1f5f9; |
| 212 | border-color: #cbd5e1; |
| 213 | color: #1e293b; |
| 214 | } |
| 215 | .wpdm-pagination .current { |
| 216 | background: var(--wpdm-primary, #008fef); |
| 217 | border-color: var(--wpdm-primary, #008fef); |
| 218 | color: #fff; |
| 219 | } |
| 220 | .wpdm-pagination .prev, |
| 221 | .wpdm-pagination .next { |
| 222 | padding: 0; |
| 223 | min-width: 36px; |
| 224 | } |
| 225 | .wpdm-pagination .dots { |
| 226 | border: none; |
| 227 | background: transparent; |
| 228 | color: #94a3b8; |
| 229 | } |
| 230 | </style> |
| 231 |