chart-body.php
5 years ago
earning-report-top-menu.php
5 years ago
report-date_range.php
5 years ago
report-last_month.php
5 years ago
report-last_week.php
5 years ago
report-last_year.php
5 years ago
report-this_month.php
5 years ago
report-this_week.php
5 years ago
report-this_year.php
5 years ago
report.php
5 years ago
statement.php
5 years ago
statements.php
5 years ago
report-this_year.php
114 lines
| 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 |