Luca Parisio 4 месяцев назад
Родитель
Сommit
1a0ec5de1c
2 измененных файлов с 28 добавлено и 9 удалено
  1. 19 3
      app/Http/Livewire/Member.php
  2. 9 6
      resources/views/livewire/member.blade.php

+ 19 - 3
app/Http/Livewire/Member.php

@@ -298,6 +298,16 @@ class Member extends Component
         $this->image_old = '';
     }
 
+    public function updatedPresenceYearFilter()
+    {
+        $this->loadMemberPresences();   
+    }
+
+    public function updatedPresenceTitleFilter()
+    {
+        $this->loadMemberPresences();   
+    }
+
     public function updatedCourseName()
     {
         $this->course_course_id = null;
@@ -636,7 +646,7 @@ class Member extends Component
         
         $this->loadMemberCards();
         $this->loadMemberCourses();
-        // $this->loadMemberPresences();
+        
         $this->loadMemberCategories();
         $this->loadMemberCertificates();
 
@@ -881,10 +891,12 @@ class Member extends Component
     {
         $course_ids = array();
         
-        $calendars = \App\Models\Calendar::whereNull('manual')->orderBy('from')->get();
+        //$calendars = \App\Models\Calendar::whereNull('manual')->orderBy('from')->get();
 
+        /*
         foreach($calendars as $calendar)
         {
+  
             $days = ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'];
             $dow = date('w', strtotime($calendar->from));
             $d = $days[$dow];
@@ -901,7 +913,9 @@ class Member extends Component
             //$course_ids = array_push($course_ids, $courses);
 
         }
-
+        */
+        $course_ids = \App\Models\MemberCourse::where('member_id', $this->dataId)->pluck('course_id')->toArray();
+        
         // Manuali (recuperi)
         $calendar_recuperi = \App\Models\Calendar::where('manual', 1)->pluck('name')->toArray();
         
@@ -1203,6 +1217,8 @@ class Member extends Component
                 //$this->loadMemberCategories();
                 //$this->loadMemberCertificates();
 
+                $this->loadMemberPresences();
+
                 $this->emit('setIds', $this->nation_id, $this->birth_nation_id);
 
                 $this->emit('load-select');

+ 9 - 6
resources/views/livewire/member.blade.php

@@ -1214,7 +1214,7 @@
                                     @if($dataId > 0)
 
                                         @if(!$addCourse && !$updateCourse)
-                                            @if($active["status"] != 2 && $active["status"] != 1 )
+                                            @if(false && $active["status"] != 2 && $active["status"] != 1 )
                                                 <div class="alert alert-warning" role="alert">
                                                     <strong>Attenzione:</strong> Per aggiungere corsi è necessario avere un tesseramento.
                                                 </div>
@@ -1313,11 +1313,14 @@
                                                 </tbody>
                                             </table>
                                             @if($dataId > 0)
-                                                @if ($active["status"] == 2 || $active["status"] == 1)
-                                                    <button class="btn--ui primary" wire:click.prevent="addCourse()" style="max-width:200px">Aggiungi</button>
-                                                @else
-                                                    <button class="btn--ui lightGrey" disabled style="max-width:200px">Aggiungi corso (non disponibile)</button>
-                                                    <small class="text-muted d-block mt-1">Completa prima il tesseramento per abilitare l'aggiunta di corsi</small>
+                                                <button class="btn--ui primary" wire:click.prevent="addCourse()" style="max-width:200px">Aggiungi</button>
+                                                @if(false)
+                                                    @if ($active["status"] == 2 || $active["status"] == 1)
+                                                        <button class="btn--ui primary" wire:click.prevent="addCourse()" style="max-width:200px">Aggiungi</button>
+                                                    @else
+                                                        <button class="btn--ui lightGrey" disabled style="max-width:200px">Aggiungi corso (non disponibile)</button>
+                                                        <small class="text-muted d-block mt-1">Completa prima il tesseramento per abilitare l'aggiunta di corsi</small>
+                                                    @endif
                                                 @endif
                                             @endif
                                         @else