Przeglądaj źródła

Merge remote-tracking branch 'origin/iao_team_ferrari' into iao_team

Luca Parisio 2 miesięcy temu
rodzic
commit
81fda52e65

+ 23 - 9
app/Http/Livewire/Member.php

@@ -2275,6 +2275,7 @@ class Member extends Component
 
     public function setMonth($m)
     {
+        if ($m < 1 || $m > 12) return;
 
         $payed = false;
         $exist = -1;
@@ -2292,16 +2293,29 @@ class Member extends Component
             $this->course_months[] = array("m" => $m, "status" => "");
         }
 
-        /*
-        if (in_array($m, $this->course_months))
-        {
-            $i = array_search($m, $this->course_months);
-            array_splice($this->course_months, $i, 1);
+        $rank = function (int $mm) { return ($mm - 9 + 12) % 12; };
+        usort($this->course_months, function ($a, $b) use ($rank) {
+            return $rank((int)$a['m']) <=> $rank((int)$b['m']);
+        });
+        $this->course_months = array_values($this->course_months);
+
+        if ($this->course_course_id && !empty($this->course_months)) {
+            try {
+                $course = \App\Models\Course::findOrFail($this->course_course_id);
+                $year = (int)$course->year;
+
+                $first_month = (int)$this->course_months[0]['m'];
+                $last_month  = (int)$this->course_months[count($this->course_months) - 1]['m'];
+                $start_year = ($first_month >= 9) ? $year : $year + 1;
+                $end_year   = ($last_month  >= 9) ? $year : $year + 1;
+
+                $start = \Illuminate\Support\Carbon::create($start_year, $first_month, 1, 0, 0, 0, 'Europe/Rome')->startOfDay();
+                $end = \Illuminate\Support\Carbon::create($end_year, $last_month, 1, 0, 0, 0, 'Europe/Rome')->endOfMonth()->endOfDay();
+
+                $this->course_date_from = $start->format('Y-m-d');
+                $this->course_date_to   = $end->format('Y-m-d');
+            } catch (\Throwable $e) {}
         }
-        else
-        {
-            $this->course_months[] = $m;
-        }*/
     }
 
     public function newPayment($course)

+ 17 - 7
app/Http/Livewire/Presence.php

@@ -85,13 +85,23 @@ class Presence extends Component
             $months = date("n", strtotime($this->calendar->from));
 
             // Elenco utenti iscritti al corso "padre"
