admin-summary.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. if (!defined('WPINC')) {
  3. die;
  4. }
  5. /** @var array $records */
  6. /** @var int $total */
  7. /** @var int $total_pages */
  8. /** @var int $current_page */
  9. /** @var string $current_status */
  10. /** @var int $current_product */
  11. /** @var string $current_search */
  12. /** @var int $per_page */
  13. /** @var array $fpp_products */
  14. $base_url = admin_url('edit.php?post_type=product&page=studiou-fpp-summary');
  15. ?>
  16. <div class="wrap studiou-fpp-admin-wrap">
  17. <h1><?php esc_html_e('Free Photo Files', 'studiou-wc-free-photo-product'); ?></h1>
  18. <div class="studiou-fpp-admin-notice-area"></div>
  19. <!-- Filters -->
  20. <div class="studiou-fpp-filters">
  21. <form method="get" action="<?php echo esc_url(admin_url('edit.php')); ?>">
  22. <input type="hidden" name="post_type" value="product" />
  23. <input type="hidden" name="page" value="studiou-fpp-summary" />
  24. <select name="status">
  25. <option value=""><?php esc_html_e('All Statuses', 'studiou-wc-free-photo-product'); ?></option>
  26. <option value="ready" <?php selected($current_status, 'ready'); ?>><?php esc_html_e('Ready', 'studiou-wc-free-photo-product'); ?></option>
  27. <option value="downloaded" <?php selected($current_status, 'downloaded'); ?>><?php esc_html_e('Downloaded', 'studiou-wc-free-photo-product'); ?></option>
  28. <option value="solved" <?php selected($current_status, 'solved'); ?>><?php esc_html_e('Solved', 'studiou-wc-free-photo-product'); ?></option>
  29. </select>
  30. <select name="product_id">
  31. <option value=""><?php esc_html_e('All Products', 'studiou-wc-free-photo-product'); ?></option>
  32. <?php foreach ($fpp_products as $pid => $pname) : ?>
  33. <option value="<?php echo esc_attr($pid); ?>" <?php selected($current_product, $pid); ?>><?php echo esc_html($pname); ?></option>
  34. <?php endforeach; ?>
  35. </select>
  36. <input type="search" name="s" value="<?php echo esc_attr($current_search); ?>" placeholder="<?php esc_attr_e('Search file name...', 'studiou-wc-free-photo-product'); ?>" />
  37. <button type="submit" class="button"><?php esc_html_e('Filter', 'studiou-wc-free-photo-product'); ?></button>
  38. </form>
  39. </div>
  40. <!-- Bulk actions -->
  41. <div class="studiou-fpp-bulk-actions">
  42. <select id="studiou-fpp-bulk-action">
  43. <option value=""><?php esc_html_e('Bulk Actions', 'studiou-wc-free-photo-product'); ?></option>
  44. <option value="download_zip"><?php esc_html_e('Download ZIP', 'studiou-wc-free-photo-product'); ?></option>
  45. <option value="status_ready"><?php esc_html_e('Set Status: Ready', 'studiou-wc-free-photo-product'); ?></option>
  46. <option value="status_downloaded"><?php esc_html_e('Set Status: Downloaded', 'studiou-wc-free-photo-product'); ?></option>
  47. <option value="status_solved"><?php esc_html_e('Set Status: Solved', 'studiou-wc-free-photo-product'); ?></option>
  48. <option value="delete"><?php esc_html_e('Delete', 'studiou-wc-free-photo-product'); ?></option>
  49. </select>
  50. <button type="button" class="button" id="studiou-fpp-bulk-apply"><?php esc_html_e('Apply', 'studiou-wc-free-photo-product'); ?></button>
  51. <span class="spinner" id="studiou-fpp-bulk-spinner"></span>
  52. <span class="studiou-fpp-total-count">
  53. <?php echo esc_html(sprintf(
  54. _n('%d file', '%d files', $total, 'studiou-wc-free-photo-product'),
  55. $total
  56. )); ?>
  57. </span>
  58. </div>
  59. <!-- Files table -->
  60. <table class="wp-list-table widefat fixed striped studiou-fpp-files-table">
  61. <thead>
  62. <tr>
  63. <td class="manage-column column-cb check-column">
  64. <input type="checkbox" id="studiou-fpp-select-all" />
  65. </td>
  66. <th class="column-thumbnail"><?php esc_html_e('Preview', 'studiou-wc-free-photo-product'); ?></th>
  67. <th class="column-filename"><?php esc_html_e('File Name', 'studiou-wc-free-photo-product'); ?></th>
  68. <th class="column-product"><?php esc_html_e('Product', 'studiou-wc-free-photo-product'); ?></th>
  69. <th class="column-order"><?php esc_html_e('Order', 'studiou-wc-free-photo-product'); ?></th>
  70. <th class="column-customer"><?php esc_html_e('Customer', 'studiou-wc-free-photo-product'); ?></th>
  71. <th class="column-status"><?php esc_html_e('Status', 'studiou-wc-free-photo-product'); ?></th>
  72. <th class="column-date"><?php esc_html_e('Date', 'studiou-wc-free-photo-product'); ?></th>
  73. <th class="column-actions"><?php esc_html_e('Actions', 'studiou-wc-free-photo-product'); ?></th>
  74. </tr>
  75. </thead>
  76. <tbody>
  77. <?php if (empty($records)) : ?>
  78. <tr>
  79. <td colspan="9"><?php esc_html_e('No files found.', 'studiou-wc-free-photo-product'); ?></td>
  80. </tr>
  81. <?php else : ?>
  82. <?php foreach ($records as $record) :
  83. $attachment_url = wp_get_attachment_url($record->attachment_id);
  84. $thumb = wp_get_attachment_image_src($record->attachment_id, 'thumbnail');
  85. $thumb_url = $thumb ? $thumb[0] : wp_mime_type_icon($record->attachment_id);
  86. $product_title = get_the_title($record->product_id);
  87. $customer_name = '';
  88. if ($record->customer_id > 0) {
  89. $user = get_userdata($record->customer_id);
  90. $customer_name = $user ? $user->display_name : '#' . $record->customer_id;
  91. } else {
  92. $customer_name = __('Guest', 'studiou-wc-free-photo-product');
  93. }
  94. $order_link = '';
  95. if ($record->order_id > 0) {
  96. $order_url = Studiou_WC_FPP_Admin::get_order_edit_url($record->order_id);
  97. $order_link = '<a href="' . esc_url($order_url) . '">#' . esc_html($record->order_id) . '</a>';
  98. } else {
  99. $order_link = '<span class="studiou-fpp-no-order">—</span>';
  100. }
  101. ?>
  102. <tr data-file-id="<?php echo esc_attr($record->id); ?>">
  103. <th scope="row" class="check-column">
  104. <input type="checkbox" class="studiou-fpp-file-cb" value="<?php echo esc_attr($record->id); ?>" />
  105. </th>
  106. <td class="column-thumbnail">
  107. <img src="<?php echo esc_url($thumb_url); ?>" alt="" class="studiou-fpp-thumb" />
  108. </td>
  109. <td class="column-filename">
  110. <?php if ($attachment_url) : ?>
  111. <a href="<?php echo esc_url($attachment_url); ?>" target="_blank"><?php echo esc_html($record->file_name); ?></a>
  112. <?php else : ?>
  113. <?php echo esc_html($record->file_name); ?>
  114. <?php endif; ?>
  115. </td>
  116. <td class="column-product">
  117. <a href="<?php echo esc_url(get_edit_post_link($record->product_id)); ?>"><?php echo esc_html($product_title); ?></a>
  118. </td>
  119. <td class="column-order">
  120. <?php echo $order_link; ?>
  121. </td>
  122. <td class="column-customer">
  123. <?php echo esc_html($customer_name); ?>
  124. </td>
  125. <td class="column-status">
  126. <select class="studiou-fpp-status-select" data-file-id="<?php echo esc_attr($record->id); ?>">
  127. <option value="ready" <?php selected($record->status, 'ready'); ?>><?php esc_html_e('Ready', 'studiou-wc-free-photo-product'); ?></option>
  128. <option value="downloaded" <?php selected($record->status, 'downloaded'); ?>><?php esc_html_e('Downloaded', 'studiou-wc-free-photo-product'); ?></option>
  129. <option value="solved" <?php selected($record->status, 'solved'); ?>><?php esc_html_e('Solved', 'studiou-wc-free-photo-product'); ?></option>
  130. </select>
  131. </td>
  132. <td class="column-date">
  133. <?php echo esc_html(date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($record->created_at))); ?>
  134. </td>
  135. <td class="column-actions">
  136. <?php if ($attachment_url) : ?>
  137. <a href="<?php echo esc_url($attachment_url); ?>" class="button button-small" download title="<?php esc_attr_e('Download', 'studiou-wc-free-photo-product'); ?>">
  138. <span class="dashicons dashicons-download" style="line-height:1.4;"></span>
  139. </a>
  140. <?php endif; ?>
  141. <button type="button" class="button button-small studiou-fpp-delete-single" data-file-id="<?php echo esc_attr($record->id); ?>" title="<?php esc_attr_e('Delete', 'studiou-wc-free-photo-product'); ?>">
  142. <span class="dashicons dashicons-trash" style="line-height:1.4;color:#b32d2e;"></span>
  143. </button>
  144. </td>
  145. </tr>
  146. <?php endforeach; ?>
  147. <?php endif; ?>
  148. </tbody>
  149. </table>
  150. <!-- Pagination -->
  151. <?php if ($total_pages > 1) : ?>
  152. <div class="tablenav bottom">
  153. <div class="tablenav-pages">
  154. <?php
  155. $pagination = paginate_links(array(
  156. 'base' => add_query_arg('paged', '%#%'),
  157. 'format' => '',
  158. 'current' => $current_page,
  159. 'total' => $total_pages,
  160. 'prev_text' => '&laquo;',
  161. 'next_text' => '&raquo;',
  162. ));
  163. if ($pagination) {
  164. echo $pagination;
  165. }
  166. ?>
  167. </div>
  168. </div>
  169. <?php endif; ?>
  170. </div>