Esempio n. 1
0
            $message = __('You do not have required permissions for this action.', 'tc');
        }
    }
}
if (isset($_GET['page_num'])) {
    $page_num = (int) $_GET['page_num'];
} else {
    $page_num = 1;
}
if (isset($_GET['s'])) {
    $orderssearch = $_GET['s'];
} else {
    $orderssearch = '';
}
$current_status = isset($_GET['post_status']) ? $_GET['post_status'] : 'any';
$wp_orders_search = new TC_Orders_Search($orderssearch, $page_num, '', $current_status);
$fields = $orders->get_order_fields();
$columns = $orders->get_columns();
?>
<div class="wrap tc_wrap">
    <h2><?php 
echo $orders->form_title;
if (isset($_GET['action']) && $_GET['action'] == 'details') {
    ?>
<a href="edit.php?post_type=tc_events&page=<?php 
    echo $_GET['page'];
    ?>
" class="add-new-h2"><?php 
    _e('Back', 'tc');
    ?>
</a><?php 
        function tc_store_report_display()
        {
            global $tc;
            $days_range = 30;
            $days = $days_range * -1;
            $paid_orders_count = 0;
            $total_revenue = 0;
            $todays_revenue = 0;
            $paid_orders_search = new TC_Orders_Search('', '', '', 'order_paid', $days, '>');
            $paid_orders = array();
            $range_dates_earnings = $this->create_date_range_array(date("Y-m-d"), date('Y-m-d', strtotime('+' . ($days_range - 1) . ' days')));
            $count_of_tickets = 0;
            foreach ($paid_orders_search->get_results() as $order) {
                $order_object = new TC_Order($order->ID);
                $args = array('posts_per_page' => -1, 'post_parent' => $order->ID, 'post_type' => 'tc_tickets_instances', 'post_status' => 'publish');
                $tickets = get_posts($args);
                $count_of_tickets = $count_of_tickets + count($tickets);
                $total_revenue = $total_revenue + $order_object->details->tc_payment_info['total'];
                $paid_orders[] = $order_object->details->tc_payment_info['total'];
                $createDate = new DateTime($order_object->details->post_date);
                $strip_date = $createDate->format('Y-m-d');
                $range_dates_earnings[$strip_date] = 0;
                $range_dates_earnings[$strip_date] = $range_dates_earnings[$strip_date] + $order_object->details->tc_payment_info['total'];
                $paid_orders_count++;
            }
            $todays_revenue = $range_dates_earnings[date("Y-m-d")];
            $total_revenue = round($total_revenue, 2);
            $pending_orders_count = 0;
            $pending_orders_search = new TC_Orders_Search('', '', '', 'order_received', $days, '>');
            foreach ($pending_orders_search->get_results() as $order) {
                $order_object = new TC_Order($order->ID);
                $pending_orders_count++;
            }
            ?>
			<ul class="tc-status-list">
				<li class="sales-this-month">
					<a>
						<i class="fa fa-money tc-icon tc-icon-dashboard-sales"></i> 
						<strong><span class="amount"><?php 
            echo $tc->get_cart_currency_and_format($total_revenue);
            ?>
</span></strong>
						<span class="tc-dashboard-widget-subtitle"><?php 
            printf(_n('last %d day earnings', 'last %d days earnings', $days_range, 'tc'), $days_range);
            ?>
</span>
						<span class = "tc-bar"><?php 
            $vals = '';
            foreach ($range_dates_earnings as $key => $val) {
                $vals = $vals . $val . '|';
            }
            echo rtrim($vals, "|");
            ?>
						</span>
					</a>

				</li>


				<li class="todays-earnings">
					<a>
						<i class="fa fa-money tc-icon tc-icon-dashboard-todays-earnings"></i> 
						<strong><?php 
            echo $tc->get_cart_currency_and_format($todays_revenue);
            ?>
</strong>
						<span class="tc-dashboard-widget-subtitle"><?php 
            _e('today\'s earnings', 'tc');
            ?>
</span>
					</a>
				</li>
				<li class="sold-tickets">
					<a>
						<i class="fa fa-ticket tc-icon tc-icon-dashboard-sold"></i> 
						<strong><?php 
            printf(_n('%d ticket sold', '%d tickets sold', $count_of_tickets, 'tc'), $count_of_tickets);
            ?>
</strong>
						<span class="tc-dashboard-widget-subtitle"><?php 
            printf(_n('in the last %d day', 'in the last %d days', $days_range, 'tc'), $days_range);
            ?>
</span>
					</a>
				</li>
				<li class="completed-orders">
					<a>
						<i class="fa fa-shopping-cart tc-icon tc-icon-dashboard-completed"></i> 
						<strong><?php 
            printf(_n('%d order completed', '%d orders completed', $paid_orders_count, 'tc'), $paid_orders_count);
            ?>
</strong>
						<span class="tc-dashboard-widget-subtitle"><?php 
            printf(_n('in the last %d day', 'in the last %d days', $days_range, 'tc'), $days_range);
            ?>
</span>
					</a>
				</li>
				<li class="pending-orders">
					<a>
						<i class="fa fa-shopping-cart tc-icon tc-icon-dashboard-pending"></i> 
						<strong><?php 
            printf(_n('%d pending order', '%d pending orders', $pending_orders_count, 'tc'), $pending_orders_count);
            ?>
</strong>
						<span class="tc-dashboard-widget-subtitle"><?php 
            printf(_n('in the last %d day', 'in the last %d days', $days_range, 'tc'), $days_range);
            ?>
</span>
					</a>
				</li>

			</ul>
			<?php 
        }
 function get_stats_general($echo = true)
 {
     global $tc, $wpdb;
     if ($this->get_api_key_id()) {
         /* //FOR PERIOD
          * FOR EACH EVENT
          * - event id
          * - event name
          * - number of sales
          * - number of ticket types
          * 
          */
         // Get revenue and number of orders for the selected period
         $cache_name_revenue = 'tc_stats_general_revenue_' . $this->period . '_' . $this->results_per_page . '_' . $this->page_number;
         $cache_name_number_of_orders = 'tc_stats_general_number_of_orders_' . $this->period . '_' . $this->results_per_page . '_' . $this->page_number;
         $revenue = wp_cache_get($cache_name_revenue);
         $number_of_orders = wp_cache_get($cache_name_number_of_orders);
         if (false === $revenue || false === $number_of_orders) {
             $number_of_orders = 0;
             $total_revenue = 0;
             $wp_orders_search = new TC_Orders_Search('', '', 0, array('order_paid', 'order_received'), $this->period, $this->period_compare);
             foreach ($wp_orders_search->get_results() as $order) {
                 $order_object = new TC_Order($order->ID);
                 $total_revenue = $total_revenue + $order_object->details->tc_payment_info['total'];
                 $number_of_orders++;
             }
             $total_revenue = round($total_revenue, 2);
             $revenue = $total_revenue;
             wp_cache_set($cache_name_revenue, $revenue);
             wp_cache_set($cache_name_number_of_orders, $number_of_orders);
         }
         $data = array('revenue' => stripslashes($revenue), 'currency' => stripslashes($tc->get_cart_currency()), 'number_of_orders' => $number_of_orders);
         $json = json_encode(apply_filters('tc_get_stats_general_data_output', $data));
         if ($echo) {
             echo $json;
             exit;
         } else {
             return $json;
         }
     }
 }