-            $members_courses = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")
-                ->where('when', 'like', '%"from":"' . $h . '"%')
-                ->whereNot('months', 'like', '%"m":' . $months . ',"status":2%')
-                ->whereDate('date_from', '<=', $this->calendar->from)                                 
-                ->whereDate('date_to', '>=', $this->calendar->from)      
-                ->whereIn('course_id', $courses)
-                ->pluck('member_id')->toArray();
+            // $members_courses = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")
+            //     ->where('when', 'like', '%"from":"' . $h . '"%')
+            //     ->whereNot('months', 'like', '%"m":' . $months . ',"status":2%')
+            //     ->whereDate('date_from', '<=', $this->calendar->from)                                 
+            //     ->whereDate('date_to', '>=', $this->calendar->from)      
+            //     ->whereIn('course_id', $courses)
+            //     ->pluck('member_id')->toArray();
+
+            // $members_courses = \App\Models\MemberCourse::whereRaw("JSON_CONTAINS(`when`, JSON_OBJECT('day', JSON_ARRAY(?), 'from', ?), '$')", [$d, $h])->where('months', 'like', '%"m":' . $months . ',%')->whereIn('course_id', $courses)->pluck('member_id')->toArray();
+            $members_courses = \App\Models\MemberCourse::query()
+                        ->whereRaw("JSON_CONTAINS(`when`, JSON_OBJECT('day', JSON_ARRAY(?), 'from', ?), '$')", [$d, $h])
+                        ->whereRaw("JSON_CONTAINS(months, JSON_OBJECT('m', CAST(? AS UNSIGNED)), '$')", [$months])
+                        ->whereRaw("NOT JSON_CONTAINS(months, JSON_OBJECT('m', CAST(? AS UNSIGNED), 'status', 2), '$')", [$months])
+                        ->whereRaw("NOT JSON_CONTAINS(months, JSON_OBJECT('m', CAST(? AS UNSIGNED), 'status', '2'), '$')", [$months])
+                        ->whereIn('course_id', $courses)
+                        ->pluck('member_id')
+                        ->toArray();
 
             if ($this->filter != '') {
                 $filter = $this->filter;

+ 140 - 22
app/Http/Livewire/RecordINOUT.php

@@ -200,28 +200,78 @@ class RecordINOUT extends Component
 
                 $this->columns[] = $filter;
 
-                $f = $filter;
-                if ($m == 'x')
-                    $f = str_replace("x-", "", $filter);
+                list($m, $y) = explode("-", $filter);
+
+                // $f = $filter;
+                // if ($m == 'x')
+                //     $f = str_replace("x-", "", $filter);
 
                 //$dt = $y . "-0" . $m;
 
-                $records = \App\Models\Record::where('type', 'IN')
+                // $records = \App\Models\Record::where('type', 'IN')
+                //     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+                //     ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
+                //     ->where(function ($query)  {
+                //         $query->where('deleted', false)->orWhere('deleted', null);
+                //     })
+                //     ->where(function ($query)  {
+                //         $query->where('financial_movement', false)->orWhere('financial_movement', null);
+                //     })
+                //     ->whereNotIn('member_id', $exclude_from_records)
+                //     /*->where(function ($query) use ($f, $dt)  {
+                //         $query->where('records.date', 'like', '%' . $dt . '%')->orWhere('records_rows.when', 'like', '%' . $f . '%');
+                //     })*/
+                //     ->where('records_rows.when', 'like', '%"' . $f . '"%')
+                //     ->get();
+                // //$records = $records->orderBy('date', 'DESC')->get();
+
+                $recordsQuery = \App\Models\Record::where('records.type', 'IN')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
                     ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
-                    ->where(function ($query)  {
+                    ->where(function ($query) {
                         $query->where('deleted', false)->orWhere('deleted', null);
                     })
-                    ->where(function ($query)  {
+                    ->where(function ($query) {
                         $query->where('financial_movement', false)->orWhere('financial_movement', null);
                     })
-                    ->whereNotIn('member_id', $exclude_from_records)
-                    /*->where(function ($query) use ($f, $dt)  {
-                        $query->where('records.date', 'like', '%' . $dt . '%')->orWhere('records_rows.when', 'like', '%' . $f . '%');
-                    })*/
-                    ->where('records_rows.when', 'like', '%"' . $f . '"%')
-                    ->get();
-                //$records = $records->orderBy('date', 'DESC')->get();
+                    ->whereNotIn('member_id', $exclude_from_records);
+
+                if ($m === 'x') {
+                    // Anno fiscale da settembre $y a agosto $y+1
+                    $months = array_merge(range(9, 12), range(1, 8));
+                    $years = [
+                        9 => $y, 10 => $y, 11 => $y, 12 => $y,
+                        1 => $y+1, 2 => $y+1, 3 => $y+1, 4 => $y+1,
+                        5 => $y+1, 6 => $y+1, 7 => $y+1, 8 => $y+1
+                    ];
+
+                    $recordsQuery->where(function ($q) use ($months, $years) {
+                        foreach ($months as $month) {
+                            $year = $years[$month];
+                            // variante entrambi numeri stringhe
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":\"{$year}\"}')");
+                            // variante month stringa e year int
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":{$year}}')");
+                            // variante month int e year stringa
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":\"{$year}\"}')");
+                            // variante entrambi numeri int
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":{$year}}')");
+                        }
+                    });
+
+                } else {
+                    $recordsQuery->where(function ($q) use ($m, $y) {
+                        // variante entrambi numeri stringhe
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":\"{$y}\"}')");
+                        // variante month stringa e year int
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":{$y}}')");
+                        // variante month int e year stringa
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":\"{$y}\"}')");
+                        // variante entrambi numeri int
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":{$y}}')");
+                    });
+                }
+                $records = $recordsQuery->get();
 
                 $ccc = 0;
                 $ids = '';
