Bladeren bron

modifiche a modulo presenze e report

ferrari 4 maanden geleden
bovenliggende
commit
f532e49fd2

+ 78 - 17
app/Http/Livewire/Member.php

@@ -791,8 +791,74 @@ class Member extends Component
         $this->annullate = 0;
         $this->annullate = 0;
         $this->recuperi = 0;
         $this->recuperi = 0;
 
 
+        define("PRESENZE", 0);
+        define("ASSENZE", 1);
+        define("RECUPERO", 2);
+        define("ANNULLATE", 3);
+
+        $chartData = [
+            PRESENZE => [
+                "label" => "Presenze",
+                "backgroundColor" => "#0c6197",
+                "data" => array_fill(0, 12, 0),
+                "grouped" => true,
+                "stack" => "chartData",
+                "barThickness" => "flex",
+                "barPercentage" => 0.5,
+                "categoryPercentage" => 0.3,
+            ],
+            ASSENZE => [
+                "label" => "Assenze",
+                "backgroundColor" => "#ff0000",
+                "data" => array_fill(0, 12, 0),
+                "grouped" => true,
+                "stack" => "chartData",
+                "barThickness" => "flex",
+                "barPercentage" => 0.5,
+                "categoryPercentage" => 0.3,
+                
+            ],
+            RECUPERO => [
+                "label" => "Recupero",
+                "backgroundColor" => "#7136f6",
+                "data" => array_fill(0, 12, 0),
+                "grouped" => true,
+                "stack" => "chartData",
+                "barThickness" => "flex",
+                "barPercentage" => 0.5,
+                "categoryPercentage" => 0.3,
+                
+            ],
+            ANNULLATE => [
+                "label" => "Annullate",
+                "backgroundColor" => "#808080",
+                "data" => array_fill(0, 12, 0),
+                "grouped" => true,
+                "stack" => "chartData",
+                "barThickness" => "flex",
+                "barPercentage" => 0.5,
+                "categoryPercentage" => 0.3,
+                
+            ],
+        ];
+        $monthMap = [
+            9 => 0,
+            10 => 1,
+            11 => 2,
+            12 => 3,
+            1 => 4,
+            2 => 5,
+            3 => 6,
+            4 => 7,
+            5 => 8,
+            6 => 9,
+            7 => 10,
+            8 => 11,
+        ];
+
         foreach($calendars as $calendar)
         foreach($calendars as $calendar)
         {
         {
+            
             $days = ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'];
             $days = ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'];
             $dow = date('w', strtotime($calendar->from));
             $dow = date('w', strtotime($calendar->from));
             $d = $days[$dow];
             $d = $days[$dow];
@@ -808,23 +874,10 @@ class Member extends Component
                 $status = '';
                 $status = '';
                 if (in_array($calendar->id, $presences))
                 if (in_array($calendar->id, $presences))
                 {
                 {
-                    $status = "<span style=\"color:green\">Prezenza ordinaria</span>";
+                    $status = "<span style=\"color:#0c6197\">Prezenza ordinaria</span>";
                     $this->presenze += 1;
                     $this->presenze += 1;
-                    $monthMap = [
-                        9 => 0,
-                        10 => 1,
-                        11 => 2,
-                        12 => 3,
-                        1 => 4,
-                        2 => 5,
-                        3 => 6,
-                        4 => 7,
-                        5 => 8,
-                        6 => 9,
-                        7 => 10,
-                        8 => 11,
-                    ];
                     $this->valori[$monthMap[date('n', strtotime($calendar->from))]] += 1;
                     $this->valori[$monthMap[date('n', strtotime($calendar->from))]] += 1;
+                    $chartData[PRESENZE]["data"][$monthMap[date('n', strtotime($calendar->from))]] += 1;
                 }
                 }
                 else
                 else
                 {
                 {
@@ -832,6 +885,8 @@ class Member extends Component
                     {
                     {
                         $status = "<span style=\"color:gray\">Annullata</span>";
                         $status = "<span style=\"color:gray\">Annullata</span>";
                         $this->annullate += 1;
                         $this->annullate += 1;
+
+                        $chartData[ANNULLATE]["data"][$monthMap[date('n', strtotime($calendar->from))]] += 1;
                     }
                     }
                     else
                     else
                     {
                     {
@@ -839,6 +894,8 @@ class Member extends Component
                         {
                         {
                             $status = "<span style=\"color:red\">Assenza</span>";
                             $status = "<span style=\"color:red\">Assenza</span>";
                             $this->assenze += 1;
                             $this->assenze += 1;
+
+                            $chartData[ASSENZE]["data"][$monthMap[date('n', strtotime($calendar->from))]] += 1;
                         }
                         }
                     }
                     }
                 }
                 }
@@ -847,6 +904,8 @@ class Member extends Component
                 {
                 {
                     $status = "<span style=\"color:gray\">Annullata</span>";
                     $status = "<span style=\"color:gray\">Annullata</span>";
                     $this->annullate += 1;
                     $this->annullate += 1;
+
+                    $chartData[ANNULLATE]["data"][$monthMap[date('n', strtotime($calendar->from))]] += 1;
                 }
                 }
                 
                 
                 $this->member_presences[] = array('calendar_id' => $calendar->id, 'from' => $calendar->from, 'to' => $calendar->to, 'status' => $status);//\App\Models\Presence::where('member_id', $this->dataId)->get();
                 $this->member_presences[] = array('calendar_id' => $calendar->id, 'from' => $calendar->from, 'to' => $calendar->to, 'status' => $status);//\App\Models\Presence::where('member_id', $this->dataId)->get();
@@ -867,8 +926,10 @@ class Member extends Component
         $presences_recuperi = \App\Models\Presence::whereIn('calendar_id', $calendar_recuperi)->where('member_id', $this->dataId)->get();
         $presences_recuperi = \App\Models\Presence::whereIn('calendar_id', $calendar_recuperi)->where('member_id', $this->dataId)->get();
         foreach($presences_recuperi as $p)
         foreach($presences_recuperi as $p)
         {
         {
-            $this->member_presences[] = array('calendar_id' => $p->calendar->id, 'from' => $p->calendar->from, 'to' => $p->calendar->to, 'status' => '<span style="color:violet">Recupero</span>');//\App\Models\Presence::where('member_id', $this->dataId)->get();
+            $this->member_presences[] = array('calendar_id' => $p->calendar->id, 'from' => $p->calendar->from, 'to' => $p->calendar->to, 'status' => '<span style="color:#7136f6">Recupero</span>');//\App\Models\Presence::where('member_id', $this->dataId)->get();
             $this->recuperi += 1;
             $this->recuperi += 1;
+
+            $chartData[RECUPERO]["data"][$monthMap[date('n', strtotime($p->calendar->from))]] += 1;
         }
         }
 
 
         $sortVariable='from';
         $sortVariable='from';
@@ -878,7 +939,7 @@ class Member extends Component
         );
         );
 
 
         
         
