/**
  * Handles output of the reports page in admin.
  */
 public static function output()
 {
     $reports = self::get_reports();
     $first_tab = array_keys($reports);
     $current_tab = !empty($_GET['tab']) ? sanitize_title($_GET['tab']) : $first_tab[0];
     /** @noinspection PhpUnusedLocalVariableInspection */
     $current_report = isset($_GET['report']) ? sanitize_title($_GET['report']) : current(array_keys($reports[$current_tab]['reports']));
     include_once 'reports/admin-report.class.php';
     $template = fflcommerce_locate_template('admin/reports/layout');
     /** @noinspection PhpIncludeInspection */
     include_once $template;
 }
 public function output()
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     $ranges = array('all' => __('All Time', 'fflcommerce'), 'year' => __('Year', 'fflcommerce'), 'last_month' => __('Last Month', 'fflcommerce'), 'month' => __('This Month', 'fflcommerce'), '30day' => __('Last 30 Days', 'fflcommerce'), '7day' => __('Last 7 Days', 'fflcommerce'), 'today' => __('Today', 'fflcommerce'));
     $this->chart_colours = array('discount_amount' => '#3498db', 'coupon_count' => '#d4d9dc');
     $current_range = !empty($_GET['range']) ? sanitize_text_field($_GET['range']) : '30day';
     if (!in_array($current_range, array('custom', 'all', 'year', 'last_month', 'month', '30day', '7day', 'today'))) {
         $current_range = '30day';
     }
     $this->calculate_current_range($current_range);
     $template = fflcommerce_locate_template('admin/reports/by-date');
     /** @noinspection PhpIncludeInspection */
     include $template;
 }
 /**
  * Handles output of the reports page in admin.
  */
 public static function output()
 {
     if (false === ($addons = get_transient('fflcommerce_extensions_data'))) {
         $addons_json = wp_remote_get('http://www.fflcommerce.com/products.json');
         if (!is_wp_error($addons_json)) {
             $addons = json_decode(wp_remote_retrieve_body($addons_json));
             if ($addons) {
                 set_transient('fflcommerce_extensions_data', $addons, 7 * 24 * 3600);
                 // One week
             }
         }
     }
     $template = fflcommerce_locate_template('admin/extensions');
     /** @noinspection PhpIncludeInspection */
     include $template;
 }
示例#4
0
 public function output()
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     $ranges = array('year' => __('Year', 'fflcommerce'), 'last_month' => __('Last Month', 'fflcommerce'), 'month' => __('This Month', 'fflcommerce'), '7day' => __('Last 7 Days', 'fflcommerce'), 'today' => __('Today', 'fflcommerce'));
     $this->chart_colours = array('signups' => '#3498db', 'customers' => '#1abc9c', 'guests' => '#8fdece');
     $current_range = !empty($_GET['range']) ? sanitize_text_field($_GET['range']) : '7day';
     if (!in_array($current_range, array('custom', 'year', 'last_month', 'month', '7day', 'today'))) {
         $current_range = '7day';
     }
     $this->calculate_current_range($current_range);
     $admin_users = new WP_User_Query(array('role' => 'administrator', 'fields' => 'ID'));
     $manager_users = new WP_User_Query(array('role' => 'shop_manager', 'fields' => 'ID'));
     $users_query = new WP_User_Query(array('fields' => array('user_registered'), 'exclude' => array_merge($admin_users->get_results(), $manager_users->get_results())));
     $this->customers = $users_query->get_results();
     foreach ($this->customers as $key => $customer) {
         if (strtotime($customer->user_registered) < $this->start_date || strtotime($customer->user_registered) > $this->end_date) {
             unset($this->customers[$key]);
         }
     }
     $template = fflcommerce_locate_template('admin/reports/by-date');
     /** @noinspection PhpIncludeInspection */
     include $template;
 }
 /**
  * Output the report
  */
 public function output()
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     $ranges = array('all' => __('All Time', 'fflcommerce'), 'year' => __('Year', 'fflcommerce'), 'last_month' => __('Last Month', 'fflcommerce'), 'month' => __('This Month', 'fflcommerce'), '30day' => __('Last 30 Days', 'fflcommerce'), '7day' => __('Last 7 Days', 'fflcommerce'), 'today' => __('Today', 'fflcommerce'));
     $this->chart_colours = array('sales_amount' => '#b1d4ea', 'net_sales_amount' => '#3498db', 'average' => '#95a5a6', 'order_count' => '#dbe1e3', 'item_count' => '#ecf0f1', 'shipping_amount' => '#5cc488', 'coupon_amount' => '#f1c40f');
     $current_range = !empty($_GET['range']) ? sanitize_text_field($_GET['range']) : '30day';
     if (!in_array($current_range, array('custom', 'all', 'year', 'last_month', 'month', '30day', '7day', 'today'))) {
         $current_range = '30day';
     }
     $this->calculate_current_range($current_range);
     $template = fflcommerce_locate_template('admin/reports/by-date');
     /** @noinspection PhpIncludeInspection */
     include $template;
 }