@@ -256,18 +306,66 @@ class RecordINOUT extends Component
                 }
                 //die;
 
-                $records = \App\Models\Record::where('type', 'OUT')
+                // $records = \App\Models\Record::where('type', 'OUT')
+                //     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+                //     ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
+                //     ->where(function ($query)  {
+                //         $query->where('deleted', false)->orWhere('deleted', null);
+                //     })
+                //     ->where(function ($query)  {
+                //         $query->where('financial_movement', false)->orWhere('financial_movement', null);
+                //     })
+                //     ->whereNotIn('member_id', $exclude_from_records)
+                //     ->where('records_rows.when', 'like', '%"' . $f . '"%')->get();
+                //$records = $records->orderBy('date', 'DESC')->get();
+
+                $recordsQuery = \App\Models\Record::where('records.type', 'OUT')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
                     ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
-                    ->where(function ($query)  {
+                    ->where(function ($query) {
                         $query->where('deleted', false)->orWhere('deleted', null);
                     })
-                    ->where(function ($query)  {
+                    ->where(function ($query) {
                         $query->where('financial_movement', false)->orWhere('financial_movement', null);
                     })
-                    ->whereNotIn('member_id', $exclude_from_records)
-                    ->where('records_rows.when', 'like', '%"' . $f . '"%')->get();
-                //$records = $records->orderBy('date', 'DESC')->get();
+                    ->whereNotIn('member_id', $exclude_from_records);
+
+                if ($m === 'x') {
+                    // Anno fiscale da settembre $y a agosto $y+1
+                    $months = array_merge(range(9, 12), range(1, 8));
+                    $years = [
+                        9 => $y, 10 => $y, 11 => $y, 12 => $y,
+                        1 => $y+1, 2 => $y+1, 3 => $y+1, 4 => $y+1,
+                        5 => $y+1, 6 => $y+1, 7 => $y+1, 8 => $y+1
+                    ];
+
+                    $recordsQuery->where(function ($q) use ($months, $years) {
+                        foreach ($months as $month) {
+                            $year = $years[$month];
+                            // variante entrambi numeri stringhe
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":\"{$year}\"}')");
+                            // variante month stringa e year int
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":{$year}}')");
+                            // variante month int e year stringa
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":\"{$year}\"}')");
+                            // variante entrambi numeri int
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":{$year}}')");
+                        }
+                    });
+
+                } else {
+                    $recordsQuery->where(function ($q) use ($m, $y) {
+                        // variante entrambi numeri stringhe
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":\"{$y}\"}')");
+                        // variante month stringa e year int
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":{$y}}')");
+                        // variante month int e year stringa
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":\"{$y}\"}')");
+                        // variante entrambi numeri int
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":{$y}}')");
+                    });
+                }
+                $records = $recordsQuery->get();
 
                 foreach($records as $record)
                 {
@@ -286,7 +384,6 @@ class RecordINOUT extends Component
                         $this->records_out[$filter][$record->causal_id] = $amount;
                     $this->updateParent("OUT", $record->causal_id, $amount, $filter);
                 }
-
             }
         }
 
@@ -423,7 +520,12 @@ class RecordINOUT extends Component
                 $ret = '';
                 break;
         }
-        $ret .= $y;
+        if ($m == 'x') {
+            $nextY = $y+1;
+            $ret = "{$y}/{$nextY}";
+        } else {
+            $ret .= $y;
+        }
         return $ret;
     }
 
