PluginProbe
Tutor LMS – eLearning and online course solution / 1.6.8
Tutor LMS – eLearning and online course solution v1.6.8
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
tutor / templates / dashboard / earning / report-this_year.php
report-this_year.php
114 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template for displaying instructors earnings
4 *
5 * @since v.1.1.2
6 *
7 * @author Themeum
8 * @url https://themeum.com
9 *
10 * @package TutorLMS/Templates
11 * @version 1.4.3
12 */
13
14 global $wpdb;
15
16 $user_id = get_current_user_id();
17
18 /**
19 * Getting the Last Month
20 */
21 $year = date('Y');
22 $dataFor = 'yearly';
23
24 $earning_sum = tutor_utils()->get_earning_sum($user_id, compact('year', 'dataFor'));
25
26
27 if ( ! $earning_sum){
28 echo '<p>'.__('No Earning info available', 'tutor' ).'</p>';
29 return;
30 }
31
32 $complete_status = tutor_utils()->get_earnings_completed_statuses();
33 $statuses = $complete_status;
34 $complete_status = "'".implode("','", $complete_status)."'";
35
36
37 /**
38 * Query This Month
39 */
40
41 $salesQuery = $wpdb->get_results( "
42 SELECT SUM(instructor_amount) as total_earning,
43 MONTHNAME(created_at) as month_name
44 from {$wpdb->prefix}tutor_earnings
45 WHERE user_id = {$user_id} AND order_status IN({$complete_status})
46 AND YEAR(created_at) = {$year}
47 GROUP BY MONTH (created_at)
48 ORDER BY MONTH(created_at) ASC ;");
49
50 $total_earning = wp_list_pluck($salesQuery, 'total_earning');
51 $months = wp_list_pluck($salesQuery, 'month_name');
52 $monthWiseSales = array_combine($months, $total_earning);
53
54 /**
55 * Format yearly
56 */
57 $emptyMonths = array();
58 for ($m=1; $m<=12; $m++) {
59 $emptyMonths[date('F', mktime(0,0,0,$m, 1, date('Y')))] = 0;
60 }
61 $chartData = array_merge($emptyMonths, $monthWiseSales);
62
63 $statements = tutor_utils()->get_earning_statements($user_id, compact('year', 'dataFor', 'statuses'));
64
65
66 ?>
67
68 <div class="tutor-dashboard-info-cards">
69 <div class="tutor-dashboard-info-card" title="<?php _e('All time', 'tutor'); ?>">
70 <p>
71 <span> <?php _e('My Earning', 'tutor'); ?> </span>
72 <span class="tutor-dashboard-info-val"><?php echo tutor_utils()->tutor_price($earning_sum->instructor_amount); ?></span>
73 </p>
74 </div>
75 <div class="tutor-dashboard-info-card" title="<?php _e('Based on course price', 'tutor'); ?>">
76 <p>
77 <span> <?php _e('All time sales', 'tutor'); ?> </span>
78 <span class="tutor-dashboard-info-val"><?php echo tutor_utils()->tutor_price($earning_sum->course_price_total); ?></span>
79 </p>
80 </div>
81 <div class="tutor-dashboard-info-card">
82 <p>
83 <span> <?php _e('Deducted Commissions', 'tutor'); ?> </span>
84 <span class="tutor-dashboard-info-val"><?php echo tutor_utils()->tutor_price($earning_sum->admin_amount); ?></span>
85 </p>
86 </div>
87
88
89 <?php if ($earning_sum->deduct_fees_amount > 0){ ?>
90 <div class="tutor-dashboard-info-card" title="<?php _e('Deducted Fees', 'tutor'); ?>">
91 <p>
92 <span> <?php _e('Deducted Fees', 'tutor'); ?> </span>
93 <span class="tutor-dashboard-info-val"><?php echo tutor_utils()->tutor_price($earning_sum->deduct_fees_amount); ?></span>
94 </p>
95 </div>
96 <?php } ?>
97 </div>
98
99
100
101
102
103 <div class="tutor-dashboard-item-group">
104 <h4><?php echo sprintf(__("Earning Data for the year of %s", 'tutor'), $year);?></h4>
105 <?php
106 tutor_load_template('dashboard.earning.chart-body', compact('chartData', 'statements'));
107 ?>
108 </div>
109
110 <div class="tutor-dashboard-item-group">
111 <h4><?php _e('Sales statements for this period', 'tutor') ?></h4>
112 <?php tutor_load_template('dashboard.earning.statement', compact('chartData', 'statements')); ?>
113 </div>
114