示例#6
0
/**
 * Helper function to locate proper template and set up environment based on passed array.
 *
 * @param string $template Template name.
 * @param array $variables Template variables
 */
function fflcommerce_render($template, array $variables)
{
    $file = fflcommerce_locate_template($template);
    extract($variables);
    /** @noinspection PhpIncludeInspection */
    require $file;
}
 public function output()
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     $ranges = array('all' => __('All Time', 'fflcommerce'), 'year' => __('Year', 'fflcommerce'), 'last_month' => __('Last Month', 'fflcommerce'), 'month' => __('This Month', 'fflcommerce'), '30day' => __('Last 30 Days', 'fflcommerce'), '7day' => __('Last 7 Days', 'fflcommerce'), 'today' => __('Today', 'fflcommerce'));
     $this->chart_colours = array('#3498db', '#34495e', '#1abc9c', '#2ecc71', '#f1c40f', '#e67e22', '#e74c3c', '#2980b9', '#8e44ad', '#2c3e50', '#16a085', '#27ae60', '#f39c12', '#d35400', '#c0392b');
     $current_range = !empty($_GET['range']) ? sanitize_text_field($_GET['range']) : '30day';
     if (!in_array($current_range, array('custom', 'all', 'year', 'last_month', 'month', '30day', '7day', 'today'))) {
         $current_range = '30day';
     }
     $this->calculate_current_range($current_range);
     // Get item sales data
     if ($this->show_categories) {
         $orders = $this->get_order_report_data(array('data' => array('order_items' => array('type' => 'meta', 'name' => 'category_data', 'process' => true), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'order_types' => array('shop_order'), 'query_type' => 'get_results', 'filter_range' => true));
         $this->item_sales = array();
         $this->item_sales_and_times = array();
         if (is_array($orders)) {
             foreach ($orders as $order_items) {
                 foreach ($order_items as $order_item) {
                     switch ($this->chart_groupby) {
                         case 'hour':
                             $time = date('H', strtotime($order_item->post_date)) * 3600 . '000';
                             break;
                         case 'day':
                             $time = strtotime(date('Ymd', strtotime($order_item->post_date))) * 1000;
                             break;
                         case 'month':
                         default:
                             $time = strtotime(date('Ym', strtotime($order_item->post_date)) . '01') * 1000;
                             break;
                     }
                     $this->item_sales_and_times[$time][$order_item->product_id] = isset($this->item_sales_and_times[$time][$order_item->product_id]) ? $this->item_sales_and_times[$time][$order_item->product_id] + $order_item->order_item_total : $order_item->order_item_total;
                     $this->item_sales[$order_item->product_id] = isset($this->item_sales[$order_item->product_id]) ? $this->item_sales[$order_item->product_id] + $order_item->order_item_total : $order_item->order_item_total;
                 }
             }
         }
     }
     $template = fflcommerce_locate_template('admin/reports/by-date');
     /** @noinspection PhpIncludeInspection */
     include $template;
 }
 public static function status_logs()
 {
     $logs = self::scan_log_files();
     if (!empty($_REQUEST['log_file']) && isset($logs[sanitize_title($_REQUEST['log_file'])])) {
         /** @noinspection PhpUnusedLocalVariableInspection */
         $viewed_log = $logs[sanitize_title($_REQUEST['log_file'])];
     } elseif ($logs) {
         /** @noinspection PhpUnusedLocalVariableInspection */
         $viewed_log = current($logs);
     }
     $template = fflcommerce_locate_template('admin/status/logs');
     /** @noinspection PhpIncludeInspection */
     include $template;
 }