@@ -454,6 +556,7 @@ class RecordINOUT extends Component
     {
 
         $rows_in = array();
+        $rows_out = array();
 
         if ($this->filterCausalsIn != null && sizeof($this->filterCausalsIn) > 0)
         {
@@ -470,7 +573,22 @@ class RecordINOUT extends Component
             $rows_in = $this->rows_in;
         }
 
-        $path = $this->generateExcel($this->columns, $rows_in, $this->records_in, $this->rows_out, $this->records_out,false);
+        if ($this->filterCausalsOut != null && sizeof($this->filterCausalsOut) > 0)
+        {
+            foreach($this->rows_out as $r)
+            {
+                if (in_array($r["id"], $this->filterCausalsOut) || in_array($r["parent_id"], $this->filterCausalsOut) || in_array($r["first_parent_id"], $this->filterCausalsOut))
+                {
+                    $rows_out[] = $r;
+                }
+            }
+        }
+        else
+        {
+            $rows_out = $this->rows_out;
+        }
+
+        $path = $this->generateExcel($this->columns, $rows_in, $this->records_in, $rows_out, $this->records_out,false);
 
         return response()->download($path)->deleteFileAfterSend();
 

+ 65 - 15
app/Http/Livewire/Reports.php

@@ -169,6 +169,13 @@ class Reports extends Component
 
         $incomeRecords = DB::table('records')
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+            ->join('causals', function ($join) {
+                $join->on('causals.id', '=', 'records_rows.causal_id')
+                    ->where(function ($query) {
+                        $query->where('causals.no_reports', 0)
+                            ->orWhereNull('causals.no_reports');
+                    });
+            })
             ->whereBetween('records.date', [$dateRange['start'], $dateRange['end']])
             ->where('records.type', 'IN')
             ->select(DB::raw('MONTH(records.date) as month_num'), DB::raw('SUM(records_rows.amount) as total'))
@@ -177,6 +184,13 @@ class Reports extends Component
 
         $expenseRecords = DB::table('records')
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+            ->join('causals', function ($join) {
+                $join->on('causals.id', '=', 'records_rows.causal_id')
+                    ->where(function ($query) {
+                        $query->where('causals.no_reports', 0)
+                            ->orWhereNull('causals.no_reports');
+                    });
+            })
             ->whereBetween('records.date', [$dateRange['start'], $dateRange['end']])
             ->where('records.type', 'OUT')
             ->select(DB::raw('MONTH(records.date) as month_num'), DB::raw('SUM(records_rows.amount) as total'))
@@ -216,13 +230,20 @@ class Reports extends Component
             ]
         ];
     }
