Browse Source

Fix ai corsi

Luca Parisio 1 năm trước cách đây
mục cha
commit
3a0df252f0
73 tập tin đã thay đổi với 5265 bổ sung775 xóa
  1. 5 1
      app/Http/Livewire/Causal.php
  2. 108 3
      app/Http/Livewire/Course.php
  3. 123 0
      app/Http/Livewire/CourseDuration.php
  4. 117 0
      app/Http/Livewire/CourseFrequency.php
  5. 117 0
      app/Http/Livewire/CourseLevel.php
  6. 82 0
      app/Http/Livewire/CourseList.php
  7. 28 0
      app/Http/Livewire/CourseMember.php
  8. 117 0
      app/Http/Livewire/CourseSubscription.php
  9. 121 0
      app/Http/Livewire/CourseType.php
  10. 302 14
      app/Http/Livewire/Member.php
  11. 80 0
      app/Http/Livewire/Receipt.php
  12. 6 4
      app/Http/Livewire/Record.php
  13. 137 133
      app/Http/Livewire/RecordIN.php
  14. 49 15
      app/Http/Livewire/RecordINOUT.php
  15. 70 67
      app/Http/Livewire/RecordOUT.php
  16. 32 6
      app/Http/Livewire/Sponsor.php
  17. 1 0
      app/Models/Causal.php
  18. 24 0
      app/Models/Configuration.php
  19. 36 0
      app/Models/Course.php
  20. 23 0
      app/Models/CourseDuration.php
  21. 22 0
      app/Models/CourseFrequency.php
  22. 22 0
      app/Models/CourseLevel.php
  23. 22 0
      app/Models/CourseSubscription.php
  24. 23 0
      app/Models/CourseType.php
  25. 1 0
      app/Models/Member.php
  26. 15 1
      app/Models/MemberCourse.php
  27. 20 0
      app/helpers.php
  28. 32 0
      database/migrations/2024_06_11_160000_add_no_records_to_causals_table.php
  29. 35 0
      database/migrations/2024_06_17_163000_create_course_types_table.php
  30. 44 0
      database/migrations/2024_06_17_163100_add_fields_to_courses_table.php
  31. 41 0
      database/migrations/2024_06_17_164000_add_fields_to_member_courses_table.php
  32. 35 0
      database/migrations/2024_06_19_163000_add_fields_to_records_table.php
  33. 35 0
      database/migrations/2024_06_22_163000_create_course_durations_table.php
  34. 34 0
      database/migrations/2024_06_22_163030_create_course_subscriptions_table.php
  35. 37 0
      database/migrations/2024_06_22_163100_add_other_fields_to_courses_table.php
  36. 33 0
      database/migrations/2024_06_22_163200_add_other_fields_to_member_courses_table.php
  37. 34 0
      database/migrations/2024_07_22_151500_create_course_frequencies_table.php
  38. 34 0
      database/migrations/2024_07_22_151501_create_course_levels_table.php
  39. 36 0
      database/migrations/2024_07_22_151600_add_relations_to_courses_table.php
  40. 32 0
      database/migrations/2024_07_23_165600_add_subscribed_to_member_courses_table.php
  41. 43 0
      database/migrations/2024_07_24_094500_create_configuration_table.php
  42. 32 0
      database/migrations/2024_07_24_130600_add_subscription_price_to_member_courses_table.php
  43. 35 2
      resources/views/layouts/app.blade.php
  44. 30 3
      resources/views/livewire/bank.blade.php
  45. 45 11
      resources/views/livewire/card.blade.php
  46. 2 2
      resources/views/livewire/category.blade.php
  47. 9 2
      resources/views/livewire/causal.blade.php
  48. 30 3
      resources/views/livewire/city.blade.php
  49. 140 7
      resources/views/livewire/course.blade.php
  50. 176 0
      resources/views/livewire/course_duration.blade.php
  51. 165 0
      resources/views/livewire/course_frequency.blade.php
  52. 165 0
      resources/views/livewire/course_level.blade.php
  53. 172 0
      resources/views/livewire/course_list.blade.php
  54. 102 0
      resources/views/livewire/course_member.blade.php
  55. 165 0
      resources/views/livewire/course_subscription.blade.php
  56. 165 0
      resources/views/livewire/course_type.blade.php
  57. 511 117
      resources/views/livewire/member.blade.php
  58. 30 3
      resources/views/livewire/nation.blade.php
  59. 30 3
      resources/views/livewire/payment_method.blade.php
  60. 30 3
      resources/views/livewire/province.blade.php
  61. 182 0
      resources/views/livewire/receipt.blade.php
  62. 13 9
      resources/views/livewire/records.blade.php
  63. 219 185
      resources/views/livewire/records_in.blade.php
  64. 3 3
      resources/views/livewire/records_in_out.blade.php
  65. 2 2
      resources/views/livewire/records_in_out_old.blade.php
  66. 199 124
      resources/views/livewire/records_out.blade.php
  67. 29 2
      resources/views/livewire/reminders.blade.php
  68. 25 0
      resources/views/livewire/settings.blade.php
  69. 54 9
      resources/views/livewire/sponsor.blade.php
  70. 30 3
      resources/views/livewire/supplier.blade.php
  71. 30 3
      resources/views/livewire/vat.blade.php
  72. 235 35
      routes/web.php
  73. 2 0
      storage/debugbar/.gitignore

+ 5 - 1
app/Http/Livewire/Causal.php

@@ -6,7 +6,7 @@ use Livewire\Component;
 
 class Causal extends Component
 {
-    public $records, $parent_id,  $name, $enabled, $money, $user_status, $no_first, $type, $dataId, $update = false, $add = false;
+    public $records, $parent_id,  $name, $enabled, $money, $user_status, $no_first, $no_records, $type, $dataId, $update = false, $add = false;
 
     protected $rules = [
         'name' => 'required',
@@ -24,6 +24,7 @@ class Causal extends Component
         $this->money = false;
         $this->user_status = false;
         $this->no_first = false;
+        $this->no_records = false;
         $this->enabled = true;
     }
 
@@ -60,6 +61,7 @@ class Causal extends Component
                 'money' => $this->money,
                 'user_status' => $this->user_status,
                 'no_first' => $this->no_first,
+                'no_records' => $this->no_records,
                 'enabled' => $this->enabled
             ]);
             session()->flash('success','Causale creata');
@@ -80,6 +82,7 @@ class Causal extends Component
                 $this->money = $causal->money;
                 $this->user_status = $causal->user_status;
                 $this->no_first = $causal->no_first;
+                $this->no_records = $causal->no_records;
                 $this->enabled = $causal->enabled;
                 $this->type = $causal->type;
                 $this->parent_id = $causal->parent_id;
@@ -102,6 +105,7 @@ class Causal extends Component
                 'parent_id' => $this->parent_id,
                 'user_status' => $this->user_status,
                 'no_first' => $this->no_first,
+                'no_records' => $this->no_records,
                 'money' => $this->money,
                 'enabled' => $this->enabled
             ]);

+ 108 - 3
app/Http/Livewire/Course.php

@@ -6,10 +6,40 @@ use Livewire\Component;
 
 class Course extends Component
 {
+
+    protected $listeners = ['setCausal' => 'setCausal'];
+
     public $records, $parent_id, $name, $enabled, $dataId, $update = false, $add = false;
+    public $course_type_id,
+        $course_duration_id,
+        $course_frequency_id,
+        $course_level_id,
+        $causal_id,
+        $max_members,
+        $instructor,
+        $price,
+        $months,
+        $date_from, $date_to;
+
+    public $course_types = [];
+    public $course_durations = [];
+    public $course_frequencies = [];
+    public $course_levels = [];
+    public $causals = [];
+
+    public $monthList = [];
+
+    public $typeIN = 'IN';
+
+    // public $selectedMonthList = [];
 
     protected $rules = [
-        'name' => 'required'
+        'name' => 'required',
+        'course_type_id' => 'required',
+        'course_duration_id' => 'required',
+        'course_frequency_id' => 'required',
+        'course_level_id' => 'required',
+        'causal_id' => 'required'
     ];
 
     protected $messages = [
@@ -19,12 +49,47 @@ class Course extends Component
     public function resetFields(){
         $this->name = '';
         $this->parent_id = null;
+        $this->course_type_id = null;
+        $this->course_duration_id = null;
+        $this->course_frequency_id = null;
+        $this->course_level_id = null;
+        $this->causal_id = null;
+        $this->max_members = 0;
+        $this->instructor = '';
+        $this->price = 0;
+        $this->date_from = null;
+        $this->date_to = null;
+        $this->months = array();
         $this->enabled = true;
     }
 
+    public function mount()
+    {
+        for($i=date("Y"); $i<=date("Y") + 1; $i++)
+        {
+            $this->monthList[$i][1] = "Gennaio";
+            $this->monthList[$i][2] = "Febbraio";
+            $this->monthList[$i][3] = "Marzo";
+            $this->monthList[$i][4] = "Aprile";
+            $this->monthList[$i][5] = "Maggio";
+            $this->monthList[$i][6] = "Giugno";
+            $this->monthList[$i][7] = "Luglio";
+            $this->monthList[$i][8] = "Agosto";
+            $this->monthList[$i][9] = "Settembre";
+            $this->monthList[$i][10] = "Ottobre";
+            $this->monthList[$i][11] = "Novembre";
+            $this->monthList[$i][12] = "Dicembre";
+        }
+        $this->course_types = \App\Models\CourseType::select('*')->where('enabled', true)->get();
+        $this->course_durations = \App\Models\CourseDuration::select('*')->where('enabled', true)->get();
+        $this->course_levels = \App\Models\CourseLevel::select('*')->where('enabled', true)->get();
+        $this->course_frequencies = \App\Models\CourseFrequency::select('*')->where('enabled', true)->get();
+        $this->causals = \App\Models\Causal::select('*')->where('type', 'IN')->where('enabled', true)->get();
+    }
+
     public function render()
     {
-        $this->records = \App\Models\Course::where('parent_id', null)->get();
+        $this->records = \App\Models\Course::where('parent_id', null)->with('type', 'duration')->get();
         return view('livewire.course');
     }
 
@@ -35,6 +100,7 @@ class Course extends Component
         $this->update = false;
     }
 
+    /*
     public function addLevel($parent_id)
     {
         $this->resetFields();
@@ -42,7 +108,7 @@ class Course extends Component
         $this->add = true;
         $this->update = false;
     }
-
+    */
     public function store()
     {
         $this->validate();
@@ -50,6 +116,17 @@ class Course extends Component
             \App\Models\Course::create([
                 'name' => $this->name,
                 'parent_id' => $this->parent_id,
+                'course_type_id' => $this->course_type_id,
+                'course_duration_id' => $this->course_duration_id,
+                'course_frequency_id' => $this->course_frequency_id,
+                'course_level_id' => $this->course_level_id,
+                'date_from' => $this->date_from,
+                'date_to' => $this->date_to,
+                'causal_id' => $this->causal_id,
+                'max_members' => $this->max_members,
+                'instructor' => $this->instructor,
+                'price' => currencyToDouble($this->price),
+                'months' => json_encode($this->months),
                 'enabled' => $this->enabled
             ]);
             session()->flash('success','Corso creato');
@@ -69,6 +146,17 @@ class Course extends Component
                 $this->name = $course->name;
                 $this->enabled = $course->enabled;
                 $this->parent_id = $course->parent_id;
+                $this->course_type_id = $course->course_type_id;
+                $this->course_duration_id = $course->course_duration_id;
+                $this->course_frequency_id = $course->course_frequency_id;
+                $this->course_level_id = $course->course_level_id;
+                $this->date_from = $course->date_from;
+                $this->date_to = $course->date_to;
+                $this->causal_id = $course->causal_id;
+                $this->max_members = $course->max_members;
+                $this->instructor = $course->instructor;
+                $this->price = formatPrice($course->price);
+                $this->months = json_decode($course->months);
                 $this->dataId = $course->id;
                 $this->update = true;
                 $this->add = false;
@@ -85,6 +173,17 @@ class Course extends Component
             \App\Models\Course::whereId($this->dataId)->update([
                 'name' => $this->name,
                 'parent_id' => $this->parent_id,
+                'course_type_id' => $this->course_type_id,
+                'course_duration_id' => $this->course_duration_id,
+                'course_frequency_id' => $this->course_frequency_id,
+                'course_level_id' => $this->course_level_id,
+                'date_from' => $this->date_from,
+                'date_to' => $this->date_to,
+                'causal_id' => $this->causal_id,
+                'max_members' => $this->max_members,
+                'instructor' => $this->instructor,
+                'price' => currencyToDouble($this->price),
+                'months' => json_encode($this->months),
                 'enabled' => $this->enabled
             ]);
             session()->flash('success','Corso aggiornato');
@@ -111,4 +210,10 @@ class Course extends Component
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
     }
+
+    public function setCausal($id, $idx)
+    {
+        $this->causal_id = $id;
+    }
+
 }

+ 123 - 0
app/Http/Livewire/CourseDuration.php

