Просмотр исходного кода

modulo presenze - Campo e istruttore per presenza

ferrari 4 месяцев назад
Родитель
Сommit
969f1c2d5c

+ 46 - 1
app/Http/Livewire/Presence.php

@@ -14,6 +14,7 @@ class Presence extends Component
     public $member_ids = [];
 
     public $court_id, $instructor_id, $motivation_id, $motivation_manual_id, $note, $manual;
+    public $save_court_id, $save_instructor_id, $save_notes;
 
     public $newMemberFirstName, $newMemberLastName, $newMemberEmail, $newMemberToComplete, $newMemberFiscalCode, $newMemberFiscalCodeExist, $newMemberMotivationId;
 
@@ -50,6 +51,9 @@ class Presence extends Component
         $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_add = \App\Models\Motivation::select('*')->where('enabled', true)->where('type', 'add')->get();
+        $this->save_court_id = 0;
+        $this->save_instructor_id = 0;
+        $this->save_notes = '';
     }
 
     public function updatedNewMemberMotivationId()
@@ -165,6 +169,9 @@ class Presence extends Component
         $my_presence = false;
         $motivation = '';
         $status = 0;
+        $court = '';
+        $instructor = '';
+        $notes = '';
 
         $has_presence = \App\Models\Presence::where('calendar_id', $this->calendar->id)->where('member_id', $member->id)->first();
         if ($has_presence) {
@@ -174,6 +181,16 @@ class Presence extends Component
                 $motivation = \App\Models\Motivation::findOrFail($has_presence->motivation_id)->name;
             }
             $status = $has_presence->status;
+
+            if ($has_presence->court_id > 0) {
+                $court = \App\Models\Court::findOrFail($has_presence->court_id)->name;
+            }
+            if ($has_presence->instructor_id > 0) {
+                $instructor = \App\Models\User::findOrFail($has_presence->instructor_id)->name;
+            }
+            if (!is_null($has_presence->notes)) {
+                $notes = $has_presence->notes;
+            }
         }
 
         if (in_array($member->id, $this->newMembers)) {
@@ -181,7 +198,19 @@ class Presence extends Component
             $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,
+            'court' => $court,
+            'instructor' => $instructor,
+            'notes' => $notes,
+        );
     }
 
     public function save($ids)
@@ -214,6 +243,16 @@ class Presence extends Component
             $p->motivation_id = $mid;
             $p->user_id = \Auth::user()->id;
             $p->status = 0;
+            if ($this->save_court_id > 0) {
+                $p->court_id = $this->save_court_id;
+            }
+            if ($this->save_instructor_id > 0) {
+                $p->instructor_id = $this->save_instructor_id;
+            }
+            if ($this->save_notes != '') {
+                $p->notes = $this->save_notes;
+            }
+
             $p->save();
         }
         $this->emit('setSaving');
@@ -291,6 +330,9 @@ class Presence extends Component
                 $p->motivation_id = $this->newMemberMotivationId;
                 $p->user_id = \Auth::user()->id;
                 $p->status = 0;
+                $p->court_id = null;
+                $p->instructor_id = null;
+                $p->notes = null;
                 $p->save();
 
                 $this->emit('reload');
@@ -320,6 +362,9 @@ class Presence extends Component
                     $p->motivation_id = $this->newMemberMotivationId;
                     $p->user_id = \Auth::user()->id;
                     $p->status = 0;