-    
+
     public function getYearlyTotals()
     {
         Log::info('=== getyearlyTotals called ===');
 
         $incomeRecords = DB::table('records')
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+            ->join('causals', function ($join) {
+                $join->on('causals.id', '=', 'records_rows.causal_id')
+                    ->where(function ($query) {
+                        $query->where('causals.no_reports', 0)
+                            ->orWhereNull('causals.no_reports');
+                    });
+            })
             ->where('records.type', 'IN')
             ->selectRaw("
                 CASE
@@ -237,6 +258,13 @@ class Reports extends Component
 
         $expenseRecords = DB::table('records')
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+            ->join('causals', function ($join) {
+                $join->on('causals.id', '=', 'records_rows.causal_id')
+                    ->where(function ($query) {
+                        $query->where('causals.no_reports', 0)
+                            ->orWhereNull('causals.no_reports');
+                    });
+            })
             ->where('records.type', 'OUT')
             ->selectRaw("
                 CASE
@@ -248,21 +276,21 @@ class Reports extends Component
             ")
             ->groupBy('year_num')
             ->get();
-        
+
         // Mappa anno/totale
         $incomeByYear = $incomeRecords->pluck('total', 'year_num');
         $expenseByYear = $expenseRecords->pluck('total', 'year_num');
 
         // Unione di tutti gli anni presenti ordinati
         $allYears = $incomeByYear->keys()
-                                ->merge($expenseByYear->keys())
-                                ->unique()
-                                ->sort()
-                                ->values();
+            ->merge($expenseByYear->keys())
+            ->unique()
+            ->sort()
+            ->values();
 
         // Allineo i dati dei due array, se non presente l'anno: default 0
-        $incomeData  = $allYears->map(fn ($y) => (float) ($incomeByYear[$y]  ?? 0))->toArray();
-        $expenseData = $allYears->map(fn ($y) => (float) ($expenseByYear[$y] ?? 0))->toArray();
+        $incomeData  = $allYears->map(fn($y) => (float) ($incomeByYear[$y]  ?? 0))->toArray();
+        $expenseData = $allYears->map(fn($y) => (float) ($expenseByYear[$y] ?? 0))->toArray();
 
 
         return [
@@ -288,12 +316,26 @@ class Reports extends Component
 
         $totalIncome = DB::table('records')
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+            ->join('causals', function ($join) {
+                $join->on('causals.id', '=', 'records_rows.causal_id')
+                    ->where(function ($query) {
+                        $query->where('causals.no_reports', 0)
+                            ->orWhereNull('causals.no_reports');
+                    });
+            })
             ->whereBetween('records.date', [$dateRange['start'], $dateRange['end']])
             ->where('records.type', 'IN')
             ->sum('records_rows.amount');
 
         $totalExpenses = DB::table('records')
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
+            ->join('causals', function ($join) {
+                $join->on('causals.id', '=', 'records_rows.causal_id')
+                    ->where(function ($query) {
+                        $query->where('causals.no_reports', 0)
+                            ->orWhereNull('causals.no_reports');
+                    });
+            })
             ->whereBetween('records.date', [$dateRange['start'], $dateRange['end']])
             ->where('records.type', 'OUT')
             ->sum('records_rows.amount');
@@ -415,7 +457,7 @@ class Reports extends Component
                 Log::info('Processing course: ' . $course->name . ' (ID: ' . $course->id . ')' . $course);
 
                 $levelName = is_object($course->level) ? $course->level->name : 'No Level';
-                $typeName = '';//$course->getFormattedTypeField();
+                $typeName = ''; //$course->getFormattedTypeField();
                 $frequencyName = is_object($course->frequency) ? $course->frequency->name : 'No Frequency';
                 $year = $course->year ?? '';
 
@@ -563,8 +605,7 @@ class Reports extends Component
             if ($member_course->months) {
                 $monthsData = json_decode($member_course->months, true);
 
-                if (is_array($monthsData) && count($monthsData) > 0) 
-                {
+                if (is_array($monthsData) && count($monthsData) > 0) {
 
 
 
@@ -577,7 +618,7 @@ class Reports extends Component
                             $monthlyData[$monthNumber]['total'] += $pricePerMonth;
                             $monthlyData[$monthNumber]['participants']++;
                             $hasData = true;
-                            
+
                             //if (!is_null($rate->record_id) && $rate->record_id !== '') {
                             if ($month["status"] == 1) {
                                 $monthlyData[$monthNumber]['participants']--;
@@ -637,7 +678,7 @@ class Reports extends Component
             ];
         }
 
-        $daIncassareData = array_map(function($tot, $inc) {
+        $daIncassareData = array_map(function ($tot, $inc) {
             return $tot - $inc;
         }, $totalData, $earnedData);
 
@@ -683,7 +724,14 @@ class Reports extends Component
             ->whereRaw('YEAR(expire_date) <= ?', [$endYear])
             ->get();
 
-        $cardTypes = $memberCards->pluck('card.name')->unique()->filter()->sort()->values();
+        $cardTypes = $memberCards->pluck('card.name')->unique()->filter()->sort()->values()->toArray();
+        usort($cardTypes, function($a, $b) {
+            if ($a == $b) return 0;
+            if ($a == "UISP") return 1;
+            if ($b == "UISP") return 1;
+
+            return strcmp($a, $b);
+        });
 
         $seasonCounts = [];
         $seasonCardCounts = [];
@@ -756,6 +804,7 @@ class Reports extends Component
                 'tension' => 0.3,
                 'fill' => true
             ];
+            if ($cardType != "UISP") $cardTypeDatasets[$cardType]["hidden"] = true;
         }
 
         foreach ($seasonCounts as $seasonPeriod => $members) {
@@ -781,7 +830,8 @@ class Reports extends Component
                 'pointRadius' => 6,
                 'tension' => 0.3,
                 'fill' => true,
-                'type' => 'line'
+                'type' => 'line',
+                'hidden' => true
             ]
         ];
         foreach ($cardTypeDatasets as $dataset) {

+ 18 - 2
public/css/chart-reports.css

@@ -433,6 +433,7 @@
 
 .table-cell.net {
     font-weight: 600;
+    white-space: nowrap;
 }
 
 .table-row.positive .table-cell.net {
@@ -614,6 +615,11 @@
     font-weight: 600;
 }
 
+.course-table .table-cell.earned {
+    justify-content: flex-end;
+    font-weight: 600;
+}
+
 .course-table .table-cell.delta.positive {
     color: #10b981;
 }
@@ -632,6 +638,14 @@
     font-size: 0.8rem;
     color: #10b981;
 }
+
+.course-table .table-cell.earned.positive {
+    color: #10b981;
+}
+
+.course-table .table-cell.earned.neutral {
+    color: #6b7280;
+}
 /*
 .course-table .table-cell.percentage.good {
     color: #10b981;
@@ -747,7 +761,8 @@
 
 .causals-table.compact .table-header {
     display: grid;
-    grid-template-columns: 2fr 60px 45px;
+    /* grid-template-columns: 2fr 80px 45px; */
+    grid-template-columns: 2fr auto;
     gap: 8px;
     padding: 8px 12px;
     font-size: 0.7rem;
@@ -755,7 +770,8 @@
 
 .causals-table.compact .table-row {
     display: grid;
-    grid-template-columns: 2fr 60px 45px;
+    /* grid-template-columns: 2fr 80px 45px; */
+    grid-template-columns: 2fr auto;
     gap: 8px;
     padding: 6px 12px;
     font-size: 0.75rem;

+ 8 - 0
public/css/style.css

@@ -16813,4 +16813,12 @@ body input[type=checkbox][name="annulla_lezione"]:checked {
 
 body div.dt-button-background {
   pointer-events: none;
+}
+
+select[multiple] {
+    max-height: 44px;
+}
+
+select[multiple] option {
+    display: none;
 }

+ 2 - 2
resources/views/layouts/app.blade.php

@@ -333,11 +333,11 @@
                                                 <span class="ms-3 d-md-inline">Calendario</span>
                                             </a>
                                         </li>
-                                        <li class="nav-item" style="{{Request::is('presence_reports') || Request::is('absence_reports') ? 'background-color: #c5d9e6;' : ''}}">
+                                        {{-- <li class="nav-item" style="{{Request::is('presence_reports') || Request::is('absence_reports') ? 'background-color: #c5d9e6;' : ''}}">
                                             <a href="/presence_reports" class="nav-link d-flex align-items-center linkMenu">
                                                 <span class="ms-3 d-md-inline">Presenze</span>
                                             </a>
-                                        </li>
+                                        </li> --}}
                                     </ul>
                                 </div>
                             </div>

+ 5 - 5
resources/views/livewire/records_in_out.blade.php

@@ -16,14 +16,14 @@
         <form action="" class=" d-flex align-items-center ">
 
             <select class="form-select form-select-lg me-1 " id="month" style="width:150px !important;">
-                <option value="x" {{$month == "x" ? 'selected' : ""}}>Anno completo</option>
+                <option value="x" {{$month == "x" ? 'selected' : ""}}>Stagione</option>
                 @foreach(getMonthList() as $mid => $mname)
                     <option value="{{$mid}}" {{$month == $mid ? 'selected' : ""}}>{{$mname}}</option>
                 @endforeach
             </select>
 
-            <select class="form-select " style="width:100px !important;" id="year">
-                @for($y=date("Y") + 5; $y>date("Y") - 2; $y--)
+            <select class="form-select " style="width:130px !important;" id="year">
+                @for($y=date("Y") + 5; $y>=date("Y") - 2; $y--)
                     <option value="{{$y}}" {{$y == date("Y") ? 'selected' : ''}}>{{$y}}</option>
                 @endfor
             </select>
@@ -75,7 +75,7 @@
                         Filtra per causale
                         </div>
                         <div class="col-md-12 m-1">
-                            <select name="search_causal_id[]" class="form-select filterCausalsIn filterCausals" multiple="multiple" wire:model="filterCausalsIn">
+                            <select name="search_causal_id[]" class="form-select filterCausalsIn filterCausals" multiple="multiple" wire:model="filterCausalsIn" wire:change='reset-collapse'>
                                 @foreach($causalsIn as $causal)
                                     <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
                                 @endforeach
@@ -195,7 +195,7 @@
                             <label class="form-label">Filtra per causale</label>
                         </div>
                         <div class="col-md-12 m-1">
-                            <select name="search_causal_id_x[]" class="form-select filterCausalsOut filterCausals" multiple="multiple" wire:model="filterCausalsOut">
+                            <select name="search_causal_id_x[]" class="form-select filterCausalsOut filterCausals" multiple="multiple" wire:model="filterCausalsOut" wire:change='reset-collapse'>
                                 @foreach($causalsOut as $causal)
                                     <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
                                 @endforeach

+ 26 - 23
resources/views/livewire/reports.blade.php

@@ -14,14 +14,14 @@
                     <div class="yearly-table-container" id="yearly-table"></div>
                 </div>
             </div>
-            <div class="chart-card">
+            {{-- <div class="chart-card">
                 <div class="chart-header">
                     <h3 class="chart-title">Tesserati per Stagione</h3>
                 </div>
                 <div class="chart-body">
                     <div class="members-table-container" id="members-table"></div>
                 </div>
-            </div>
+            </div> --}}
         </div>
 
         <div class="controls-section">
@@ -99,6 +99,9 @@
                             <div class="chart-container">
                                 <canvas id="members-chart"></canvas>
                             </div>
+                            <div class="chart-body">
+                                <div class="members-table-container" id="members-table"></div>
+                            </div>
                         </div>
                     </div>
                 </div>
@@ -109,7 +112,7 @@
         <div class="chart-row">
             <div class="chart-card modern-course-card">
                 <div class="chart-header">
-                    <h3 class="chart-title">Analisi Corsi</h3>
+                    <h3 class="chart-title">Analisi incassi corsi</h3>
                 </div>
                 <div class="chart-body">
                     <div class="course-controls">
@@ -300,7 +303,7 @@
                                 callbacks: {
                                     label: function (context) {
                                         return context.dataset.label + ': €' +
-                                            new Intl.NumberFormat('it-IT').format(context.parsed.y);
+                                            new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(context.parsed.y);
                                     }
                                 }
                             },
@@ -315,7 +318,7 @@
                                 grid: { color: 'rgba(0, 0, 0, 0.05)' },
                                 ticks: {
                                     callback: function (value) {
-                                        return '€' + new Intl.NumberFormat('it-IT').format(value);
+                                        return '€' + new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(value);
                                     }
                                 }
                             }
@@ -588,7 +591,6 @@
                             barThickness: "flex",
                             barPercentage: 0.65,
                             categoryPercentage: 0.4,
-
                         };
                     } else {
                         return {
@@ -602,7 +604,6 @@
                             barThickness: "flex",
                             barPercentage: 0.65,
                             categoryPercentage: 0.4,
-
                         };
                     }
                 });
@@ -697,13 +698,14 @@
                     const expense = parseFloat(expenseData[index] || 0);
                     const net = income - expense;
                     const rowClass = net < 0 ? 'negative' : (net > 0 ? 'positive' : 'neutral');
+                    const plusSymbol = net > 0 ? "+" : "";
 
                     tableHtml += `
                         <div class="table-row ${rowClass}">
                             <div class="table-cell month-name">${month}</div>
-                            <div class="table-cell income">€${new Intl.NumberFormat('it-IT').format(income)}</div>
-                            <div class="table-cell expense">€${new Intl.NumberFormat('it-IT').format(expense)}</div>
-                            <div class="table-cell net">€${new Intl.NumberFormat('it-IT').format(net)}</div>
+                            <div class="table-cell income">€${new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(income)}</div>
+                            <div class="table-cell expense">€${new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(expense)}</div>
+                            <div class="table-cell net">€${plusSymbol}${new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(net)}</div>
                         </div>
                     `;
                 });