@@ -0,0 +1,123 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class CourseDuration extends Component
+{
+    public $records, $name, $duration, $enabled, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required',
+        'duration' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio',
+        'duration.required' => 'La durata è obbligatoria',
+    ];
+
+    public $sortField ='name';
+    public $sortAsc = true;
+
+    public function sortBy($field)
+    {
+        if($this->sortField === $field)
+        {
+            $this->sortAsc = ! $this->sortAsc;
+        } else {
+            $this->sortAsc = true;
+        }
+
+        $this->sortField = $field;
+    }
+
+    public function resetFields(){
+        $this->name = '';
+        $this->duration = 0;
+        $this->enabled = true;
+    }
+
+    public function render()
+    {
+        $this->records = \App\Models\CourseDuration::select('id', 'name', 'duration', 'enabled')->get();
+        return view('livewire.course_duration');
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseDuration::create([
+                'name' => $this->name,
+                'duration' => $this->duration,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $course_duration = \App\Models\CourseDuration::findOrFail($id);
+            if( !$course_duration) {
+                session()->flash('error','Dato non trovato');
+            } else {
+                $this->name = $course_duration->name;
+                $this->duration = $course_duration->duration;
+                $this->enabled = $course_duration->enabled;
+                $this->dataId = $course_duration->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseDuration::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'duration' => $this->duration,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\CourseDuration::find($id)->delete();
+            session()->flash('success',"Dato eliminato");
+        }catch(\Exception $e){
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+}

+ 117 - 0
app/Http/Livewire/CourseFrequency.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class CourseFrequency extends Component
+{
+    public $records, $name, $enabled, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public $sortField ='name';
+    public $sortAsc = true;
+
+    public function sortBy($field)
+    {
+        if($this->sortField === $field)
+        {
+            $this->sortAsc = ! $this->sortAsc;
+        } else {
+            $this->sortAsc = true;
+        }
+
+        $this->sortField = $field;
+    }
+
+    public function resetFields(){
+        $this->name = '';
+        $this->enabled = true;
+    }
+
+    public function render()
+    {
+        $this->records = \App\Models\CourseFrequency::select('id', 'name', 'enabled')->get();
+        return view('livewire.course_frequency');
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseFrequency::create([
+                'name' => $this->name,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $course_frequency = \App\Models\CourseFrequency::findOrFail($id);
+            if( !$course_frequency) {
+                session()->flash('error','Dato non trovato');
+            } else {
+                $this->name = $course_frequency->name;
+                $this->enabled = $course_frequency->enabled;
+                $this->dataId = $course_frequency->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseFrequency::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\CourseFrequency::find($id)->delete();
+            session()->flash('success',"Dato eliminato");
+        }catch(\Exception $e){
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+}

+ 117 - 0
app/Http/Livewire/CourseLevel.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class CourseLevel extends Component
+{
+    public $records, $name, $enabled, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public $sortField ='name';
+    public $sortAsc = true;
+
+    public function sortBy($field)
+    {
+        if($this->sortField === $field)
+        {
+            $this->sortAsc = ! $this->sortAsc;
+        } else {
+            $this->sortAsc = true;
+        }
+
+        $this->sortField = $field;
+    }
+
+    public function resetFields(){
+        $this->name = '';
+        $this->enabled = true;
+    }
+
+    public function render()
+    {
+        $this->records = \App\Models\CourseLevel::select('id', 'name', 'enabled')->get();
+        return view('livewire.course_level');
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseLevel::create([
+                'name' => $this->name,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $course_level = \App\Models\CourseLevel::findOrFail($id);
+            if( !$course_level) {
+                session()->flash('error','Dato non trovato');
+            } else {
+                $this->name = $course_level->name;
+                $this->enabled = $course_level->enabled;
+                $this->dataId = $course_level->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseLevel::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\CourseLevel::find($id)->delete();
+            session()->flash('success',"Dato eliminato");
+        }catch(\Exception $e){
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+}

+ 82 - 0
app/Http/Livewire/CourseList.php

@@ -0,0 +1,82 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class CourseList extends Component
+{
+
+    public $records = array();
+    public $courses = array();
+
+    public $counrsId = 0;
+
+    public $months = array('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic');
+
+    public function mount()
+    {
+
+        $this->courses = \App\Models\Course::orderBy('name')->get();
+
+        if (sizeof($this->courses) > 0)
+            $this->courseId = $this->courses[0]->id;
+
+    }
+
+    public function render()
+    {
+
+        // Carico tutti i corsi associati
+        $member_course = \App\Models\MemberCourse::where('course_id', $this->courseId)->with('member')->get();
+
+        $this->records = array();
+
+        foreach($member_course as $x)
+        {
+            $this->records[] = array(
+                $x->member_id . "§" . $x->member->first_name . " " . $x->member->last_name,
+                $this->getColor($x->months, 1),
+                $this->getColor($x->months, 2),
+                $this->getColor($x->months, 3),
+                $this->getColor($x->months, 4),
+                $this->getColor($x->months, 5),
+                $this->getColor($x->months, 6),
+                $this->getColor($x->months, 7),
+                $this->getColor($x->months, 8),
+                $this->getColor($x->months, 9),
+                $this->getColor($x->months, 10),
+                $this->getColor($x->months, 11),
+                $this->getColor($x->months, 12)
+            );
+        }
+
+        return view('livewire.course_list');
+
+    }
+
+    public function getColor($months, $m)
+    {
+        $class = "grey";
+        foreach(json_decode($months) as $mm)
+        {
+            if ($mm->m == $m)
+            {
+                if ($mm->status == "")
+                {
+                    $class = "orange";
+                }
+                if ($mm->status == "1")
+                {
+                    $class = "green";
+                }
+                if ($mm->status == "2")
+                {
+                    $class = "yellow";
+                }
+            }
+        }
+        return $class;
+    }
+
+}

+ 28 - 0
app/Http/Livewire/CourseMember.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class CourseMember extends Component
+{
+
+    public $records = array();
+
+    public function mount()
+    {
+
+
+    }
+
+    public function render()
+    {
+
+        // Carico tutti i corsi associati
+        $this->records = \App\Models\MemberCourse::with('member')->get();
+
+        return view('livewire.course_member');
+
+    }
+
+}

+ 117 - 0
app/Http/Livewire/CourseSubscription.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class CourseSubscription extends Component
+{
+    public $records, $name, $enabled, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public $sortField ='name';
+    public $sortAsc = true;
+
+    public function sortBy($field)
+    {
+        if($this->sortField === $field)
+        {
+            $this->sortAsc = ! $this->sortAsc;
+        } else {
+            $this->sortAsc = true;
+        }
+
+        $this->sortField = $field;
+    }
+
+    public function resetFields(){
+        $this->name = '';
+        $this->enabled = true;
+    }
+
+    public function render()
+    {
+        $this->records = \App\Models\CourseSubscription::select('id', 'name', 'enabled')->get();
+        return view('livewire.course_subscription');
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseSubscription::create([
+                'name' => $this->name,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $course_subscription = \App\Models\CourseSubscription::findOrFail($id);
+            if( !$course_subscription) {
+                session()->flash('error','Dato non trovato');
+            } else {
+                $this->name = $course_subscription->name;
+                $this->enabled = $course_subscription->enabled;
+                $this->dataId = $course_subscription->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseSubscription::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\CourseSubscription::find($id)->delete();
+            session()->flash('success',"Dato eliminato");
+        }catch(\Exception $e){
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+}

+ 121 - 0
app/Http/Livewire/CourseType.php

@@ -0,0 +1,121 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+
+class CourseType extends Component
+{
+    public $records, $name, $duration, $enabled, $dataId, $update = false, $add = false;
+
+    protected $rules = [
+        'name' => 'required'
+    ];
+
+    protected $messages = [
+        'name.required' => 'Il nome è obbligatorio'
+    ];
+
+    public $sortField ='name';
+    public $sortAsc = true;
+
+    public function sortBy($field)
+    {
+        if($this->sortField === $field)
+        {
+            $this->sortAsc = ! $this->sortAsc;
+        } else {
+            $this->sortAsc = true;
+        }
+
+        $this->sortField = $field;
+    }
+
+    public function resetFields(){
+        $this->name = '';
+        $this->duration = 0;
+        $this->enabled = true;
+    }
+
+    public function render()
+    {
+        $this->records = \App\Models\CourseType::select('id', 'name', 'duration', 'enabled')->get();
+        return view('livewire.course_type');
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->add = true;
+        $this->update = false;
+    }
+
+    public function store()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseType::create([
+                'name' => $this->name,
+                'duration' => $this->duration,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato creato');
+            $this->resetFields();
+            $this->add = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function edit($id){
+        try {
+            $course_type = \App\Models\CourseType::findOrFail($id);
+            if( !$course_type) {
+                session()->flash('error','Dato non trovato');
+            } else {
+                $this->name = $course_type->name;
+                $this->duration = $course_type->duration;
+                $this->enabled = $course_type->enabled;
+                $this->dataId = $course_type->id;
+                $this->update = true;
+                $this->add = false;
+            }
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function update()
+    {
+        $this->validate();
+        try {
+            \App\Models\CourseType::whereId($this->dataId)->update([
+                'name' => $this->name,
+                'duration' => $this->duration,
+                'enabled' => $this->enabled
+            ]);
+            session()->flash('success','Dato aggiornato');
+            $this->resetFields();
+            $this->update = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->add = false;
+        $this->update = false;
+        $this->resetFields();
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\CourseType::find($id)->delete();
+            session()->flash('success',"Dato eliminato");
+        }catch(\Exception $e){
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+}

+ 302 - 14
app/Http/Livewire/Member.php

@@ -69,6 +69,11 @@ class Member extends Component
     public $cards = array();
     public $categories = array();
     public $courses = array();
+    public $course_subscriptions = array();
+
+    public $createSubscription = false;
+    public $payMonths = array();
+    public $showCourse = array();
 
     public $searchTxt;
     public $search;
@@ -89,7 +94,7 @@ class Member extends Component
     public $member_categories = array(), $category_category_id;
 
     // Courses data
-    public $member_courses = array(), $course_course_id, $course_date_from, $course_date_to, $course_when = array(), $addCourse, $updateCourse, $courseDataId;
+    public $member_courses = array(), $course_course_id, $course_date_from, $course_date_to, $course_when = array(), $addCourse, $updateCourse, $courseDataId, $course_course_subscription_id, $course_status, $course_note, $course_price, $course_subscription_price, $course_subscribed, $course_months = array();
 
     // Certificates data
     public $member_certificates = array(), $certificate_type, $certificate_filename_old, $certificate_filename, $certificate_expire_date, $certificate_status, $addCertificate, $updateCertificate, $certificateDataId;
@@ -104,6 +109,7 @@ class Member extends Component
     protected $rules = [
         'first_name' => 'required',
         'last_name' => 'required',
+        'birth_date' => 'before_or_equal:today'
     ];
 
     public function resetFields(){
@@ -179,9 +185,16 @@ class Member extends Component
     public function resetCourseFields(){
         $this->course_course_id = null;
         $this->course_when = array();
-        $this->course_when[] = array('day' => '', 'from' => '', 'to' => '');
+        $this->course_when[] = array('day' => array(), 'from' => '', 'to' => '');
         $this->course_date_from = null;
         $this->course_date_to = null;
+        $this->course_course_subscription_id = null;
+        $this->course_status = 0;
+        $this->course_price = 0;
+        $this->course_subscription_price = 0;
+        $this->course_subscribed = false;
+        $this->course_months = array();
+        $this->course_note = '';
     }
 
     public function executeMultipleAction(){
@@ -245,6 +258,7 @@ class Member extends Component
 
     public function updatedBirthDate()
     {
+        $this->validateOnly('birth_date');
         $date1 = new DateTime($this->birth_date);
         $date2 = new DateTime("now");
         $interval = $date1->diff($date2);
@@ -267,9 +281,11 @@ class Member extends Component
 
         $this->getCategories(\App\Models\Category::select('id', 'name')->where('parent_id', null)->get(), 0);
 
-        $this->courses = array();
+        $this->courses = \App\Models\Course::select('id', 'name')->where('parent_id', null)->get();
+
+        $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->where('enabled', true)->get();
 
-        $this->getCourses(\App\Models\Course::select('id', 'name')->where('parent_id', null)->get(), 0);
+        // $this->getCourses(\App\Models\Course::select('id', 'name')->where('parent_id', null)->get(), 0);
 
         /*$this->nations = \App\Models\Nation::select('id', 'name')->orderBy('name')->get();
         $this->provinces = \App\Models\Province::where('nation_id', 1)->orderBy('name')->get();
@@ -279,6 +295,11 @@ class Member extends Component
         if ($c)
             $this->causalId = $c->id;
 
+        if (isset($_GET["member_detail"]))
+        {
+            $this->showDetailF($_GET["member_detail"]);
+            $this->refreshAfter = 1;
+        }
         /*$this->birthNations = \App\Models\Nation::select('id', 'name')->orderBy('name')->get();
         $this->birthProvinces = \App\Models\Province::where('nation_id', 1)->orderBy('name')->get();
         $this->birthCities = \App\Models\City::where('province_id', 178)->orderBy('name')->orderBy('name')->get();*/
@@ -459,18 +480,32 @@ class Member extends Component
             //$datas = $datas->get(); // ->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')->paginate(10);
 
             //$this->records = $this->records->get();
-            $this->loadMemberCards();
-            $this->loadMemberCourses();
-            $this->loadMemberCategories();
-            $this->loadMemberCertificates();
+
 
             $this->emit('load-data-table');
         }
 
+        $this->loadMemberCards();
+        $this->loadMemberCourses();
+        $this->loadMemberCategories();
+        $this->loadMemberCertificates();
 
         return view('livewire.member', ['datas' => $datas]);
     }
 
+    public function updatedCourseCourseId()
+    {
+        if ($this->course_course_id > 0)
+        {
+            $c = \App\Models\Course::findOrFail($this->course_course_id);
+            $this->course_price = formatPrice($c->price);
+        }
+        else
+        {
+            $this->course_price = 0;
+        }
+    }
+
     public function loadMemberCards()
     {
         $this->member_cards = \App\Models\MemberCard::where('member_id', $this->dataId)->get();
@@ -495,7 +530,7 @@ class Member extends Component
         // return view('livewire.member');
     }
 
-    public function showDetail($id)
+    public function showDetailF($id)
     {
         $this->currentMember = \App\Models\Member::findOrFail($id);
         $this->currentStatus = $this->currentMember->getStatus();
@@ -516,7 +551,12 @@ class Member extends Component
     {
         $this->emit('load-select');
 
-        $this->validate();
+        $rules = [
+            'first_name' => 'required',
+            'last_name' => 'required'
+        ];
+
+        $this->validate($rules);
         try {
 
             $name = '';
@@ -941,7 +981,7 @@ class Member extends Component
     public function storeCourse()
     {
 
-        $this->validate(['course_course_id' => 'required']);
+        $this->validate(['course_course_id' => 'required', 'course_status' => 'required', 'course_course_subscription_id' => 'required']);
         try {
 
             \App\Models\MemberCourse::create([
@@ -949,6 +989,13 @@ class Member extends Component
                 'course_id' => $this->course_course_id,
                 'date_from' => $this->course_date_from,
                 'date_to' => $this->course_date_to,
+                'course_subscription_id' => $this->course_course_subscription_id,
+                'status' => $this->course_status,
+                'subscribed' => false, // default non iscritto
+                'price' => currencyToDouble($this->course_price),
+                'subscription_price' => currencyToDouble($this->course_subscription_price),
+                'notes' => $this->course_note,
+                'months' => json_encode($this->course_months),
                 'when' => json_encode($this->course_when)
             ]);
             session()->flash('success, Corso creato');
@@ -968,7 +1015,21 @@ class Member extends Component
                 $this->course_course_id = $memberCourse->course_id;
                 $this->course_date_from = $memberCourse->date_from;
                 $this->course_date_to = $memberCourse->date_to;
-                $this->course_when = json_decode($memberCourse->when);
+                foreach(json_decode($memberCourse->when) as $z)
+                {
+                    $this->course_when[] = array("day" => $z->day, "from" => $z->from, "to" => $z->to);
+                }
+                //$this->course_when = json_decode($memberCourse->when);
+                $this->course_course_subscription_id = $memberCourse->course_subscription_id;
+                $this->course_status = $memberCourse->status;
+                $this->course_subscribed = $memberCourse->subscribed == 1 ? true : false;
+                $this->course_price = formatPrice($memberCourse->price);
+                $this->course_subscription_price = formatPrice($memberCourse->subscription_price);
+                $this->course_note = $memberCourse->notes;
+                foreach(json_decode($memberCourse->months) as $z)
+                {
+                    $this->course_months[] = array("m" => $z->m, "status" => $z->status);
+                }
                 $this->courseDataId = $memberCourse->id;
                 $this->updateCourse = true;
                 $this->addCourse = false;
@@ -990,10 +1051,16 @@ class Member extends Component
                 'course_id' => $this->course_course_id,
                 'date_from' => $this->course_date_from,
                 'date_to' => $this->course_date_to,
+                'course_subscription_id' => $this->course_course_subscription_id,
+                'status' => $this->course_status,
+                'price' => currencyToDouble($this->course_price),
+                'subscription_price' => currencyToDouble($this->course_subscription_price),
+                'notes' => $this->course_note,
+                'months' => json_encode($this->course_months),
                 'when' => json_encode($this->course_when)
             ]);
             session()->flash('success','Corso aggiornato');
-            $this->resetCardFields();
+            $this->resetCourseFields();
             $this->updateCourse = false;
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
@@ -1019,7 +1086,7 @@ class Member extends Component
 
     public function addRow()
     {
-        $this->course_when[] = array('day' => '', 'from' => '', 'to' => '');
+        $this->course_when[] = array('day' => array(), 'from' => '', 'to' => '');
     }
 
     public function delRow($idx)
@@ -1270,6 +1337,225 @@ class Member extends Component
             $this->error_fc = true;
     }
 
+    public function setMonth($m)
+    {
+
+        $exist = -1;
+        foreach($this->course_months as $idx => $x)
+        {
+            if ($x["m"] == $m)
+            {
+                $exist = $idx;
+                break;
+            }
+        }
+        if ($exist > -1)
+        {
+            array_splice($this->course_months, $exist, 1);
+        }
+        else
+        {
+            $this->course_months[] = array("m" => $m, "status" => "");
+        }
+
+        /*
+        if (in_array($m, $this->course_months))
+        {
+            $i = array_search($m, $this->course_months);
+            array_splice($this->course_months, $i, 1);
+        }
+        else
+        {
+            $this->course_months[] = $m;
+        }*/
+
+    }
+
+    public function newPayment($course)
+    {
+        $c = \App\Models\Course::findOrFail($course["course_id"]);
+        return redirect()->to('/in?new=1&memberId=' . $this->dataId . '&causalId=' . $c->causal_id . '&createSubscription=' . $this->createSubscription .  (sizeof($this->payMonths) > 0 ? '&months=' . implode("|", $this->payMonths) : "") . '&price=' . $course["price"] . '&subscription_price=' . $course["subscription_price"] . "&courseId=" . $course["id"]);
+
+    }
+
+    public function block($course)
+    {
+        $xxx = json_decode($course["months"]);
+        foreach($xxx as $idx => $mm)
+        {
+            if (in_array($mm->m, $this->payMonths))
+            {
+                $xxx[$idx]->status = 2;
+            }
+        }
+        $c = \App\Models\MemberCourse::findOrFail($course["id"]);
+        $c->months = json_encode($xxx);
+        $c->save();
+        $this->payMonths = array();
+    }
+
+    public function setPayMonth($m, $months)
+    {
+        if (in_array($m, $this->payMonths))
+        {
+            $i = array_search($m, $this->payMonths);
+            array_splice($this->payMonths, $i, 1);
+        }
+        else
+        {
+            foreach(json_decode($months) as $mm)
+            {
+                if ($mm->m == $m)
+                {
+                    if ($mm->status == "")
+                        $this->payMonths[] = $m;
+                }
+            }
+        }
+
+    }
+
+    public function setCreateSubscription($subscribed)
+    {
+        if (!$subscribed)
+            $this->createSubscription = !$this->createSubscription;
+    }
+
+    public function showHideCourse($id)
+    {
+        if (in_array($id, $this->showCourse))
+        {
+            $i = array_search($id, $this->showCourse);
+            array_splice($this->showCourse, $i, 1);
+        }
+        else
+        {
+            $this->showCourse[] = $id;
+        }
+    }
+
+    public function getMonthStatus($m, $months)
+    {
+
+        $class = "grey";
+
+        foreach(json_decode($months) as $mm)
+        {
+            if ($mm->m == $m)
+            {
+                if ($mm->status == "")
+                {
+                    if (in_array($m, $this->payMonths))
+                        $class = "blue";
+                    else
+                        $class = "orange";
+                }
+                if ($mm->status == "1")
+                {
+                    $class = "green";
+                }
+                if ($mm->status == "2")
+                {
+                    $class = "yellow";
+                }
+            }
+        }
+
+        return $class;
+    }
+
+    public function getSubscriptionStatus($subscribed)
+    {
+
+        $class = "grey";
+
+        if ($this->createSubscription)
+            $class = "blue";
+        else
+            $class = "orange";
+        if ($subscribed)
+            $class = "green";
+
+        return $class;
+    }
+
+    public function checkMonth($m)
+    {
+        $ret = false;
+        foreach($this->course_months as $idx => $x)
+        {
+            if ($x["m"] == $m)
+            {
+                $ret = true;
+                break;
+            }
+        }
+        return $ret;
+    }
+
+    public function setDay($idx, $d)
+    {
+
+        if (in_array($d, $this->course_when[$idx]["day"]))
+        {
+            $i = array_search($d, $this->course_when[$idx]["day"]);
+            array_splice($this->course_when[$idx]["day"], $i, 1);
+
+        }
+        else
+        {
+            $this->course_when[$idx]["day"][] = $d;
+        }
+
+    }
+
+    public function getMonth($m)
+    {
+        $ret = '';
+        switch ($m) {
+            case 1:
+                $ret = 'Gennaio';
+                break;
+            case 2:
+                $ret = 'Febbraio';
+                break;
+            case 3:
+                $ret = 'Marzo';
+                break;
+            case 4:
+                $ret = 'Aprile';
+                break;
+            case 5:
+                $ret = 'Maggio';
+                break;
+            case 6:
+                $ret = 'Giugno';
+                break;
+            case 7:
+                $ret = 'Luglio';
+                break;
+            case 8:
+                $ret = 'Agosto';
+                break;
+            case 9:
+                $ret = 'Settembre';
+                break;
+            case 10:
+                $ret = 'Ottobre';
+                break;
+            case 11:
+                $ret = 'Novembre';
+                break;
+            case 12:
+                $ret = 'Dicembre';
+                break;
+            default:
+                $ret = '';
+                break;
+        }
+        return $ret;
+    }
+
 }
 
 class codicefiscale {
@@ -1581,4 +1867,6 @@ class codicefiscale {
     }
 
 
+
+
 }

+ 80 - 0
app/Http/Livewire/Receipt.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+use Barryvdh\DomPDF\Facade\Pdf;
+
+class Receipt extends Component
+{
+    public $records;
+
+    public $filterStatus = '';
+    public $hasFilter = false;
+    public $filterFrom = '', $filterTo = '';
+
+    public function updatedFilterFrom()
+    {
+        $this->emit('destroy-data-table');
+    }
+
+    public function updatedFilterTo()
+    {
+        $this->emit('destroy-data-table');
+    }
+
+    public function render()
+    {
+
+        if ($this->hasFilter)
+        {
+            $r = \App\Models\Receipt::with('member');
+            if ($this->filterStatus != '')
+                $r = $r->where('status', $this->filterStatus);
+            if ($this->filterFrom != '')
+                $r = $r->where('date', '>=', $this->filterFrom);
+            if ($this->filterTo != '')
+                $r = $r->where('date', '<=', $this->filterTo);
+
+            $this->records = $r->get();
+        }
+        else
+        {
+            $this->records = \App\Models\Receipt::with('member')->get();
+        }
+
+        $this->emit('load-data-table');
+
+        return view('livewire.receipt');
+    }
+
+    public function printReceipt($id)
+    {
+        $this->emit('load-data-table');
+        $receipt = \App\Models\Receipt::findOrFail($id);
+        //$pdf = PDF::loadView('pdf/receipt', array('datas' => $datas, 'from' => $x, 'to' => $y, 'who' => '', 'matricola' => $matricola));
+        $pdf = PDF::loadView('receipt', array('receipt' => $receipt))->output();
+        return response()->streamDownload(
+            fn () => print($pdf),
+            "ricevuta_" . $receipt->number . "_" . $receipt->year . ".pdf"
+        );
+
+        /*return response()->streamDownload(function () {
+            echo $pdf->stream();
+        }, 'test.pdf');*/
+    }
+
+    public function search()
+    {
+        $this->hasFilter = true;
+    }
+
+    public function disableSearch()
+    {
+        $this->filterStatus = "";
+        $this->filterTo = '';
+        $this->filterFrom = '';
+        $this->hasFilter = false;
+    }
+
+}

+ 6 - 4
app/Http/Livewire/Record.php

@@ -42,8 +42,8 @@ class Record extends Component
     public function mount()
     {
 
-        $this->fromDate = date("Y-m-01");
-        $this->toDate = date("Y-m-t");
+        $this->fromDate = date("Y-m-d");
+        $this->toDate = date("Y-m-d");
         /*
         $this->selectedFilterFromDay = 1;
         $this->selectedFilterToDay = 31;
@@ -64,7 +64,7 @@ class Record extends Component
             $this->years[] = array('value' => $year, 'text' => $year);
         }
         */
-        $this->payments = \App\Models\PaymentMethod::select('id', 'name')->get();
+        $this->payments = \App\Models\PaymentMethod::select('id', 'name')->where('enabled', true)->get();
 
     }
 
@@ -266,7 +266,9 @@ class Record extends Component
                     $prefix = $idx . "$";
 
 
-                $causal = $prefix . $data->date . "§" . $causalCheck->getTree();
+                // aggiungere il nome * * *
+                //$causal = $prefix . $data->date . "§" . $causalCheck->getTree();
+                $causal = $prefix . $data->date . "§" . $causalCheck->getTree() . "§" . ($data->type == "IN" ? ($data->member->last_name . " " . $data->member->first_name)  : $data->supplier->name ?? "");
 
                 if (isset($this->records[$causal]))
                 {

+ 137 - 133
app/Http/Livewire/RecordIN.php

@@ -24,6 +24,7 @@ class RecordIN extends Component
     public $multiYearTo = 0;
     public $multiMonthFrom = 0;
     public $multiYearFrom = 0;
+    public $createSubscription = 0;
 
     public function sortBy($field)
     {
@@ -37,6 +38,9 @@ class RecordIN extends Component
         $this->sortField = $field;
     }
 
+    public $courseId = 0;
+    public $months = array();
+
     public $records, $dataId, $member_id, $supplier_id,
     $causal_id,
     $payment_method_id,
@@ -93,8 +97,8 @@ class RecordIN extends Component
     protected $messages = [
         'member_id.required' => 'La persona è obbligatorio',
         'payment_method_id.required' => 'Il metodo di pagamento è obbligatorio',
-        'causal_id.required' => 'La causale è obbligatoria',
-        'amount.required' => 'L\'importo è obbligatorio',
+        'rows.*.causal_id.required' => 'La causale è obbligatoria',
+        'rows.*.amount.required' => 'L\'importo è obbligatorio',
     ];
 
     public function updatedMemberId() {
@@ -164,6 +168,8 @@ class RecordIN extends Component
         $this->newMemberFiscalCodeExist = false;
         $this->currentReceip = null;
         $this->parent = '';
+        $this->courseId = 0;
+        $this->months = array();
         $this->rows = array();
         $this->rows[] = array('causal_id' => isset($_GET["causalId"]) ? $_GET["causalId"] : null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')),  'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
         $this->emit('load-data-table');
@@ -242,7 +248,7 @@ class RecordIN extends Component
         //$this->buildTree(\App\Models\Causal::all(), null);
 
         $this->members = \App\Models\Member::select(['id', 'first_name', 'last_name', 'fiscal_code'])->orderBy('last_name')->orderBy('first_name')->get();
-        $this->payments = \App\Models\PaymentMethod::select('id', 'name')->orderBy('name')->get();
+        $this->payments = \App\Models\PaymentMethod::select('id', 'name')->where('enabled', true)->orderBy('name')->get();
         $this->vats = \App\Models\Vat::select('id', 'name', 'value')->orderBy('value')->get();
 
         if ($this->first)
@@ -267,6 +273,42 @@ class RecordIN extends Component
                 $this->refreshAfter = 1;
                 $this->edit($_GET["id"]);
             }
+            $count = 0;
+            $this->courseId = $_GET["courseId"];
+            $mc = \App\Models\MemberCourse::findOrFail($this->courseId);
+            $course = \App\Models\Course::findOrFail($mc->course_id);
+            if (isset($_GET["months"]))
+            {
+
+                $price = $_GET["price"] / 100 * 100;
+                $this->refreshAfter = 1;
+                $desc = "Pagamento";
+                $months = explode("|", $_GET["months"]);
+                $this->months = $months;
+                $this->rows[0]["amount"] = formatPrice($price * sizeof($months));
+                foreach($months as $idx => $m)
+                {
+                    $this->rows[0]["when"][$idx]["month"] = $m;
+                    $this->rows[0]["when"][$idx]["year"] = date("Y");
+
+                    $desc .= " " . $this->getMonth($m);
+                }
+                $this->rows[0]["note"] = $desc;
+                $count += 1;
+            }
+            if (isset($_GET["createSubscription"]) && $_GET["createSubscription"] == 1)
+            {
+
+                $this->createSubscription = 1;
+                $this->courseId = $_GET["courseId"];
+                $price = $_GET["subscription_price"] / 100 * 100;
+                $this->refreshAfter = 1;
+                if ($count == 1)
+                    $this->rows[] = array('causal_id' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')),  'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
+                $this->rows[$count]["causal_id"] = null;
+                $this->rows[$count]["amount"] = formatPrice($price);
+                $this->rows[$count]["note"] = "Pagamento iscrizione " . $course->name;
+            }
         }
         $this->first = false;
 
@@ -291,135 +333,8 @@ class RecordIN extends Component
 
     public function render()
     {
-        $datas = [];
-        if ($this->hasFilter)
-        {
-
-            $datas = \App\Models\Record::select('records.*', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name'), \DB::raw('payment_methods.name as payment')) // , \DB::raw('SUM(records.id) As total'))
-                    ->leftJoin('members', 'records.member_id', '=', 'members.id')
-                    ->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
-                    ->where('records.type', 'IN');
-
-            // $datas = \App\Models\Record::where('type', 'IN')->with('member', 'payment_method');
-            if ($this->filterCommercial > 0)
-            {
-                $datas = $datas->where('commercial', $this->filterCommercial == 1 ? true : false);
-            }
-            if ($this->filterMember > 0)
-            {
-                $datas = $datas->where('member_id', $this->filterMember);
-            }
-            if ($this->filterPaymentMethod > 0)
-            {
-                $datas = $datas->where('payment_method_id', $this->filterPaymentMethod);
-            }
-            /*if (sizeof($this->filterCausals) > 0)
-            {
-                $datas = $datas->whereIn('causal_id', $this->filterCausals);
-            }*/
-            if ($this->filterFrom != '')
-            {
-                $datas = $datas->where('date', '>=', $this->filterFrom);
-            }
-            if ($this->filterTo != '')
-            {
-                $datas = $datas->where('date', '<=', $this->filterTo);
-            }
-            // $this->records = $datas->orderBy('date', 'DESC')->get();
-
-            //$this->records = $datas->get();
-
-            $this->total = 0;
-            foreach($datas->get() as $r)
-            {
-                foreach($r->rows as $rr)
-                {
-                    $this->total += $rr->amount;
-                    if ($rr->vat_id > 0)
-                        $this->total += getVatValue($rr->amount, $rr->vat_id);
-                }
-            }
-
-            $datas = $datas->get();//->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')->paginate(20);
-
-            //$this->total = $this->records->sum('amount');
-
-        }
-        else
-        {
-            if ($this->selectedFilter == '')
-            {
-                // $this->records = \App\Models\Record::where('type', 'IN')->with('member', 'payment_method')->limit(20)->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();
-
-                $datas = \App\Models\Record::select('records.*', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name'), \DB::raw('payment_methods.name as payment')) // , \DB::raw('SUM(records.id) As total'))
-                    ->leftJoin('members', 'records.member_id', '=', 'members.id')
-                    ->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
-                    ->where('records.type', 'IN')
-                    ->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')
-                    ->paginate(20);
-
-            }
-            else
-            {
-                if ($this->selectedFilter == 0)
-                {
-                    $fromDate = date("Y-m-d");
-                    $toDate = date("Y-m-d");
-                }
-                if ($this->selectedFilter == 1)
-                {
-                    $fromDate = date("Y-m-01");
-                    $toDate = date("Y-m-t");
-                }
-                if ($this->selectedFilter == 2)
-                {
-                    $fromDate = date("Y-01-01");
-                    $toDate = date("Y-12-31");
-                }
-                if ($this->selectedFilter == 3)
-                {
-                    $fromDate = date("2000-01-01");
-                    $toDate = date("Y-12-31");
-                }
-                /*
-                $this->records = \App\Models\Record::where('type', 'IN')->whereBetween('date', [$fromDate, $toDate])->with('member', 'payment_method')->get();
-                $datas = \App\Models\Record::select('records.*', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name'), \DB::raw('payment_methods.name as payment'), \DB::raw('SUM(records.id) As total'))
-                    ->leftJoin('members', 'records.member_id', '=', 'members.id')
-                    ->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
-                    //->where('analytics.date', Carbon::today()->toDateString())
-                    ->paginate(1);*/
-                $datas = \App\Models\Record::select('records.*', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name'), \DB::raw('payment_methods.name as payment')) // , \DB::raw('SUM(records.id) As total'))
-                    ->leftJoin('members', 'records.member_id', '=', 'members.id')
-                    ->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
-                    ->where('records.type', 'IN')
-                    ->whereBetween('date', [$fromDate, $toDate])
-                    ->get();
-                    /*->orderBy($this->sortField, $this->sortAsc ? 'ASC' : 'DESC')
-                    ->paginate(20);*/
-            }
-        }
-
-        /*
-        foreach($this->records as $r)
-        {
-            $r->total = $r->getTotal();
-            $r->person = $r->member ? ($r->member->first_name . " " . $r->member->last_name) : '';
-            $r->payment = $r->payment_method ? $r->payment_method->name : '';
-        }
-
-        if ($this->sortField != '')
-        {
-            if ($this->sortAsc)
-                $this->records = $this->records->sortBy($this->sortField);
-            else
-                $this->records = $this->records->sortByDesc($this->sortField);
-        }
-        else
-            $this->records = $this->records->sortByDesc('id');
-        */
-
-        $this->emit('load-data-table');
 
+        $datas = [];
         return view('livewire.records_in', ['datas' => $datas]);
     }
 
@@ -460,8 +375,9 @@ class RecordIN extends Component
             $rules["member_id"] = 'required';*/
         if($this->commercial)
             $rules["member_id"] = 'required';
-
+        //dd($this->getErrorBag());
         $this->validate($rules);
+        //dd("£ASDSDFS");
         try {
 
             $record = \App\Models\Record::create([
@@ -498,6 +414,27 @@ class RecordIN extends Component
             $record->amount = $tot;
             $record->save();
 
+            // se sto pagando un corso, aggiorno lo status dei mesi
+            if ($this->courseId > 0)
+            {
+                $record->months = json_encode($this->months);
+                $record->member_course_id = $this->courseId;
+                $record->save();
+                $c = \App\Models\MemberCourse::findOrFail($this->courseId);
+                $xxx = json_decode($c->months);
+                foreach($xxx as $idx => $mm)
+                {
+                    if (in_array($mm->m, $this->months))
+                    {
+                        $xxx[$idx]->status = 1;
+                    }
+                }
+                $c->months = json_encode($xxx);
+                if ($this->createSubscription == 1)
+                    $c->subscribed = true;
+                $c->save();
+            }
+
             if ($generate)
                 $this->createReceipt();
             session()->flash('success','Movimento creato');
@@ -656,7 +593,27 @@ class RecordIN extends Component
     public function delete($id)
     {
         try{
-            \App\Models\Record::find($id)->delete();
+
+            $r = \App\Models\Record::find($id);
+
+            if ($r->member_course_id > 0)
+            {
+                $months = json_decode($r->months);
+                $c = \App\Models\MemberCourse::findOrFail($r->member_course_id);
+                $xxx = json_decode($c->months);
+                foreach($xxx as $idx => $mm)
+                {
+                    if (in_array($mm->m, $months))
+                    {
+                        $xxx[$idx]->status = "";
+                    }
+                }
+                $c->months = json_encode($xxx);
+                $c->save();
+            }
+
+            $r->delete();
+
             session()->flash('success',"Movimento eliminato");
         }catch(\Exception $e){
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
@@ -927,4 +884,51 @@ class RecordIN extends Component
         $this->multiP = false;
     }
 
+    public function getMonth($m)
+    {
+        $ret = '';
+        switch ($m) {
+            case 1:
+                $ret = 'Gennaio';
+                break;
+            case 2:
+                $ret = 'Febbraio';
+                break;
+            case 3:
+                $ret = 'Marzo';
+                break;
+            case 4:
+                $ret = 'Aprile';
+                break;
+            case 5:
+                $ret = 'Maggio';
+                break;
+            case 6:
+                $ret = 'Giugno';
+                break;
+            case 7:
+                $ret = 'Luglio';
+                break;
+            case 8:
+                $ret = 'Agosto';
+                break;
+            case 9:
+                $ret = 'Settembre';
+                break;
+            case 10:
+                $ret = 'Ottobre';
+                break;
+            case 11:
+                $ret = 'Novembre';
+                break;
+            case 12:
+                $ret = 'Dicembre';
+                break;
+            default:
+                $ret = '';
+                break;
+        }
+        return $ret;
+    }
+
 }

+ 49 - 15
app/Http/Livewire/RecordINOUT.php

@@ -23,7 +23,7 @@ class RecordINOUT extends Component
     public $year_2;
     public $show_block_2;
 
-    public $borsellino_id = 0;
+    //public $borsellino_id = 0;
 
     public $columns = array();
     public $rows_in = array();
@@ -46,12 +46,23 @@ class RecordINOUT extends Component
     public $filterCausalsIn = null;
     public $filterCausalsOut = null;
 
+    public $excludeCausals = array();
+
     public function mount()
     {
 
         $borsellino = \App\Models\Causal::where('money', true)->first();
         if ($borsellino)
-            $this->borsellino_id = $borsellino->id;
+            $this->excludeCausals[] = $borsellino->id;
+            //$this->borsellino_id = $borsellino->id;
+
+        // Aggiungo
+        $excludes = \App\Models\Causal::where('no_records', true)->get();
+        foreach($excludes as $e)
+        {
+            $this->excludeCausals[] = $e->id;
+        }
+
 
         $this->month = date("m");
         $this->year = date("Y");
@@ -59,11 +70,11 @@ class RecordINOUT extends Component
         $this->year_2 = date("Y");
         $this->show_block_2 = false;
 
-        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->where('id', '<>', $this->borsellino_id)->get(), 'IN', 0);
-        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->where('id', '<>', $this->borsellino_id)->get(), 'OUT', 0);
+        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get(), 'IN', 0);
+        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->whereNotIn('id', $this->excludeCausals)->get(), 'OUT', 0);
 
-        $this->causalsIn = \App\Models\Causal::where('parent_id', null)->where('type', 'IN')->get();
-        $this->causalsOut = \App\Models\Causal::where('parent_id', null)->where('type', 'OUT')->get();
+        $this->causalsIn = \App\Models\Causal::where('parent_id', null)->where('type', 'IN')->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get();
+        $this->causalsOut = \App\Models\Causal::where('parent_id', null)->where('type', 'OUT')->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get();
 
     }
 
@@ -71,10 +82,15 @@ class RecordINOUT extends Component
     {
         foreach($records as $record)
         {
+            $first_parent_id = null;
+            if ($record->parent_id != null)
+            {
+                $first_parent_id = \App\Models\Causal::where('id', $record->parent_id)->first()->parent_id;
+            }
             if ($type == 'IN')
-                $this->rows_in[] = array('id' => $record->id, 'name' => $record->name, 'level' => $indentation, 'parent_id' => $record->parent_id);
+                $this->rows_in[] = array('id' => $record->id, 'name' => $record->name, 'level' => $indentation, 'parent_id' => $record->parent_id, 'first_parent_id' => $first_parent_id);
             if ($type == 'OUT')
-                $this->rows_out[] = array('id' => $record->id, 'name' => $record->name, 'level' => $indentation, 'parent_id' => $record->parent_id);
+                $this->rows_out[] = array('id' => $record->id, 'name' => $record->name, 'level' => $indentation, 'parent_id' => $record->parent_id, 'first_parent_id' => $first_parent_id);
             if(count($record->childs))
                 $this->getCausale($record->childs, $type, $indentation + 1);
         }
@@ -116,7 +132,7 @@ class RecordINOUT extends Component
 
                 $records = \App\Models\Record::where('type', 'IN')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
-                    ->where('records_rows.causal_id', '<>', $this->borsellino_id)
+                    ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
                     ->where('records_rows.when', 'like', '%' . $f . '%')->get();
                 //$records = $records->orderBy('date', 'DESC')->get();
 
@@ -141,7 +157,7 @@ class RecordINOUT extends Component
 
                 $records = \App\Models\Record::where('type', 'OUT')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
-                    ->where('records_rows.causal_id', '<>', $this->borsellino_id)
+                    ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
                     ->where('records_rows.when', 'like', '%' . $f . '%')->get();
                 //$records = $records->orderBy('date', 'DESC')->get();
 
@@ -320,7 +336,25 @@ class RecordINOUT extends Component
     public function export()
     {
 
-        $path = $this->generateExcel($this->columns, $this->rows_in, $this->records_in, $this->rows_out, $this->records_out);
+        $rows_in = array();
+
+        if ($this->filterCausalsIn != null && sizeof($this->filterCausalsIn) > 0)
+        {
+            foreach($this->rows_in as $r)
+            {
+                if (in_array($r["id"], $this->filterCausalsIn) || in_array($r["parent_id"], $this->filterCausalsIn) || in_array($r["first_parent_id"], $this->filterCausalsIn))
+                {
+                    $rows_in[] = $r;
+                }
+            }
+        }
+        else
+        {
+            $rows_in = $this->rows_in;
+        }
+
+        $path = $this->generateExcel($this->columns, $rows_in, $this->records_in, $this->rows_out, $this->records_out);
+
         return response()->download($path)->deleteFileAfterSend();
 
     }
@@ -355,7 +389,7 @@ class RecordINOUT extends Component
 
             $records = \App\Models\Record::where('type', 'IN')
                 ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
-                ->where('records_rows.causal_id', '<>', $this->borsellino_id)
+                ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
                 ->where('records_rows.when', 'like', '%' . $filter . '%')->get();
             //$records = $records->orderBy('date', 'DESC')->get();
 
@@ -380,7 +414,7 @@ class RecordINOUT extends Component
 
             $records = \App\Models\Record::where('type', 'OUT')
                 ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
-                ->where('records_rows.causal_id', '<>', $this->borsellino_id)
+                ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
                 ->where('records_rows.when', 'like', '%' . $filter . '%')->get();
             //$records = $records->orderBy('date', 'DESC')->get();
 
@@ -450,7 +484,7 @@ class RecordINOUT extends Component
             if ($in["level"] == 0)
             {
                 $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFont()->setBold(true);
-                $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('b1ed5c');
+                //$activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('b1ed5c');
             }
 
             $count += 1;
@@ -502,7 +536,7 @@ class RecordINOUT extends Component
             if ($out["level"] == 0)
             {
                 $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFont()->setBold(true);
-                $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('ed6d61');
+                //$activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('ed6d61');
             }
 
             $count += 1;

+ 70 - 67
app/Http/Livewire/RecordOUT.php

@@ -74,8 +74,7 @@ class RecordOUT extends Component
     protected $messages = [
         'supplier_id.required' => 'Il fornitore è obbligatorio',
         'payment_method_id.required' => 'Il metodo di pagamento è obbligatorio',
-        'causal_id.required' => 'La causale è obbligatoria',
-        'amount.required' => 'L\'importo è obbligatorio',
+        'rows.*.amount.required' => 'L\'importo è obbligatorio',
         'rows.*.causal_id.required' => 'La causale è obbligatoria'
     ];
 
@@ -147,7 +146,7 @@ class RecordOUT extends Component
         $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->orderBy('name')->get(), 0);
 
         $this->suppliers = \App\Models\Supplier::select('name','id')->orderBy('name')->get();
-        $this->payments = \App\Models\PaymentMethod::select('id', 'name')->orderBy('name')->get();
+        $this->payments = \App\Models\PaymentMethod::select('id', 'name')->where('enabled', true)->orderBy('name')->get();
     }
 
     public function getCausal($causal)
@@ -180,88 +179,92 @@ class RecordOUT extends Component
 
     public function render()
     {
+        $datas = [];
 
-        if ($this->hasFilter)
+        if (false)
         {
-
-            $datas = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method');
-            /*if ($this->filterCommercial > 0)
-            {
-                $datas = $datas->where('commercial', $this->filterCommercial == 1 ? true : false);
-            }*/
-            if ($this->filterSupplier > 0)
-            {
-                $datas = $datas->where('supplier_id', $this->filterSupplier);
-            }
-            if ($this->filterPaymentMethod > 0)
-            {
-                $datas = $datas->where('payment_method_id', $this->filterPaymentMethod);
-            }
-            /*if (sizeof($this->filterCausals) > 0)
-            {
-                $datas = $datas->whereIn('causal_id', $this->filterCausals);
-            }*/
-            if ($this->filterFrom != '')
+            if ($this->hasFilter)
             {
-                $datas = $datas->where('date', '>=', $this->filterFrom);
-            }
-            if ($this->filterTo != '')
-            {
-                $datas = $datas->where('date', '<=', $this->filterTo);
-            }
-            //$this->records = $datas->orderBy('date', 'DESC')->get();
 
-            $this->records = $datas->get();
+                $datas = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method');
+                /*if ($this->filterCommercial > 0)
+                {
+                    $datas = $datas->where('commercial', $this->filterCommercial == 1 ? true : false);
+                }*/
+                if ($this->filterSupplier > 0)
+                {
+                    $datas = $datas->where('supplier_id', $this->filterSupplier);
+                }
+                if ($this->filterPaymentMethod > 0)
+                {
+                    $datas = $datas->where('payment_method_id', $this->filterPaymentMethod);
+                }
+                /*if (sizeof($this->filterCausals) > 0)
+                {
+                    $datas = $datas->whereIn('causal_id', $this->filterCausals);
+                }*/
+                if ($this->filterFrom != '')
+                {
+                    $datas = $datas->where('date', '>=', $this->filterFrom);
+                }
+                if ($this->filterTo != '')
+                {
+                    $datas = $datas->where('date', '<=', $this->filterTo);
+                }
+                //$this->records = $datas->orderBy('date', 'DESC')->get();
 
-            //$this->total = $this->records->sum('amount');
+                $this->records = $datas->get();
 
-            $this->total = 0;
-            foreach($this->records as $r)
-            {
-                foreach($r->rows as $rr)
+                //$this->total = $this->records->sum('amount');
+
+                $this->total = 0;
+                foreach($this->records as $r)
                 {
-                    $this->total += $rr->amount;
+                    foreach($r->rows as $rr)
+                    {
+                        $this->total += $rr->amount;
+                    }
                 }
-            }
 
-        }
-        else
-        {
-            if ($this->selectedFilter == '')
-            {
-                $this->records = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method')->limit(20)->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();
             }
             else
             {
-                if ($this->selectedFilter == 0)
+                if ($this->selectedFilter == '')
                 {
-                    $fromDate = date("Y-m-d");
-                    $toDate = date("Y-m-d");
+                    $this->records = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method')->limit(20)->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();
                 }
-                if ($this->selectedFilter == 1)
+                else
                 {
-                    $fromDate = date("Y-m-01");
-                    $toDate = date("Y-m-t");
+                    if ($this->selectedFilter == 0)
+                    {
+                        $fromDate = date("Y-m-d");
+                        $toDate = date("Y-m-d");
+                    }
+                    if ($this->selectedFilter == 1)
+                    {
+                        $fromDate = date("Y-m-01");
+                        $toDate = date("Y-m-t");
+                    }
+                    if ($this->selectedFilter == 2)
+                    {
+                        $fromDate = date("Y-01-01");
+                        $toDate = date("Y-12-31");
+                    }
+                    if ($this->selectedFilter == 3)
+                    {
+                        $fromDate = date("2000-01-01");
+                        $toDate = date("Y-12-31");
+                    }
+                    $this->records = \App\Models\Record::where('type', 'OUT')->whereBetween('date', [$fromDate, $toDate])->with('supplier', 'payment_method')->get();
                 }
-                if ($this->selectedFilter == 2)
-                {
-                    $fromDate = date("Y-01-01");
-                    $toDate = date("Y-12-31");
-                }
-                if ($this->selectedFilter == 3)
-                {
-                    $fromDate = date("2000-01-01");
-                    $toDate = date("Y-12-31");
-                }
-                $this->records = \App\Models\Record::where('type', 'OUT')->whereBetween('date', [$fromDate, $toDate])->with('supplier', 'payment_method')->get();
             }
-        }
 
-        foreach($this->records as $r)
-        {
-            $r->total = $r->getTotal();
-            $r->supplier = $r->supplier ? $r->supplier->name : '';
-            $r->payment = $r->payment_method ? $r->payment_method->name : '';
+            foreach($this->records as $r)
+            {
+                $r->total = $r->getTotal();
+                $r->supplier = $r->supplier ? $r->supplier->name : '';
+                $r->payment = $r->payment_method ? $r->payment_method->name : '';
+            }
         }
 
         /*if ($this->sortField != '')

+ 32 - 6
app/Http/Livewire/Sponsor.php

@@ -24,7 +24,10 @@ class Sponsor extends Component
     ];
 
     protected $messages = [
-        'name.required' => 'Il nome è obbligatorio'
+        'name.required' => 'Il nome è obbligatorio',
+        'from_date.required' => 'La data è obbligatoria',
+        'to_date.required' => 'La data è obbligatoria',
+        'subscription_date.required' => 'La data è obbligatoria',
     ];
 
     public function resetFields(){
@@ -237,7 +240,12 @@ class Sponsor extends Component
 
     public function storeContract()
     {
-        $this->validate();
+        $rules = [
+            'from_date' => 'required|date',
+            'to_date' => 'required|date',
+            'subscription_date' => 'required|date'
+        ];
+        $this->validate($rules);
         try {
 
             $name = '';
@@ -257,7 +265,7 @@ class Sponsor extends Component
                 'from_date' => $this->from_date,
                 'to_date' => $this->to_date,
                 'subscription_date' => $this->subscription_date,
-                'amount' => $this->amount,
+                'amount' => $this->currencyToDouble($this->amount),
                 'file' => $name
             ]);
             session()->flash('success','Contratto creato');
@@ -278,7 +286,7 @@ class Sponsor extends Component
                 $this->from_date = $sponsorContract->from_date ? date("Y-m-d", strtotime($sponsorContract->from_date)) : "";
                 $this->to_date = $sponsorContract->to_date ? date("Y-m-d", strtotime($sponsorContract->to_date)) : "";
                 $this->subscription_date = $sponsorContract->subscription_date ? date("Y-m-d", strtotime($sponsorContract->subscription_date)) : "";
-                $this->amount = $sponsorContract->amount;
+                $this->amount = formatPrice($sponsorContract->amount);
                 $this->file_old = $sponsorContract->file;
                 $this->contractId = $sponsorContract->id;
                 $this->updateContract = true;
@@ -291,7 +299,12 @@ class Sponsor extends Component
 
     public function updateContract()
     {
-        $this->validate();
+        $rules = [
+            'from_date' => 'required|date',
+            'to_date' => 'required|date',
+            'subscription_date' => 'required|date'
+        ];
+        $this->validate($rules);
         try {
 
             $name = '';
@@ -310,7 +323,7 @@ class Sponsor extends Component
                 'from_date' => $this->from_date,
                 'to_date' => $this->to_date,
                 'subscription_date' => $this->subscription_date,
-                'amount' => $this->amount,
+                'amount' => $this->currencyToDouble($this->amount),
                 'file' => $name != '' ? $name : $this->file_old,
             ]);
             session()->flash('success','Contratto aggiornato');
@@ -328,6 +341,11 @@ class Sponsor extends Component
         $this->resetContract();
     }
 
+    public function removeFile()
+    {
+        $this->file_old = '';
+    }
+
     public function deleteContract($id)
     {
         try{
@@ -367,4 +385,12 @@ class Sponsor extends Component
         }
         return "";
     }
+
+    function currencyToDouble($val)
+    {
+        $x = str_replace("€", "", $val);
+        $x = str_replace(".", "", $x);
+        $x = str_replace(",", ".", $x);
+        return floatval(trim($x));
+    }
 }

+ 1 - 0
app/Models/Causal.php

@@ -16,6 +16,7 @@ class Causal extends Model
         'money',
         'user_status',
         'no_first',
+        'no_records',
         'enabled'
     ];
 

+ 24 - 0
app/Models/Configuration.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Configuration extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'logo',
+        'name',
+        'address',
+        'countrry',
+        'province',
+        'fiscal_code',
+        'vat',
+        'fiscal_year_month_from',
+        'fiscal_year_month_from'
+    ];
+
+}

+ 36 - 0
app/Models/Course.php

@@ -12,6 +12,17 @@ class Course extends Model
     protected $fillable = [
         'parent_id',
         'name',
+        'course_type_id',
+        'causal_id',
+        'max_members',
+        'instructor',
+        'price',
+        'months',
+        'date_from',
+        'date_to',
+        'course_duration_id',
+        'course_frequency_id',
+        'course_level_id',
         'enabled'
     ];
 
@@ -20,6 +31,31 @@ class Course extends Model
         return $this->belongsTo(Course::class);
     }
 
+    public function type()
+    {
+        return $this->belongsTo(CourseType::class, 'course_type_id');
+    }
+
+    public function duration()
+    {
+        return $this->belongsTo(CourseDuration::class, 'course_duration_id');
+    }
+
+    public function frequency()
+    {
+        return $this->belongsTo(CourseFrequency::class, 'course_frequency_id');
+    }
+
+    public function level()
+    {
+        return $this->belongsTo(CourseLevel::class, 'course_level_id');
+    }
+
+    public function member()
+    {
+        return $this->belongsTo(Member::class);
+    }
+
     public function childs() {
         return $this->hasMany(\App\Models\Course::class,'parent_id','id') ;
     }

+ 23 - 0
app/Models/CourseDuration.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CourseDuration extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'name',
+        'duration',
+        'enabled',
+    ];
+
+    public function canDelete()
+    {
+        return true;//\App\Models\PaymentMethod::where('bank_id', $this->id)->count() == 0;
+    }
+
+}

+ 22 - 0
app/Models/CourseFrequency.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CourseFrequency extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'name',
+        'enabled',
+    ];
+
+    public function canDelete()
+    {
+        return true;//\App\Models\PaymentMethod::where('bank_id', $this->id)->count() == 0;
+    }
+
+}

+ 22 - 0
app/Models/CourseLevel.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CourseLevel extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'name',
+        'enabled',
+    ];
+
+    public function canDelete()
+    {
+        return true;//\App\Models\PaymentMethod::where('bank_id', $this->id)->count() == 0;
+    }
+
+}

+ 22 - 0
app/Models/CourseSubscription.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CourseSubscription extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'name',
+        'enabled',
+    ];
+
+    public function canDelete()
+    {
+        return true;//\App\Models\PaymentMethod::where('bank_id', $this->id)->count() == 0;
+    }
+
+}

+ 23 - 0
app/Models/CourseType.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class CourseType extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'name',
+        'duration',
+        'enabled',
+    ];
+
+    public function canDelete()
+    {
+        return true;//\App\Models\PaymentMethod::where('bank_id', $this->id)->count() == 0;
+    }
+
+}

+ 1 - 0
app/Models/Member.php

@@ -112,6 +112,7 @@ class Member extends Model
         $date1 = new DateTime($this->birth_date);
         $date2 = new DateTime("now");
         $interval = $date1->diff($date2);
+        return strval($interval->y);
         return $interval->y;
     }
 

+ 15 - 1
app/Models/MemberCourse.php

@@ -14,7 +14,16 @@ class MemberCourse extends Model
         'course_id',
         'date_from',
         'date_to',
-        'when'
+        'when',
+        'course_type_id',
+        'status',
+        'price',
+        'subscription_price',
+        'months',
+        'days',
+        'course_subscription_id',
+        'notes',
+        'subscribed'
     ];
 
     public function member()
@@ -26,4 +35,9 @@ class MemberCourse extends Model
     {
         return $this->belongsTo(Course::class);
     }
+
+    public function courseSubscription()
+    {
+        return $this->belongsTo(CourseSubscription::class);
+    }
 }

+ 20 - 0
app/helpers.php

@@ -46,3 +46,23 @@ function mysqlToDate($dt)
     list($year, $month, $day) = explode("-", $date);
     return $day . "/" . $month . "/" . $year;
 }
+
+
+function currencyToDouble($val)
+{
+    $x = str_replace("€", "", $val);
+    $x = str_replace(".", "", $x);
+    $x = str_replace(",", ".", $x);
+    return floatval(trim($x));
+}
+
+function getConfiguration($field)
+{
+    $ret = "";
+    $conf = \App\Models\Configurration::first();
+    if ($conf)
+    {
+        $ret = $conf[$field];
+    }
+    return $ret;
+}

+ 32 - 0
database/migrations/2024_06_11_160000_add_no_records_to_causals_table.php

@@ -0,0 +1,32 @@
+<?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('causals', function (Blueprint $table) {
+            $table->integer('no_records')->default(0);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('causals', function (Blueprint $table) {
+            $table->dropColumn('no_records');
+        });
+    }
+};

+ 35 - 0
database/migrations/2024_06_17_163000_create_course_types_table.php

@@ -0,0 +1,35 @@
+<?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::create('course_types', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->integer('duration');
+            $table->integer('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('course_types');
+    }
+};

+ 44 - 0
database/migrations/2024_06_17_163100_add_fields_to_courses_table.php

@@ -0,0 +1,44 @@
+<?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('courses', function (Blueprint $table) {
+            $table->unsignedBigInteger('course_type_id')->nullable();
+            $table->foreign('course_type_id')->nullable()->references('id')->on('course_types')->onUpdate('cascade')->onDelete('cascade');
+            $table->unsignedBigInteger('causal_id')->nullable();
+            $table->foreign('causal_id')->nullable()->references('id')->on('causals')->onUpdate('cascade')->onDelete('cascade');
+            $table->integer('max_members');
+            $table->string('instructor')->nullable();
+            $table->decimal('price', $precision = 8, $scale = 2);
+            $table->string('months')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('courses', function (Blueprint $table) {
+            $table->dropColumn('course_type_id');
+            $table->dropColumn('causal_id');
+            $table->dropColumn('max_members');
+            $table->dropColumn('instructor');
+            $table->dropColumn('price');
+            $table->dropColumn('months');
+        });
+    }
+};

+ 41 - 0
database/migrations/2024_06_17_164000_add_fields_to_member_courses_table.php

@@ -0,0 +1,41 @@
+<?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('member_courses', function (Blueprint $table) {
+            $table->unsignedBigInteger('course_type_id')->nullable();
+            $table->foreign('course_type_id')->nullable()->references('id')->on('course_types')->onUpdate('cascade')->onDelete('cascade');
+            $table->integer('status');
+            $table->decimal('price', $precision = 8, $scale = 2);
+            $table->string('months')->nullable();
+            $table->string('notes')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('member_courses', function (Blueprint $table) {
+            $table->dropColumn('course_type_id');
+            $table->dropColumn('status');
+            $table->dropColumn('price');
+            $table->dropColumn('months');
+            $table->dropColumn('notes');
+        });
+    }
+};

+ 35 - 0
database/migrations/2024_06_19_163000_add_fields_to_records_table.php

@@ -0,0 +1,35 @@
+<?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('records', function (Blueprint $table) {
+            $table->unsignedBigInteger('member_course_id')->nullable();
+            $table->foreign('member_course_id')->nullable()->references('id')->on('member_courses')->onUpdate('cascade')->onDelete('cascade');
+            $table->string('months')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('records', function (Blueprint $table) {
+            $table->dropColumn('member_course_id');
+            $table->dropColumn('months');
+        });
+    }
+};

+ 35 - 0
database/migrations/2024_06_22_163000_create_course_durations_table.php

@@ -0,0 +1,35 @@
+<?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::create('course_durations', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->integer('duration');
+            $table->integer('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('course_durations');
+    }
+};

+ 34 - 0
database/migrations/2024_06_22_163030_create_course_subscriptions_table.php

@@ -0,0 +1,34 @@
+<?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::create('course_subscriptions', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->integer('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('course_subscriptions');
+    }
+};

+ 37 - 0
database/migrations/2024_06_22_163100_add_other_fields_to_courses_table.php

@@ -0,0 +1,37 @@
+<?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('courses', function (Blueprint $table) {
+            $table->unsignedBigInteger('course_duration_id')->nullable();
+            $table->foreign('course_duration_id')->nullable()->references('id')->on('course_durations')->onUpdate('cascade')->onDelete('cascade');
+            $table->date('date_from')->nullable();
+            $table->date('date_to')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('courses', function (Blueprint $table) {
+            $table->dropColumn('course_duration_id');
+            $table->dropColumn('date_from');
+            $table->dropColumn('date_to');
+        });
+    }
+};

+ 33 - 0
database/migrations/2024_06_22_163200_add_other_fields_to_member_courses_table.php

@@ -0,0 +1,33 @@
+<?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('member_courses', function (Blueprint $table) {
+            $table->unsignedBigInteger('course_subscription_id')->nullable();
+            $table->foreign('course_subscription_id')->nullable()->references('id')->on('course_subscriptions')->onUpdate('cascade')->onDelete('cascade');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('member_courses', function (Blueprint $table) {
+            $table->dropColumn('course_subscription_id');
+        });
+    }
+};

+ 34 - 0
database/migrations/2024_07_22_151500_create_course_frequencies_table.php

@@ -0,0 +1,34 @@
+<?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::create('course_frequencies', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->integer('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('course_frequencies');
+    }
+};

+ 34 - 0
database/migrations/2024_07_22_151501_create_course_levels_table.php

@@ -0,0 +1,34 @@
+<?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::create('course_levels', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->integer('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('course_levels');
+    }
+};

+ 36 - 0
database/migrations/2024_07_22_151600_add_relations_to_courses_table.php

@@ -0,0 +1,36 @@
+<?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('courses', function (Blueprint $table) {
+            $table->unsignedBigInteger('course_frequency_id')->nullable();
+            $table->foreign('course_frequency_id')->nullable()->references('id')->on('course_frequencies')->onUpdate('cascade')->onDelete('cascade');
+            $table->unsignedBigInteger('course_level_id')->nullable();
+            $table->foreign('course_level_id')->nullable()->references('id')->on('course_levels')->onUpdate('cascade')->onDelete('cascade');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('courses', function (Blueprint $table) {
+            $table->dropColumn('course_frequency_id');
+            $table->dropColumn('course_level_id');
+        });
+    }
+};

+ 32 - 0
database/migrations/2024_07_23_165600_add_subscribed_to_member_courses_table.php

@@ -0,0 +1,32 @@
+<?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('member_courses', function (Blueprint $table) {
+            $table->integer('subscribed')->default(0);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('member_courses', function (Blueprint $table) {
+            $table->dropColumn('subscribed');
+        });
+    }
+};

+ 43 - 0
database/migrations/2024_07_24_094500_create_configuration_table.php

@@ -0,0 +1,43 @@
+<?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::create('configuration', function (Blueprint $table) {
+            $table->id();
+            $table->string('logo')->nullable();
+            $table->string('name')->nullable();
+            $table->string('address')->nullable();
+            $table->string('countrry')->nullable();
+            $table->string('province')->nullable();
+            $table->string('fiscal_code')->nullable();
+            $table->string('vat')->nullable();
+            $table->integer('fiscal_year_month_from')->defaulut(1);
+            $table->integer('fiscal_year_month_to')->default(12);
+            $table->unsignedBigInteger('subscription_causal_id')->nullable();
+            $table->foreign('subscription_causal_id')->nullable()->references('id')->on('causals')->onUpdate('cascade')->onDelete('cascade');
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('configuration');
+    }
+};

+ 32 - 0
database/migrations/2024_07_24_130600_add_subscription_price_to_member_courses_table.php

@@ -0,0 +1,32 @@
+<?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('member_courses', function (Blueprint $table) {
+            $table->decimal('subscription_price', $precision = 8, $scale = 2);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('member_courses', function (Blueprint $table) {
+            $table->dropColumn('subscription_price');
+        });
+    }
+};

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

@@ -17,10 +17,27 @@
     background-color: #006099 !important;
     border-color: var(--bs-pagination-active-border-color);
   }
-  .buttons-print, .buttons-csv{
+  .buttons-print, .buttons-csv, .buttons-excel, .buttons-pdf{
     background-color: #006099 !important;
   }
-
+    .top{
+        margin-bottom:20px;
+    }
+    .bottom{
+        margin-top:20px;
+    }
+    .rightPagination > div.dt-info
+    {
+        text-align:right;
+    }
+    .col-4 > div.dt-length
+    {
+        text-align:center;
+    }
+    div.dt-container div.dt-length label
+    {
+        margin-top:10px;
+    }
   </style>
 
 </head>
@@ -65,6 +82,11 @@
                             <i class="ico--ui ico--ui_menu uscite"></i> <span class="ms-3 d-none d-md-inline">Uscite</span>
                         </a>
                     </li>
+                    <li class="nav-item">
+                        <a href="/receipts" class="nav-link d-flex align-items-center">
+                            <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Ricevute</span>
+                        </a>
+                    </li>
                     <li class="nav-item">
                         <a href="/records_in_out" class="nav-link d-flex align-items-center">
                             <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Entrate/uscite gestionale</span>
@@ -75,6 +97,16 @@
                             <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Prima Nota</span>
                         </a>
                     </li>
+                    <li class="nav-item">
+                        <a href="/course_list" class="nav-link d-flex align-items-center">
+                            <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Pagamento corsi</span>
+                        </a>
+                    </li>
+                    <li class="nav-item">
+                        <a href="/course_member" class="nav-link d-flex align-items-center">
+                            <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Iscritti corsi</span>
+                        </a>
+                    </li>
                 </ul>
 
                 <ul class="nav nav-pills flex-column align-items-center align-items-sm-start w-100" id="menu-scadenze">
@@ -245,6 +277,7 @@
   <script src="/assets/js/tablesaw.js"></script>
   <script src="/assets/js/tablesaw-init.js"></script>
 
+
     @livewireScripts
 
     @stack('scripts')

+ 30 - 3
resources/views/livewire/bank.blade.php

@@ -7,7 +7,7 @@
         <header id="title--section" class="d-flex align-items-center justify-content-between">
             <div class="title--section_name d-flex align-items-center justify-content-between">
                 <i class="ico--ui title_section utenti me-2"></i>
-                <h2 class="primary">Elenco Banche</h2>
+                <h2 class="primary">Banche</h2>
             </div>
 
             <div class="title--section_addButton"  wire:click="add()" style="cursor: pointer;">
@@ -40,7 +40,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Nome</th>
@@ -146,6 +146,10 @@
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
@@ -166,7 +170,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Banche',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Banche',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Banche',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 45 - 11
resources/views/livewire/card.blade.php

@@ -3,7 +3,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco Tessere @else Inserimento/modifica tessera @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)Tessere @else Inserimento/modifica tessera @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -45,7 +45,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col" >Nome</th>
@@ -55,7 +55,7 @@
                         <th scope="col">...</th>
                     </tr>
                 </thead>
-                <tbody id="checkall-target">
+                <tbody>
                     @foreach($records as $record)
                         <tr>
                             <td>{{$record->name}}</td>
@@ -208,6 +208,10 @@
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
@@ -223,15 +227,45 @@
 
         function loadDataTable(){
             $('#tablesaw-350').DataTable({
-                thead: {
-                'th': {'background-color': 'blue'}
-                },
-                layout: {
-                    topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
-                    }
-                },
+                //layout: {
+                //    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Tessere',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Tessere',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Tessere',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ],
+
+                //    },
+
+                //},
+                //dom: '<"row"<"col-4"B><"col-4"l><"col-4"f>>rtip',
+                dom: '<"top"><"row top"<"col-6"B><"col-6"f>>rt<"bottom"<"row"<"col-4"p><"col-4"l><"col-4 rightPagination"i>>><"clear">',
+                //"dom": '<"top"i>rt<"bottom"flp><"clear">',
+                lengthChange: true,
                 pagingType: 'numbers',
+                lengthMenu: [
+                    [10, 25, 50, -1],
+                    [10, 25, 50, 'Tutti']
+                ],
                 "language": {
                     "url": "/assets/js/Italian.json"
                 }

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

@@ -3,7 +3,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco Categorie @else Inserimento/modifica categoria @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)Categorie @else Inserimento/modifica categoria @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -23,7 +23,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Nome</th>

+ 9 - 2
resources/views/livewire/causal.blade.php

@@ -3,7 +3,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco causali @else Inserimento/modifica causale @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)causali @else Inserimento/modifica causale @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -22,7 +22,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Nome</th>
@@ -120,6 +120,13 @@
                             </div>
                         </div>
 
+                        <div class="form--item mb-3">
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="checkbox" id="no_records" wire:model="no_records">
+                                <label class="form-check-label" for="no_records">Escludi da ingressi/uscite</label>
+                            </div>
+                        </div>
+
                         <!-- // inline input field -->
 
                         <div class="form--item">

+ 30 - 3
resources/views/livewire/city.blade.php

@@ -3,7 +3,7 @@
 <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco comuni @else Inserimento/modifica comuni @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)comuni @else Inserimento/modifica comuni @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -23,7 +23,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Provincia</th>
@@ -121,6 +121,10 @@
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
@@ -141,7 +145,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Comuni',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Comuni',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Comuni',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 140 - 7
resources/views/livewire/course.blade.php

@@ -3,7 +3,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco Corsi @else Inserimento/modifica corso @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)Corsi @else Inserimento/modifica corso @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -23,10 +23,12 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Nome</th>
+                        <th scope="col">Tipologia</th>
+                        <th scope="col">Durata</th>
                         <th scope="col">...</th>
                     </tr>
                 </thead>
@@ -34,15 +36,13 @@
                     @foreach($records as $record)
                         <tr>
                             <td>{{$record->name}}</td>
+                            <td>{{$record->type->name ?? ""}}</td>
+                            <td>{{$record->duration->name ?? ""}}</td>
                             <td>
-                                <button type="button" class="btn btn-outline-success btn-sm" wire:click="addLevel({{ $record->id }})">Aggiungi livello</button>
                                 <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
                                 <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
                             </td>
                         </tr>
-                        @if(count($record->childs))
-                            @include('livewire/course_child',['records' => $record->childs, 'indentation' => 1])
-                        @endif
                     @endforeach
 
                 </tbody>
@@ -66,7 +66,7 @@
                     <form action="">
 
                         <div class="row mb-3">
-                            <div class="col">
+                            <div class="col-6">
                                 <div class="form--item">
                                     <label for="inputName" class="form-label">Nome</label>
                                     <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
@@ -75,6 +75,126 @@
                                     @enderror
                                 </div>
                             </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Tipologia</label>
+                                    <select class="form-select form-select-lg me-1 @error('course_type_id') is-invalid @enderror" wire:model="course_type_id">
+                                        <option value="">
+                                        @foreach($course_types as $c)
+                                            <option value="{{$c["id"]}}">{{$c["name"]}}</option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Durata</label>
+                                    <select class="form-select form-select-lg me-1 @error('course_duration_id') is-invalid @enderror" wire:model="course_duration_id">
+                                        <option value="">
+                                        @foreach($course_durations as $c)
+                                            <option value="{{$c["id"]}}">{{$c["name"]}}</option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Frequenza</label>
+                                    <select class="form-select form-select-lg me-1 @error('course_frequency_id') is-invalid @enderror" wire:model="course_frequency_id">
+                                        <option value="">
+                                        @foreach($course_frequencies as $c)
+                                            <option value="{{$c["id"]}}">{{$c["name"]}}</option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Livello</label>
+                                    <select class="form-select form-select-lg me-1 @error('course_level_id') is-invalid @enderror" wire:model="course_level_id">
+                                        <option value="">
+                                        @foreach($course_levels as $c)
+                                            <option value="{{$c["id"]}}">{{$c["name"]}}</option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                            </div>
+                            <div class="col-3">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Data inizio</label>
+                                    <input class="form-control" type="date" placeholder="Data inizio" wire:model="date_from">
+                                </div>
+                            </div>
+                            <div class="col-3">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Data fine</label>
+                                    <input class="form-control" type="date" placeholder="Data fine" wire:model="date_to">
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Prezzo mensile</label>
+                                    <input class="form-control js-keyupTitle @error('price') is-invalid @enderror" type="text" id="price" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00" wire:model="price">
+                                    @error('price')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Causale</label>
+                                    <livewire:causals :type="$typeIN" :idx="0" :causal_id="$causal_id" :wire:key="0" />
+                                    @error('causal_id')
+                                        <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
+                                    @enderror
+
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">N° partecipanti</label>
+                                    <input class="form-control js-keyupTitle @error('max_members') is-invalid @enderror" type="text" id="max_members" placeholder="Numero massimo partecipanti" wire:model="max_members">
+                                    @error('max_members')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Istruttore</label>
+                                    <input class="form-control js-keyupTitle @error('instructor') is-invalid @enderror" type="text" id="instructor" placeholder="Istruttore" wire:model="instructor">
+                                    @error('instructor')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+
+
+                            <!--<div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Durata</label>
+                                    <input class="form-control js-keyupTitle " type="text" id="duration" placeholder="Durata" wire:model="duration">
+
+                                </div>
+                            </div>-->
+                            @if(false)
+                                <div class="col-12">
+                                    <div class="form--item">
+                                        <label for="inputName" class="form-label">Seleziona mesi</label>
+                                        @foreach($monthList as $idx => $y)
+                                            <div class="row">
+                                                <div class="col-12">
+                                                    <b>{{$idx}}</b>
+                                                </div>
+                                                @foreach($y as $m)
+                                                    <div class="col-3">{{$m}}</div>
+                                                @endforeach
+                                            </div>
+                                            <div class="row"><br></div>
+                                        @endforeach
+                                    </div>
+                                </div>
+                            @endif
                         </div>
 
                         <div class="form--item">
@@ -94,3 +214,16 @@
 
     @endif
 </div>
+
+@push('scripts')
+    <script>
+
+        function onlyNumberAmount(input) {
+            let v = input.value.replace(/\D+/g, '');
+            if (v.length > 14) v = v.slice(0, 14);
+            input.value = "€ " + v.replace(/(\d)(\d\d)$/, "$1,$2").replace(/(^\d{1,3}|\d{3})(?=(?:\d{3})+(?:,|$))/g, '$1.');
+        }
+
+    </script>
+
+@endpush

+ 176 - 0
resources/views/livewire/course_duration.blade.php

@@ -0,0 +1,176 @@
+<div class="col card--ui" id="card--dashboard">
+    @if(!$add && !$update)
+
+        <header id="title--section" class="d-flex align-items-center justify-content-between">
+            <div class="title--section_name d-flex align-items-center justify-content-between">
+                <i class="ico--ui title_section utenti me-2"></i>
+                <h2 class="primary">Durata corsi</h2>
+            </div>
+
+            <div class="title--section_addButton"  wire:click="add()" style="cursor: pointer;">
+                <div class="card--ui card--ui_btnAddHeaderUser entrata d-flex justify-items-between">
+                    <header class="d-flex justify-content-between"><div class="card-title d-flex align-items-start"><h2>Aggiungi&nbsp;&nbsp;&nbsp;</h2></div><a href="#" wire:click="add()"><i class="ico--ui big add primary"></i></a></header>
+                </div>
+            </div>
+
+        </header>
+
+        <section id="resume-table">
+            <div class="compare--chart_wrapper d-none"></div>
+
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+                <thead>
+                    <tr>
+                        <th scope="col">Nome</th>
+                        <th scope="col">Mesi</th>
+                        <th scope="col">Abilitato</th>
+                        <th scope="col">...</th>
+                    </tr>
+                </thead>
+                <tbody id="checkall-target">
+                    @foreach($records as $record)
+                        <tr>
+                            <td>{{$record->name}}</td>
+                            <td>{{$record->duration}}</td>
+                            <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
+                            <td>
+                                <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
+                                <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
+                            </td>
+                        </tr>
+                    @endforeach
+
+                </tbody>
+            </table>
+
+        </section>
+
+    @else
+
+        <div class="container">
+
+            @if (session()->has('error'))
+                <div class="alert alert-danger" role="alert">
+                    {{ session()->get('error') }}
+                </div>
+            @endif
+
+            <div class="row">
+                <div class="col">
+
+                    <form action="">
+
+                        <div class="row mb-3">
+                            <div class="col">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Nome</label>
+                                    <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
+                                    @error('name')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+                            <div class="col">
+                                <div class="form--item">
+                                    <label for="inputDuration" class="form-label">Durata</label>
+                                    <input class="form-control js-keyupTitle @error('duration') is-invalid @enderror" type="text" id="duration" placeholder="Valore" wire:model="duration" type="number">
+                                    @error('duration')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+                            <div class="col">
+                                <div class="form-check form-check-inline">
+                                    <input class="form-check-input" type="checkbox" id="enabled" wire:model="enabled">
+                                    <label class="form-check-label" for="enabled">Abilitato</label>
+                                </div>
+                            </div>
+                        </div>
+
+                        <!-- // inline input field -->
+
+                        <div class="form--item">
+                            @if($add)
+                                <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
+                            @endif
+                            @if($update)
+                                <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
+                            @endif
+                            <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
+                        </div>
+
+                    </form>
+                </div>
+            </div>
+        </div>
+
+    @endif
+</div>
+
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
+@push('scripts')
+    <script>
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        Livewire.on('load-data-table', () => {
+            loadDataTable();
+        });
+
+        function loadDataTable(){
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
+                    }
+                },
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
+
+        }
+
+    </script>
+@endpush
+

+ 165 - 0
resources/views/livewire/course_frequency.blade.php

@@ -0,0 +1,165 @@
+<div class="col card--ui" id="card--dashboard">
+    @if(!$add && !$update)
+
+        <header id="title--section" class="d-flex align-items-center justify-content-between">
+            <div class="title--section_name d-flex align-items-center justify-content-between">
+                <i class="ico--ui title_section utenti me-2"></i>
+                <h2 class="primary">Frequenza corsi</h2>
+            </div>
+
+            <div class="title--section_addButton"  wire:click="add()" style="cursor: pointer;">
+                <div class="card--ui card--ui_btnAddHeaderUser entrata d-flex justify-items-between">
+                    <header class="d-flex justify-content-between"><div class="card-title d-flex align-items-start"><h2>Aggiungi&nbsp;&nbsp;&nbsp;</h2></div><a href="#" wire:click="add()"><i class="ico--ui big add primary"></i></a></header>
+                </div>
+            </div>
+
+        </header>
+
+        <section id="resume-table">
+            <div class="compare--chart_wrapper d-none"></div>
+
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+                <thead>
+                    <tr>
+                        <th scope="col">Nome</th>
+                        <th scope="col">Abilitato</th>
+                        <th scope="col">...</th>
+                    </tr>
+                </thead>
+                <tbody id="checkall-target">
+                    @foreach($records as $record)
+                        <tr>
+                            <td>{{$record->name}}</td>
+                            <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
+                            <td>
+                                <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
+                                <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
+                            </td>
+                        </tr>
+                    @endforeach
+
+                </tbody>
+            </table>
+
+        </section>
+
+    @else
+
+        <div class="container">
+
+            @if (session()->has('error'))
+                <div class="alert alert-danger" role="alert">
+                    {{ session()->get('error') }}
+                </div>
+            @endif
+
+            <div class="row">
+                <div class="col">
+
+                    <form action="">
+
+                        <div class="row mb-3">
+                            <div class="col">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Nome</label>
+                                    <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
+                                    @error('name')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+                            <div class="col">
+                                <div class="form-check form-check-inline">
+                                    <label class="form-check-label" for="enabled">Abilitato</label><br>
+                                    <input class="form-check-input" type="checkbox" id="enabled" wire:model="enabled">
+                                </div>
+                            </div>
+                        </div>
+
+                        <!-- // inline input field -->
+
+                        <div class="form--item">
+                            @if($add)
+                                <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
+                            @endif
+                            @if($update)
+                                <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
+                            @endif
+                            <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
+                        </div>
+
+                    </form>
+                </div>
+            </div>
+        </div>
+
+    @endif
+</div>
+
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
+@push('scripts')
+    <script>
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        Livewire.on('load-data-table', () => {
+            loadDataTable();
+        });
+
+        function loadDataTable(){
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Frequenza corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
+                    }
+                },
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
+
+        }
+
+    </script>
+@endpush
+

+ 165 - 0
resources/views/livewire/course_level.blade.php

@@ -0,0 +1,165 @@
+<div class="col card--ui" id="card--dashboard">
+    @if(!$add && !$update)
+
+        <header id="title--section" class="d-flex align-items-center justify-content-between">
+            <div class="title--section_name d-flex align-items-center justify-content-between">
+                <i class="ico--ui title_section utenti me-2"></i>
+                <h2 class="primary">Livello corsi</h2>
+            </div>
+
+            <div class="title--section_addButton"  wire:click="add()" style="cursor: pointer;">
+                <div class="card--ui card--ui_btnAddHeaderUser entrata d-flex justify-items-between">
+                    <header class="d-flex justify-content-between"><div class="card-title d-flex align-items-start"><h2>Aggiungi&nbsp;&nbsp;&nbsp;</h2></div><a href="#" wire:click="add()"><i class="ico--ui big add primary"></i></a></header>
+                </div>
+            </div>
+
+        </header>
+
+        <section id="resume-table">
+            <div class="compare--chart_wrapper d-none"></div>
+
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+                <thead>
+                    <tr>
+                        <th scope="col">Nome</th>
+                        <th scope="col">Abilitato</th>
+                        <th scope="col">...</th>
+                    </tr>
+                </thead>
+                <tbody id="checkall-target">
+                    @foreach($records as $record)
+                        <tr>
+                            <td>{{$record->name}}</td>
+                            <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
+                            <td>
+                                <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
+                                <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
+                            </td>
+                        </tr>
+                    @endforeach
+
+                </tbody>
+            </table>
+
+        </section>
+
+    @else
+
+        <div class="container">
+
+            @if (session()->has('error'))
+                <div class="alert alert-danger" role="alert">
+                    {{ session()->get('error') }}
+                </div>
+            @endif
+
+            <div class="row">
+                <div class="col">
+
+                    <form action="">
+
+                        <div class="row mb-3">
+                            <div class="col">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Nome</label>
+                                    <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
+                                    @error('name')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+                            <div class="col">
+                                <div class="form-check form-check-inline">
+                                    <label class="form-check-label" for="enabled">Abilitato</label><br>
+                                    <input class="form-check-input" type="checkbox" id="enabled" wire:model="enabled">
+                                </div>
+                            </div>
+                        </div>
+
+                        <!-- // inline input field -->
+
+                        <div class="form--item">
+                            @if($add)
+                                <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
+                            @endif
+                            @if($update)
+                                <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
+                            @endif
+                            <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
+                        </div>
+
+                    </form>
+                </div>
+            </div>
+        </div>
+
+    @endif
+</div>
+
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
+@push('scripts')
+    <script>
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        Livewire.on('load-data-table', () => {
+            loadDataTable();
+        });
+
+        function loadDataTable(){
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Livello corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
+                    }
+                },
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
+
+        }
+
+    </script>
+@endpush
+

+ 172 - 0
resources/views/livewire/course_list.blade.php

@@ -0,0 +1,172 @@
+<div class="col card--ui" id="card--dashboard">
+
+    <header id="title--section" class="d-flex align-items-center justify-content-between">
+        <div class="title--section_name d-flex align-items-center justify-content-between">
+            <i class="ico--ui title_section utenti me-2"></i>
+            <h2 class="primary">Pagamento corsi</h2>
+        </div>
+
+    </header>
+
+    <section id="subheader" class="d-flex align-items-center ">
+        <form action="" class="group--action d-flex align-items-center">
+            <select class="form-select form-select-lg me-1" wire:model='courseId'>
+                @foreach($courses as $c)
+                    <option value="{{$c->id}}">{{$c->name}}
+                @endforeach
+            </select>
+        </form>
+
+    </section>
+
+    <section id="resume-table">
+        <div class="compare--chart_wrapper d-none"></div>
+
+        <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+            <thead>
+                <tr>
+                    <th scope="col"></th>
+                    @foreach($months as $m)
+                        <th scope="col">&nbsp;&nbsp;&nbsp;&nbsp;{{$m}}</th>
+                    @endforeach
+                </tr>
+            </thead>
+            <tbody id="checkall-target">
+                @foreach($records as $record)
+                    <tr>
+                        @php
+                        list($id, $name) = explode("§", $record[0]);
+                        @endphp
+                        <td><a href="/members?member_detail={{$id}}">{{$name}}</a></td>
+                        @for($x=1; $x<=12; $x++)
+                            <td><a class="{{$record[$x]}}">&nbsp;</a></td>
+                        @endfor
+                    </tr>
+                @endforeach
+
+            </tbody>
+        </table>
+
+    </section>
+
+</div>
+
+@push('scripts')
+    <style>
+        a.grey
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #006099;
+            background-color: #d3dce1 !important;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.blue
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: #006099 !important;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.yellow
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: #ffe238;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.orange
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: #FF7E38;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.green
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: green;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+    </style>
+@endpush

+ 102 - 0
resources/views/livewire/course_member.blade.php

@@ -0,0 +1,102 @@
+<div class="col card--ui" id="card--dashboard">
+
+    <header id="title--section" class="d-flex align-items-center justify-content-between">
+        <div class="title--section_name d-flex align-items-center justify-content-between">
+            <i class="ico--ui title_section utenti me-2"></i>
+            <h2 class="primary">Iscritti ai corsi</h2>
+        </div>
+
+    </header>
+
+    <section id="resume-table">
+        <div class="compare--chart_wrapper d-none"></div>
+
+        <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+            <thead>
+                <tr>
+                    <th scope="col">#</th>
+                    <th scope="col">Corso</th>
+                    <th scope="col">Cognome</th>
+                    <th scope="col">Nome</th>
+                    <th scope="col">Età</th>
+                    <th scope="col">Telefono</th>
+                    <th scope="col">Email</th>
+                </tr>
+            </thead>
+            <tbody id="checkall-target">
+                @foreach($records as $idx => $record)
+                    <tr>
+                        <td>{{$idx +1}}</td>
+                        <td>{{$record->course->name}}</td>
+                        <td>{{$record->member->last_name}}</td>
+                        <td>{{$record->member->first_name}}</td>
+                        <td>{{$record->member->getAge() . " (" . date("Y", strtotime($record->member->birth_date)) . ")"}}</td>
+                        <td>{{$record->member->phone}}</td>
+                        <td>{{$record->member->email}}</td>
+                    </tr>
+                @endforeach
+
+            </tbody>
+        </table>
+
+    </section>
+</div>
+
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
+@push('scripts')
+    <script>
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        Livewire.on('load-data-table', () => {
+            loadDataTable();
+        });
+
+        function loadDataTable(){
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Iscritti corsi'
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Iscritti corsi'
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Iscritti corsi'
+                            }
+                        ]
+                    }
+                },
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
+
+        }
+
+    </script>
+@endpush
+

+ 165 - 0
resources/views/livewire/course_subscription.blade.php

@@ -0,0 +1,165 @@
+<div class="col card--ui" id="card--dashboard">
+    @if(!$add && !$update)
+
+        <header id="title--section" class="d-flex align-items-center justify-content-between">
+            <div class="title--section_name d-flex align-items-center justify-content-between">
+                <i class="ico--ui title_section utenti me-2"></i>
+                <h2 class="primary">Abbonamento corsi</h2>
+            </div>
+
+            <div class="title--section_addButton"  wire:click="add()" style="cursor: pointer;">
+                <div class="card--ui card--ui_btnAddHeaderUser entrata d-flex justify-items-between">
+                    <header class="d-flex justify-content-between"><div class="card-title d-flex align-items-start"><h2>Aggiungi&nbsp;&nbsp;&nbsp;</h2></div><a href="#" wire:click="add()"><i class="ico--ui big add primary"></i></a></header>
+                </div>
+            </div>
+
+        </header>
+
+        <section id="resume-table">
+            <div class="compare--chart_wrapper d-none"></div>
+
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+                <thead>
+                    <tr>
+                        <th scope="col">Nome</th>
+                        <th scope="col">Abilitato</th>
+                        <th scope="col">...</th>
+                    </tr>
+                </thead>
+                <tbody id="checkall-target">
+                    @foreach($records as $record)
+                        <tr>
+                            <td>{{$record->name}}</td>
+                            <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
+                            <td>
+                                <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
+                                <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
+                            </td>
+                        </tr>
+                    @endforeach
+
+                </tbody>
+            </table>
+
+        </section>
+
+    @else
+
+        <div class="container">
+
+            @if (session()->has('error'))
+                <div class="alert alert-danger" role="alert">
+                    {{ session()->get('error') }}
+                </div>
+            @endif
+
+            <div class="row">
+                <div class="col">
+
+                    <form action="">
+
+                        <div class="row mb-3">
+                            <div class="col">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Nome</label>
+                                    <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
+                                    @error('name')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+                            <div class="col">
+                                <div class="form-check form-check-inline">
+                                    <label class="form-check-label" for="enabled">Abilitato</label><br>
+                                    <input class="form-check-input" type="checkbox" id="enabled" wire:model="enabled">
+                                </div>
+                            </div>
+                        </div>
+
+                        <!-- // inline input field -->
+
+                        <div class="form--item">
+                            @if($add)
+                                <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
+                            @endif
+                            @if($update)
+                                <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
+                            @endif
+                            <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
+                        </div>
+
+                    </form>
+                </div>
+            </div>
+        </div>
+
+    @endif
+</div>
+
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
+@push('scripts')
+    <script>
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        Livewire.on('load-data-table', () => {
+            loadDataTable();
+        });
+
+        function loadDataTable(){
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
+                    }
+                },
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
+
+        }
+
+    </script>
+@endpush
+

+ 165 - 0
resources/views/livewire/course_type.blade.php

@@ -0,0 +1,165 @@
+<div class="col card--ui" id="card--dashboard">
+    @if(!$add && !$update)
+
+        <header id="title--section" class="d-flex align-items-center justify-content-between">
+            <div class="title--section_name d-flex align-items-center justify-content-between">
+                <i class="ico--ui title_section utenti me-2"></i>
+                <h2 class="primary">Tipologia corsi</h2>
+            </div>
+
+            <div class="title--section_addButton"  wire:click="add()" style="cursor: pointer;">
+                <div class="card--ui card--ui_btnAddHeaderUser entrata d-flex justify-items-between">
+                    <header class="d-flex justify-content-between"><div class="card-title d-flex align-items-start"><h2>Aggiungi&nbsp;&nbsp;&nbsp;</h2></div><a href="#" wire:click="add()"><i class="ico--ui big add primary"></i></a></header>
+                </div>
+            </div>
+
+        </header>
+
+        <section id="resume-table">
+            <div class="compare--chart_wrapper d-none"></div>
+
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+                <thead>
+                    <tr>
+                        <th scope="col">Nome</th>
+                        <th scope="col">Abilitato</th>
+                        <th scope="col">...</th>
+                    </tr>
+                </thead>
+                <tbody id="checkall-target">
+                    @foreach($records as $record)
+                        <tr>
+                            <td>{{$record->name}}</td>
+                            <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
+                            <td>
+                                <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
+                                <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
+                            </td>
+                        </tr>
+                    @endforeach
+
+                </tbody>
+            </table>
+
+        </section>
+
+    @else
+
+        <div class="container">
+
+            @if (session()->has('error'))
+                <div class="alert alert-danger" role="alert">
+                    {{ session()->get('error') }}
+                </div>
+            @endif
+
+            <div class="row">
+                <div class="col">
+
+                    <form action="">
+
+                        <div class="row mb-3">
+                            <div class="col">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Nome</label>
+                                    <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
+                                    @error('name')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
+                            <div class="col">
+                                <div class="form-check form-check-inline">
+                                    <label class="form-check-label" for="enabled">Abilitato</label><br>
+                                    <input class="form-check-input" type="checkbox" id="enabled" wire:model="enabled">
+                                </div>
+                            </div>
+                        </div>
+
+                        <!-- // inline input field -->
+
+                        <div class="form--item">
+                            @if($add)
+                                <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
+                            @endif
+                            @if($update)
+                                <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
+                            @endif
+                            <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
+                        </div>
+
+                    </form>
+                </div>
+            </div>
+        </div>
+
+    @endif
+</div>
+
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
+@push('scripts')
+    <script>
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        Livewire.on('load-data-table', () => {
+            loadDataTable();
+        });
+
+        function loadDataTable(){
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Tipologia corsi',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
+                    }
+                },
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
+
+        }
+
+    </script>
+@endpush
+

+ 511 - 117
resources/views/livewire/member.blade.php

@@ -151,8 +151,17 @@
                                         </div>
                                     </div>
                                     <div class="col-md-4">
-                                        <span class="title-detail">Dal: <span class="title-detail_date">{{$member_course->date_from ? date("d/m/Y", strtotime($member_course->date_from)) : ''}}</span></span></small><br>
-                                        <span class="title-detail">Al: <span class="title-detail_date">{{$member_course->date_to ? date("d/m/Y", strtotime($member_course->date_to)) : ''}}</span></span></small><br>
+                                        @php
+                                        $aMo = json_decode($member_course->months);
+                                        if (sizeof($aMo) == 1)
+                                        {
+                                            print($this->getMonth($aMo[0]->m));
+                                        }
+                                        if (sizeof($aMo) > 1)
+                                        {
+                                            print($this->getMonth($aMo[0]->m) . " - " . $this->getMonth($aMo[sizeof($aMo) - 1]->m));
+                                        }
+                                        @endphp
                                     </div>
                                     <div class="col-md-4">
                                         <span class="title-detail">
@@ -160,7 +169,10 @@
                                                 @if($xx > 0)
                                                     <br>
                                                 @endif
-                                                {{$x->day}} : {{$x->from}} - {{$x->to}}
+                                                @foreach($x->day as $d)
+                                                    {{$d}}
+                                                @endforeach
+                                                h {{$x->from}} - {{$x->to}}
                                             @endforeach
                                         </span>
                                     </div>
@@ -209,6 +221,34 @@
                     </div>
                     <!-- filter item -->
 
+                    <div class="filter--item">
+                        <span class="filter--item_title">Stato tesseramento</span>
+
+                        <div class="filter--item_formElement row">
+                            <div class="col-6">
+                                <div class="form-check form-check-inline  align-items-center">
+                                    <input class="form-check-input " type="radio" name="chkStatus" checked value="-1">
+                                    <label class="form-check-label ms-2" >Tutti</label>
+                                </div>
+                                <div class="form-check form-check-inline  align-items-center">
+                                    <input class="form-check-input " type="radio"   name="chkStatus" value="2">
+                                    <label class="form-check-label ms-2" >Attivo</label>
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form-check form-check-inline  align-items-center">
+                                    <input class="form-check-input " type="radio"  name="chkStatus" value="1">
+                                    <label class="form-check-label ms-2" >Sospeso</label>
+                                </div>
+                                <div class="form-check form-check-inline  align-items-center">
+                                    <input class="form-check-input " type="radio"  name="chkStatus" value="0">
+                                    <label class="form-check-label ms-2" >Non tesserato</label>
+                                </div>
+
+                            </div>
+                        </div>
+                    </div>
+
                     <div class="filter--item">
                         <span class="filter--item_title">Certificato Medico</span>
 
@@ -238,6 +278,21 @@
                     </div>
                     <!-- filter item -->
 
+                    <div class="filter--item">
+                        <span class="filter--item_title">Età (anni)</span>
+
+                        <div class="filter--item_formElement row">
+                            <div class="col-6">
+                                <label class="form-check-label ms-2" >Da</label>
+                                <input class="form-control " type="number" style="color:white" name="txtFromYear">
+                            </div>
+                            <div class="col-6">
+                                <label class="form-check-label ms-2" >A</label>
+                                <input class="form-control " type="number" style="color:white" name="txtToYear">
+                            </div>
+                        </div>
+                    </div>
+
                     <div class="filter--item">
                         <span class="filter--item_title">Gruppo di Appartenenza</span>
 
@@ -275,7 +330,7 @@
             <header id="title--section" class="d-flex align-items-center justify-content-between">
                 <div class="title--section_name d-flex align-items-center justify-content-between">
                     <i class="ico--ui title_section utenti me-2"></i>
-                    <h2 class="primary">@if(!$add && !$update)Elenco Utenti @else Inserimento/modifica utente @endif</h2>
+                    <h2 class="primary">@if(!$add && !$update)Utenti @else Inserimento/modifica utente @endif</h2>
                 </div>
 
                 @if(!$add && !$update)
@@ -321,10 +376,10 @@
                 <section id="resume-table">
                     <div class="compare--chart_wrapper d-none"></div>
 
-                    <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+                    <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                         <thead>
                             <tr>
-                                <!--<th scope="col"><label><input class="table-check" type="checkbox" data-tablesaw-checkall=""></th>-->
+                                <!--<th scope="col">#</th>-->
                                 <th scope="col">Codice</th>
                                 <th scope="col">Cognome</th>
                                 <th scope="col">Nome</th>
@@ -439,16 +494,16 @@
                     <div id="card--nuovoUtente">
                         <ul class="nav nav-tabs" id="myTab" role="tablist">
                             <li class="nav-item" role="presentation">
-                            <button wire:ignore.self class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home-tab-pane" type="button" role="tab" aria-controls="home-tab-pane" aria-selected="true">INFO GENERICHE</button>
+                            <button wire:ignore.self class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home-tab-pane" type="button" role="tab" aria-controls="home-tab-pane" aria-selected="true">DATI PERSONALI</button>
                             </li>
                             <li class="nav-item" role="presentation">
                             <button wire:ignore.self class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile-tab-pane" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="false">TESSERAMENTO</button>
                             </li>
                             <li class="nav-item" role="presentation">
-                            <button wire:ignore.self class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact-tab-pane" type="button" role="tab" aria-controls="contact-tab-pane" aria-selected="false">GRUPPI DI APPARTENENZA</button>
+                            <button wire:ignore.self class="nav-link" id="course-tab" data-bs-toggle="tab" data-bs-target="#course-tab-pane" type="button" role="tab" aria-controls="course-tab-pane" aria-selected="false">CORSI</button>
                             </li>
                             <li class="nav-item" role="presentation">
-                            <button wire:ignore.self class="nav-link" id="course-tab" data-bs-toggle="tab" data-bs-target="#course-tab-pane" type="button" role="tab" aria-controls="course-tab-pane" aria-selected="false">CORSI</button>
+                            <button wire:ignore.self class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact-tab-pane" type="button" role="tab" aria-controls="contact-tab-pane" aria-selected="false">GRUPPI DI APPARTENENZA</button>
                             </li>
                         </ul>
                         <div class="tab-content card--ui card--ui_maxwidth" id="myTabContent">
@@ -513,57 +568,83 @@
                                                 <div class="col-md-12">
                                                     <label for="inputDate" class="form-label">Data di nascita {!!$age != '' ? ' <b>(' . $age . ')</b>' : ''!!}{!!$under18 ? '<span style="color:red;font-weight:bold">&nbsp;MINORENNE</span>' : ''!!}</label>
                                                     <div class="input-group mb-3">
-                                                        <input class="form-control" type="date" id="birth_date" placeholder="Data di nascita" wire:model="birth_date">
+                                                        <input class="form-control @error('birth_date') is-invalid @enderror" type="date" id="birth_date" placeholder="Data di nascita" wire:model="birth_date">
                                                         <!--<input id="inputDate" type="text" class="form-control" aria-label="Recipient's username" aria-describedby="button-addon2">-->
                                                         <!--<button class="btn btn-outline-secondary" type="button" id="button-addon2">Date</button>-->
                                                     </div>
                                                 </div>
+
+                                                <div class="col-md-12">
+                                                    <label for="birth_nation_id" class="form-label">Nazione di Nascita</label>
+                                                    <select id="birth_nation_id" class="form-select nationBirthClass" aria-label="Nazione di nascita" wire:model="birth_nation_id">
+                                                        <option value="{{$birth_nation_id}}">{{$this->getNation($birth_nation_id)}}
+                                                    </select>
+                                                </div>
+                                                @if($isBirthItaly)
+                                                    <div class="col-md-12">
+                                                        <label for="birth_province_id" class="form-label">Provincia di Nascita</label>
+                                                        <select id="birth_province_id" class="form-select provinceBirthClass" aria-label="Provincia di nascita" wire:model="birth_province_id">
+                                                            <option value="{{$birth_province_id}}">{{$this->getProvince($birth_province_id)}}
+                                                        </select>
+                                                    </div>
+                                                    <div class="col-md-12">
+                                                        <label for="birth_city_id" class="form-label">Comune di Nascita</label>
+                                                        <select id="birth_city_id" class="form-select cityBirthClass" aria-label="Comune di nascita" wire:model="birth_city_id" >
+                                                            <option value="{{$birth_city_id}}">{{$this->getCity($birth_city_id)}}
+                                                        </select>
+                                                    </div>
+                                                @else
+                                                    <div class="col-md-6">
+                                                        <label for="birth_place" class="form-label">Paese di nascita</label>
+                                                        <input class="form-control " type="text" id="birth_place" placeholder="Paese di nascita" wire:model="birth_place">
+                                                    </div>
+                                                @endif
+
+                                                <div class="col-md-12">
+                                                    <label for="fiscal_code" class="form-label">Codice fiscale (<a wire:click="getFiscalCode()" href="#" style="font-size:18px;color: #006099;font-weight: bold;">calcola</a>)</label>
+                                                    <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code"  maxlength="16">
+                                                    @if($this->error_fc)
+                                                        <span style="color:red;font-size:12px">Dati mancanti</span>
+                                                    @endif
+                                                </div>
+
                                                 @if($under18)
 
                                                     <div class="col-md-6">
-                                                        <label for="father_name" class="form-label">Nome genitore 1</label>
+                                                        <label for="father_name" class="form-label"><b>Genitore 1</b></label>
                                                         <input class="form-control" type="text" id="father_name" placeholder="Nome genitore 1" wire:model="father_name">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="mother_name" class="form-label">Nome genitore 2</label>
+                                                        <label for="mother_name" class="form-label"><b>Genitore 2</b></label>
                                                         <input class="form-control " type="text" id="mother_name" placeholder="Nome genitore 2" wire:model="mother_name">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="father_email" class="form-label">Email genitore 1</label>
                                                         <input class="form-control" type="text" id="father_email" placeholder="Email genitore 1" wire:model="father_email">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="mother_email" class="form-label">Email genitore 2</label>
                                                         <input class="form-control " type="text" id="mother_email" placeholder="Email genitore 2" wire:model="mother_email">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="father_phone" class="form-label">Telefono genitore 1</label>
                                                         <input class="form-control" type="text" id="father_phone" placeholder="Telefono genitore 1" wire:model="father_phone">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="mother_phone" class="form-label">Telefono genitore 2</label>
                                                         <input class="form-control " type="text" id="mother_phone" placeholder="Telefono genitore 2" wire:model="mother_phone">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="father_fiscal_code" class="form-label">Codice fiscale genitore 1</label>
                                                         <input class="form-control" type="text" id="father_fiscal_code" placeholder="Codice fiscale genitore 1" wire:model="father_fiscal_code" maxlength="16">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="mother_fiscal_code" class="form-label">Codice fiscale genitore 2</label>
                                                         <input class="form-control " type="text" id="mother_fiscal_code" placeholder="Codice fiscale genitore 2" wire:model="mother_fiscal_code" maxlength="16">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="father_doc_number" class="form-label">Numero documento genitore 1</label>
                                                         <input class="form-control" type="text" id="father_doc_number" placeholder="Numero documento genitore 1" wire:model="father_doc_number">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="mother_doc_number" class="form-label">Numero documento genitore 2</label>
                                                         <input class="form-control " type="text" id="mother_doc_number" placeholder="Numero documento genitore 2" wire:model="mother_doc_number">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="father_doc_type" class="form-label">Tipo documento genitore 1</label>
                                                         <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="father_doc_type">
-                                                            <option value=""></option>
+                                                            <option value="">Seleziona il tipo documento</option>
                                                             <option value="Carta di identità">Carta di identità</option>
                                                             <option value="Passaporto">Passaporto</option>
                                                             <option value="Patente">Patente</option>
@@ -571,9 +652,8 @@
                                                         </select>
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="mother_doc_type" class="form-label">Tipo documento genitore 2</label>
                                                         <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="mother_doc_type">
-                                                            <option value=""></option>
+                                                            <option value="">Seleziona il tipo documento</option>
                                                             <option value="Carta di identità">Carta di identità</option>
                                                             <option value="Passaporto">Passaporto</option>
                                                             <option value="Patente">Patente</option>
@@ -582,39 +662,6 @@
                                                     </div>
 
                                                 @endif
-                                                <div class="col-md-12">
-                                                    <label for="birth_nation_id" class="form-label">Nazione di Nascita</label>
-                                                    <select id="birth_nation_id" class="form-select nationBirthClass" aria-label="Nazione di nascita" wire:model="birth_nation_id">
-                                                        <option value="{{$birth_nation_id}}">{{$this->getNation($birth_nation_id)}}
-                                                    </select>
-                                                </div>
-                                                @if($isBirthItaly)
-                                                    <div class="col-md-12">
-                                                        <label for="birth_province_id" class="form-label">Provincia di Nascita</label>
-                                                        <select id="birth_province_id" class="form-select provinceBirthClass" aria-label="Provincia di nascita" wire:model="birth_province_id">
-                                                            <option value="{{$birth_province_id}}">{{$this->getProvince($birth_province_id)}}
-                                                        </select>
-                                                    </div>
-                                                    <div class="col-md-12">
-                                                        <label for="birth_city_id" class="form-label">Comune di Nascita</label>
-                                                        <select id="birth_city_id" class="form-select cityBirthClass" aria-label="Comune di nascita" wire:model="birth_city_id" >
-                                                            <option value="{{$birth_city_id}}">{{$this->getCity($birth_city_id)}}
-                                                        </select>
-                                                    </div>
-                                                @else
-                                                    <div class="col-md-6">
-                                                        <label for="birth_place" class="form-label">Paese di nascita</label>
-                                                        <input class="form-control " type="text" id="birth_place" placeholder="Paese di nascita" wire:model="birth_place">
-                                                    </div>
-                                                @endif
-
-                                                <div class="col-md-12">
-                                                    <label for="fiscal_code" class="form-label">Codice fiscale (<a wire:click="getFiscalCode()" href="#" style="font-size:18px;color: #006099;font-weight: bold;">calcola</a>)</label>
-                                                    <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code"  maxlength="16">
-                                                    @if($this->error_fc)
-                                                        <span style="color:red;font-size:12px">Dati mancanti</span>
-                                                    @endif
-                                                </div>
 
                                                 @if($dataId > 0)
                                                     <span class="title-form primary d-block w-100">Stato</span>
@@ -688,7 +735,7 @@
                                                 <div class="col-6">
                                                     <label for="document_type" class="form-label">Tipo</label>
                                                     <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="document_type">
-                                                        <option value=""></option>
+                                                        <option value="">--Seleziona--</option>
                                                         <option value="Carta di identità">Carta di identità</option>
                                                         <option value="Passaporto">Passaporto</option>
                                                         <option value="Patente">Patente</option>
@@ -702,7 +749,7 @@
                                                 <div class="col-6">
                                                     <label for="document_from" class="form-label">Rilasciato da</label>
                                                     <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="document_from">
-                                                        <option value=""></option>
+                                                        <option value="">--Seleziona--</option>
                                                         <option value="Comune">Comune</option>
                                                         <option value="Motorizzazione">Motorizzazione</option>
                                                         <option value="Ministero degli interni">Ministero degli interni</option>
@@ -813,7 +860,7 @@
                                 @if($dataId > 0)
 
                                     @if(!$addCard && !$updateCard)
-                                        <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350-1">
+                                        <table class="table tablesaw tablesaw-stack" id="tablesaw-350-1">
                                             <thead>
                                                 <tr>
                                                     <th scope="col">Carta</th>
@@ -965,39 +1012,87 @@
                             <div class="tab-pane fade tasseramento-tab" id="course-tab-pane" role="tabpanel" aria-labelledby="course-tab" tabindex="0" wire:ignore.self>
 
 
+
                                 @if($dataId > 0)
 
                                     @if(!$addCourse && !$updateCourse)
-                                        <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350-2">
-                                            <thead>
-                                                <tr>
-                                                    <th scope="col">Corso</th>
-                                                    <th scope="col">Dal</th>
-                                                    <th scope="col">Al</th>
-                                                    <th scope="col">Quando</th>
-                                                    <th scope="col">...</th>
-                                                </tr>
-                                            </thead>
+                                        <table class="table tablesaw tablesaw-stack" id="tablesaw-350-2" style="min-width:800px">
                                             <tbody id="checkall-target">
                                                 @foreach($member_courses as $member_course)
                                                     <tr>
-                                                        <td>{{$member_course->course->getTree()}}</td>
-                                                        <td>{{$member_course->date_from ? date("d/m/Y", strtotime($member_course->date_from)) : ''}}</td>
-                                                        <td>{{$member_course->date_to ? date("d/m/Y", strtotime($member_course->date_to)) : ''}}</td>
-                                                        <td>
-
+                                                        <td style="width:10%">
+                                                            <b>{{$member_course->course->name}}</b><br>
+                                                        </td>
+                                                        <td style="width:10%">
+                                                            {{$member_course->course->type->name}}<br>
+                                                        </td>
+                                                        <td style="width:10%">
+                                                            {{$member_course->course->level->name}}<br>
+                                                        </td>
+                                                        <td style="width:20%">
                                                             @foreach(json_decode($member_course->when) as $xx => $x)
                                                                 @if($xx > 0)
                                                                     <br>
                                                                 @endif
-                                                                {{$x->day}} : {{$x->from}} - {{$x->to}}
+                                                                @foreach($x->day as $d)
+                                                                    {{$d}}
+                                                                @endforeach
+                                                                h {{$x->from}} - {{$x->to}}
                                                             @endforeach
                                                         </td>
-                                                        <td>
-                                                            <button type="button" class="btn btn-outline-primary btn-sm" wire:click="editCourse({{ $member_course->id }})">Modifica</button>
+                                                        <td style="width:20%">
+                                                            @php
+                                                            $aMo = json_decode($member_course->months);
+                                                            if (sizeof($aMo) == 1)
+                                                            {
+                                                                print($this->getMonth($aMo[0]->m));
+                                                            }
+                                                            if (sizeof($aMo) > 1)
+                                                            {
+                                                                print($this->getMonth($aMo[0]->m) . " - " . $this->getMonth($aMo[sizeof($aMo) - 1]->m));
+                                                            }
+                                                            @endphp
+                                                        </td>
+                                                        @if(false)
+                                                            <td style="width:10%">Iscrizione:<br><b>{{$member_course->status == 1 ? 'Pagata' : ($member_course->status == 2 ? 'Da pagare' : 'Sospesa')}}</b></td>
+                                                        @endif
+                                                        <td style="text-align:right;width:30%">
+                                                            <button type="button" class="btn btn-outline-primary btn-sm" wire:click="showHideCourse({{ $member_course->id }})">Dettaglio</button>&nbsp;
+                                                            <button type="button" class="btn btn-outline-primary btn-sm" wire:click="editCourse({{ $member_course->id }})">Modifica</button>&nbsp;
                                                             <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="deleteCourse({{ $member_course->id }})">Elimina</button>
                                                         </td>
+
                                                     </tr>
+                                                    @if(in_array($member_course->id, $showCourse))
+                                                        <tr>
+                                                            <td colspan="6">
+                                                                <a class="{{$this->getSubscriptionStatus($member_course->subscribed)}}" wire:click="setCreateSubscription({{$member_course->subscribed}})" style="float:none; width:150px;">Iscrizione</a><br>
+                                                                <a class="{{$this->getMonthStatus(1, $member_course->months)}}" wire:click="setPayMonth(1, '{{ $member_course->months }}')">Gen</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(2, $member_course->months)}}" wire:click="setPayMonth(2, '{{ $member_course->months }}')">Feb</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(3, $member_course->months)}}" wire:click="setPayMonth(3, '{{ $member_course->months }}')">Mar</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(4, $member_course->months)}}" wire:click="setPayMonth(4, '{{ $member_course->months }}')">Apr</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(5, $member_course->months)}}" wire:click="setPayMonth(5, '{{ $member_course->months }}')">Mag</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(6, $member_course->months)}}" wire:click="setPayMonth(6, '{{ $member_course->months }}')">Giu</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(7, $member_course->months)}}" wire:click="setPayMonth(7, '{{ $member_course->months }}')">Lug</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(8, $member_course->months)}}" wire:click="setPayMonth(8, '{{ $member_course->months }}')">Ago</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(9, $member_course->months)}}" wire:click="setPayMonth(9, '{{ $member_course->months }}')">Set</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(10, $member_course->months)}}" wire:click="setPayMonth(10, '{{ $member_course->months }}')">Ott</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(11, $member_course->months)}}" wire:click="setPayMonth(11, '{{ $member_course->months }}')">Nov</a>&nbsp;
+                                                                <a class="{{$this->getMonthStatus(12, $member_course->months)}}" wire:click="setPayMonth(12, '{{ $member_course->months }}')">Dic</a>&nbsp;
+                                                            </td>
+                                                        </tr>
+                                                        <tr>
+                                                            <td colspan="6">
+                                                                @if(sizeof($payMonths) > 0 || $createSubscription)
+                                                                    <button class="btn--ui primary" style="color:white" wire:click="newPayment({{$member_course}})">Nuova entrata</button>&nbsp;
+                                                                    <button class="btn--ui primary" style="color:white" wire:click="block({{$member_course}})">Sospendi</button>
+                                                                @endif<br>
+                                                                <br><b>Note</b><br>
+                                                                {{$member_course->notes}}
+                                                            </td>
+                                                        </tr>
+                                                    @endif
+
                                                 @endforeach
 
                                             </tbody>
@@ -1008,48 +1103,92 @@
                                         <div class="form--wrapper">
                                             <form class="form--utente">
                                                 <div class="row ">
-                                                    <div class="col-md-12">
+                                                    <div class="col-md-6">
                                                         <label for="course_course_id" class="form-label">Corso</label>
-                                                        @livewire('courses', ['course_id' => $course_course_id])
-                                                        @if(false)
-                                                            <select id="course_course_id" class="form-select coursesClass @error('course_course_id') is-invalid @enderror" aria-label="Corso" wire:model="course_course_id">
-                                                                <option value="">--Seleziona--
-                                                                @foreach($courses as $course)
-                                                                    <option value="{{$course["id"]}}">{{$course["name"]}}
-                                                                @endforeach
-                                                            </select>
-                                                        @endif
+                                                        <select id="course_course_id" class="form-select  @error('course_course_id') is-invalid @enderror" aria-label="Corso" wire:model="course_course_id" >
+                                                            <option value="">
+                                                            @foreach($courses as $course)
+                                                                <option value="{{$course["id"]}}">{{$course["name"]}}
+                                                            @endforeach
+                                                        </select>
+                                                    </div>
+                                                    <div class="col-md-6">
+                                                        <label for="course_course_subscription_id" class="form-label">Abbonamento</label>
+                                                        <select id="course_course_subscription_id" class="form-select  @error('course_course_subscription_id') is-invalid @enderror" aria-label="Abbonamento" wire:model="course_course_subscription_id">
+                                                            <option value="">
+                                                            @foreach($course_subscriptions as $t)
+                                                                <option value="{{$t["id"]}}">{{$t["name"]}}
+                                                            @endforeach
+                                                        </select>
+
                                                     </div>
                                                 </div>
                                                 <div class="row ">
                                                     <div class="col-md-6">
-                                                        <label for="course_date_from" class="form-label">Dal</label>
-                                                        <input class="form-control" type="date" id="course_date_from" placeholder="Dal" wire:model="course_date_from">
+                                                        <label for="course_price" class="form-label">Costo mensile</label>
+                                                        <input class="form-control" type="text" id="course_price" placeholder="Costo mensile" wire:model="course_price" onkeyup="onlyNumberAmount(this)">
                                                     </div>
                                                     <div class="col-md-6">
-                                                        <label for="course_date_to" class="form-label">Al</label>
-                                                        <input class="form-control" type="date" id="course_date_to" placeholder="Al" wire:model="course_date_to">
+                                                        <label for="course_status" class="form-label">Stato iscrizione</label>
+                                                        <select id="course_status" class="form-select  @error('course_status') is-invalid @enderror" aria-label="Stato" wire:model="course_status">
+                                                            <option value="">
+                                                            <option value="1">Pagata
+                                                            <option value="2">Da pagare
+                                                            <option value="3">Sospesa
+                                                        </select>
                                                     </div>
                                                 </div>
-                                                @foreach($course_when as $idW => $when)
+                                                <div class="row ">
+                                                    <div class="col-md-12">
+                                                        <label for="duration" class="form-label">Durata del corso</label><br>
+                                                        <a class="{{$this->checkMonth(1) ? 'selected' : 'notSelected'}}" wire:click="setMonth(1)">Gen</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(2) ? 'selected' : 'notSelected'}}" wire:click="setMonth(2)">Feb</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(3) ? 'selected' : 'notSelected'}}" wire:click="setMonth(3)">Mar</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(4) ? 'selected' : 'notSelected'}}" wire:click="setMonth(4)">Apr</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(5) ? 'selected' : 'notSelected'}}" wire:click="setMonth(5)">Mag</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(6) ? 'selected' : 'notSelected'}}" wire:click="setMonth(6)">Giu</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(7) ? 'selected' : 'notSelected'}}" wire:click="setMonth(7)">Lug</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(8) ? 'selected' : 'notSelected'}}" wire:click="setMonth(8)">Ago</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(9) ? 'selected' : 'notSelected'}}" wire:click="setMonth(9)">Set</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(10) ? 'selected' : 'notSelected'}}" wire:click="setMonth(10)">Ott</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(11) ? 'selected' : 'notSelected'}}" wire:click="setMonth(11)">Nov</a>&nbsp;
+                                                        <a class="{{$this->checkMonth(12) ? 'selected' : 'notSelected'}}" wire:click="setMonth(12)">Dic</a>&nbsp;
+                                                    </div>
+                                                </div>
+                                                <div class="row">
+                                                    <div class="col-md-6">
+                                                        <label for="course_subscription_price" class="form-label">Costo iscrizione</label>
+                                                        <input class="form-control" type="text" id="course_subscription_price" placeholder="Costo iscrizione" wire:model="course_subscription_price" onkeyup="onlyNumberAmount(this)">
+                                                    </div>
+                                                </div>
+                                                @if(false)
                                                     <div class="row ">
-                                                        <div class="col-md-5">
-                                                            <label for="" class="form-label">Giorno</label>
-                                                            <select class="form-select" aria-label="Corso" wire:model="course_when.{{$idW}}.day">
-                                                                <option value="">
-                                                                <option value="lun">Lunedì
-                                                                <option value="mar">Martedì
-                                                                <option value="mer">Mercoledì
-                                                                <option value="gio">Giovedì
-                                                                <option value="ven">Venerdì
-                                                                <option value="sab">Sabato
-                                                                <option value="dom">Domenica
-                                                            </select>
+                                                        <div class="col-md-6">
+                                                            <label for="course_date_from" class="form-label">Dal</label>
+                                                            <input class="form-control" type="date" id="course_date_from" placeholder="Dal" wire:model="course_date_from">
+                                                        </div>
+                                                        <div class="col-md-6">
+                                                            <label for="course_date_to" class="form-label">Al</label>
+                                                            <input class="form-control" type="date" id="course_date_to" placeholder="Al" wire:model="course_date_to">
+                                                        </div>
+                                                    </div>
+                                                @endif
+                                                @foreach($course_when as $idW => $when)
+                                                    <div class="row day" >
+                                                        <div class="col-md-12">
+                                                            <label for="" class="form-label">Giorno</label><br>
+                                                            <a class="{{in_array('lun', $course_when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'lun')">Lun</a>&nbsp;
+                                                            <a class="{{in_array('mar', $course_when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'mar')">Mar</a>&nbsp;
+                                                            <a class="{{in_array('mer', $course_when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'mer')">Mer</a>&nbsp;
+                                                            <a class="{{in_array('gio', $course_when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'gio')">Gio</a>&nbsp;
+                                                            <a class="{{in_array('ven', $course_when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'ven')">Ven</a>&nbsp;
+                                                            <a class="{{in_array('sab', $course_when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'sab')">Sab</a>&nbsp;
+                                                            <a class="{{in_array('dom', $course_when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'dom')">Dom</a>&nbsp;
                                                         </div>
                                                         <div class="col-md-3">
                                                             <label for="" class="form-label">Dalle</label>
                                                             <select class="form-select" wire:model="course_when.{{$idW}}.from">
-                                                                <option value="">
+                                                                <option value="">--Seleziona--
                                                                 @for($c=6;$c<=23;$c++)
                                                                     <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00
                                                                     <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30
@@ -1059,7 +1198,7 @@
                                                         <div class="col-md-3">
                                                             <label for="" class="form-label">Alle</label>
                                                             <select class="form-select" wire:model="course_when.{{$idW}}.to">
-                                                                <option value="">
+                                                                <option value="">--Seleziona--
                                                                 @for($c=6;$c<=23;$c++)
                                                                     <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00
                                                                     <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30
@@ -1071,8 +1210,15 @@
                                                             <button class="btn--ui primary" wire:click.prevent="delRow({{$idW}})">-</button>
                                                         </div>
                                                     </div>
-                                                @endforeach<br>
-                                                <button class="btn--ui primary" wire:click.prevent="addRow()">Aggiungi giorno</button>
+                                                @endforeach
+                                                <br>
+                                                <div class="row ">
+                                                    <div class="col-md-12">
+                                                        <label for="course_date_from" class="form-label">Note</label>
+                                                        <input class="form-control" type="text" id="course_note" placeholder="Note" wire:model="course_note">
+                                                    </div>
+                                                </div>
+                                                <button class="btn--ui primary" style="float:right" wire:click.prevent="addRow()">+</button>
                                             </form>
                                         </div>
 
@@ -1219,8 +1365,17 @@
                                             </div>
                                             <div class="row">
                                                 <span class="title-detail">
-                                                    Dal: <span class="title-detail_date">{{$member_course->date_from ? date("d/m/Y", strtotime($member_course->date_from)) : ''}}</span>
-                                                    Al: <span class="title-detail_date">{{$member_course->date_to ? date("d/m/Y", strtotime($member_course->date_to)) : ''}}</span>
+                                                    @php
+                                                    $aMo = json_decode($member_course->months);
+                                                    if (sizeof($aMo) == 1)
+                                                    {
+                                                        print($this->getMonth($aMo[0]->m));
+                                                    }
+                                                    if (sizeof($aMo) > 1)
+                                                    {
+                                                        print($this->getMonth($aMo[0]->m) . " - " . $this->getMonth($aMo[sizeof($aMo) - 1]->m));
+                                                    }
+                                                    @endphp
                                                 </span>
                                             </div>
                                             <div class="row">
@@ -1229,7 +1384,10 @@
                                                         @if($xx > 0)
                                                             <br>
                                                         @endif
-                                                        {{$x->day}} : {{$x->from}} - {{$x->to}}
+                                                        @foreach($x->day as $d)
+                                                            {{$d}}
+                                                        @endforeach
+                                                        {{$x->from}} - {{$x->to}}
                                                     @endforeach
                                                 </span>
                                             </div>
@@ -1282,6 +1440,182 @@
         {
             width:100% !important;
         }
+        a.notSelected
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #006099;
+            background-color: #d3dce1 !important;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.selected
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: #006099 !important;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        div.day
+        {
+            margin-top:20px;
+            color: #006099;
+            background-color: #ffffff !important;
+            padding: 20px;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: 2px solid #d3dce1;
+        }
+        a.grey
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #006099;
+            background-color: #d3dce1 !important;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.blue
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: #006099 !important;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.yellow
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: #ffe238;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.orange
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: #FF7E38;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.green
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: green;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
     </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>
@@ -1505,6 +1839,12 @@
             }, 100)
         @endif
 
+        function onlyNumberAmount(input) {
+            let v = input.value.replace(/\D+/g, '');
+            if (v.length > 14) v = v.slice(0, 14);
+            input.value = "€ " + v.replace(/(\d)(\d\d)$/, "$1,$2").replace(/(^\d{1,3}|\d{3})(?=(?:\d{3})+(?:,|$))/g, '$1.');
+        }
+
     </script>
 
 @endpush
@@ -1512,11 +1852,20 @@
 @push('scripts')
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
     <script>
 
+        function showData(id)
+        {
+            @this.showDetailF(id);
+        }
+
         function editData(id)
         {
             @this.edit(id);
@@ -1577,13 +1926,35 @@
             var chkCertificateScadenza = $(".chkCertificateScadenza").is(':checked') ? "1" : "";
             var chkCertificateScaduti = $(".chkCertificateScaduti").is(':checked') ? "1" : "";
 
+            var status = $('input[name="chkStatus"]:checked').val();
+
+            var fromYear = $('input[name="txtFromYear"]').val();
+            var toYear = $('input[name="txtToYear"]').val();
+
             $('#tablesaw-350').DataTable({
                 //destroy: true,
-                ajax: '/get_members?cards=' + cards + "&categories=" + categories + "&chkCertificateNormal=" + chkCertificateNormal + "&chkCertificateAgonistico=" + chkCertificateAgonistico + "&chkCertificateScadenza=" + chkCertificateScadenza + "&chkCertificateScaduti=" + chkCertificateScaduti,
+                ajax: '/get_members?cards=' + cards + "&categories=" + categories + "&chkCertificateNormal=" + chkCertificateNormal + "&chkCertificateAgonistico=" + chkCertificateAgonistico + "&chkCertificateScadenza=" + chkCertificateScadenza + "&chkCertificateScaduti=" + chkCertificateScaduti + "&status=" + status + "&fromYear=" + fromYear + "&toYear=" + toYear,
                 columns: [
                     { data: 'id' },
-                    { data: "first_name" },
-                    { data: "last_name"},
+                    {
+                        data: "last_name",
+                        render: function (data){
+                            // Split class and text
+                            const d = data.split("|");
+                            var ret = '<a href="#" onclick="showData(' + d[1] + ')">' + d[0] + '</a>';
+                            return ret;
+                        }
+                    },
+                    {
+                        data: "first_name",
+                        render: function (data){
+                            // Split class and text
+                            const d = data.split("|");
+                            var ret = '<a href="#" onclick="showData(' + d[1] + ')">' + d[0] + '</a>';
+                            return ret;
+                        }
+                    },
+
                     { data: "phone"},
                     { data: "age"},
                     {
@@ -1650,13 +2021,36 @@
                     },
                 ],
                 fixedHeader: false,
-                order: [[1, 'asc'], [2, 'asc']],
+                order: [[2, 'asc'], [3, 'asc']],
                 thead: {
                 'th': {'background-color': 'blue'}
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Utenti',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Utenti',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Utenti',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 30 - 3
resources/views/livewire/nation.blade.php

@@ -3,7 +3,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco Nazioni @else Inserimento/modifica nazione @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)Nazioni @else Inserimento/modifica nazione @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -45,7 +45,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Codice</th>
@@ -164,6 +164,10 @@
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
@@ -184,7 +188,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Nazioni',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Nazioni',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Nazioni',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 30 - 3
resources/views/livewire/payment_method.blade.php

@@ -3,7 +3,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco metodi pagamento @else Inserimento/modifica metodo pagamento @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)metodi pagamento @else Inserimento/modifica metodo pagamento @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -41,7 +41,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Banca</th>
@@ -170,6 +170,10 @@
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
@@ -190,7 +194,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Metodi di pagamento',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Metodi di pagamento',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Metodi di pagamento',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 30 - 3
resources/views/livewire/province.blade.php

@@ -3,7 +3,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco Province @else Inserimento/modifica provincia @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)Province @else Inserimento/modifica provincia @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -22,7 +22,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Nazione</th>
@@ -153,6 +153,10 @@
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
@@ -173,7 +177,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Provincie',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Provincie',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Provincie',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 182 - 0
resources/views/livewire/receipt.blade.php

@@ -0,0 +1,182 @@
+<div class="col">
+    <div class="row h-100">
+<div class="col-auto filterWrapper" id="filter--section"  wire:ignore.self>
+    <aside>
+        <header>
+            <h2>Filtra Ricevute</h2>
+        </header>
+
+        <form action="" id="filter--form" class="dark-form row">
+            <div class="filter--item">
+                <span class="filter--item_title">Stato</span>
+
+                <div class="filter--item_formElement">
+                    <select class="form-select" wire:model="filterStatus" onchange="destroyDataTable()">
+                        <option value="">--Seleziona--
+                        <option value="1">Attiva
+                        <option value="99">Annullata
+                    </select>
+                </div>
+            </div>
+
+            <div class="filter--item">
+                <span class="filter--item_title">Periodo</span>
+                <div class="filter--item_formElement">
+                    <input id="date" type="date" class="form-control"  wire:model="filterFrom" style="background-color:white">
+                </div>
+                <div class="filter--item_formElement">
+                    <input id="date" type="date" class="form-control"  wire:model="filterTo" style="background-color:white" >
+                </div>
+
+            </div>
+
+
+        </form>
+
+        <footer>
+            <div class="filter--buttons d-flex align-items-center justify-content-between">
+                <button class="btn--ui small dark disable" wire:click.prevent="disableSearch()" onclick="destroyDataTable()">cancella</button>
+                <button class="btn--ui small white" wire:click.prevent="search()" onclick="destroyDataTable()">filtra</button>
+            </div>
+        </footer>
+
+
+    </aside>
+</div>
+
+<div class="col card--ui" id="card--dashboard">
+
+    <header id="title--section" class="d-flex align-items-center justify-content-between">
+        <div class="title--section_name d-flex align-items-center justify-content-between">
+            <i class="ico--ui title_section utenti me-2"></i>
+            <h2 class="primary">Ricevute</h2>
+        </div>
+
+        <div class="title--section_addButton"  wire:click="add()" style="cursor: pointer;">
+            <div class="card--ui card--ui_btnAddHeaderUser entrata d-flex justify-items-between">
+                <header class="d-flex justify-content-between"><div class="card-title d-flex align-items-start"><h2>Aggiungi&nbsp;&nbsp;&nbsp;</h2></div><a href="#" wire:click="add()"><i class="ico--ui big add primary"></i></a></header>
+            </div>
+        </div>
+
+    </header>
+
+    <button id="open-filter" onclick="pcsh1()"></button>
+    <button id="close-filter" onclick="pcsh2()"></button>
+
+    <section id="resume-table">
+        <div class="compare--chart_wrapper d-none"></div>
+
+        <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+            <thead>
+                <tr>
+                    <th scope="col">Anno</th>
+                    <th scope="col">Numero</th>
+                    <th scope="col">Destinatario</th>
+                    <th scope="col">Stato</th>
+                    <th scope="col">Data</th>
+                    <th scope="col">...</th>
+                </tr>
+            </thead>
+            <tbody id="checkall-target">
+                @foreach($records as $record)
+                    <tr>
+                        <td>{{$record->year}}</td>
+                        <td>{{$record->number}}</td>
+                        <td>{{$record->type == 'IN' ? ($record->member->first_name . " " . $record->member->last_name) : 'Uscita'}}</td>
+                        <td>
+                            <span class="tablesaw-cell-content">
+                                <span class="badge tessera-badge {{$record->status == 1 ? 'active' : 'suspended'}}">{{$record->status == 1 ? 'Attivo' : 'Annullata'}}</span>
+                            </span>
+                        </td>
+                        <td>{{date("d/m/Y", strtotime($record->date))}}</td>
+                        <td>
+                            <button type="button" class="btn btn-outline-primary btn-sm" onclick="document.location.href='/in?id={{$record->record_id}}'">Dettaglio</button>
+                            <button type="button" class="btn btn-outline-primary btn-sm" wire:click="printReceipt({{ $record->id }})">Stampa</button>
+                        </td>
+                    </tr>
+                @endforeach
+
+            </tbody>
+        </table>
+
+    </section>
+
+</div>
+
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
+@push('scripts')
+    <script>
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        Livewire.on('load-data-table', () => {
+            setTimeout(function() {loadDataTable()}, 100);
+        });
+
+        Livewire.on('destroy-data-table', () => {
+            $('#tablesaw-350').DataTable().destroy();
+        });
+
+        function destroyDataTable()
+        {
+            $('#tablesaw-350').DataTable().destroy();
+        }
+
+        function loadDataTable(){
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Ricevute',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Ricevute',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Ricevute',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
+                    }
+                },
+                order: [[0, 'desc'], [1, 'desc']],
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
+
+        }
+
+    </script>
+@endpush
+

+ 13 - 9
resources/views/livewire/records.blade.php

@@ -67,18 +67,20 @@
         <!--
         <canvas id="recordChart"></canvas>
             -->
-        <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+        <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
             <thead>
                 <tr>
                     <th scope="col">Data</th>
-                    <th scope="col">Causale</th>
+                    <th scope="col" style="border-left:3px solid white;">Causale</th>
+                    <th scope="col" style="border-left:3px solid white;">Nominativo</th>
                     @foreach($payments as $p)
                         <th colspan="2" scope="col" style="text-align:center; border-left:3px solid white;">{{$p->name}}</th>
                     @endforeach
                 </tr>
                 <tr>
                     <th scope="col"></th>
-                    <th scope="col"></th>
+                    <th scope="col" style="border-left:3px solid white;"></th>
+                    <th scope="col" style="border-left:3px solid white;"></th>
                     @foreach($payments as $p)
                         <th scope="col" style="text-align:center; border-left:3px solid white;">Entrate</th>
                         <th scope="col" style="text-align:center">Uscite</th>
@@ -93,10 +95,11 @@
                     <tr>
                         @php
                         $check = strpos($causal, "$") ? explode("$", $causal)[1] : $causal;
-                        list($d, $c) = explode("§", $check);
+                        list($d, $c, $n) = explode("§", $check);
                         @endphp
                         <td style="background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{date("d/m/Y", strtotime($d))}}</td>
                         <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$c}}</td>
+                        <td style="border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">{{$n}}</td>
                         @foreach($payments as $p)
                             @if(isset($record[$p->name]))
                                 <td style="text-align:center; border-left:3px solid white !important;background-color:{{$count % 2 == 0 ? 'white' : '#f2f4f7'}}">
@@ -122,15 +125,16 @@
             </tbody>
             <tfoot>
                 <tr>
+                    <td></td>
                     <td></td>
                     <td><b>Totale</b></td>
                     @foreach($payments as $p)
                         @if(isset($totals[$p->name]))
-                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:green"><b>{{formatPrice($totals[$p->name]["IN"])}}</b></span></td>
-                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:red"><b>{{formatPrice($totals[$p->name]["OUT"])}}</b></span></td>
+                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice($totals[$p->name]["IN"])}}</b></span></td>
+                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice($totals[$p->name]["OUT"])}}</b></span></td>
                         @else
-                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:green"><b>{{formatPrice(0)}}</b></span></td>
-                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:red"><b>{{formatPrice(0)}}</b></span></td>
+                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice(0)}}</b></span></td>
+                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice(0)}}</b></span></td>
                         @endif
                     @endforeach
                 </tr>
@@ -145,7 +149,7 @@
                             @if($diff < 0)
                                 <td></td>
                             @endif
-                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:{{$diff > 0 ? 'green' : 'red'}}"><b>{{formatPrice($diff)}}</b></span></td>
+                            <td style="text-align:center"><span class="tablesaw-cell-content primary" style="color:{{$diff > 0 ? 'green' : 'red'}}; font-size:18px;"><b>{{formatPrice($diff)}}</b></span></td>
                             @if($diff > 0)
                                 <td></td>
                             @endif

+ 219 - 185
resources/views/livewire/records_in.blade.php

@@ -1,7 +1,7 @@
 <div class="col">
     <div class="row h-100">
 
-    <div class="col-auto filterWrapper" id="filter--section" wire:ignore.self>
+    <div class="col-auto filterWrapper" id="filter--section" wire:ignore>
         <aside>
 
             <header>
@@ -14,15 +14,15 @@
 
                     <div class="filter--item_formElement">
                         <div class="form-check form-check-inline d-inline-flex align-items-center">
-                            <input class="form-check-input" type="radio" value="0" id="all_commercial" wire:model="filterCommercial" onclick="destroyDataTable()">
+                            <input class="form-check-input" type="radio" value="0" name="filterCommercial" checked>
                             <label class="form-check-label ms-2" for="inlineCheckbox1">Entrambe</label>
                         </div>
                         <div class="form-check form-check-inline d-inline-flex align-items-center">
-                            <input class="form-check-input" type="radio" value="1" id="commercial" wire:model="filterCommercial" onclick="destroyDataTable()">
+                            <input class="form-check-input" type="radio" value="1" name="filterCommercial" >
                             <label class="form-check-label ms-2" for="inlineCheckbox1">Commerciale</label>
                         </div>
                         <div class="form-check form-check-inline d-inline-flex align-items-center">
-                            <input class="form-check-input" type="radio" value="2" id="not_commercial" wire:model="filterCommercial" onclick="destroyDataTable()">
+                            <input class="form-check-input" type="radio" value="2" name="filterCommercial">
                             <label class="form-check-label ms-2" for="inlineCheckbox1">Non commerciale</label>
                         </div>
                     </div>
@@ -33,8 +33,8 @@
                     <span class="filter--item_title">Persona</span>
 
                     <div class="filter--item_formElement">
-                        <select name="search_member_id" class="form-select filterMember" wire:model="filterMember" onclick="destroyDataTable()">
-                            <option value="">
+                        <select name="search_member_id" class="form-select filterMember">
+                            <option value="">--Seleziona--
                             @foreach($members as $member)
                                 <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}}
                             @endforeach
@@ -46,8 +46,8 @@
                     <span class="filter--item_title">Pagamento</span>
 
                     <div class="filter--item_formElement">
-                        <select name="search_payment_method_id" class="form-select filterPaymentMethod"  wire:model="filterPaymentMethod" onclick="destroyDataTable()">
-                            <option value="">
+                        <select name="search_payment_method_id" class="form-select filterPaymentMethod">
+                            <option value="">--Seleziona--
                             @foreach($payments as $payment)
                                 <option value="{{$payment->id}}">{{$payment->name}}
                             @endforeach
@@ -60,8 +60,8 @@
                     <span class="filter--item_title">Causali</span>
 
                     <div class="filter--item_formElement">
-                        <select name="search_causal_id[]" class="form-select filterCausals" multiple="multiple" wire:model="filterCausals"  onclick="destroyDataTable()">
-                            <option value="">
+                        <select name="search_causal_id" class="form-select filterCausals">
+                            <option value="">--Seleziona--
                             @foreach($causals as $causal)
                                 <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
                             @endforeach
@@ -74,80 +74,36 @@
                 <div class="filter--item">
                     <span class="filter--item_title">Periodo </span>
                     <div class="filter--item_formElement">
-                        <input id="date" type="date" class="form-control"  wire:model="filterFrom" style="background-color:white" onclick="destroyDataTable()">
+                        <input id="dateFrom" type="date" class="form-control filterFrom" style="background-color:white" >
                     </div>
                     <div class="filter--item_formElement">
-                        <input id="date" type="date" class="form-control"  wire:model="filterTo" style="background-color:white" onclick="destroyDataTable()">
+                        <input id="dateTo" type="date" class="form-control filterTo" style="background-color:white" >
                     </div>
 
                 </div>
-                <!-- filter item -->
-                <!--
-                <div class="filter--item">
-                    <span class="filter--item_title">Modalità di Pagamento</span>
-
-                    <div class="filter--item_formElement row">
-                        <div class="col-6">
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Contanti</label>
-                            </div>
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option2">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Borsellino</label>
-                            </div>
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option3">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Bonifico</label>
-                            </div>
-                        </div>
-                        <div class="col-6">
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option4">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">POS</label>
-                            </div>
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option5">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Playtomic</label>
-                            </div>
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option6">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Assegno</label>
-                            </div>
-                        </div>
-                    </div>
-
-                </div>
-                -->
-                <!-- filter item -->
 
             </form>
 
             <footer>
-                @if($hasFilter)
-                    <div class="d-flex align-items-center">
-                        Totale&nbsp;:&nbsp;<b>{{formatPrice($total)}}</b>
-                    </div>
-                @endif
+                <div class="d-flex align-items-center totalDiv">
+
+                </div>
                 <div class="filter--buttons d-flex align-items-center justify-content-between">
-                    <button class="btn--ui small dark disable" wire:click.prevent="disableSearch()" onclick="destroyDataTable()">cancella</button>
-                    <button class="btn--ui small white" wire:click.prevent="search()" onclick="destroyDataTable()">filtra</button>
+                    <button class="btn--ui small dark disable" onclick="reset()">cancella</button>
+                    <button class="btn--ui small white" onclick="loadDataTable()">filtra</button>
                 </div>
             </footer>
 
-
         </aside>
     </div>
 
         <div class="col card--ui" id="card--dashboard">
 
-            @if(!$add && !$update)
-
 
                 <header id="title--section" class="d-flex align-items-center justify-content-between">
                     <div class="title--section_name d-flex align-items-center justify-content-between">
-                        <i class="ico--ui title_section utenti me-2"></i>
-                        <h2 class="primary">@if(!$add && !$update)Elenco Entrate @else Inserimento/modifica entrata @endif</h2>
+                        <i class="ico--ui title_section entrate me-2"></i>
+                        <h2 class="primary">@if(!$add && !$update)Entrate @else Inserimento/modifica entrata @endif</h2>
                     </div>
 
                     @if(!$add && !$update)
@@ -160,101 +116,37 @@
 
                 </header>
 
+
+            @if(!$add && !$update)
+
                 <button id="open-filter" onclick="pcsh1()"></button>
                 <button id="close-filter" onclick="pcsh2()"></button>
 
                 <section id="subheader" class="d-flex align-items-center justify-content-between">
-                    <form action="" class="group--action d-flex align-items-center">
-                            <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="multipleAction">
-                                <option selected>Azione multipla</option>
-                                <option value="delete">Elimina</option>
-                                </select>
-                                <button type="submit" class="btn--ui" wire:click.prevent="executeMultipleAction()">applica</button>
-                            </form>
-
-                    <form action="" class="compare--form d-flex align-items-center">
-                        <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="selectedFilter">
-                            <option value="">--Seleziona--</option>
-                            <option value="0">Oggi</option>
-                            <option value="1">Questo mese: <span class="date-range">{{date("01/m/Y")}} - {{date("t/m/Y")}}</span></option>
-                            <option value="2">Questo anno: <span class="date-range">{{date("01/01/Y")}} - {{date("31/12/Y")}}</span></option>
-                            <option value="3">Tutte</option>
-                            </select>
-                        </form>
                 </section>
 
-
                 <section id="resume-table">
                     <div class="compare--chart_wrapper d-none"></div>
 
-                    <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+                    <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                         <thead>
                             <tr>
-                                <th scope="col"></th>
+                                <!--<th scope="col"></th>-->
                                 <th scope="col">Data pagamento</th>
                                 <th scope="col">Importo</th>
                                 <th scope="col">Nome</th>
                                 <th scope="col">Cognome</th>
+                                <th scope="col">Commerciale</th>
                                 <th scope="col">Causale</th>
                                 <th scope="col">Pagamento</th>
-
                                 <th scope="col">...</th>
                             </tr>
                         </thead>
+
                         <tbody id="checkall-target">
-                            @foreach($datas as $record)
-                                <tr>
-                                    <td> <label><input class="table-check" type="checkbox" wire:model="multipleIds" value="{{$record->id}}"><span class="sr-only d-inline-block d-lg-none ms-2 mobile-row-selector"> Seleziona riga</span></label></td>
-                                    <td data-sort="{{$record->date}}">{{date("d/m/Y", strtotime($record->date))}}</td>
-                                    <td data-sort="{{$record->getTotal()}}"><span class="tablesaw-cell-content primary">{{formatPrice($record->getTotal())}}</span></td>
-                                    <td>
-                                        {{$record->first_name}}
-                                    </td>
-                                    <td>
-                                        {{$record->last_name}}
-                                    </td>
-                                    <td>
-                                        @foreach($record->rows as $row)
-                                            {{$row->causal->getTree()}}<br>
-                                        @endforeach
-                                    </td>
-                                    <td>{{$record->payment_method->name}}</td>
-
-                                    <td>
-                                        <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
-                                        <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
-                                        <button type="button" class="btn btn-outline-default btn-sm" wire:click="duplicate({{ $record->id }})">Duplica</button>
-                                    </td>
-                                </tr>
-                            @endforeach
                         </tbody>
                     </table>
 
-                    <!--
-                    <div class="paginator d-flex justify-content-center">
-                        <nav aria-label="Page navigation example">
-                            <ul class="pagination">
-                                <li class="page-item">
-                                <a class="page-link" href="#" aria-label="Previous">
-                                    <span aria-hidden="true"></span>
-                                </a>
-                                </li>
-                                <li class="page-item"><a class="page-link" href="#">1</a></li>
-                                <li class="page-item"><a class="page-link" href="#">2</a></li>
-                                <li class="page-item"><a class="page-link" href="#">3</a></li>
-                                <li class="page-item"><a class="page-link" href="#">3</a></li>
-
-                                <li class="page-item"><span class="more-page">...</span></li>
-
-                                <li class="page-item">
-                                <a class="page-link" href="#" aria-label="Next">
-                                    <span aria-hidden="true"></span>
-                                </a>
-                                </li>
-                            </ul>
-                            </nav>
-                    </div>
-                    -->
                 </section>
 
             @else
@@ -265,12 +157,6 @@
                     </div>
                 @endif
 
-                <header id="title--section" class="d-flex align-items-center justify-content-between">
-                    <div class="title--section_name d-flex align-items-center justify-content-between">
-                        <i class="ico--ui title_section entrate me-2"></i>
-                        <h2 class="primary">{{$add ? 'Nuova' : 'Modifica'}} Entrata</h2>
-                    </div>
-                </header>
 
                 <section id="accountingEntry" class="d-flex">
                     <div class="accountingEntry_data" wire:key='reload-{{$selectId}}'>
@@ -306,7 +192,7 @@
                                     <div class="col-md-6">
                                         <span class="title-form d-block w-100">Persona</span>
                                         <select name="member_id" class="form-select memberClass @error('member_id') is-invalid @enderror" aria-label="Seleziona una persona" wire:model="member_id">
-                                            <option value="">
+                                            <option value="">--Seleziona--
                                             @foreach($members as $member)
                                                 <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}} ({{$member->fiscal_code}})
                                             @endforeach
@@ -344,7 +230,7 @@
                                     <div class="col-md-12" >
 
                                         <select name="payment_method_id" class="form-select paymentClass @error('payment_method_id') is-invalid @enderror" aria-label="Seleziona un metodo di pagamento" wire:model="payment_method_id" style="width:100%">
-                                            <option value="">
+                                            <option value="">--Seleziona--
                                             @foreach($payments as $payment)
                                                 <option value="{{$payment->id}}">{{$payment->name}}
                                             @endforeach
@@ -357,28 +243,16 @@
 
                                 @foreach($rows as $idx => $row)
 
-                                    <div class="row gx-2 mt-3" wire:ignore>
+                                    <div class="row gx-2 mt-3" >
                                         <span class="title-form d-block w-100">Causale</span>
                                         <div class="col-md-12">
 
                                             <livewire:causals :type="$typeIN" :idx="$idx" :causal_id="$rows[$idx]['causal_id']" :wire:key="$idx" />
 
-
-
-                                            @if(false)
-                                            <select name="rows.{{$idx}}.causal_id" class="form-select causalClass @error('row.' . $idx . '.causal_id') is-invalid @enderror" aria-label="Seleziona una causale" wire:model="rows.{{$idx}}.causal_id">
-                                                    <option value="">
-                                                    @foreach($causals as $causal)
-                                                        <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
-                                                    @endforeach
-
-                                            </select>
-                                            @endif
-
-
-                                            @error('causal_id')
-                                                <div class="invalid-feedback">{{ $message }}</div>
+                                            @error('rows.'. $idx . '.causal_id')
+                                                <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
                                             @enderror
+
                                         </div>
                                     </div>
 
@@ -412,8 +286,8 @@
                                             @if($update)
                                                 <input type="text" class="form-control totalInput text-end @error('amount') is-invalid @enderror" id="rows.{{$idx}}.amount" placeholder="€ 0,00" wire:model="rows.{{$idx}}.amount"  onkeyup="onlyNumberAmount(this)" wire:keydown.enter="update(false)">
                                             @endif
-                                            @error('amount')
-                                                <div class="invalid-feedback">{{ $message }}</div>
+                                            @error('rows.'. $idx . '.amount')
+                                                <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
                                             @enderror
                                         </div>
 
@@ -615,14 +489,41 @@
                                 </ul>
 
                                 @if(sizeof($rows) > 0)
-                                    <ul class="resume-item date p-0">
-                                        <li><strong>Causale</strong></li>
-                                        <li>
-                                            @foreach($rows as $row)
-                                                {{$this->getCausal($row["causal_id"])}} <span style="float:right"><b>{{$row["amount"]}}</b></span><br>
-                                            @endforeach
-                                        </li>
-                                    </ul>
+                                    <table width="100%">
+                                        <tr>
+                                            <td><b>Causale</b></td>
+                                            @if($commercial == 1)
+                                                <td><b>Imponibile</b></td>
+                                                <td><b>% Iva</b></td>
+                                                <td><b>Iva</b></td>
+                                            @endif
+                                            <td style="float:right"><b>Totale</b></td>
+                                        </tr>
+                                        @foreach($rows as $row)
+                                            <tr>
+                                                <td>{{$this->getCausal($row["causal_id"])}}</td>
+                                                @php
+                                                $vat_value = 0;
+                                                @endphp
+                                                @if($commercial == 1)
+                                                    <td>{{$row["amount"]}}</td>
+                                                    @php
+                                                    $vat_name = '';
+                                                    if ($row["vat_id"] > 0)
+                                                    {
+                                                        $v = \App\Models\Vat::findOrFail(intval($row["vat_id"]));
+                                                        $vat_name = $v->name;
+                                                        $vat_value = $this->currencyToDouble($row["amount"]) / 100 * $v->value;
+                                                    }
+                                                    @endphp
+                                                    <td>{{$vat_name}}</td>
+                                                    <td>{{$vat_value > 0 ? formatPrice($vat_value) : ''}}</td>
+                                                @endif
+                                                <td style="float:right">{{formatPrice($this->currencyToDouble($row["amount"]) + $vat_value)}}</td>
+                                            </tr>
+                                        @endforeach
+                                    </table>
+
                                 @endif
 
                             </header>
@@ -822,21 +723,21 @@
             });
 
             $('.filterMember').select2();
-            $('.filterMember').on('change', function (e) {
+            /*$('.filterMember').on('change', function (e) {
                 var data = $('.filterMember').select2("val");
                 @this.set('filterMember', data);
                 @this.search();
-            });
+            });*/
             $('.filterPaymentMethod').select2();
-            $('.filterPaymentMethod').on('change', function (e) {
+            /*$('.filterPaymentMethod').on('change', function (e) {
                 var data = $('.filterPaymentMethod').select2("val");
                 @this.set('filterPaymentMethod', data);
-            });
+            });*/
             $('.filterCausals').select2();
-            $('.filterCausals').on('change', function (e) {
+            /*$('.filterCausals').on('change', function (e) {
                 var data = $('.filterCausals').select2("val");
                 @this.set('filterCausals', data);
-            });
+            });*/
 
         });
 
@@ -855,21 +756,21 @@
         });
 
         $('.filterMember').select2();
-        $('.filterMember').on('change', function (e) {
+        /*$('.filterMember').on('change', function (e) {
             var data = $('.filterMember').select2("val");
             @this.set('filterMember', data);
             @this.search();
-        });
+        });*/
         $('.filterPaymentMethod').select2();
-        $('.filterPaymentMethod').on('change', function (e) {
+        /*$('.filterPaymentMethod').on('change', function (e) {
             var data = $('.filterPaymentMethod').select2("val");
             @this.set('filterPaymentMethod', data);
-        });
+        });*/
         $('.filterCausals').select2();
-        $('.filterCausals').on('change', function (e) {
+        /*$('.filterCausals').on('change', function (e) {
             var data = $('.filterCausals').select2("val");
             @this.set('filterCausals', data);
-        });
+        });*/
 
         function onlyNumberAmount(input) {
             let v = input.value.replace(/\D+/g, '');
@@ -881,12 +782,68 @@
 
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
     <script>
 
         $(document).ready(function() {
+
+            // Carico i dati dal local storage
+            var filterCommercial = localStorage.getItem("filterCommercial");
+            if (filterCommercial)
+            {
+                $('input[name="filterCommercial"]').val(filterCommercial);
+            }
+            var filterMember = localStorage.getItem("filterMember");
+            if (filterMember)
+            {
+                $('.filterMember').val(filterMember);
+                $('.filterMember').trigger('change');
+            }
+            var filterPaymentMethod = localStorage.getItem("filterPaymentMethod");
+            if (filterPaymentMethod)
+            {
+                $('.filterPaymentMethod').val(filterPaymentMethod);
+                $('.filterPaymentMethod').trigger('change');
+            }
+            var filterCausals = localStorage.getItem("filterCausals");
+            if (filterCausals)
+            {
+                $('.filterCausals').val(filterCausals);
+                $('.filterCausals').trigger('change');
+            }
+            var filterFrom = localStorage.getItem("filterFrom");
+            if (filterFrom)
+            {
+                $('.filterFrom').val(filterFrom);
+            }
+            var filterTo = localStorage.getItem("filterTo");
+            if (filterTo)
+            {
+                $('.filterTo').val(filterTo);
+            }
+
             loadDataTable();
         } );
 
+        function editData(id)
+        {
+            @this.edit(id);
+        }
+
+        function duplicateData(id)
+        {
+            @this.duplicate(id);
+        }
+
+        function deleteData(id)
+        {
+            if (confirm('Sei sicuro?'))
+                @this.delete(id);
+        }
+
         Livewire.on('load-data-table', () => {
             setTimeout(function() {loadDataTable()}, 100);
 
@@ -901,14 +858,83 @@
             $('#tablesaw-350').DataTable().destroy();
         }
 
+        function reset()
+        {
+            $('input[name="filterCommercial"]').val(0);
+            $('.filterMember').val('');
+            $('.filterMember').trigger('change');
+            $('.filterPaymentMethod').val('');
+            $('.filterPaymentMethod').trigger('change');
+            $('.filterCausals').val('');
+            $('.filterCausals').trigger('change');
+            $('.filterFrom').val('');
+            $('.filterTo').val('');
+            localStorage.clear();
+            loadDataTable();
+        }
+
         function loadDataTable(){
 
             if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
                 $('#tablesaw-350').DataTable().destroy();
             }
 
+            var filterCommercial = $('input[name="filterCommercial"]:checked').val();
+            var filterMember = $('.filterMember').val();
+            var filterPaymentMethod = $('.filterPaymentMethod').val();
+            var filterCausals = $('.filterCausals').val();
+            var filterFrom = $('.filterFrom').val();
+            var filterTo = $('.filterTo').val();
+
+            // Salvo i filtri della ricerca
+            localStorage.setItem("filterCommercial", filterCommercial);
+            localStorage.setItem("filterMember", filterMember);
+            localStorage.setItem("filterPaymentMethod", filterPaymentMethod);
+            localStorage.setItem("filterCausals", filterCausals);
+            localStorage.setItem("filterFrom", filterFrom);
+            localStorage.setItem("filterTo", filterTo);
+
             $('#tablesaw-350').DataTable({
+                ajax: '/get_record_in?filterCommercial=' + filterCommercial + "&filterMember=" + filterMember + "&filterPaymentMethod=" + filterPaymentMethod + "&filterCausals=" + filterCausals + "&filterFrom=" + filterFrom + "&filterTo=" + filterTo,
+                columns: [
+                    //{ data: 'id' },
+                    {
+                        data: "date",
+                        render: function (data, type){
+                            if (data == "")
+                                return " TOTALE";
+                            if (type == "sort"){
+                                return new Date(data).getTime();
+                            }
+                            // Split class and text
+                            const j = data.split(" ");
+                            const d = j[0].split("-");
+                            var ret = d[2] + "/" + d[1] + "/" + d[0];
+                            return ret;
+                        }
+                    },
+                    { data: 'total' },
+                    { data: 'first_name' },
+                    { data: 'last_name' },
+                    { data: 'commercial' },
+                    { data: 'causals' },
+                    { data: 'payment' },
+                    {
+                        data: "action",
+                        render: function (data){
+                            if (data == "")
+                                return "";
+                            const j = data.split("|");
+                            $(".totalDiv").html('Totale&nbsp;:&nbsp;<b>' + j[1] + '</b>');
+                            var ret = '<button type="button" class="btn btn-outline-primary btn-sm" onclick="editData(' + j[0] + ')">Modifica</button>&nbsp;';
+                            ret += '<button type="button" class="btn btn-outline-danger btn-sm" onclick="deleteData(' + j[0] + ')">Elimina</button>';
+                            ret += '<button type="button" class="btn btn-outline-default btn-sm" onclick="duplicateData(' + j[0] + ')">Duplica</button>';
+                            return ret;
+                        }
+                    },
+                ],
                 fixedHeader: false,
+                order: [[0, 'desc']],
                 thead: {
                 'th': {'background-color': 'blue'}
                 },
@@ -916,17 +942,25 @@
                     topStart: {
                         buttons: [
                             {
-                                extend: 'csv',
+                                extend: 'excelHtml5',
+                                title: 'Entrate',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Entrate',
                                 exportOptions: {
-                                    columns: ":not(':first,:last')"
+                                    columns: ":not(':last')"
                                 }
                             },
-                            //'excel',
-                            //'pdf',
                             {
                                 extend: 'print',
+                                text: 'Stampa',
+                                title: 'Entrate',
                                 exportOptions: {
-                                    columns: ":not(':first,:last')"
+                                    columns: ":not(':last')"
                                 }
                             }
                         ]

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

@@ -95,7 +95,7 @@
                                 <tbody id="checkall-target">
 
                                     @foreach($rows_in as $in)
-                                        @if($filterCausalsIn == null || (sizeof($filterCausalsIn) == 0 || in_array($in["id"], $filterCausalsIn)))
+                                        @if($filterCausalsIn == null || (sizeof($filterCausalsIn) == 0 || in_array($in["id"], $filterCausalsIn) || in_array($in["parent_id"], $filterCausalsIn) || in_array($in["first_parent_id"], $filterCausalsIn)))
                                             <tr data-id="{{$in["id"]}}" data-parent="{{$in["parent_id"]}}">
                                                 <td>{!!str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $in["level"])!!}{{$in["name"]}}</td>
                                                 @foreach($columns as $column)
@@ -234,7 +234,7 @@
                     </div>
                 </section>
 
-
+                <a style="display:none" href="javascript:void(0);" id="collapseAll" class="act-button-collapse-all">Collapse All</a>
 
         </div>
     </div>
@@ -338,7 +338,7 @@
                     plusButton: '<span class="i"> + </span>',
                     minusButton: '<span class="i"> - </span>'
                 });
-                $(".act-button-collapse-all").trigger('click');
+                $("#collapseAll").trigger("click")
             });
         }
 

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

@@ -57,7 +57,7 @@
 
                         <h1>Entrate</h1>
 
-                        <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+                        <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                             <thead>
                                 <tr>
                                     <th scope="col">Data</th>
@@ -96,7 +96,7 @@
 
                         <h1>Uscite</h1>
 
-                        <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350x">
+                        <table class="table tablesaw tablesaw-stack" id="tablesaw-350x">
                             <thead>
                                 <tr>
                                     <th scope="col">Data</th>

+ 199 - 124
resources/views/livewire/records_out.blade.php

@@ -9,32 +9,35 @@
             </header>
 
             <form action="" id="filter--form" class="dark-form row">
+            <!--
                 <div class="filter--item">
                     <span class="filter--item_title">Commerciale</span>
 
                     <div class="filter--item_formElement">
                         <div class="form-check form-check-inline d-inline-flex align-items-center">
-                            <input class="form-check-input" type="radio" value="0" id="all_commercial" wire:model="filterCommercial">
+                            <input class="form-check-input" type="radio" value="0" name="filterCommercial" checked>
                             <label class="form-check-label ms-2" for="inlineCheckbox1">Entrambe</label>
                         </div>
                         <div class="form-check form-check-inline d-inline-flex align-items-center">
-                            <input class="form-check-input" type="radio" value="1" id="commercial" wire:model="filterCommercial">
+                            <input class="form-check-input" type="radio" value="1" name="filterCommercial">
                             <label class="form-check-label ms-2" for="inlineCheckbox1">Commerciale</label>
                         </div>
                         <div class="form-check form-check-inline d-inline-flex align-items-center">
-                            <input class="form-check-input" type="radio" value="2" id="not_commercial" wire:model="filterCommercial">
+                            <input class="form-check-input" type="radio" value="2" name="filterCommercial">
                             <label class="form-check-label ms-2" for="inlineCheckbox1">Non commerciale</label>
                         </div>
                     </div>
                 </div>
+
+                -->
                 <!-- filter item -->
 
                 <div class="filter--item">
                     <span class="filter--item_title">Fornitore</span>
 
                     <div class="filter--item_formElement">
-                        <select name="search_supplier_id" class="form-select filterSupplier" wire:model="filterSupplier">
-                            <option value="">
+                        <select name="search_supplier_id" class="form-select filterSupplier">
+                            <option value="">--Seleziona--
                             @foreach($suppliers as $supplier)
                                 <option value="{{$supplier->id}}">{{$supplier->name}}
                             @endforeach
@@ -46,8 +49,8 @@
                     <span class="filter--item_title">Pagamento</span>
 
                     <div class="filter--item_formElement">
-                        <select name="search_payment_method_id" class="form-select filterPaymentMethod"  wire:model="filterPaymentMethod">
-                            <option value="">
+                        <select name="search_payment_method_id" class="form-select filterPaymentMethod">
+                            <option value="">--Seleziona--
                             @foreach($payments as $payment)
                                 <option value="{{$payment->id}}">{{$payment->name}}
                             @endforeach
@@ -60,8 +63,8 @@
                     <span class="filter--item_title">Causali</span>
 
                     <div class="filter--item_formElement">
-                        <select name="search_causal_id" class="form-select filterCausals" multiple="multiple" wire:model="filterCausals">
-                            <option value="">
+                        <select name="search_causal_id" class="form-select filterCausals">
+                            <option value="">--Seleziona--
                             @foreach($causals as $causal)
                                 <option value="{{$causal["id"]}}">{{$causal["name"]}}
                             @endforeach
@@ -74,51 +77,13 @@
                 <div class="filter--item">
                     <span class="filter--item_title">Periodo </span>
                     <div class="filter--item_formElement">
-                        <input id="date" type="date" class="form-control"  wire:model="filterFrom" style="background-color:white">
+                        <input id="dateFrom" type="date" class="form-control filterFrom" style="background-color:white">
                     </div>
                     <div class="filter--item_formElement">
-                        <input id="date" type="date" class="form-control"  wire:model="filterTo" style="background-color:white">
+                        <input id="dateTo" type="date" class="form-control filterTo" style="background-color:white">
                     </div>
                 </div>
-                <!-- filter item -->
-                <!--
-                <div class="filter--item">
-                    <span class="filter--item_title">Modalità di Pagamento</span>
-
-                    <div class="filter--item_formElement row">
-                        <div class="col-6">
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Contanti</label>
-                            </div>
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option2">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Borsellino</label>
-                            </div>
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option3">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Bonifico</label>
-                            </div>
-                        </div>
-                        <div class="col-6">
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option4">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">POS</label>
-                            </div>
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option5">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Playtomic</label>
-                            </div>
-                            <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option6">
-                                <label class="form-check-label ms-2" for="inlineCheckbox1">Assegno</label>
-                            </div>
-                        </div>
-                    </div>
 
-                </div>
-                -->
-                <!-- filter item -->
 
             </form>
 
@@ -129,8 +94,8 @@
                     </div>
                 @endif
                 <div class="filter--buttons d-flex align-items-center justify-content-between">
-                    <button class="btn--ui small dark disable" wire:click.prevent="disableSearch()">cancella</button>
-                    <button class="btn--ui small white" wire:click.prevent="search()">filtra</button>
+                    <button class="btn--ui small dark disable" onclick="reset()">cancella</button>
+                    <button class="btn--ui small white" onclick="loadDataTable()">filtra</button>
                 </div>
             </footer>
 
@@ -139,12 +104,11 @@
     </div>
         <div class="col card--ui" id="card--dashboard">
 
-            @if(!$add && !$update)
 
             <header id="title--section" class="d-flex align-items-center justify-content-between">
                 <div class="title--section_name d-flex align-items-center justify-content-between">
-                    <i class="ico--ui title_section utenti me-2"></i>
-                    <h2 class="primary" style="color:#F28322">@if(!$add && !$update)Elenco Uscite @else Inserimento/modifica uscita @endif</h2>
+                    <i class="ico--ui title_section uscite me-2"></i>
+                    <h2 class="primary" style="color:#F28322">@if(!$add && !$update)Uscite @else Inserimento/modifica uscita @endif</h2>
                 </div>
 
                 @if(!$add && !$update)
@@ -157,64 +121,51 @@
 
             </header>
 
+            @if(!$add && !$update)
+
+
             <button id="open-filter" onclick="pcsh1()"></button>
                 <button id="close-filter" onclick="pcsh2()"></button>
 
                 <section id="subheader" class="d-flex align-items-center justify-content-between">
-                    <form action="" class="group--action d-flex align-items-center">
-                            <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="multipleAction">
-                                <option selected>Azione multipla</option>
-                                <option value="delete">Elimina</option>
+                    @if(false)
+                        <form action="" class="group--action d-flex align-items-center">
+                                <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="multipleAction">
+                                    <option selected>Azione multipla</option>
+                                    <option value="delete">Elimina</option>
+                                    </select>
+                                    <button type="submit" class="btn--ui" wire:click.prevent="executeMultipleAction()">applica</button>
+                                </form>
+
+                        <form action="" class="compare--form d-flex align-items-center">
+                            <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="selectedFilter">
+                                <option value="">--Seleziona--</option>
+                                <option value="0">Oggi</option>
+                                <option value="1">Questo mese: <span class="date-range">{{date("01/m/Y")}} - {{date("t/m/Y")}}</span></option>
+                                <option value="2">Questo anno: <span class="date-range">{{date("01/01/Y")}} - {{date("31/12/Y")}}</span></option>
+                                <option value="3">Tutte</option>
                                 </select>
-                                <button type="submit" class="btn--ui" wire:click.prevent="executeMultipleAction()">applica</button>
                             </form>
-
-                    <form action="" class="compare--form d-flex align-items-center">
-                        <select class="form-select form-select-lg me-1" aria-label=".form-select-lg example" wire:model="selectedFilter">
-                            <option value="">--Seleziona--</option>
-                            <option value="0">Oggi</option>
-                            <option value="1">Questo mese: <span class="date-range">{{date("01/m/Y")}} - {{date("t/m/Y")}}</span></option>
-                            <option value="2">Questo anno: <span class="date-range">{{date("01/01/Y")}} - {{date("31/12/Y")}}</span></option>
-                            <option value="3">Tutte</option>
-                            </select>
-                        </form>
+                    @endif
                 </section>
 
                 <section id="resume-table">
                     <div class="compare--chart_wrapper d-none"></div>
 
-                    <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+                    <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                         <thead>
                             <tr>
-                                <th scope="col"></th>
-                                <th scope="col">Data</th>
+                                <!--<th scope="col"></th>-->
+                                <th scope="col">Data pagamento</th>
                                 <th scope="col">Importo</th>
                                 <th scope="col">Fornitore</th>
                                 <th scope="col">Causale</th>
                                 <th scope="col">Pagamento</th>
-
                                 <th scope="col">...</th>
                             </tr>
                         </thead>
+
                         <tbody id="checkall-target">
-                            @foreach($records as $record)
-                                <tr>
-                                    <td> <label><input class="table-check" type="checkbox" wire:model="multipleIds" value="{{$record->id}}"><span class="sr-only d-inline-block d-lg-none ms-2 mobile-row-selector"> Seleziona riga</span></label></td>
-                                    <td>{{date("d/m/Y", strtotime($record->date))}}</td>
-                                    <td><span class="tablesaw-cell-content primary">{{formatPrice($record->getTotal())}}</span></td>
-                                    <td>{{$record->supplier}}</td>
-                                    <td>
-                                        @foreach($record->rows as $row)
-                                            {{$row->causal->getTree()}}<br>
-                                        @endforeach
-                                    </td>
-                                    <td>{{$record->payment_method->name}}</td>
-                                    <td>
-                                        <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
-                                        <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
-                                    </td>
-                                </tr>
-                            @endforeach
                         </tbody>
                     </table>
                     <!--
@@ -252,14 +203,6 @@
                     </div>
                 @endif
 
-                <header id="title--section" class="d-flex align-items-center justify-content-between">
-                    <div class="title--section_name d-flex align-items-center justify-content-between">
-                        <i class="ico--ui title_section entrate me-2"></i>
-                        <h2 class="primary">{{$add ? 'Nuova' : 'Modifica'}} Uscita</h2>
-                    </div>
-
-
-                </header>
 
                 <section id="accountingExit" class="d-flex"  wire:key='reload-{{$selectId}}'>
                     <div class="accountingExit_data">
@@ -295,7 +238,7 @@
                                         <span class="title-form d-block w-100">Fornitore</span>
 
                                         <select name="supplier_id" class="form-select supplierClass @error('supplier_id') is-invalid @enderror" aria-label="Seleziona un fornitore" wire:model="supplier_id">
-                                            <option value="">
+                                            <option value="">--Seleziona--
                                             @foreach($suppliers as $supplier)
                                                 <option value="{{$supplier->id}}">{{$supplier->name}}
                                             @endforeach
@@ -311,7 +254,7 @@
 
                                     <div class="col-md-12">
                                         <select name="payment_method_id" class="form-select paymentClass @error('payment_method_id') is-invalid @enderror" aria-label="Seleziona un metodo di pagamento" wire:model="payment_method_id">
-                                            <option value="">
+                                            <option value="">--Seleziona--
                                             @foreach($payments as $payment)
                                                 <option value="{{$payment->id}}">{{$payment->name}}
                                             @endforeach
@@ -332,7 +275,7 @@
 
                                             @if(false)
                                                 <select name="rows.{{$idx}}.causal_id" class="form-select causalClass @error('row.' . $idx . '.causal_id') is-invalid @enderror" aria-label="Seleziona una causale" wire:model="rows.{{$idx}}.causal_id">
-                                                    <option value="">
+                                                    <option value="">--Seleziona--
                                                     @foreach($causals as $causal)
                                                         <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
                                                     @endforeach
@@ -342,8 +285,8 @@
                                                 @enderror
                                             @endif
 
-                                            @error('rows.' . $idx . '.causal_id')
-                                                <div class="invalid-feedback">{{ $message }}</div>
+                                            @error('rows.'. $idx . '.causal_id')
+                                                <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
                                             @enderror
 
                                         </div>
@@ -368,8 +311,8 @@
                                             @if($update)
                                                 <input type="text" class="form-control totalInput text-end @error('amount') is-invalid @enderror" id="rows.{{$idx}}.amount" placeholder="€ 0,00" wire:model="rows.{{$idx}}.amount"  onkeyup="onlyNumberAmount(this)" wire:keydown.enter="update(false)">
                                             @endif
-                                            @error('rows.' . $idx . '.amount')
-                                                <div class="invalid-feedback">{{ $message }}</div>
+                                            @error('rows.'. $idx . '.amount')
+                                                <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
                                             @enderror
                                         </div>
                                     </div>
@@ -664,18 +607,18 @@
 
             $('.filterSupplier').select2();
             $('.filterSupplier').on('change', function (e) {
-                var data = $('.filterSupplier').select2("val");
-                @this.set('filterSupplier', data);
+                //var data = $('.filterSupplier').select2("val");
+                //@this.set('filterSupplier', data);
             });
             $('.filterPaymentMethod').select2();
             $('.filterPaymentMethod').on('change', function (e) {
-                var data = $('.filterPaymentMethod').select2("val");
-                @this.set('filterPaymentMethod', data);
+                //var data = $('.filterPaymentMethod').select2("val");
+                //@this.set('filterPaymentMethod', data);
             });
             $('.filterCausals').select2();
             $('.filterCausals').on('change', function (e) {
-                var data = $('.filterCausals').select2("val");
-                @this.set('filterCausals', data);
+                //var data = $('.filterCausals').select2("val");
+                //@this.set('filterCausals', data);
             });
 
         });
@@ -686,18 +629,18 @@
 
         $('.filterSupplier').select2();
         $('.filterSupplier').on('change', function (e) {
-            var data = $('.filterSupplier').select2("val");
-            @this.set('filterSupplier', data);
+            //var data = $('.filterSupplier').select2("val");
+            //@this.set('filterSupplier', data);
         });
         $('.filterPaymentMethod').select2();
         $('.filterPaymentMethod').on('change', function (e) {
-            var data = $('.filterPaymentMethod').select2("val");
-            @this.set('filterPaymentMethod', data);
+            //var data = $('.filterPaymentMethod').select2("val");
+            //@this.set('filterPaymentMethod', data);
         });
         $('.filterCausals').select2();
         $('.filterCausals').on('change', function (e) {
-            var data = $('.filterCausals').select2("val");
-            @this.set('filterCausals', data);
+            //var data = $('.filterCausals').select2("val");
+            //@this.set('filterCausals', data);
         });
 
         function onlyNumberAmount(input) {
@@ -709,19 +652,143 @@
 
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
     <script>
 
         $(document).ready(function() {
+
+            var filterSupplier = localStorage.getItem("filterSupplier");
+            if (filterSupplier)
+            {
+                $('.filterSupplier').val(filterSupplier);
+                $('.filterSupplier').trigger('change');
+            }
+            var filterPaymentMethod = localStorage.getItem("filterPaymentMethod");
+            if (filterPaymentMethod)
+            {
+                $('.filterPaymentMethod').val(filterPaymentMethod);
+                $('.filterPaymentMethod').trigger('change');
+            }
+            var filterCausals = localStorage.getItem("filterCausals");
+            if (filterCausals)
+            {
+                $('.filterCausals').val(filterCausals);
+                $('.filterCausals').trigger('change');
+            }
+            var filterFrom = localStorage.getItem("filterFrom");
+            if (filterFrom)
+            {
+                $('.filterFrom').val(filterFrom);
+            }
+            var filterTo = localStorage.getItem("filterTo");
+            if (filterTo)
+            {
+                $('.filterTo').val(filterTo);
+            }
+
             loadDataTable();
         } );
 
+        function editData(id)
+        {
+            @this.edit(id);
+        }
+
+        function deleteData(id)
+        {
+            if (confirm('Sei sicuro?'))
+                @this.delete(id);
+        }
+
         Livewire.on('load-data-table', () => {
-            loadDataTable();
+            setTimeout(function() {loadDataTable()}, 100);
+
         });
 
+        Livewire.on('destroy-data-table', () => {
+            $('#tablesaw-350').DataTable().destroy();
+        });
+
+        function destroyDataTable()
+        {
+            $('#tablesaw-350').DataTable().destroy();
+        }
+
+        function reset()
+        {
+            $('.filterSupplier').val('');
+            $('.filterSupplier').trigger('change');
+            $('.filterPaymentMethod').val('');
+            $('.filterPaymentMethod').trigger('change');
+            $('.filterCausals').val('');
+            $('.filterCausals').trigger('change');
+            $('.filterFrom').val('');
+            $('.filterTo').val('');
+            localStorage.clear();
+            loadDataTable();
+        }
+
         function loadDataTable(){
+
+            if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
+                $('#tablesaw-350').DataTable().destroy();
+            }
+
+            var filterSupplier = $('.filterSupplier').val();
+            var filterPaymentMethod = $('.filterPaymentMethod').val();
+            var filterCausals = $('.filterCausals').val();
+            var filterFrom = $('.filterFrom').val();
+            var filterTo = $('.filterTo').val();
+
+            localStorage.setItem("filterSupplier", filterSupplier);
+            localStorage.setItem("filterPaymentMethod", filterPaymentMethod);
+            localStorage.setItem("filterCausals", filterCausals);
+            localStorage.setItem("filterFrom", filterFrom);
+            localStorage.setItem("filterTo", filterTo);
+
+
+            console.log("/get_record_out?filterSupplier=" + filterSupplier + "&filterPaymentMethod=" + filterPaymentMethod + "&filterCausals=" + filterCausals + "&filterFrom=" + filterFrom + "&filterTo=" + filterTo);
+
             $('#tablesaw-350').DataTable({
+                ajax: "/get_record_out?filterSupplier=" + filterSupplier + "&filterPaymentMethod=" + filterPaymentMethod + "&filterCausals=" + filterCausals + "&filterFrom=" + filterFrom + "&filterTo=" + filterTo,
+                columns: [
+                    {
+                        data: "date",
+                        render: function (data, type){
+                            if (data == "")
+                                return " TOTALE";
+                            if (type == "sort"){
+                                return new Date(data).getTime();
+                            }
+                            // Split class and text
+                            const j = data.split(" ");
+                            const d = j[0].split("-");
+                            var ret = d[2] + "/" + d[1] + "/" + d[0];
+                            return ret;
+                        }
+                    },
+                    { data: 'total' },
+                    { data: 'supplier' },
+                    { data: 'causals' },
+                    { data: 'payment' },
+                    {
+                        data: "action",
+                        render: function (data){
+                            if (data == "")
+                                return "";
+                            const j = data.split("|");
+                            //$(".totalDiv").html('Totale&nbsp;:&nbsp;<b>' + j[1] + '</b>');
+                            var ret = '<button type="button" class="btn btn-outline-primary btn-sm" onclick="editData(' + j[0] + ')">Modifica</button>&nbsp;';
+                            ret += '<button type="button" class="btn btn-outline-danger btn-sm" onclick="deleteData(' + j[0] + ')">Elimina</button>';
+                            return ret;
+                        }
+                    },
+                ],
                 fixedHeader: false,
+                order: [[0, 'desc']],
                 thead: {
                 'th': {'background-color': 'blue'}
                 },
@@ -729,17 +796,25 @@
                     topStart: {
                         buttons: [
                             {
-                                extend: 'csv',
+                                extend: 'excelHtml5',
+                                title: 'Uscite',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Uscite',
                                 exportOptions: {
-                                    columns: ":not(':first,:last')"
+                                    columns: ":not(':last')"
                                 }
                             },
-                            //'excel',
-                            //'pdf',
                             {
                                 extend: 'print',
+                                text: 'Stampa',
+                                title: 'Uscite',
                                 exportOptions: {
-                                    columns: ":not(':first,:last')"
+                                    columns: ":not(':last')"
                                 }
                             }
                         ]

+ 29 - 2
resources/views/livewire/reminders.blade.php

@@ -67,7 +67,7 @@
     <section id="resume-table">
         <div class="compare--chart_wrapper d-none"></div>
 
-        <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+        <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
             <thead>
                 <tr>
                     <th scope="col" >Tipologia</th>
@@ -121,6 +121,10 @@
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
@@ -151,7 +155,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Scadenze',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Scadenze',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Scadenze',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 25 - 0
resources/views/livewire/settings.blade.php

@@ -61,6 +61,31 @@
                     <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">IVA</span>
                 </a>
             </div>
+            <div class="col-md-3 p-3">
+                <a href="/course_types" class="nav-link d-flex align-items-center">
+                    <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Tipologie corsi</span>
+                </a>
+            </div>
+            <div class="col-md-3 p-3">
+                <a href="/course_durations" class="nav-link d-flex align-items-center">
+                    <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Durata corsi</span>
+                </a>
+            </div>
+            <div class="col-md-3 p-3">
+                <a href="/course_subscriptions" class="nav-link d-flex align-items-center">
+                    <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Abbonamenti corsi</span>
+                </a>
+            </div>
+            <div class="col-md-3 p-3">
+                <a href="/course_levels" class="nav-link d-flex align-items-center">
+                    <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Livelli corsi</span>
+                </a>
+            </div>
+            <div class="col-md-3 p-3">
+                <a href="/course_frequencies" class="nav-link d-flex align-items-center">
+                    <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Frequenze corsi</span>
+                </a>
+            </div>
         </div>
     </div>
 

+ 54 - 9
resources/views/livewire/sponsor.blade.php

@@ -4,7 +4,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco Sponsor @else Inserimento/modifica sponsor @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)Sponsor @else Inserimento/modifica sponsor @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -38,7 +38,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Ragione sociale</th>
@@ -245,7 +245,7 @@
                                 <section id="resume-table">
                                     <div class="compare--chart_wrapper d-none"></div>
 
-                                    <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350-1">
+                                    <table class="table tablesaw tablesaw-stack" id="tablesaw-350-1">
                                         <thead>
                                             <tr>
                                                 <th scope="col">Data inizio</th>
@@ -262,8 +262,12 @@
                                                     <td>{{date("d/m/Y", strtotime($contract->from_date))}}</td>
                                                     <td>{{date("d/m/Y", strtotime($contract->to_date))}}</td>
                                                     <td>{{date("d/m/Y", strtotime($contract->subscription_date))}}</td>
-                                                    <td>{{$contract->amount}}</td>
-                                                    <td>{!!$contract->file != '' ? '<a href="/storage/app/public/' . $contract->file . '" target="_blank">Visualizza</a>' : ''!!}</td>
+                                                    <td>{{formatPrice($contract->amount)}}</td>
+                                                    <td>
+                                                        @if ($contract->file != '')
+                                                            <a href="{{ asset('storage/app/public/'.$contract->file) }}" target="_blank">Visualizza</a>
+                                                        @endif
+                                                    </td>
                                                     <td>
                                                         <button type="button" class="btn btn-outline-primary btn-sm" wire:click="editContract({{ $contract->id }})">Modifica</button>
                                                         <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="deleteContract({{ $contract->id }})">Elimina</button>
@@ -318,7 +322,7 @@
                                                     <div class="col">
                                                         <div class="form--item">
                                                             <label class="form-label">Importo</label>
-                                                            <input class="form-control js-keyupTitle @error('amount') is-invalid @enderror" type="text" id="amount" placeholder="Importo" wire:model="amount">
+                                                            <input class="form-control js-keyupTitle @error('amount') is-invalid @enderror" type="text" id="amount" placeholder="Importo" wire:model="amount" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00">
                                                             @error('amount')
                                                                 <div class="invalid-feedback">{{ $message }}</div>
                                                             @enderror
@@ -327,8 +331,10 @@
                                                     <div class="col">
                                                         <div class="form--item">
                                                             <label class="form-label">Contratto</label>
-                                                            <input class="form-control" type="file" wire:model="file">
-                                                            {!!$file_old != '' ? '<br><a href="/storage/app/public/' . $file_old . '" target="_blank">Visualizza</a>' : ''!!}
+                                                            <input class="form-control" type="file" wire:model="file" accept="image/*,.pdf,.doc,.docx">
+                                                            @if ($file_old != '')
+                                                                <br><a href="/storage/app/public/{{$file_old}}" target="_blank">Visualizza</a>&nbsp;&nbsp;&nbsp;(<a wire:click.prevent="removeFile()">Elimina</a>)
+                                                            @endif
                                                         </div>
                                                     </div>
                                                 </div>
@@ -392,6 +398,16 @@
     <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
 @endpush
 
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
 @push('scripts')
     <script>
         function matchStart(params, data) {
@@ -473,6 +489,12 @@
             });
         });
 
+        function onlyNumberAmount(input) {
+            let v = input.value.replace(/\D+/g, '');
+            if (v.length > 14) v = v.slice(0, 14);
+            input.value = "€ " + v.replace(/(\d)(\d\d)$/, "$1,$2").replace(/(^\d{1,3}|\d{3})(?=(?:\d{3})+(?:,|$))/g, '$1.');
+        }
+
     </script>
 
     <script>
@@ -493,7 +515,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Sponsor',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Sponsor',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Sponsor',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 30 - 3
resources/views/livewire/supplier.blade.php

@@ -4,7 +4,7 @@
     <header id="title--section" class="d-flex align-items-center justify-content-between">
         <div class="title--section_name d-flex align-items-center justify-content-between">
             <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Elenco Fornitori @else Inserimento/modifica fornitore @endif</h2>
+            <h2 class="primary">@if(!$add && !$update)Fornitori @else Inserimento/modifica fornitore @endif</h2>
         </div>
 
         @if(!$add && !$update)
@@ -22,7 +22,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Nome</th>
@@ -363,6 +363,10 @@
 
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
     <script>
 
         $(document).ready(function() {
@@ -381,7 +385,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Fornitori',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Fornitori',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Fornitori',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 30 - 3
resources/views/livewire/vat.blade.php

@@ -4,7 +4,7 @@
         <header id="title--section" class="d-flex align-items-center justify-content-between">
             <div class="title--section_name d-flex align-items-center justify-content-between">
                 <i class="ico--ui title_section utenti me-2"></i>
-                <h2 class="primary">Elenco IVA</h2>
+                <h2 class="primary">IVA</h2>
             </div>
 
             <div class="title--section_addButton"  wire:click="add()" style="cursor: pointer;">
@@ -18,7 +18,7 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
-            <table class="table tablesaw tablesaw-stack" data-tablesaw="" id="tablesaw-350">
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
                         <th scope="col">Nome</th>
@@ -111,6 +111,10 @@
     <link href="/css/datatables.css" rel="stylesheet" />
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
 @endpush
 
 @push('scripts')
@@ -131,7 +135,30 @@
                 },
                 layout: {
                     topStart: {
-                        buttons: [{ extend: 'csv', text: 'Esporta' }, 'excel', 'pdf', { extend: 'print', text: 'Stampa' }]
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Aliquote IVA',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Aliquote IVA',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Aliquote IVA',
+                                exportOptions: {
+                                    columns: ":not(':last')"
+                                }
+                            }
+                        ]
                     }
                 },
                 pagingType: 'numbers',

+ 235 - 35
routes/web.php

@@ -27,6 +27,14 @@ Route::get('/provinces', \App\Http\Livewire\Province::class);
 Route::get('/cities', \App\Http\Livewire\City::class);
 Route::get('/banks', \App\Http\Livewire\Bank::class);
 Route::get('/vats', \App\Http\Livewire\Vat::class);
+Route::get('/course_types', \App\Http\Livewire\CourseType::class);
+Route::get('/course_subscriptions', \App\Http\Livewire\CourseSubscription::class);
+Route::get('/course_durations', \App\Http\Livewire\CourseDuration::class);
+Route::get('/course_levels', \App\Http\Livewire\CourseLevel::class);
+Route::get('/course_frequencies', \App\Http\Livewire\CourseFrequency::class);
+Route::get('/course_list', \App\Http\Livewire\CourseList::class);
+Route::get('/course_member', \App\Http\Livewire\CourseMember::class);
+Route::get('/receipts', \App\Http\Livewire\Receipt::class);
 Route::get('/cards', \App\Http\Livewire\Card::class);
 Route::get('/causals', \App\Http\Livewire\Causal::class);
 Route::get('/payment_methods', \App\Http\Livewire\PaymentMethod::class);
@@ -83,7 +91,7 @@ Route::get('/get_members', function(){
     $datas = [];
 
     // $datas = \App\Models\Member::select('members.*')->where('id', '>', 0);
-    $x = \App\Models\Member::select('id', 'first_name', 'last_name', 'phone')->where('id', '>', 0);
+    $x = \App\Models\Member::select('id', 'first_name', 'last_name', 'phone', 'birth_date')->where('id', '>', 0);
     if ($_GET["cards"] != "")
     {
         $card_ids = \App\Models\MemberCard::whereIn('card_id', explode(",", $_GET["cards"]))->pluck('member_id');
@@ -94,6 +102,14 @@ Route::get('/get_members', function(){
         $cats_ids = \App\Models\MemberCategory::whereIn('category_id', explode(",", $_GET["categories"]))->pluck('member_id');
         $x = $x->whereIn('id', $cats_ids);
     }
+    if ($_GET["fromYear"] != "")
+    {
+        $x = $x->where('birth_date', '<', date("Y-m-d", strtotime("-" . $_GET["fromYear"] . " year", time())));
+    }
+    if ($_GET["toYear"] != "")
+    {
+        $x = $x->where('birth_date', '>', date("Y-m-d", strtotime("-" . $_GET["toYear"] . " year", time())));
+    }
 
     $certs = [];
 
@@ -124,51 +140,65 @@ Route::get('/get_members', function(){
 
     $x = $x->get();
 
+    $filterStatus = isset($_GET["status"]) ? $_GET["status"] : -1;
 
     foreach($x as $idx => $r)
     {
         $status = $r->getStatus();
         $status = $status["status"];
 
-        $class = $status > 0 ? ($status == 2 ? 'active' : 'suspended') : 'due';
-        $text = $status > 0 ? ($status == 2 ? 'Tesserato' : 'Sospeso') : 'Non tesserato';
-
         $state = $r->isActive();
-        $x = $state["status"] > 0 ? ($state["status"] == 2 ? 'active' : 'suspended') : '';
-        $x .= "|";
-        $x .= $state["status"] > 0 ? ($state["status"] == 2 ? 'Attivo' : 'Sospesa') : '';
-        $x .= "|";
-        $x .= $state["status"] ? 'Scadenza : ' : ($state["date"] != '' ? 'Scaduto : ' : '');
-        $x .= "|";
-        $x .= $state["date"] != '' ? date("d/m/Y", strtotime($state["date"])) : '';
-
-        $has_certificate = $r->hasCertificate();
-        $y = '';
-        if($has_certificate["date"] != '')
+
+        $procede = true;
+        if ($filterStatus >= 0)
         {
-            if($has_certificate["date"] < date("Y-m-d"))
-                $y .= '0';
+            if ($state["status"] != $filterStatus)
+                $procede = false;
+        }
 
-            if($has_certificate["date"] >= date("Y-m-d") && $has_certificate["date"] < date("Y-m-d", strtotime("+1 month")))
-                $y .= '1';
+        if ($procede)
+        {
+            $class = $status > 0 ? ($status == 2 ? 'active' : 'suspended') : 'due';
+            $text = $status > 0 ? ($status == 2 ? 'Tesserato' : 'Sospeso') : 'Non tesserato';
 
-            if($has_certificate["date"] >= date("Y-m-d", strtotime("+1 month")))
-                $y .= '2';
-            $y .= '|';
-            $y .= $has_certificate["date"] != '' ? date("d/m/Y", strtotime($has_certificate["date"])) : '';
-        }
 
-        $datas[] = array(
-            'id' => $r->id,
-            'first_name' => $r->first_name,
-            'last_name' => $r->last_name,
-            'phone' => $r->phone,
-            'age' => $r->getAge(),
-            'status' => $class . "|" . $text,
-            'state' => $x,
-            'certificate' => $y,
-            'action' => $r->id
-        );
+            $x = $state["status"] > 0 ? ($state["status"] == 2 ? 'active' : 'suspended') : '';
+            $x .= "|";
+            $x .= $state["status"] > 0 ? ($state["status"] == 2 ? 'Attivo' : 'Sospesa') : '';
+            $x .= "|";
+            $x .= $state["status"] ? 'Scadenza : ' : ($state["date"] != '' ? 'Scaduto : ' : '');
+            $x .= "|";
+            $x .= $state["date"] != '' ? date("d/m/Y", strtotime($state["date"])) : '';
+
+            $has_certificate = $r->hasCertificate();
+            $y = '';
+            if($has_certificate["date"] != '')
+            {
+                if($has_certificate["date"] < date("Y-m-d"))
+                    $y .= '0';
+
+                if($has_certificate["date"] >= date("Y-m-d") && $has_certificate["date"] < date("Y-m-d", strtotime("+1 month")))
+                    $y .= '1';
+
+                if($has_certificate["date"] >= date("Y-m-d", strtotime("+1 month")))
+                    $y .= '2';
+                $y .= '|';
+                $y .= $has_certificate["date"] != '' ? date("d/m/Y", strtotime($has_certificate["date"])) : '';
+            }
+
+            $datas[] = array(
+                //'c' => $idx + 1,
+                'id' => "ID" . str_pad($r->id, 5, "0", STR_PAD_LEFT),
+                'first_name' => $r->first_name . "|" . $r->id,
+                'last_name' => $r->last_name . "|" . $r->id,
+                'phone' => $r->phone,
+                'age' => $r->getAge(),
+                'status' => $class . "|" . $text,
+                'state' => $x,
+                'certificate' => $y,
+                'action' => $r->id
+            );
+        }
         /*
         $r->age = $r->getAge();
         $active = $r->isActive();
@@ -189,3 +219,173 @@ Route::get('/get_members', function(){
 
 
 });
+
+Route::get('/get_record_in', function(){
+
+    $datas = [];
+
+    $x = \App\Models\Record::select('records.*', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name'), \DB::raw('payment_methods.name as payment')) // , \DB::raw('SUM(records.id) As total'))
+            ->leftJoin('members', 'records.member_id', '=', 'members.id')
+            ->leftJoin('payment_methods', 'records.payment_method_id', '=', 'payment_methods.id')
+            ->where('records.type', 'IN');
+
+    // $datas = \App\Models\Record::where('type', 'IN')->with('member', 'payment_method');
+    if ($_GET["filterCommercial"] > 0)
+    {
+        $x = $x->where('commercial', $_GET["filterCommercial"] == 1 ? true : false);
+    }
+    if ($_GET["filterMember"] > 0)
+    {
+        $x = $x->where('member_id', $_GET["filterMember"]);
+    }
+    if ($_GET["filterPaymentMethod"] > 0)
+    {
+        $x = $x->where('payment_method_id', $_GET["filterPaymentMethod"]);
+    }
+    if ($_GET["filterCausals"] > 0)
+    {
+        $causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
+        $x = $x->whereIn('records.id', $causals);
+    }
+    if ($_GET["filterFrom"] != '')
+    {
+        $x = $x->where('date', '>=', $_GET["filterFrom"]);
+    }
+    if ($_GET["filterTo"] != '')
+    {
+        $x = $x->where('date', '<=', $_GET["filterTo"]);
+    }
+
+    $total = 0;
+    foreach($x->get() as $r)
+    {
+        foreach($r->rows as $rr)
+        {
+            $total += $rr->amount;
+            if ($rr->vat_id > 0)
+                $total += getVatValue($rr->amount, $rr->vat_id);
+        }
+    }
+
+    $x = $x->get();
+
+    foreach($x as $idx => $r)
+    {
+
+        $causals = '';
+        foreach($r->rows as $row)
+        {
+            $causals .= $row->causal->getTree() . "<br>";
+        }
+
+        $datas[] = array(
+            //'id' => $r->id,
+            'date' => $r->date,
+            'total' => formatPrice($r->getTotal()),
+            'first_name' => $r->first_name,
+            'last_name' => $r->last_name,
+            'commercial' => $r->commercial ? 'SI' : 'NO',
+            'causals' => $causals,
+            'payment' => $r->payment_method->name,
+            'action' => $r->id . "|" . formatPrice($total)
+        );
+
+
+    }
+
+    $datas[] = array(
+        //'id' => $r->id,
+        'date' => '',
+        'total' => formatPrice($total),
+        'first_name' => '',
+        'last_name' => '',
+        'commercial' => '',
+        'causals' => '',
+        'payment' => '',
+        'action' => ''
+    );
+
+    return json_encode(array("data" => $datas));
+
+});
+
+Route::get('/get_record_out', function(){
+
+    $datas = [];
+
+    $x = \App\Models\Record::where('type', 'OUT')->with('supplier', 'payment_method');
+
+    if ($_GET["filterSupplier"] > 0)
+    {
+        $x = $x->where('supplier_id', $_GET["filterSupplier"]);
+    }
+    if ($_GET["filterPaymentMethod"] > 0)
+    {
+        $x = $x->where('payment_method_id', $_GET["filterPaymentMethod"]);
+    }
+    if ($_GET["filterCausals"] > 0)
+    {
+        $causals = \App\Models\RecordRow::where('causal_id', $_GET["filterCausals"])->pluck('record_id');
+        $x = $x->whereIn('records.id', $causals);
+    }
+    if ($_GET["filterFrom"] != '')
+    {
+        $x = $x->where('date', '>=', $_GET["filterFrom"]);
+    }
+    if ($_GET["filterTo"] != '')
+    {
+        $x = $x->where('date', '<=', $_GET["filterTo"]);
+    }
+
+    $total = 0;
+    foreach($x->get() as $r)
+    {
+        foreach($r->rows as $rr)
+        {
+            $total += $rr->amount;
+            if ($rr->vat_id > 0)
+                $total += getVatValue($rr->amount, $rr->vat_id);
+        }
+    }
+
+    $x = $x->get();
+
+    foreach($x as $idx => $r)
+    {
+
+        $causals = '';
+        foreach($r->rows as $row)
+        {
+            $causals .= $row->causal->getTree() . "<br>";
+        }
+
+        $datas[] = array(
+            //'id' => $r->id,
+            'date' => $r->date,
+            'total' => formatPrice($r->getTotal()),
+            'supplier' => $r->supplier->name,
+            'causals' => $causals,
+            'payment' => $r->payment_method->name,
+            'action' => $r->id . "|" . formatPrice($total)
+        );
+
+    }
+
+    $datas[] = array(
+        //'id' => $r->id,
+        'date' => '',
+        'total' => formatPrice($total),
+        'supplier' => '',
+        'causals' => '',
+        'payment' => '',
+        'action' => ''
+    );
+
+    return json_encode(array("data" => $datas));
+
+});
+
+Route::get('/migrate', function(){
+    \Artisan::call('migrate');
+    dd('migrated!');
+});

+ 2 - 0
storage/debugbar/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore