|
@@ -72,12 +72,18 @@ class StudiouWC_Admin_View {
|
|
|
|
|
|
|
|
$per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 20;
|
|
$per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 20;
|
|
|
$paged = isset($_GET['paged']) ? intval($_GET['paged']) : 1;
|
|
$paged = isset($_GET['paged']) ? intval($_GET['paged']) : 1;
|
|
|
- $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'category';
|
|
|
|
|
|
|
+ $default_orderby = ($view === 'order_customers_list') ? 'customer_name' : 'category';
|
|
|
|
|
+ $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : $default_orderby;
|
|
|
$order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'ASC';
|
|
$order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'ASC';
|
|
|
-
|
|
|
|
|
- // Get report data
|
|
|
|
|
- $report_data = $this->db_manager->get_product_categories_summary($date_from, $date_to, $statuses, $per_page, $paged, $orderby, $order);
|
|
|
|
|
- $total_items = $this->db_manager->get_total_items($date_from, $date_to, $statuses);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Get report data based on view
|
|
|
|
|
+ if ($view === 'order_customers_list') {
|
|
|
|
|
+ $report_data = $this->db_manager->get_order_customers_list($date_from, $date_to, $statuses, $per_page, $paged, $orderby, $order);
|
|
|
|
|
+ $total_items = $this->db_manager->get_order_customers_total_items($date_from, $date_to, $statuses);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $report_data = $this->db_manager->get_product_categories_summary($date_from, $date_to, $statuses, $per_page, $paged, $orderby, $order);
|
|
|
|
|
+ $total_items = $this->db_manager->get_total_items($date_from, $date_to, $statuses);
|
|
|
|
|
+ }
|
|
|
$total_pages = ceil($total_items / $per_page);
|
|
$total_pages = ceil($total_items / $per_page);
|
|
|
|
|
|
|
|
$this->render_reports_page($view, $date_from, $date_to, $statuses, $per_page, $paged, $orderby, $order, $report_data, $total_items, $total_pages, $settings);
|
|
$this->render_reports_page($view, $date_from, $date_to, $statuses, $per_page, $paged, $orderby, $order, $report_data, $total_items, $total_pages, $settings);
|
|
@@ -97,7 +103,11 @@ class StudiouWC_Admin_View {
|
|
|
|
|
|
|
|
<?php if (!empty($report_data)): ?>
|
|
<?php if (!empty($report_data)): ?>
|
|
|
<?php $this->render_pagination_top($total_items, $total_pages, $paged); ?>
|
|
<?php $this->render_pagination_top($total_items, $total_pages, $paged); ?>
|
|
|
- <?php $this->render_data_table($report_data, $orderby, $order, $settings); ?>
|
|
|
|
|
|
|
+ <?php if ($view === 'order_customers_list'): ?>
|
|
|
|
|
+ <?php $this->render_customers_data_table($report_data, $orderby, $order); ?>
|
|
|
|
|
+ <?php else: ?>
|
|
|
|
|
+ <?php $this->render_data_table($report_data, $orderby, $order, $settings); ?>
|
|
|
|
|
+ <?php endif; ?>
|
|
|
<?php else: ?>
|
|
<?php else: ?>
|
|
|
<p><?php _e('No data found for the selected criteria.', StudiouWC_Main::get_text_domain()); ?></p>
|
|
<p><?php _e('No data found for the selected criteria.', StudiouWC_Main::get_text_domain()); ?></p>
|
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
@@ -120,6 +130,9 @@ class StudiouWC_Admin_View {
|
|
|
<option value="product_categories_summary" <?php selected($view, 'product_categories_summary'); ?>>
|
|
<option value="product_categories_summary" <?php selected($view, 'product_categories_summary'); ?>>
|
|
|
<?php _e('Product Categories and Variants Summary', StudiouWC_Main::get_text_domain()); ?>
|
|
<?php _e('Product Categories and Variants Summary', StudiouWC_Main::get_text_domain()); ?>
|
|
|
</option>
|
|
</option>
|
|
|
|
|
+ <option value="order_customers_list" <?php selected($view, 'order_customers_list'); ?>>
|
|
|
|
|
+ <?php _e('Order Customers List', StudiouWC_Main::get_text_domain()); ?>
|
|
|
|
|
+ </option>
|
|
|
</select>
|
|
</select>
|
|
|
</td>
|
|
</td>
|
|
|
</tr>
|
|
</tr>
|
|
@@ -250,6 +263,33 @@ class StudiouWC_Admin_View {
|
|
|
<?php
|
|
<?php
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function render_customers_data_table($report_data, $orderby, $order) {
|
|
|
|
|
+ ?>
|
|
|
|
|
+ <table class="wp-list-table widefat fixed striped">
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th><a href="<?php echo esc_url(add_query_arg(array('orderby' => 'customer_name', 'order' => $order === 'ASC' ? 'DESC' : 'ASC'))); ?>"><?php _e('Customer Name', StudiouWC_Main::get_text_domain()); ?></a></th>
|
|
|
|
|
+ <th><a href="<?php echo esc_url(add_query_arg(array('orderby' => 'customer_email', 'order' => $order === 'ASC' ? 'DESC' : 'ASC'))); ?>"><?php _e('Email', StudiouWC_Main::get_text_domain()); ?></a></th>
|
|
|
|
|
+ <th><?php _e('Phone', StudiouWC_Main::get_text_domain()); ?></th>
|
|
|
|
|
+ <th><a href="<?php echo esc_url(add_query_arg(array('orderby' => 'orders_count', 'order' => $order === 'ASC' ? 'DESC' : 'ASC'))); ?>"><?php _e('Orders Count', StudiouWC_Main::get_text_domain()); ?></a></th>
|
|
|
|
|
+ <th><a href="<?php echo esc_url(add_query_arg(array('orderby' => 'total_price', 'order' => $order === 'ASC' ? 'DESC' : 'ASC'))); ?>"><?php _e('Total Orders Price', StudiouWC_Main::get_text_domain()); ?></a></th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ <?php foreach ($report_data as $row): ?>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td><?php echo esc_html($row['customer_name']); ?></td>
|
|
|
|
|
+ <td><?php echo esc_html($row['customer_email']); ?></td>
|
|
|
|
|
+ <td><?php echo esc_html($row['customer_phone']); ?></td>
|
|
|
|
|
+ <td><?php echo esc_html($row['orders_count']); ?></td>
|
|
|
|
|
+ <td><?php echo wc_price($row['total_price']); ?></td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ <?php endforeach; ?>
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+ <?php
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private function render_reports_javascript() {
|
|
private function render_reports_javascript() {
|
|
|
?>
|
|
?>
|
|
|
<script>
|
|
<script>
|