@@ -738,9 +740,9 @@
                     tableHtml += `
                         <div class="table-row ${rowClass}">
                             <div class="table-cell month-name">${year}</div>
-                            <div class="table-cell income">€${new Intl.NumberFormat('it-IT').format(income)}</div>
-                            <div class="table-cell expense">€${new Intl.NumberFormat('it-IT').format(expense)}</div>
-                            <div class="table-cell net">€${new Intl.NumberFormat('it-IT').format(net)}</div>
+                            <div class="table-cell income">€${new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(income)}</div>
+                            <div class="table-cell expense">€${new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(expense)}</div>
+                            <div class="table-cell net">€${new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(net)}</div>
                         </div>
                     `;
                 });
@@ -881,7 +883,7 @@
                                 },
                                 ticks: {
                                     callback: function (value) {
-                                        return '€' + new Intl.NumberFormat('it-IT').format(value);
+                                        return '€' + new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(value);
                                     }
                                 }
                             }
@@ -906,7 +908,7 @@
                                 callbacks: {
                                     label: function (context) {
                                         return context.dataset.label + ': €' +
-                                            new Intl.NumberFormat('it-IT').format(context.parsed.y);
+                                            new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(context.parsed.y);
                                     }
                                 }
                             }
@@ -1163,14 +1165,14 @@
                                             let index = item.dataIndex;
                                             let monthNameExtended = item.dataset["monthNamesExtended"] ? item.dataset["monthNamesExtended"][index] : 0;
 
