ferrari 2 месяцев назад
Родитель
Сommit
45312a944b
3 измененных файлов с 74 добавлено и 29 удалено
  1. 30 21
      app/Http/Livewire/Member.php
  2. 10 0
      public/css/style.css
  3. 34 8
      resources/views/livewire/member.blade.php

+ 30 - 21
app/Http/Livewire/Member.php

@@ -166,7 +166,7 @@ class Member extends Component
     public $presenze = 0;
     public $presenze = 0;
     public $assenze = 0;
     public $assenze = 0;
     public $annullate = 0;
     public $annullate = 0;
-    public $recuperi = 0;
+    public $recuperi = [];
 
 
     protected $rules = [
     protected $rules = [
         'first_name' => 'required',
         'first_name' => 'required',
@@ -746,12 +746,12 @@ class Member extends Component
         $this->presenze = 0;
         $this->presenze = 0;
         $this->assenze = 0;
         $this->assenze = 0;
         $this->annullate = 0;
         $this->annullate = 0;
-        $this->recuperi = 0;
+        $this->recuperi = [];
 
 
         define("PRESENZE", 0);
         define("PRESENZE", 0);
         define("ASSENZE", 1);
         define("ASSENZE", 1);
-        define("RECUPERO", 2);
-        define("ANNULLATE", 3);
+        // define("RECUPERO", 2);
+        define("ANNULLATE", 2);
 
 
         $chartData = [
         $chartData = [
             PRESENZE => [
             PRESENZE => [
@@ -775,17 +775,16 @@ class Member extends Component
                 "categoryPercentage" => 0.3,
                 "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,
-                
-            ],
+            // RECUPERO => [
+            //     "label" => "Recupero",
+            //     "backgroundColor" => "#7136f6",
+            //     "data" => array_fill(0, 12, 0),
+            //     "grouped" => true,
+            //     "stack" => "chartData",
+            //     "barThickness" => "flex",
+            //     "barPercentage" => 0.5,
+            //     "categoryPercentage" => 0.3,
+            // ],
             ANNULLATE => [
             ANNULLATE => [
                 "label" => "Annullate",
                 "label" => "Annullate",
                 "backgroundColor" => "#808080",
                 "backgroundColor" => "#808080",
@@ -834,7 +833,7 @@ class Member extends Component
                 $annullata = false;
                 $annullata = false;
                 if (in_array($calendar->id, $presences))
                 if (in_array($calendar->id, $presences))
                 {
                 {
-                    $status = "<span style=\"color:#0c6197\">Prezenza ordinaria</span>";
+                    $status = "<span style=\"color:#0c6197\">Presenza</span>";
                     $this->presenze += 1;
                     $this->presenze += 1;
                     $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;
                     $chartData[PRESENZE]["data"][$monthMap[date('n', strtotime($calendar->from))]] += 1;
@@ -869,7 +868,7 @@ class Member extends Component
                     $chartData[ANNULLATE]["data"][$monthMap[date('n', strtotime($calendar->from))]] += 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, 'motivation' => null);//\App\Models\Presence::where('member_id', $this->dataId)->get();
             }
             }
 
 
             //$courses = array(1);
             //$courses = array(1);
@@ -883,14 +882,23 @@ class Member extends Component
         }
         }
 
 
         // Manuali (recuperi)
         // Manuali (recuperi)
+        // $calendar_recuperi = \App\Models\Calendar::where('manual', 1)->where('name', $this->presenceTitleFilter)->pluck('id')->toArray();
         $calendar_recuperi = \App\Models\Calendar::where('manual', 1)->where('name', $this->presenceTitleFilter)->pluck('id')->toArray();
         $calendar_recuperi = \App\Models\Calendar::where('manual', 1)->where('name', $this->presenceTitleFilter)->pluck('id')->toArray();
         $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:#7136f6">Recupero</span>');//\App\Models\Presence::where('member_id', $this->dataId)->get();
-            $this->recuperi += 1;
+            // $this->member_presences[] = array('calendar_id' => $p->calendar->id, 'from' => $p->calendar->from, 'to' => $p->calendar->to, 'status' => '<span style="color:#7136f6">Recupero</span>', 'motivation' => $p->motivation->name);//\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:#0c6197\">Presenza</span>', 'motivation' => $p->motivation->name);//\App\Models\Presence::where('member_id', $this->dataId)->get();
+
+            if ($p->motivation) {
+                if (!isset($this->recuperi[$p->motivation->name])) $this->recuperi[$p->motivation->name] = 0;
+
+                $this->recuperi[$p->motivation->name] += 1;
+            }
+            $this->presenze += 1;
 
 
-            $chartData[RECUPERO]["data"][$monthMap[date('n', strtotime($p->calendar->from))]] += 1;
+            $chartData[PRESENZE]["data"][$monthMap[date('n', strtotime($p->calendar->from))]] += 1;
+            // $chartData[RECUPERO]["data"][$monthMap[date('n', strtotime($p->calendar->from))]] += 1;
         }
         }
 
 
         $sortVariable='from';
         $sortVariable='from';
@@ -946,7 +954,8 @@ class Member extends Component
         // Manuali (recuperi)
         // Manuali (recuperi)
         $calendar_recuperi = \App\Models\Calendar::where('manual', 1)->pluck('name')->toArray();
         $calendar_recuperi = \App\Models\Calendar::where('manual', 1)->pluck('name')->toArray();
         
         
-        $this->presenceYears = \App\Models\Course::where('created_at', '>', '2025-08-01')->whereIn('id', $course_ids)->orderBy('year')->groupBy('year')->pluck('year')->toArray();
+        // $this->presenceYears = \App\Models\Course::where('created_at', '>', '2025-08-01')->whereIn('id', $course_ids)->orderBy('year')->groupBy('year')->pluck('year')->toArray();
+        $this->presenceYears = \App\Models\Course::whereIn('id', $course_ids)->orderBy('year')->groupBy('year')->pluck('year')->toArray();
         $this->presenceTitle = \App\Models\Course::whereIn('id', $course_ids)->orderBy('name')->groupBy('name')->pluck('name')->toArray();
         $this->presenceTitle = \App\Models\Course::whereIn('id', $course_ids)->orderBy('name')->groupBy('name')->pluck('name')->toArray();
 
 
         foreach($calendar_recuperi as $cr)
         foreach($calendar_recuperi as $cr)

+ 10 - 0
public/css/style.css

@@ -16821,4 +16821,14 @@ select[multiple] {
 
 
 select[multiple] option {
 select[multiple] option {
     display: none;
     display: none;
+}
+
+.presenzechart-wrapper {
+  position: relative;
+}
+
+button.download-png {
+    position: absolute;
+    top: 0;
+    right: 0;
 }
 }

+ 34 - 8
resources/views/livewire/member.blade.php

@@ -1151,7 +1151,7 @@
                                             </div>
                                             </div>
                                         </div>
                                         </div>
                                         <br>
                                         <br>
-                                        <div class="row ">
+                                        <div class="row align-items-center">
                                             <div class="col-md-3">
                                             <div class="col-md-3">
                                                 <div class="box-presenze">
                                                 <div class="box-presenze">
                                                     Presenze<br>
                                                     Presenze<br>
@@ -1164,22 +1164,29 @@
                                                     {{$assenze}}
                                                     {{$assenze}}
                                                 </div>
                                                 </div>
                                             </div>
                                             </div>
-                                            <div class="col-md-3">
-                                                <div class="box-recupero">
-                                                    Recupero<br>
-                                                    {{$recuperi}}
-                                                </div>
-                                            </div>
-                                            <div class="col-md-3">
+                                            <div class="col-md-3" style="border-right: 1px solid gray">
                                                 <div class="box-annullate">
                                                 <div class="box-annullate">
                                                     Annullate<br>
                                                     Annullate<br>
                                                     {{$annullate}}
                                                     {{$annullate}}
                                                 </div>
                                                 </div>
                                             </div>
                                             </div>
+                                            <div class="col-md-3">
+                                                <div class="row">
+                                                    {{-- <div class="col-12"><div class="box-recupero">Recupero {{$recuperi}}</div></div>
+                                                    <div class="col-12"><div class="box-recupero">Recupero {{$recuperi}}</div></div> --}}
+                                                    @foreach ($recuperi as $name => $count)
+                                                    <div class="col-12"><div class="box-presenze">{!!$name!!} {{$count}}</div></div>
+                                                    @endforeach
+                                                    {{-- <div class="col-12"><div class="box-presenze">Recupero {{$recuperi}}</div></div> --}}
+                                                </div>
+                                            </div>
                                         </div>                                        
                                         </div>                                        
                                         <div class="row ">
                                         <div class="row ">
                                             <div class="col-md-12">
                                             <div class="col-md-12">
+                                                <div class="presenzechart-wrapper">
                                                     <canvas id="presenzeChart" style="padding:20px"></canvas>
                                                     <canvas id="presenzeChart" style="padding:20px"></canvas>
+                                                    <button class="btn--ui download-png" onclick="downloadChart('presenzeChart')" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Scarica grafico"><i class="fas fa-download"></i></button>
+                                                </div>
                                             </div>
                                             </div>
                                         </div>
                                         </div>
                                         @if (!empty($member_presences))
                                         @if (!empty($member_presences))
@@ -1191,6 +1198,7 @@
                                                             <th>Data</th>
                                                             <th>Data</th>
                                                             <th>Orario</th>
                                                             <th>Orario</th>
                                                             <th>Stato</th>
                                                             <th>Stato</th>
+                                                            <th>Motivazione</th>
                                                         </tr>                                                        
                                                         </tr>                                                        
                                                     </thead>
                                                     </thead>
                                                     <tbody>
                                                     <tbody>
@@ -1199,6 +1207,7 @@
                                                                 <td>{{date("d/m/Y", strtotime($mp["from"]))}}</td>
                                                                 <td>{{date("d/m/Y", strtotime($mp["from"]))}}</td>
                                                                 <td>{{date("H:i", strtotime($mp["from"]))}} - {{date("H:i", strtotime($mp["to"]))}}</td>
                                                                 <td>{{date("H:i", strtotime($mp["from"]))}} - {{date("H:i", strtotime($mp["to"]))}}</td>
                                                                 <td>{!!$mp["status"]!!}</td>
                                                                 <td>{!!$mp["status"]!!}</td>
+                                                                <td>{!!$mp["motivation"]!!}</td>
                                                             </tr>
                                                             </tr>
                                                         @endforeach
                                                         @endforeach
                                                     </tbody>
                                                     </tbody>
@@ -2848,6 +2857,15 @@
             }, 200);
             }, 200);
         });
         });
 
 
+        function downloadChart(chartId) {
+            x.toBase64Image()
+            var a = document.createElement('a');
+            a.href = Chart.getChart(chartId).toBase64Image()
+            a.download = @this.first_name + " " + @this.last_name + ' - Grafico Presenze.png';
+            a.click();
+            a.remove();
+        }
+
         Livewire.on('load-chart', (mesi, valori, chartData) => {
         Livewire.on('load-chart', (mesi, valori, chartData) => {
 
 
             try {
             try {
@@ -2895,6 +2913,14 @@
                                     borderColor: '#e9ecef',
                                     borderColor: '#e9ecef',
                                     borderWidth: 2,
                                     borderWidth: 2,
                                     cornerRadius: 0,
                                     cornerRadius: 0,
+                                    titleFont: {
+                                        size: 18,
+                                        weight: 'bold',
+                                    },
+                                    bodyFont: {
+                                        size: 16,
+                                        weight: '400',
+                                    },
                                 },
                                 },
                             },
                             },
                         }
                         }