+                    $p->court_id = null;
+                    $p->instructor_id = null;
+                    $p->notes = null;
                     $p->save();
                     //}
                     /*}

+ 4 - 1
app/Models/Presence.php

@@ -14,7 +14,10 @@ class Presence extends Model
         'calendar_id',
         'member_course_id',
         'user_id',
-        'motivation_id'
+        'motivation_id',
+        'court_id',
+        'instructor_id',
+        'notes',
     ];
 
     public function member()

+ 38 - 0
database/migrations/2025_09_17_144135_add_fields_to_presences_table.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('presences', function (Blueprint $table) {
+            $table->unsignedBigInteger('court_id')->nullable();
+            $table->foreign('court_id')->nullable()->references('id')->on('courts')->onUpdate('cascade')->onDelete('cascade');
+            $table->unsignedBigInteger('instructor_id')->nullable();
+            $table->foreign('instructor_id')->nullable()->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
+            $table->string('notes')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('presences', function (Blueprint $table) {
+            $table->dropColumn('court_id');
+            $table->dropColumn('instructor_id');
+            $table->dropColumn('notes');
+        });
+    }
+};

+ 2 - 2
resources/views/livewire/calendar.blade.php

@@ -168,7 +168,7 @@
                             
                         </div>
                     </div>  
-                    <div class="row">
+                    {{-- <div class="row">
                         <div class="col-md-6">
                             <label for="course_frequency_id" class="form-label">Campo</label>
                             <select class="form-select form-select-lg me-1" id="court_id">
@@ -194,7 +194,7 @@
                             <label for="note" class="form-label">Note</label>
                             <input class="form-control" type="name" id="note" placeholder="Note">                            
                         </div>
-                    </div>                    
+                    </div> --}}
                 </div>
                 <div class="modal-footer mt-2">
                     <button class="btn--ui lightGrey" >Annulla</a>

+ 379 - 306
resources/views/livewire/presence.blade.php

@@ -2,198 +2,206 @@
 
     <a class="btn--ui lightGrey" href="/calendar"><i class="fa-solid fa-arrow-left"></i></a><br><br>
 
-        <div class="compare--chart_wrapper d-none"></div>
+    <div class="compare--chart_wrapper d-none"></div>
 
-        <div class="row">
-            <div class="col-sm-12">
-                <div class="row">
-                    <div class="col-auto">
-                        <h3 class="text-primary">{{$calendar->course ? $calendar->course->name : $calendar->name}}</h3>
-                    </div>
-                    <div class="col"></div>
-                    <div class="col-auto text-end">
-                        <h4>{!!$this->getDateX()!!}<br>ora inizio {{date("H:i", strtotime($calendar->from))}}</h4>
-                    </div>
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="row">
+                <div class="col-auto">
+                    <h3 class="text-primary">{{$calendar->course ? $calendar->course->name : $calendar->name}}</h3>
+                </div>
+                <div class="col"></div>
+                <div class="col-auto text-end">
+                    <h4>{!!$this->getDateX()!!}<br>ora inizio {{date("H:i", strtotime($calendar->from))}}</h4>
                 </div>
             </div>
+        </div>
 
-            @if($manual)
+        {{-- @if($manual)
 
-                <div class="col-md-6">
-                    <label for="court_id" class="form-label">Motivazione</label>
-                    <select class="form-select form-select-lg me-1 " id="motivation_manual_id">
-                        <option value="">
-                        @foreach($motivations_add as $m)
-                            <option value="{{$m->id}}" {{$motivation_manual_id == $m->id ? 'selected' : ''}}>{{$m->name}}</option>
-                        @endforeach
-                    </select>
-                </div>
+        <div class="col-md-6">
+            <label for="court_id" class="form-label">Motivazione</label>
+            <select class="form-select form-select-lg me-1 " id="motivation_manual_id">
+                <option value="">
+                    @foreach($motivations_add as $m)
+                <option value="{{$m->id}}" {{$motivation_manual_id==$m->id ? 'selected' : ''}}>{{$m->name}}</option>
+                @endforeach
+            </select>
+        </div>
 
-            @else
-                <div class="col-md-6">
-                    <label for="court_id" class="form-label">Campo</label>
-                    <select class="form-select form-select-lg me-1 " wire:model="court_id">
-                        <option value="">
-                        @foreach($courts as $c)
-                            <option value="{{$c["id"]}}">{{$c["name"]}}</option>
-                        @endforeach
-                    </select>
-                </div>
-                <div class="col">
-                    <label for="instructor_id" class="form-label">Istruttore</label>
-                    <select class="form-select form-select-lg me-1 " wire:model="instructor_id">
-                        <option value="">
-                        @foreach($instructors as $i)
-                            <option value="{{$i["id"]}}">{{$i["name"]}}</option>
-                        @endforeach
-                    </select>
-                </div>
-                <div class="col-auto mt-2">
-                    <br>
-                    <button type="button" class="btn--ui primary" data-bs-toggle="modal" data-bs-target="#instructorModal" style="width:50px">&nbsp;<i class="fa-solid fa-plus"></i></button>
-                </div>
+        @else
+        <div class="col-md-6">
+            <label for="court_id" class="form-label">Campo</label>
+            <select class="form-select form-select-lg me-1 " wire:model="court_id">
+                <option value="">
+                    @foreach($courts as $c)
+                <option value="{{$c["id"]}}">{{$c["name"]}}</option>
+                @endforeach
+            </select>
+        </div>
+        <div class="col">
+            <label for="instructor_id" class="form-label">Istruttore</label>
+            <select class="form-select form-select-lg me-1 " wire:model="instructor_id">
+                <option value="">
+                    @foreach($instructors as $i)
+                <option value="{{$i["id"]}}">{{$i["name"]}}</option>
+                @endforeach
+            </select>
+        </div>
+        <div class="col-auto mt-2">
+            <br>
+            <button type="button" class="btn--ui primary" data-bs-toggle="modal" data-bs-target="#instructorModal" style="width:50px">&nbsp;<i class="fa-solid fa-plus"></i></button>
+        </div>
 
-                <div class="col-md-12 mt-3">
-                    <textarea class="form-control" id="note" placeholder="Note" wire:model="note"></textarea>
-                </div>
-            @endif
+        <div class="col-md-12 mt-3">
+            <textarea class="form-control" id="note" placeholder="Note" wire:model="note"></textarea>
+        </div>
+        @endif --}}
 
-        </div>    
-        
-        <div id="resume-table" class="mt-5" >
-            <div class="compare--chart_wrapper d-none"></div>
-            
-            <div class="row">
-                <div class="col-md-8 col-sm-6"></div>
-                <div class="col-md-4 col-sm-6 mb-3">
-                    <input type="text" class="form-control" placeholder="Cerca utente" wire:model="filter">
-                </div>
+    </div>
+
+    <div id="resume-table" class="mt-3">
+        <div class="compare--chart_wrapper d-none"></div>
+
+        <div class="row">
+            <div class="col-md-8 col-sm-6"></div>
+            <div class="col-md-4 col-sm-6 mb-3">
+                <input type="text" class="form-control" placeholder="Cerca utente" wire:model="filter">
             </div>
         </div>
-        
-            <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
-                <thead>
-                    <tr>
-                        <th scope="col" class="annulla-lezione" style="display: none;">Annullamento</th>
-                        <th scope="col">#</th>
-                        <th scope="col">Cognome</th>
-                        <th scope="col">Nome</th>
-                        <th scope="col">Certificato</th>
-                        <th scope="col">Motivazione</th>
-                        <th scope="col">Presenza</th>
-                    </tr>
-                </thead>
-                <tbody id="checkall-target">
-                    @foreach($records as $idx => $record)
-                        <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>{{$record["last_name"]}}</td>
-                            <td>{{$record["first_name"]}}</td>                            
-                            <td>
-                                <span class="tablesaw-cell-content d-flex align-items-center">
-                                    @php
-                                    list($status, $date) = explode("|", $record["certificate"]);
-                                    @endphp
-                                    @if($status == 0)
-                                        <i class="ico--ui check suspended me-2"></i>Scaduto
-                                    @endif
-                                    @if($status == 1)
-                                        <i class="ico--ui check due me-2"></i>In scadenza
-                                    @endif
-                                    @if($status == 2)
-                                        <i class="ico--ui check active me-2"></i> Scadenza
-                                    @endif
-                                    {{$date}}
-                                </span>
-                            </td>
-                            <td>
-                                {{$record["motivation"]}}
-                            </td>
-                            <td>
-                                @if ($record["status"] != 99)
-                                    @if ($record["presence"])
-                                        @if ($record["my_presence"])
-                                            @if($manual)
-                                                <a onclick="removeSingle({{$record['id']}})"><i class="fas fa-trash"></i></a>
-                                            @else
-                                                <input name="presence" class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : ''}}>
-                                            @endif
-                                        @else
-                                            <span style="color:#0C6197;font-size:25px;">&#10003;</span>
-                                        @endif
-                                    @else
-                                        <input name="presence" class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : ''}}>
-                                    @endif
+    </div>
+
+    <table class="table tablesaw tableHead tablesaw-stack" id="tablesaw-350" width="100%">
+        <thead>
+            <tr>
+                <th scope="col" class="annulla-lezione" style="display: none;">Annullamento</th>
+                <th scope="col">#</th>
+                <th scope="col">Cognome</th>
+                <th scope="col">Nome</th>
+                <th scope="col">Certificato</th>
+                <th scope="col">Campo</th>
+                <th scope="col">Istruttore</th>
+                <th scope="col">Presenza</th>
+                <th scope="col">Motivazione</th>
+                <th scope="col">Note</th>
+            </tr>
+        </thead>
+        <tbody id="checkall-target">
+            @foreach($records as $idx => $record)
+            <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>{{$record["last_name"]}}</td>
+                <td>{{$record["first_name"]}}</td>
+                <td>
+                    <span class="tablesaw-cell-content d-flex align-items-center">
+                        @php
+                        list($status, $date) = explode("|", $record["certificate"]);
+                        @endphp
+                        @if($status == 0)
+                        <i class="ico--ui check suspended me-2"></i>Scaduto
+                        @endif
+                        @if($status == 1)
+                        <i class="ico--ui check due me-2"></i>In scadenza
+                        @endif
+                        @if($status == 2)
+                        <i class="ico--ui check active me-2"></i> Scadenza
+                        @endif
+                        @if(is_null($status) || $status == '')
+                        <i class="ico--ui check due me-2"></i> Sospeso
+                        @endif
+                        {{$date}}
+                    </span>
+                </td>
+                <td>{{$record["court"]}}</td>
+                <td>{{$record["instructor"]}}</td>
+                <td>
+                    @if ($record["status"] != 99)
+                        @if ($record["presence"])
+                            @if ($record["my_presence"])
+                            @if($manual)
+                                    <a onclick="removeSingle({{$record['id']}})"><i class="fas fa-trash"></i></a>
                                 @else
-                                    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>
+                                    <input name="presence" class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : '' }}>
                                 @endif
-                            </td>
-                        </tr>
-                    @endforeach
-
-                </tbody>
-            </table>
-
-        
-
+                            @else
+                                <span style="color:#0C6197;font-size:25px;">&#10003;</span>
+                            @endif
+                        @else
+                            <input name="presence" class="member chkM" type="checkbox" value="{{$record["id"]}}" {{$record["presence"] ? 'checked' : '' }}>
+                        @endif
+                    @else
+                        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
+                </td>
+                <td>
+                    {{$record["motivation"]}}
+                </td>
+                <td>{{$record["notes"]}}</td>
+            </tr>
+            @endforeach
+
+        </tbody>
+    </table>
+
+
+    @if($calendar->status == 0)
+    <div class="row">
+        <div class="col">
+            <button type="button" class="btn--ui primary btSave btAdd" data-bs-toggle="modal" data-bs-target="#userModal" onclick="addUser()">Aggiungi utente</button>
+        </div>
+    </div>
+    @endif
+    <br>
+    <br>
+    <div class="row">
         @if($calendar->status == 0)
-            <div class="row">
-                <div class="col">    
-                    <button type="button" class="btn--ui primary btSave btAdd" data-bs-toggle="modal" data-bs-target="#userModal" onclick="addUser()">Aggiungi utente</button>
-                </div>
+        <div class="col">
+            @if(!$manual)
+            <div class="col-lg-4 col-md-7 col-sm-12 showDelete" style="display:none">
+                <label for="newMotivation" class="form-label">Motivazione</label>
+                <select class="form-select form-select-lg me-1 " id="motivation_id">
+                    <option value="">
+                        @foreach($motivations as $m)
+                    <option value="{{$m["id"]}}">{{$m["name"]}}</option>
+                    @endforeach
+                </select>
             </div>
-        @endif
-        <br>
-        <br>
-        <div class="row">
-            @if($calendar->status == 0)
-                <div class="col">      
-                    @if(!$manual)
-                        <div class="col-lg-4 col-md-7 col-sm-12 showDelete" style="display:none">
-                            <label for="newMotivation" class="form-label">Motivazione</label>
-                            <select class="form-select form-select-lg me-1 " id="motivation_id">
-                                <option value="">
-                                @foreach($motivations as $m)
-                                    <option value="{{$m["id"]}}">{{$m["name"]}}</option>
-                                @endforeach
-                            </select>                            
-                        </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 btSave" onclick="saveAndStay()">Salva presenze</button>
-                        
-                    @endif              
-                </div>
-                @if(!$manual)
-                    <div class="col-auto mt-2 text-end">
-                        <button type="button" class="btn--ui btSave" onclick="saveAndQuit()">Salva e chiudi</button>        
-                    </div>
-                    <div class="col-xs-12 mt-2">
-                        <div class="showDelete" style="float:left;display:none;">
-                            <button type="button" class="btn--ui lightGrey btSaveDelete" onclick="hideShowDelete()">Indietro</button>     
-                            <button type="button" class="btn--ui btSaveDelete" onclick="cancel()">Conferma</button>             
-                        </div>
-                    </div>
-                @endif
+            <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
         </div>
+        @if(!$manual)
+        <div class="col-auto mt-2 text-end">
+            <button type="button" class="btn--ui btSave" onclick="saveAndQuit()">Salva e chiudi</button>
+        </div>
+        <div class="col-xs-12 mt-2">
+            <div class="showDelete" style="float:left;display:none;">
+                <button type="button" class="btn--ui lightGrey btSaveDelete" onclick="hideShowDelete()">Indietro</button>
+                <button type="button" class="btn--ui btSaveDelete" onclick="cancel()">Conferma</button>
+            </div>
+        </div>
+        @endif
+        @endif
+    </div>
 
-        <div class="row mt-3">
-            @if($calendar->status == 0)
-                @if(!$manual)
-                    <div class="col-md-6">
-                    </div>                                
-                @endif
-            @else
-                LEZIONE ANNULLATA ({{$calendar->motivation ? $calendar->motivation->name : ''}})
-            @endif
+    <div class="row mt-3">
+        @if($calendar->status == 0)
+        @if(!$manual)
+        <div class="col-md-6">
         </div>
+        @endif
+        @else
+        LEZIONE ANNULLATA ({{$calendar->motivation ? $calendar->motivation->name : ''}})
+        @endif
+    </div>
 
-    <div  wire:ignore.self class="modal modal-lg fade" id="userModal" tabindex="-1" aria-labelledby="userModalLabel" aria-hidden="true">
+    <div wire:ignore.self class="modal modal-lg fade" id="userModal" tabindex="-1" aria-labelledby="userModalLabel" aria-hidden="true">
         <div class="modal-dialog">
             <div class="modal-content">
                 <div class="modal-header">
@@ -203,82 +211,82 @@
                 <div class="modal-body">
                     <h3 class="text-primary"><input type="radio" name="chkType" value="1" checked onchange="change(1)"> Utente già registrato</h3>
                     <div class="existUser">
-                    <div class="row mt-2 ">
-                        <div class="col-md-6">
-                            <label for="member_id" class="form-label">Aggiungere una o più persone</label>
-                            <select name="member_id" class="form-select memberClass" aria-label="Seleziona una persona"  multiple>
-                                <option value="">--Seleziona--
-                                @foreach($members as $member)
+                        <div class="row mt-2 ">
+                            <div class="col-md-6">
+                                <label for="member_id" class="form-label">Aggiungere una o più persone</label>
+                                <select name="member_id" class="form-select memberClass" aria-label="Seleziona una persona" multiple>
+                                    <option value="">--Seleziona--
+                                        @foreach($members as $member)
                                     <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}} ({{$member->fiscal_code}})
-                                @endforeach
-                            </select>
-                        </div>
-                        <div class="col-md-6">
-                            <label for="newMotivation" class="form-label">Motivazione</label>
-                            <select class="form-select form-select-lg me-1 @error('newMemberMotivationId') is-invalid @enderror" id="newMemberMotivationId">
-                                <option value="">
-                                @foreach($motivations_add as $m)
+                                        @endforeach
+                                </select>
+                            </div>
+                            <div class="col-md-6">
+                                <label for="newMotivation" class="form-label">Motivazione</label>
+                                <select class="form-select form-select-lg me-1 @error('newMemberMotivationId') is-invalid @enderror" id="newMemberMotivationId">
+                                    <option value="">
+                                        @foreach($motivations_add as $m)
                                     <option value="{{$m["id"]}}">{{$m["name"]}}</option>
-                                @endforeach
-                            </select>
+                                    @endforeach
+                                </select>
+                            </div>
                         </div>
                     </div>
-                    </div>
                     <br>
                     <hr>
                     <br>
                     <h3 class="text-primary"><input type="radio" name="chkType" value="2" onchange="change(2)"> Inserimento nuovo utente</h3>
                     <br>
                     <div class="newUser">
-                    @if($newMemberFiscalCodeExist)
+                        @if($newMemberFiscalCodeExist)
                         <span style="color:red">Attenzione, utente esistente</span>
-                    @endif
-                    <div class="row ">
-                        <div class="col-md-6">
-                            <label for="newMemberFirstName" class="form-label">Nome</label>
-                            <input class="form-control @error('newMemberFirstName') is-invalid @enderror" type="text" id="newMemberFirstName" placeholder="Nome" >
-                        </div>
-                        <div class="col-md-6">
-                            <label for="newMemberLastName" class="form-label">Cognome</label>
-                            <input class="form-control @error('newMemberLastName') is-invalid @enderror" type="text" id="newMemberLastName" placeholder="Cognome" >
-                        </div>
-                    </div>
-                    <div class="row mt-2">
-                        <div class="col-md-6">
-                            <label for="newMemberEmail" class="form-label">Email</label>
-                            <input class="form-control @error('newMemberEmail') is-invalid @enderror" type="text" id="newMemberEmail" placeholder="Email">
+                        @endif
+                        <div class="row ">
+                            <div class="col-md-6">
+                                <label for="newMemberFirstName" class="form-label">Nome</label>
+                                <input class="form-control @error('newMemberFirstName') is-invalid @enderror" type="text" id="newMemberFirstName" placeholder="Nome">
+                            </div>
+                            <div class="col-md-6">
+                                <label for="newMemberLastName" class="form-label">Cognome</label>
+                                <input class="form-control @error('newMemberLastName') is-invalid @enderror" type="text" id="newMemberLastName" placeholder="Cognome">
+                            </div>
                         </div>
-                        <div class="col-md-6">
-                            <label for="newMemberFiscalCode" class="form-label">Codice fiscale</label>
-                            <input class="form-control @error('newMemberFiscalCode') is-invalid @enderror" type="text" id="newMemberFiscalCode" placeholder="Codice fiscale" maxlength="16">                        
-                        </div>
-                    </div>
-                    <div class="row mt-2 ">
-                        <div class="col-md-6 d-flex gap-1 pt-3">
-                            <input type="checkbox" id="newMemberToComplete" wire:model="newMemberToComplete">
-                            <label for="newMemberToComplete" class="form-label">Tesserato</label>
+                        <div class="row mt-2">
+                            <div class="col-md-6">
+                                <label for="newMemberEmail" class="form-label">Email</label>
+                                <input class="form-control @error('newMemberEmail') is-invalid @enderror" type="text" id="newMemberEmail" placeholder="Email">
+                            </div>
+                            <div class="col-md-6">
+                                <label for="newMemberFiscalCode" class="form-label">Codice fiscale</label>
+                                <input class="form-control @error('newMemberFiscalCode') is-invalid @enderror" type="text" id="newMemberFiscalCode" placeholder="Codice fiscale" maxlength="16">
+                            </div>
                         </div>
-                        <div class="col-md-6">
-                            <label for="newMotivation" class="form-label">Motivazione</label>
-                            <select class="form-select form-select-lg me-1 @error('newMemberMotivationId') is-invalid @enderror" id="newMemberMotivationIdX">
-                                <option value="">
-                                @foreach($motivations_add as $m)
+                        <div class="row mt-2 ">
+                            <div class="col-md-6 d-flex gap-1 pt-3">
+                                <input type="checkbox" id="newMemberToComplete" wire:model="newMemberToComplete">
+                                <label for="newMemberToComplete" class="form-label">Tesserato</label>
+                            </div>
+                            <div class="col-md-6">
+                                <label for="newMotivation" class="form-label">Motivazione</label>
+                                <select class="form-select form-select-lg me-1 @error('newMemberMotivationId') is-invalid @enderror" id="newMemberMotivationIdX">
+                                    <option value="">
+                                        @foreach($motivations_add as $m)
                                     <option value="{{$m["id"]}}">{{$m["name"]}}</option>
-                                @endforeach
-                            </select>
+                                    @endforeach
+                                </select>
+                            </div>
                         </div>
                     </div>
                 </div>
-                </div>
                 <div class="modal-footer">
                     <button class="btn--ui lightGrey" onclick="annulla()">annulla</a>
-                    <button type="button" class="btn--ui btn-primary" onclick="createMember()">Salva</button>
+                        <button type="button" class="btn--ui btn-primary" onclick="createMember()">Salva</button>
                 </div>
             </div>
         </div>
     </div>
 
-    <div  wire:ignore.self class="modal fade" id="instructorModal" tabindex="-1" aria-labelledby="instructorModalLabel" aria-hidden="true">
+    <div wire:ignore.self class="modal fade" id="instructorModal" tabindex="-1" aria-labelledby="instructorModalLabel" aria-hidden="true">
         <div class="modal-dialog">
             <div class="modal-content">
                 <div class="modal-header">
@@ -299,12 +307,58 @@
                 </div>
                 <div class="modal-footer">
                     <button class="btn--ui lightGrey" onclick="annulla()">annulla</a>
-                    <button type="button" class="btn--ui btn-primary" wire:click.prevent="createInstructor()">Salva</button>
+                        <button type="button" class="btn--ui btn-primary" wire:click.prevent="createInstructor()">Salva</button>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div wire:ignore.self class="modal fade saved-modal" id="editPresencesModal" tabindex="-1" role="dialog" aria-labelledby="editPresencesModal" aria-hidden="true">
+        <div class="modal-dialog">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title text-primary" id="instructorModalLabel">Modifica presenza</h5>
+                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
+                </div>
+                <div class="modal-body">
+                    <div class="row">
+                        <div class="col-md-12">
+                            <label for="save_court_id" class="form-label">Campo</label>
+                            <select id="save_court_id" class="form-select form-select-lg me-1">
+                                <option value="0">
+                                    @foreach($courts as $c)
+                                <option value="{{$c["id"]}}">{{$c["name"]}}</option>
+                                @endforeach
+                            </select>
+                        </div>
+
+                        <div class="col">
+                            <label for="save_instructor_id" class="form-label">Istruttore</label>
+                            <select id="save_instructor_id" class="form-select form-select-lg me-1">
+                                <option value="0">
+                                    @foreach($instructors as $i)
+                                <option value="{{$i["id"]}}" {{\Auth::user()->id == $i["id"] ? "selected" : ""}}>{{$i["name"]}}</option>
+                                @endforeach
+                            </select>
+                        </div>
+                        <div class="col-auto mt-2">
+                            <br>
+                            <button type="button" class="btn--ui primary" data-bs-toggle="modal" data-bs-target="#instructorModal" style="width:50px">&nbsp;<i class="fa-solid fa-plus"></i></button>
+                        </div>
+
+                        <div class="col-md-12">
+                            <label for="save_notes" class="form-label">Note</label>
+                            <textarea class="form-control" id="save_notes"></textarea>
+                        </div>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button class="btn--ui lightGrey" onclick="annulla()">annulla</a>
+                        <button type="button" class="btn--ui btn-primary" onclick="save()">Salva</button>
                 </div>
             </div>
         </div>
     </div>
-    <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">
@@ -317,78 +371,85 @@
 </div>
 
 @push('scripts')
-    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
-    <style>
-        table.tableHead thead {
+<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
+<style>
+    table.tableHead thead {
         /* Important */
-            position: sticky;
-            z-index: 100;
-            top: 0;
-        }
-        .select2-container--default .select2-selection--single{
-            background-color: #E9F0F5;
-            border: 0.0625rem solid #DFE5EB;
-            font-size: 0.75rem;
-        }
-        .select2-selection
-        {
-            height: 38px !important;
-        }
-        .select2-selection__rendered
-        {
-            padding-top:3px;
-        }
-        .select2 {
-            width:100% !important;
-        }
-        .page-link.active, .active > .page-link {
-            background-color:#006099 !important;
-        }
-
-        .select2-selection--multiple{
-            overflow: hidden !important;
-            height: auto !important;
-        }
-        .select2-container {
-            box-sizing: border-box;
-            display: inline-block;
-            margin: 0;
-            position: relative;
-            vertical-align: middle;
-        }
-        .select2-container .select2-selection--single {
-            box-sizing: border-box;
-            cursor: pointer;
-            display: block;
-            height: 38px;
-            user-select: none;
-            -webkit-user-select: none;
-        }
-        .select2-container .select2-selection--single .select2-selection__rendered {
-            display: block;
-            padding-left: 8px;
-            padding-right: 20px;
-            overflow: hidden;
-            text-overflow: ellipsis;
-            white-space: nowrap;
-        }
-        /* .total.primary
+        position: sticky;
+        z-index: 100;
+        top: 0;
+    }
+
+    .select2-container--default .select2-selection--single {
+        background-color: #E9F0F5;
+        border: 0.0625rem solid #DFE5EB;
+        font-size: 0.75rem;
+    }
+
+    .select2-selection {
+        height: 38px !important;
+    }
+
+    .select2-selection__rendered {
+        padding-top: 3px;
+    }
+
+    .select2 {
+        width: 100% !important;
+    }
+
+    .page-link.active,
+    .active>.page-link {
+        background-color: #006099 !important;
+    }
+
+    .select2-selection--multiple {
+        overflow: hidden !important;
+        height: auto !important;
+    }
+
+    .select2-container {
+        box-sizing: border-box;
+        display: inline-block;
+        margin: 0;
+        position: relative;
+        vertical-align: middle;
+    }
+
+    .select2-container .select2-selection--single {
+        box-sizing: border-box;
+        cursor: pointer;
+        display: block;
+        height: 38px;
+        user-select: none;
+        -webkit-user-select: none;
+    }
+
+    .select2-container .select2-selection--single .select2-selection__rendered {
+        display: block;
+        padding-left: 8px;
+        padding-right: 20px;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+    }
+
+    /* .total.primary
         {
             font-size:38px !important;
         } */