-                                            // return item.label + '\n' + 'TOTALE ATTESO: €' + new Intl.NumberFormat('it-IT').format(sum);
-                                            return monthNameExtended + '\n' + 'TOTALE ATTESO: €' + new Intl.NumberFormat('it-IT').format(sum);
+                                            // return item.label + '\n' + 'TOTALE ATTESO: €' + new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(sum);
+                                            return monthNameExtended + '\n' + 'TOTALE ATTESO: €' + new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(sum);
                                         },
                                         // labelTextColor: function(tooltipItems) {
                                         //     return tooltipItems.dataset.backgroundColor;
                                         // },
                                         label: function (tooltipItems) {
-                                            let label = tooltipItems.dataset.label + ': €' + new Intl.NumberFormat('it-IT').format(tooltipItems.parsed.y);
+                                            let label = tooltipItems.dataset.label + ': €' + new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(tooltipItems.parsed.y);
 
                                             return label;
                                         },
@@ -1219,7 +1221,7 @@
                 let tableHtml = `<div class="course-table">
                                     <div class="table-header">
                                         <div class="table-cell month">MESE</div>
-                                        <div class="table-cell percentage">%<br/>INCASSATO</div>
+                                        <div class="table-cell percentage">TOT. INCASSATO</div>
                                         <div class="table-cell delta">TOT. DA INCASSARE</div>
                                         <div class="table-cell suspended">SOSPESI</div>
                                     </div>`;
@@ -1248,14 +1250,15 @@
                     }
 
                     // Delta styling: positive when delta is 0 (fully paid), negative when there's missing amount
-                    const deltaClass = (total > 0 && delta === 0) ? 'positive' :
-                        (delta > 0) ? 'negative' : 'neutral';
+                    const deltaClass = (total > 0 && delta === 0) ? 'positive' : (delta > 0) ? 'negative' : 'neutral';
+                    const earnedClass = (earned > 0) ? 'positive' : 'neutral';
 
                     tableHtml += `
             <div class="table-row">
                 <div class="table-cell month">${row.month}</div>
-                <div class="table-cell percentage ${percentageClass}">${percentageDisplay}</div>
-                <div class="table-cell delta ${deltaClass}">€${new Intl.NumberFormat('it-IT').format(delta)}</div>
+                <!-- <div class="table-cell percentage ${percentageClass}">${percentageDisplay}</div> -->
+                <div class="table-cell earned ${earnedClass}">€${new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(earned)}</div>
+                <div class="table-cell delta ${deltaClass}">€${new Intl.NumberFormat('it-IT', {minimumFractionDigits: 2, maximumFractionDigits: 2}).format(delta)}</div>
                 <div class="table-cell suspended">${row.suspended}</div>
             </div>
         `;

+ 1 - 0
to_import.md

@@ -0,0 +1 @@
+riportato tutto