-        $this->emit('load-chart', $this->mesi, $this->valori);
+        $this->emit('load-chart', $this->mesi, $this->valori, $chartData);
 
 
         //usort($this->member_presences, $this->cmp);
         //usort($this->member_presences, $this->cmp);
         //usort($this->member_presences, function ($a, $b) { return $a['from'] > $b['from']; });
         //usort($this->member_presences, function ($a, $b) { return $a['from'] > $b['from']; });

+ 48 - 76
app/Http/Livewire/Presence.php

@@ -50,25 +50,24 @@ class Presence extends Component
         $this->instructors = \App\Models\User::select('*')->where('level', 2)->where('enabled', true)->get();
         $this->instructors = \App\Models\User::select('*')->where('level', 2)->where('enabled', true)->get();
         $this->motivations = \App\Models\Motivation::select('*')->where('enabled', true)->where('type', 'del')->get();
         $this->motivations = \App\Models\Motivation::select('*')->where('enabled', true)->where('type', 'del')->get();
         $this->motivations_add = \App\Models\Motivation::select('*')->where('enabled', true)->where('type', 'add')->get();
         $this->motivations_add = \App\Models\Motivation::select('*')->where('enabled', true)->where('type', 'add')->get();
-        
     }
     }
 
 
-    public function updatedNewMemberMotivationId() {
+    public function updatedNewMemberMotivationId()
+    {
         $this->emit('reload');
         $this->emit('reload');
     }
     }
 
 
     public function render()
     public function render()
     {
     {
-        
+
         $this->records = [];
         $this->records = [];
 
 
         setlocale(LC_ALL, 'it_IT');
         setlocale(LC_ALL, 'it_IT');
 
 
         $presenceMembers = [];
         $presenceMembers = [];
 
 
-        if (!$this->manual)
-        {
-        
+        if (!$this->manual) {
+
             // Carco tutti gli iscritti a un corso padre in quel giorno con un range orario simile
             // Carco tutti gli iscritti a un corso padre in quel giorno con un range orario simile
             $days = ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'];
             $days = ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'];
             $dow = date('w', strtotime($this->calendar->from));
             $dow = date('w', strtotime($this->calendar->from));
@@ -83,51 +82,43 @@ class Presence extends Component
             // Elenco utenti iscritti al corso "padre"
             // Elenco utenti iscritti al corso "padre"
             $members_courses = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")->where('when', 'like', '%"from":"' . $h . '"%')->whereIn('course_id', $courses)->pluck('member_id')->toArray();
             $members_courses = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")->where('when', 'like', '%"from":"' . $h . '"%')->whereIn('course_id', $courses)->pluck('member_id')->toArray();
 
 
-            if ($this->filter != '')
-            {
+            if ($this->filter != '') {
                 $filter = $this->filter;
                 $filter = $this->filter;
                 $members = \App\Models\Member::whereIn('id', $members_courses)->where(function ($query) use ($filter) {
                 $members = \App\Models\Member::whereIn('id', $members_courses)->where(function ($query) use ($filter) {
                     $query->whereRaw("CONCAT(first_name, ' ', last_name) like '%" . $filter . "%'")
                     $query->whereRaw("CONCAT(first_name, ' ', last_name) like '%" . $filter . "%'")
                         ->orWhereRaw("CONCAT(last_name, ' ', first_name) like '%" . $filter . "%'");
                         ->orWhereRaw("CONCAT(last_name, ' ', first_name) like '%" . $filter . "%'");
                 })->orderBy('last_name')->orderBy('first_name')->get();
                 })->orderBy('last_name')->orderBy('first_name')->get();
-            }
-            else
+            } else
                 $members = \App\Models\Member::whereIn('id', $members_courses)->orderBy('last_name')->orderBy('first_name')->get();
                 $members = \App\Models\Member::whereIn('id', $members_courses)->orderBy('last_name')->orderBy('first_name')->get();
 
 
             // $presences = \App\Models\Presence::where('calendar_id', $this->calendar->id)->pluck('member_id')->toArray();
             // $presences = \App\Models\Presence::where('calendar_id', $this->calendar->id)->pluck('member_id')->toArray();
             // $my_presences = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('user_id', \Auth::user()->id)->pluck('member_id')->toArray();
             // $my_presences = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('user_id', \Auth::user()->id)->pluck('member_id')->toArray();
 
 
-            foreach($members as $member)
-            {
+            foreach ($members as $member) {
                 $presenceMembers[] = $member->id;
                 $presenceMembers[] = $member->id;
                 //$this->member_ids[] = $member->id;
                 //$this->member_ids[] = $member->id;
                 $this->records[] = $this->getMember($member);
                 $this->records[] = $this->getMember($member);
             }
             }
-
         }
         }
 
 
         // Aggiungo i membri iscritti
         // Aggiungo i membri iscritti
         $members_presences = \App\Models\Presence::where('calendar_id', $this->calendar->id)->whereNotIn('member_id', $presenceMembers)->pluck('member_id')->toArray();
         $members_presences = \App\Models\Presence::where('calendar_id', $this->calendar->id)->whereNotIn('member_id', $presenceMembers)->pluck('member_id')->toArray();
 
 
-        if ($this->filter != '')
-        {
+        if ($this->filter != '') {
             $filter = $this->filter;
             $filter = $this->filter;
             $members = \App\Models\Member::whereIn('id', $members_presences)->where(function ($query) use ($filter) {
             $members = \App\Models\Member::whereIn('id', $members_presences)->where(function ($query) use ($filter) {
                 $query->whereRaw("CONCAT(first_name, ' ', last_name) like '%" . $filter . "%'")
                 $query->whereRaw("CONCAT(first_name, ' ', last_name) like '%" . $filter . "%'")
                     ->orWhereRaw("CONCAT(last_name, ' ', first_name) like '%" . $filter . "%'");
                     ->orWhereRaw("CONCAT(last_name, ' ', first_name) like '%" . $filter . "%'");
             })->get();
             })->get();
-        }
-        else
+        } else
             $members = \App\Models\Member::whereIn('id', $members_presences)->get();
             $members = \App\Models\Member::whereIn('id', $members_presences)->get();
 
 
-        foreach($members as $member)
-        {
+        foreach ($members as $member) {
             //$this->member_ids[] = $member->id;
             //$this->member_ids[] = $member->id;
             $this->records[] = $this->getMember($member);
             $this->records[] = $this->getMember($member);
         }
         }
 
 
-        foreach($this->newMembers as $m)
-        {
+        foreach ($this->newMembers as $m) {
             $member = \App\Models\Member::findOrFail($m);
             $member = \App\Models\Member::findOrFail($m);
             //$this->member_ids[] = $member->id;
             //$this->member_ids[] = $member->id;
             $this->records[] = $this->getMember($member);
             $this->records[] = $this->getMember($member);
@@ -157,8 +148,7 @@ class Presence extends Component
 
 
         $certificate = '';
         $certificate = '';
         $y = "|";
         $y = "|";
-        if ($latestCert) 
-        {
+        if ($latestCert) {
             $latest_date = $latestCert->expire_date;
             $latest_date = $latestCert->expire_date;
             $status = '';
             $status = '';
             if ($latest_date < date("Y-m-d")) {
             if ($latest_date < date("Y-m-d")) {
@@ -177,30 +167,31 @@ class Presence extends Component
         $status = 0;
         $status = 0;
 
 
         $has_presence = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('member_id', $member->id)->first();
         $has_presence = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('member_id', $member->id)->first();
-        if ($has_presence)            
-        {
+        if ($has_presence) {
             $presence = true;
             $presence = true;
             $my_presence = $has_presence->user_id == \Auth::user()->id;
             $my_presence = $has_presence->user_id == \Auth::user()->id;
-            if ($has_presence->motivation_id > 0)
-            {
+            if ($has_presence->motivation_id > 0) {
                 $motivation = \App\Models\Motivation::findOrFail($has_presence->motivation_id)->name;
                 $motivation = \App\Models\Motivation::findOrFail($has_presence->motivation_id)->name;
             }
             }
             $status = $has_presence->status;
             $status = $has_presence->status;
         }
         }
 
 
-        if (in_array($member->id, $this->newMembers))
-        {
+        if (in_array($member->id, $this->newMembers)) {
             $presence = true;
             $presence = true;
             $my_presence = true;
             $my_presence = true;
         }
         }
 
 
         return array('id' => $member->id, 'first_name' => $member->first_name, 'last_name' => $member->last_name, 'certificate' => $y, 'presence' => $presence, 'my_presence' => $my_presence, 'status' => $status, 'motivation' => $motivation);
         return array('id' => $member->id, 'first_name' => $member->first_name, 'last_name' => $member->last_name, 'certificate' => $y, 'presence' => $presence, 'my_presence' => $my_presence, 'status' => $status, 'motivation' => $motivation);
-
     }
     }
 
 
     public function save($ids)
     public function save($ids)
     {
     {
+        $this->saveAndStay($ids);
+        return redirect()->to('/calendar');
+    }
 
 
+    public function saveAndStay($ids)
+    {
         $this->calendar->court_id = $this->court_id;
         $this->calendar->court_id = $this->court_id;
         $this->calendar->instructor_id = $this->instructor_id;
         $this->calendar->instructor_id = $this->instructor_id;
         $this->calendar->note = $this->note;
         $this->calendar->note = $this->note;
@@ -212,13 +203,11 @@ class Presence extends Component
 
 
         $x = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('user_id', \Auth::user()->id)->where('status', '<>', 99)->first();
         $x = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('user_id', \Auth::user()->id)->where('status', '<>', 99)->first();
         $mid = null;
         $mid = null;
-        if ($x)
-        {
+        if ($x) {
             $mid = $x->motivation_id;
             $mid = $x->motivation_id;
             $x->delete();
             $x->delete();
         }
         }
-        foreach($ids as $id)
-        {
+        foreach ($ids as $id) {
             $p = new \App\Models\Presence();
             $p = new \App\Models\Presence();
             $p->member_id = $id;
             $p->member_id = $id;
             $p->calendar_id = $this->calendar->id;
             $p->calendar_id = $this->calendar->id;
@@ -228,22 +217,18 @@ class Presence extends Component
             $p->save();
             $p->save();
         }
         }
         $this->emit('setSaving');
         $this->emit('setSaving');
-        return redirect()->to('/calendar');
-
     }
     }
 
 
     public function cancel($ids, $motivation_id)
     public function cancel($ids, $motivation_id)
     {
     {
 
 
         $presences = \App\Models\Presence::where('calendar_id', $this->calendar->id)->whereIn('member_id', $ids)->get();
         $presences = \App\Models\Presence::where('calendar_id', $this->calendar->id)->whereIn('member_id', $ids)->get();
-        foreach($presences as $presence)
-        {
+        foreach ($presences as $presence) {
             $presence->motivation_id = $motivation_id;
             $presence->motivation_id = $motivation_id;
             $presence->status = 99;
             $presence->status = 99;
             $presence->save();
             $presence->save();
         }
         }
         return redirect()->to('/presences?calendarId=' . $this->calendar->id);
         return redirect()->to('/presences?calendarId=' . $this->calendar->id);
-
     }
     }
 
 
     public function addMember($ids)
     public function addMember($ids)
@@ -252,11 +237,10 @@ class Presence extends Component
         $this->added = true;
         $this->added = true;
         //if (!in_array($id, $this->newMembers))
         //if (!in_array($id, $this->newMembers))
         //    $this->newMembers[] = $id;
         //    $this->newMembers[] = $id;
-        
+
         $this->member_ids = $ids;
         $this->member_ids = $ids;
 
 
         $this->emit('reload');
         $this->emit('reload');
-
     }
     }
 
 
     public function cancelCalendar()
     public function cancelCalendar()
@@ -270,8 +254,7 @@ class Presence extends Component
     public function createMember()
     public function createMember()
     {
     {
 
 
-        if (!$this->added)
-        {
+        if (!$this->added) {
             $this->newMemberFiscalCodeExist = false;
             $this->newMemberFiscalCodeExist = false;
             $this->validate([
             $this->validate([
                 "newMemberMotivationId" => 'required',
                 "newMemberMotivationId" => 'required',
@@ -285,13 +268,11 @@ class Presence extends Component
 
 
             // Check fiscal code exist
             // Check fiscal code exist
             $exist = false;
             $exist = false;
-            if ($this->newMemberFiscalCode != '')
-            {
+            if ($this->newMemberFiscalCode != '') {
                 $check = \App\Models\Member::where('fiscal_code', $this->newMemberFiscalCode)->get();
                 $check = \App\Models\Member::where('fiscal_code', $this->newMemberFiscalCode)->get();
                 $exist = $check->count() > 0;
                 $exist = $check->count() > 0;
             }
             }
-            if (!$exist)
-            {
+            if (!$exist) {
                 $member = \App\Models\Member::create([
                 $member = \App\Models\Member::create([
                     'first_name' => strtoupper($this->newMemberFirstName),
                     'first_name' => strtoupper($this->newMemberFirstName),
                     'last_name' => strtoupper($this->newMemberLastName),
                     'last_name' => strtoupper($this->newMemberLastName),
@@ -311,42 +292,36 @@ class Presence extends Component
                 $p->user_id = \Auth::user()->id;
                 $p->user_id = \Auth::user()->id;
                 $p->status = 0;
                 $p->status = 0;
                 $p->save();
                 $p->save();
-                
+
                 $this->emit('reload');
                 $this->emit('reload');
                 $this->emit('saved');
                 $this->emit('saved');
                 /*$this->newMemberFirstName = '';
                 /*$this->newMemberFirstName = '';
                 $this->newMemberLastName = '';
                 $this->newMemberLastName = '';
                 $this->newMemberEmail = '';
                 $this->newMemberEmail = '';
                 $this->newMemberFiscalCode = '';*/
                 $this->newMemberFiscalCode = '';*/
-            }
-            else
-            {
+            } else {
                 $this->newMemberFiscalCodeExist = true;
                 $this->newMemberFiscalCodeExist = true;
             }
             }
-        }
-        else
-        {
+        } else {
 
 
-            if ($this->member_ids != null)
-            {
+            if ($this->member_ids != null) {
                 $this->validate([
                 $this->validate([
                     "newMemberMotivationId" => 'required',
                     "newMemberMotivationId" => 'required',
                 ]);
                 ]);
-                foreach($this->member_ids as $m)
-                {
+                foreach ($this->member_ids as $m) {
                     //if ($this->manual)
                     //if ($this->manual)
                     //{
                     //{
-                        //\App\Models\Presence::where('calendar_id', $this->calendar->id)->where('user_id', \Auth::user()->id)->where('status', '<>', 99)->delete();
-                        //foreach($ids as $id)
-                        //{
-                            $p = new \App\Models\Presence();
-                            $p->member_id = $m;
-                            $p->calendar_id = $this->calendar->id;
-                            $p->motivation_id = $this->newMemberMotivationId;
-                            $p->user_id = \Auth::user()->id;
-                            $p->status = 0;
-                            $p->save();
-                        //}
+                    //\App\Models\Presence::where('calendar_id', $this->calendar->id)->where('user_id', \Auth::user()->id)->where('status', '<>', 99)->delete();
+                    //foreach($ids as $id)
+                    //{
+                    $p = new \App\Models\Presence();
+                    $p->member_id = $m;
+                    $p->calendar_id = $this->calendar->id;
+                    $p->motivation_id = $this->newMemberMotivationId;
+                    $p->user_id = \Auth::user()->id;
+                    $p->status = 0;
+                    $p->save();
+                    //}
                     /*}
                     /*}
                     else
                     else
                     {
                     {
@@ -359,7 +334,7 @@ class Presence extends Component
             //$this->member_id = 0;
             //$this->member_id = 0;
             $this->member_ids = [];
             $this->member_ids = [];
             $this->added = false;
             $this->added = false;
-            
+
             $this->emit('reload');
             $this->emit('reload');
             $this->emit('saved');
             $this->emit('saved');
         }
         }
@@ -367,7 +342,7 @@ class Presence extends Component
 
 
     public function createInstructor()
     public function createInstructor()
     {
     {
-        
+
         $user = \App\Models\User::create([
         $user = \App\Models\User::create([
             'name' => $this->userName,
             'name' => $this->userName,
             'email' => $this->userEmail,
             'email' => $this->userEmail,
@@ -378,8 +353,7 @@ class Presence extends Component
 
 
         $this->instructor_id = $user->id;
         $this->instructor_id = $user->id;
         $this->instructors = \App\Models\User::select('*')->where('level', 2)->where('enabled', true)->get();
         $this->instructors = \App\Models\User::select('*')->where('level', 2)->where('enabled', true)->get();
-        $this->emit('saved');        
-
+        $this->emit('saved');
     }
     }
 
 
     public function removeSingle($id)
     public function removeSingle($id)
@@ -387,16 +361,14 @@ class Presence extends Component
 
 
         \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('member_id', $id)->delete();
         \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('member_id', $id)->delete();
         $this->emit('reload');
         $this->emit('reload');
-
     }
     }
 
 
     public function revert($id)
     public function revert($id)
     {
     {
-
         $p = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('member_id', $id)->first();
         $p = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('member_id', $id)->first();
+        $p->motivation_id = null;
         $p->status = 0;
         $p->status = 0;
         $p->save();
         $p->save();
         $this->emit('reload');
         $this->emit('reload');
-
     }
     }
 }
 }

+ 51 - 51
app/Http/Livewire/Reports.php

@@ -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 = [];
         $labels = [];
         $earnedData = [];
         $earnedData = [];

+ 10 - 1
public/css/calendar.css

@@ -24,7 +24,8 @@
     --fc-bg-event-color: #8fdf82;
     --fc-bg-event-color: #8fdf82;
     --fc-bg-event-opacity: 0.3;
     --fc-bg-event-opacity: 0.3;
     --fc-highlight-color: rgba(188, 232, 241, 0.3);
     --fc-highlight-color: rgba(188, 232, 241, 0.3);
-    --fc-today-bg-color: rgba(255, 220, 40, 0.15);
+    /* --fc-today-bg-color: rgba(255, 220, 40, 0.15); */
+    --fc-today-bg-color: #c5d9e6;
     --fc-now-indicator-color: red;
     --fc-now-indicator-color: red;
 
 
     --bs-primary: #0c6197;
     --bs-primary: #0c6197;
@@ -112,6 +113,14 @@ body input[type="checkbox"] + label.form-label {
     margin-top: 0;
     margin-top: 0;
 }
 }
 
 
+.fc .fc-col-header-cell.fc-day-today {
+    background-color: var(--fc-today-bg-color);
+}
+
+.fc .fc-col-header-cell-cushion {
+    text-transform: capitalize;
+}
+
 @media (max-width: 1024px) {
 @media (max-width: 1024px) {
     body .fc .fc-toolbar.fc-header-toolbar .fc-toolbar-chunk .fc-button {
     body .fc .fc-toolbar.fc-header-toolbar .fc-toolbar-chunk .fc-button {
         font-size: 14px;
         font-size: 14px;

+ 16 - 1
public/css/style.css

@@ -16794,7 +16794,22 @@ body #card--dashboard > .btn--ui:has(i[class*="fa-arrow-left"]):hover {
   color: white;
   color: white;
   background-color: #0c6197 !important;
   background-color: #0c6197 !important;
 }
 }
-  /* END CSS Ferrari - Modifiche UI */
+
+body input[type="checkbox"]:checked:disabled {
+    background-color: #b1b1b1 !important;
+}
+
+input[type=checkbox][name="annulla_lezione"] {
+    border-color: red;
+    color: red;
+}
+
+body input[type=checkbox][name="annulla_lezione"]:checked {
+    background-color: red !important;
+    background-image: url("data:image/svg+xml,%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 485.6 485.6' xml:space='preserve'%3E%3Cpath d='M105.4,60.2c-12.5-12.5-32.8-12.5-45.3,0s-12.5,32.8,0,45.3l137.4,137.3L60.2,380.2c-12.5,12.5-12.5,32.8,0,45.3 s32.8,12.5,45.3,0l137.3-137.4l137.4,137.3c12.5,12.5,32.8,12.5,45.3,0s12.5-32.8,0-45.3L288.1,242.8l137.3-137.4 c12.5-12.5,12.5-32.8,0-45.3s-32.8-12.5-45.3,0L242.8,197.5L105.4,60.2z' fill='white'/%3E%3C/svg%3E%0A");
+    background-size: 88%;
+}
+/* END CSS Ferrari - Modifiche UI */
 
 
 body div.dt-button-background {
 body div.dt-button-background {
   pointer-events: none;
   pointer-events: none;

+ 7 - 6
resources/views/livewire/calendar.blade.php

@@ -1,6 +1,6 @@
 <style>
 <style>
     {!! $css_festivities !!} {
     {!! $css_festivities !!} {
-        background: #dcf1ff !important;
+        background: #ffff0040 !important;
     }
     }
 </style>
 </style>
 
 
@@ -15,7 +15,7 @@
             <div class="col"></div>
             <div class="col"></div>
             <div class="col-auto text-end mt-2">
             <div class="col-auto text-end mt-2">
                 <div class="form--item d-flex align-items-center form--item gap-3">
                 <div class="form--item d-flex align-items-center form--item gap-3">
-                    <label for="inputName" class="form-label mb-0">Tipologia</label>
+                    <label for="inputName" class="form-label mb-0">CORSO</label>
                     <select class="form-select form-select-lg me-1" id="name_filter" onchange="reloadCalendar()">
                     <select class="form-select form-select-lg me-1" id="name_filter" onchange="reloadCalendar()">
                         <option value="">
                         <option value="">
                         @foreach($names as $n)
                         @foreach($names as $n)
@@ -46,7 +46,7 @@
                     <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                     <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                 </div>
                 </div>
                 <div class="modal-body">
                 <div class="modal-body">
-                    <div class="row align-items-center">
+                    <div class="row align-items-center flex-nowrap">
                         <div class="col-auto">
                         <div class="col-auto">
                             <label for="course_subscription_id" class="form-label text-primary">Ora inizio</label>
                             <label for="course_subscription_id" class="form-label text-primary">Ora inizio</label>
                             <h3 class="time mb-0 text-primary">ORA</h3>
                             <h3 class="time mb-0 text-primary">ORA</h3>
@@ -248,17 +248,18 @@
 
 
         document.addEventListener('DOMContentLoaded', function() {
         document.addEventListener('DOMContentLoaded', function() {
             var calendarEl = document.getElementById('calendar');
             var calendarEl = document.getElementById('calendar');
+
+            initialView = document.body.clientWidth < 768 ? 'timeGridDay' : 'timeGridWeek';
             var calendar = new FullCalendar.Calendar(calendarEl, {
             var calendar = new FullCalendar.Calendar(calendarEl, {
-                initialView: 'timeGridWeek',
+                initialView: initialView,
                 slotMinTime: '06:00:00',
                 slotMinTime: '06:00:00',
                 headerToolbar: {
                 headerToolbar: {
                     // left: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth',
                     // left: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth',
-                    left: 'dayGridMonth,timeGridWeek',
+                    left: 'timeGridDay,timeGridWeek,dayGridMonth',
                     center: 'title',
                     center: 'title',
                     right: 'prevYear,prev,next,nextYear today',
                     right: 'prevYear,prev,next,nextYear today',
                 },
                 },
                 dateClick: function(info) {
                 dateClick: function(info) {
-                    
                     var x = info.dateStr.split("T");
                     var x = info.dateStr.split("T");
                     $("#date").val(x[0]);
                     $("#date").val(x[0]);
                     var y = x[1].split("+");
                     var y = x[1].split("+");

+ 43 - 24
resources/views/livewire/member.blade.php

@@ -2826,41 +2826,60 @@
             }, 200);
             }, 200);
         });
         });
 
 
-        Livewire.on('load-chart', (mesi, valori) => {
+        Livewire.on('load-chart', (mesi, valori, chartData) => {
 
 
-            try 
-            {
+            try {
 
 
                 const ctx = document.getElementById('presenzeChart');
                 const ctx = document.getElementById('presenzeChart');
 
 
-                try
-                {
+                try {
                     x.destroy();
                     x.destroy();
                 }
                 }
-                catch (ee)
-                {}
+                catch (ee) {}
 
 
                 x = new Chart(ctx, {
                 x = new Chart(ctx, {
-                    type: 'bar',
-                    data: {
-                    labels: mesi,
-                    datasets: [{
-                        label: 'Presenze',
-                        data: valori,
-                        borderWidth: 1
-                    }]
-                    },
-                    options: {
-                    scales: {
-                        y: {
-                        beginAtZero: true
+                        type: 'bar',
+                        data: {
+                            labels: mesi,
+                            // datasets: [
+                            //     {
+                            //         label: 'Presenze',
+                            //         data: valori,
+                            //         borderWidth: 1
+                            //     }
+                            // ],
+                            datasets: chartData,
+                        },
+                        options: {
+                            responsive: true,
+                            // maintainAspectRatio: false,
+                            interaction: {
+                                mode: 'index',
+                                intersect: false,
+                            },
+                            scales: {
+                                y: {
+                                beginAtZero: true
+                                }
+                            },
+                            plugins: {
+                                legend: {
+                                    display: false,
+                                },
+                                tooltip: {
+                                    backgroundColor: 'rgba(255, 255, 255, 1)',
+                                    titleColor: '#212529',
+                                    bodyColor: '#495057',
+                                    borderColor: '#e9ecef',
+                                    borderWidth: 2,
+                                    cornerRadius: 0,
+                                },
+                            },
                         }
                         }
                     }
                     }
-                    }
-                });
+                );
             }
             }
-            catch(e)
-            {
+            catch(e) {
                 console.log(e);
                 console.log(e);
             }
             }
         });
         });

+ 66 - 11
resources/views/livewire/presence.blade.php

@@ -74,6 +74,7 @@
             <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
             <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
                 <thead>
                 <thead>
                     <tr>
                     <tr>
+                        <th scope="col" class="annulla-lezione" style="display: none;">Annullamento</th>
                         <th scope="col">#</th>
                         <th scope="col">#</th>
                         <th scope="col">Cognome</th>
                         <th scope="col">Cognome</th>
                         <th scope="col">Nome</th>
                         <th scope="col">Nome</th>
@@ -85,6 +86,11 @@
                 <tbody id="checkall-target">
                 <tbody id="checkall-target">
                     @foreach($records as $idx => $record)
                     @foreach($records as $idx => $record)
                         <tr>
                         <tr>
+                            <td class="annulla-lezione" style="display: none;">
+                                @if ($record["status"] != 99)
+                                    <input name="annulla_lezione" class="member chkM" type="checkbox" value="{{$record["id"]}}">
+                                @endif
+                            </td>
                             <td>{{$idx + 1}}</td>
                             <td>{{$idx + 1}}</td>
                             <td>{{$record["last_name"]}}</td>
                             <td>{{$record["last_name"]}}</td>
                             <td>{{$record["first_name"]}}</td>                            
                             <td>{{$record["first_name"]}}</td>                            
@@ -115,16 +121,16 @@
                                             @if($manual)
                                             @if($manual)
                                                 <a onclick="removeSingle({{$record['id']}})"><i class="fas fa-trash"></i></a>
                                                 <a onclick="removeSingle({{$record['id']}})"><i class="fas fa-trash"></i></a>
                                             @else
                                             @else
-                                                <input class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : ''}}>
+                                                <input name="presence" class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : ''}}>
                                             @endif
                                             @endif
                                         @else
                                         @else
                                             <span style="color:#0C6197;font-size:25px;">&#10003;</span>
                                             <span style="color:#0C6197;font-size:25px;">&#10003;</span>
                                         @endif
                                         @endif
                                     @else
                                     @else
-                                        <input class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : ''}}>
+                                        <input name="presence" class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : ''}}>
                                     @endif
                                     @endif
                                 @else
                                 @else
-                                    Annullata &nbsp;&nbsp;(<a href="#" wire:click="revert({{$record["id"]}})"><small><i class="fa-solid fa-arrow-left-rotate"></i></small> Ripristina</a>)
+                                    Annullata &nbsp;&nbsp;-&nbsp;&nbsp; <a href="#" wire:click="revert({{$record["id"]}})" style="text-decoration: underline;color: #0c6197;"><small><i class="fa-solid fa-arrow-left-rotate"></i></small> Ripristina</a>
                                 @endif
                                 @endif
                             </td>
                             </td>
                         </tr>
                         </tr>
@@ -158,12 +164,13 @@
                             </select>                            
                             </select>                            
                         </div>
                         </div>
                         <button type="button" class="btn--ui lightGrey btSave" {{-- style="background-color:rgb(111, 31, 31) !important" --}} onclick="showHideDelete()">Annulla lezione per selezionati</button>                    
                         <button type="button" class="btn--ui lightGrey btSave" {{-- style="background-color:rgb(111, 31, 31) !important" --}} onclick="showHideDelete()">Annulla lezione per selezionati</button>                    
+                        <button type="button" class="btn--ui btSave" onclick="saveAndStay()">Salva presenze</button>
                         
                         
                     @endif              
                     @endif              
                 </div>
                 </div>
                 @if(!$manual)
                 @if(!$manual)
                     <div class="col-auto mt-2 text-end">
                     <div class="col-auto mt-2 text-end">
-                        <button type="button" class="btn--ui btSave" onclick="save()">Salva</button>        
+                        <button type="button" class="btn--ui btSave" onclick="saveAndQuit()">Salva e chiudi</button>        
                     </div>
                     </div>
                     <div class="col-xs-12 mt-2">
                     <div class="col-xs-12 mt-2">
                         <div class="showDelete" style="float:left;display:none;">
                         <div class="showDelete" style="float:left;display:none;">
@@ -299,6 +306,14 @@
     </div>
     </div>
     <br><br>
     <br><br>
 
 
+    <div wire:ignore.self class="modal fade saved-modal" id="savedModal" tabindex="-1" role="dialog" aria-labelledby="savedModal" aria-hidden="true">
+        <div class="modal-dialog modal-sm">
+            <div class="modal-content">
+                <div class="modal-header"></div>
+                <div class="modal-body">Presenze salvate con successo</div>
+            </div>
+        </div>
+    </div>
 </div>
 </div>
 
 
 @push('scripts')
 @push('scripts')
@@ -430,16 +445,26 @@
 
 
         window.livewire.on('setSaving', () => {
         window.livewire.on('setSaving', () => {
             isSaving = true;
             isSaving = true;
+            showSavedAlert();
         });
         });
 
 
-        function save()
+        let saved_alert_timeout;
+        function showSavedAlert() {
+            $('#savedModal').modal("show");
+            clearTimeout(saved_alert_timeout);
+            saved_alert_timeout = setTimeout(() => {
+                $('#savedModal').modal("hide");
+            }, 3000);
+        }
+
+        function saveAndQuit()
         {
         {
-            var ids = [];
-            $('input[type=checkbox]').each(function () {
+            let presence_ids = [];
+            $('input[name="presence"][type="checkbox"]').each(function () {
                 if ($(this).is(":checked")) 
                 if ($(this).is(":checked")) 
                 {
                 {
                     var val = $(this).val();
                     var val = $(this).val();
-                    ids.push(val);
+                    presence_ids.push(val);
                 }
                 }
             });
             });
 
 
@@ -448,13 +473,32 @@
                 @this.set('motivation_manual_id', motivation_manual_id);
                 @this.set('motivation_manual_id', motivation_manual_id);
             @endif
             @endif
 
 
-            @this.save(ids);
+            @this.save(presence_ids);
+        }
+
+        function saveAndStay()
+        {   
+            let presence_ids = [];
+            $('input[name="presence"][type="checkbox"]').each(function () {
+                if ($(this).is(":checked")) 
+                {
+                    var val = $(this).val();
+                    presence_ids.push(val);
+                }
+            });
+
+            @if($manual)
+                var motivation_manual_id = $("#motivation_manual_id").val();
+                @this.set('motivation_manual_id', motivation_manual_id);
+            @endif
+
+            @this.saveAndStay(presence_ids);
         }
         }
 
 
         function cancel()
         function cancel()
         {
         {
             var ids = [];
             var ids = [];
-            $('input[type=checkbox]').each(function () {
+            $('input[name="annulla_lezione"][type="checkbox"]').each(function () {
                 if ($(this).is(":checked")) 
                 if ($(this).is(":checked")) 
                 {
                 {
                     var val = $(this).val();
                     var val = $(this).val();
@@ -508,14 +552,25 @@
             $('#instructorModal').modal('hide');
             $('#instructorModal').modal('hide');
         }
         }
 
 
+        function togglePresenceCheckboxDisabled(disabled = false) {
+            let presence_checkboxes = document.querySelectorAll("input[name='presence'][type='checkbox']");
+            presence_checkboxes.forEach((presence_checkbox) => {
+                presence_checkbox.disabled = disabled;
+            });
+        }
+
         function showHideDelete()
         function showHideDelete()
         {
         {
+            togglePresenceCheckboxDisabled(true);
+            $(".annulla-lezione").show();
             $(".showDelete").show();
             $(".showDelete").show();
             $(".btSave").hide();
             $(".btSave").hide();
         }
         }
-
+        
         function hideShowDelete()
         function hideShowDelete()
         {
         {
+            togglePresenceCheckboxDisabled(false);
+            $(".annulla-lezione").hide();
             $(".showDelete").hide();
             $(".showDelete").hide();
             $(".btSave").show();
             $(".btSave").show();
         }
         }

+ 13 - 18
resources/views/livewire/reports.blade.php

@@ -5,19 +5,21 @@
 
 
     <div class="dashboard-container">
     <div class="dashboard-container">
 
 
-        <div class="chart-row">
+        <div class="chart-row" style="display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start;">
+            <div class="chart-card">
+                <div class="chart-header">
+                    <h3 class="chart-title">Entrate/Uscite totali</h3>
+                </div>
+                <div class="chart-body">
+                    <div class="yearly-table-container" id="yearly-table"></div>
+                </div>
+            </div>
             <div class="chart-card">
             <div class="chart-card">
                 <div class="chart-header">
                 <div class="chart-header">
                     <h3 class="chart-title">Tesserati per Stagione</h3>
                     <h3 class="chart-title">Tesserati per Stagione</h3>
                 </div>
                 </div>
                 <div class="chart-body">
                 <div class="chart-body">
-                    <div style="display: grid; grid-template-columns: 1fr 500px; gap: 1rem; align-items: start;">
-                        <div class="chart-container">
-                            <canvas id="members-chart"></canvas>
-                        </div>
-                        <div class="yearly-table-container" id="yearly-table">
-                        </div>
-                    </div>
+                    <div class="members-table-container" id="members-table"></div>
                 </div>
                 </div>
             </div>
             </div>
         </div>
         </div>
@@ -72,7 +74,7 @@
             <div class="chart-row">
             <div class="chart-row">
                 <div class="chart-card">
                 <div class="chart-card">
                     <div class="chart-header">
                     <div class="chart-header">
-                        <h3 class="chart-title">Causali Performanti - <span id="causals-season-title">{{ $seasonFilter }}</span></h3>
+                        <h3 class="chart-title">Redditività per Causale - <span id="causals-season-title">{{ $seasonFilter }}</span></h3>
                     </div>
                     </div>
                     <div class="chart-body">
                     <div class="chart-body">
                         <div style="display: grid; grid-template-columns: 1fr 700px; gap: 1rem; align-items: start;">
                         <div style="display: grid; grid-template-columns: 1fr 700px; gap: 1rem; align-items: start;">
@@ -95,9 +97,7 @@
                     <div class="chart-body">
                     <div class="chart-body">
                         <div style="display: grid; grid-template-columns: 1fr 500px; gap: 1rem; align-items: start;">
                         <div style="display: grid; grid-template-columns: 1fr 500px; gap: 1rem; align-items: start;">
                             <div class="chart-container">
                             <div class="chart-container">
-                                <canvas id="members-chart2"></canvas>
-                            </div>
-                            <div class="members-table-container" id="members-table">
+                                <canvas id="members-chart"></canvas>
                             </div>
                             </div>
                         </div>
                         </div>
                     </div>
                     </div>
@@ -553,7 +553,7 @@
                         minimumFractionDigits: 2,
                         minimumFractionDigits: 2,
                         maximumFractionDigits: 2
                         maximumFractionDigits: 2
                     }).format(value)}</div>
                     }).format(value)}</div>
-                <div class="table-cell percent">${percentage}%</div>
+                <!-- <div class="table-cell percent">${percentage}%</div> -->
             </div>
             </div>
         `;
         `;
                 });
                 });
@@ -563,16 +563,12 @@
             },
             },
             createMembersChart: function (seasonKey, membersData) {
             createMembersChart: function (seasonKey, membersData) {
                 const chartId = `members-chart`;
                 const chartId = `members-chart`;
-                const chartId2 = `members-chart2`;
                 const canvas = document.getElementById(chartId);
                 const canvas = document.getElementById(chartId);
-                const canvas2 = document.getElementById(chartId2);
                 if (!canvas) return;
                 if (!canvas) return;
 
 
                 this.destroyChart(chartId);
                 this.destroyChart(chartId);
-                this.destroyChart(chartId2);
 
 
                 const ctx = canvas.getContext('2d');
                 const ctx = canvas.getContext('2d');
-                const ctx2 = canvas2.getContext('2d');
 
 
                 const gradient = ctx.createLinearGradient(0, 0, 0, 400);
                 const gradient = ctx.createLinearGradient(0, 0, 0, 400);
                 gradient.addColorStop(0, 'rgba(59, 91, 219, 0.3)');
                 gradient.addColorStop(0, 'rgba(59, 91, 219, 0.3)');
@@ -677,7 +673,6 @@
                 };
                 };
 
 
                 this.charts[chartId] = new Chart(ctx, options);
                 this.charts[chartId] = new Chart(ctx, options);
-                this.charts[chartId2] = new Chart(ctx2, options);
             },
             },
             updateMonthlyTable: function (monthlyData) {
             updateMonthlyTable: function (monthlyData) {
                 const container = document.getElementById('monthly-table');
                 const container = document.getElementById('monthly-table');