|
|
@@ -518,57 +518,57 @@ class Reports extends Component
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- $rates = \App\Models\Rate::whereHas('member_course', function ($query) use ($courseId) {
|
|
|
- $query->where('course_id', $courseId);
|
|
|
- })->with('member_course')->get();
|
|
|
-
|
|
|
- if ($rates->isEmpty()) {
|
|
|
- return [
|
|
|
- 'labels' => [],
|
|
|
- 'datasets' => [],
|
|
|
- 'tableData' => [],
|
|
|
- 'isEmpty' => true,
|
|
|
- 'message' => 'Nessun dato disponibile per questo corso nella stagione ' . $this->seasonFilter
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- $hasData = false;
|
|
|
-
|
|
|
- foreach ($rates as $rate) {
|
|
|
- $totalPrice = (float)($rate->price ?? 0);
|
|
|
-
|
|
|
- if ($rate->months) {
|
|
|
- $monthsData = json_decode($rate->months, true);
|
|
|
-
|
|
|
- if (is_array($monthsData) && count($monthsData) > 0) {
|
|
|
- $pricePerMonth = $totalPrice / count($monthsData);
|
|
|
-
|
|
|
- foreach ($monthsData as $month) {
|
|
|
- $monthNumber = (int)$month;
|
|
|
-
|
|
|
- if (isset($monthlyData[$monthNumber])) {
|
|
|
- $monthlyData[$monthNumber]['total'] += $pricePerMonth;
|
|
|
- $monthlyData[$monthNumber]['participants']++;
|
|
|
- $hasData = true;
|
|
|
-
|
|
|
- if (!is_null($rate->record_id) && $rate->record_id !== '') {
|
|
|
- $monthlyData[$monthNumber]['earned'] += $pricePerMonth;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!$hasData) {
|
|
|
- return [
|
|
|
- 'labels' => [],
|
|
|
- 'datasets' => [],
|
|
|
- 'tableData' => [],
|
|
|
- 'isEmpty' => true,
|
|
|
- 'message' => 'Nessun pagamento registrato per questo corso nella stagione ' . $this->seasonFilter
|
|
|
- ];
|
|
|
- }
|
|
|
+ // $rates = \App\Models\Rate::whereHas('member_course', function ($query) use ($courseId) {
|
|
|
+ // $query->where('course_id', $courseId);
|
|
|
+ // })->with('member_course')->get();
|
|
|
+
|
|
|
+ // if ($rates->isEmpty()) {
|
|
|
+ // return [
|
|
|
+ // 'labels' => [],
|
|
|
+ // 'datasets' => [],
|
|
|
+ // 'tableData' => [],
|
|
|
+ // 'isEmpty' => true,
|
|
|
+ // 'message' => 'Nessun dato disponibile per questo corso nella stagione ' . $this->seasonFilter
|
|
|
+ // ];
|
|
|
+ // }
|
|
|
+
|
|
|
+ // $hasData = false;
|
|
|
+
|
|
|
+ // foreach ($rates as $rate) {
|
|
|
+ // $totalPrice = (float)($rate->price ?? 0);
|
|
|
+
|
|
|
+ // if ($rate->months) {
|
|
|
+ // $monthsData = json_decode($rate->months, true);
|
|
|
+
|
|
|
+ // if (is_array($monthsData) && count($monthsData) > 0) {
|
|
|
+ // $pricePerMonth = $totalPrice / count($monthsData);
|
|
|
+
|
|
|
+ // foreach ($monthsData as $month) {
|
|
|
+ // $monthNumber = (int)$month;
|
|
|
+
|
|
|
+ // if (isset($monthlyData[$monthNumber])) {
|
|
|
+ // $monthlyData[$monthNumber]['total'] += $pricePerMonth;
|
|
|
+ // $monthlyData[$monthNumber]['participants']++;
|
|
|
+ // $hasData = true;
|
|
|
+
|
|
|
+ // if (!is_null($rate->record_id) && $rate->record_id !== '') {
|
|
|
+ // $monthlyData[$monthNumber]['earned'] += $pricePerMonth;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (!$hasData) {
|
|
|
+ // return [
|
|
|
+ // 'labels' => [],
|
|
|
+ // 'datasets' => [],
|
|
|
+ // 'tableData' => [],
|
|
|
+ // 'isEmpty' => true,
|
|
|
+ // 'message' => 'Nessun pagamento registrato per questo corso nella stagione ' . $this->seasonFilter
|
|
|
+ // ];
|
|
|
+ // }
|
|
|
|
|
|
$labels = [];
|
|
|
$earnedData = [];
|