-        /* .total.primary.comp
+    /* .total.primary.comp
         {
             font-size:32px !important;
         } */
-    </style>
-    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
-    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
+</style>
+<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
 @endpush
 
 @push('scripts')
-    <script>
-
-        var type = 1;
+<script>
+    var type = 1;
 
         var showAlert = false;
         var isSaving = false;
@@ -437,6 +498,7 @@
             $('#userModal').modal('hide');
             $('#deleteModal').modal('hide');
             $('#instructorModal').modal('hide');
+            $('#editPresencesModal').modal('hide');
         });
 
         window.livewire.on('deleteSaved', () => {
@@ -457,26 +519,22 @@
             }, 3000);
         }
 
+        let stay = false;
         function saveAndQuit()
         {
-            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
+            stay = false;
 
-            @this.save(presence_ids);
+            $('#editPresencesModal').modal("show");
         }
 
         function saveAndStay()
+        {
+            stay = true;
+
+            $('#editPresencesModal').modal("show");
+        }
+
+        function save()
         {   
             let presence_ids = [];
             $('input[name="presence"][type="checkbox"]').each(function () {
@@ -492,7 +550,21 @@
                 @this.set('motivation_manual_id', motivation_manual_id);
             @endif
 
-            @this.saveAndStay(presence_ids);
+            
+            var save_court_id = $("#save_court_id").val();
+            @this.set('save_court_id', save_court_id);
+            var save_instructor_id = $("#save_instructor_id").val();
+            @this.set('save_instructor_id', save_instructor_id);
+            var save_notes = $("#save_notes").val();
+            @this.set('save_notes', save_notes);
+
+            if (stay == true) {
+                @this.saveAndStay(presence_ids);
+            } else {
+                @this.save(presence_ids);
+            }
+            
+            $('#editPresencesModal').modal("hide");
         }
 
         function cancel()
@@ -550,6 +622,7 @@
             $('#userModal').modal('hide');
             $('#deleteModal').modal('hide');
             $('#instructorModal').modal('hide');
+            $('#editPresencesModal').modal('hide');
         }
 
         function togglePresenceCheckboxDisabled(disabled = false) {
@@ -607,9 +680,9 @@
             type = val;
         }
         
-    </script>
+</script>
 @endpush
 
 @push("css")
-    <link href="/css/calendar.css" rel="stylesheet" />
+<link href="/css/calendar.css" rel="stylesheet" />
 @endpush