Luca Parisio 1 năm trước cách đây
mục cha
commit
19f22fbb36

+ 39 - 15
app/Http/Livewire/Member.php

@@ -38,7 +38,7 @@ class Member extends Component
 
     public $records, $first_name, $last_name, $image, $image_old, $status, $birth_place, $birth_city_id, $birth_province_id, $birth_nation_id, $birth_date, $gender, $fiscal_code, $address, $zip_code, $nation_id, $province_id, $city_id, $phone, $phone2, $phone3, $email, $enabled, $dataId, $update = false, $add = false;
 
-    public $father_name, $mother_name, $father_email, $mother_email, $father_phone, $mother_phone, $father_fiscal_code, $mother_fiscal_code;
+    public $father_name, $mother_name, $father_email, $mother_email, $father_phone, $mother_phone, $father_fiscal_code, $mother_fiscal_code, $father_doc_number, $father_doc_type, $mother_doc_number, $mother_doc_type;
 
     public $document_type, $document_number, $document_from, $document_expire_date, $document_files, $document_files_old;
 
@@ -126,6 +126,10 @@ class Member extends Component
         $this->mother_phone = '';
         $this->father_fiscal_code = '';
         $this->mother_fiscal_code = '';
+        $this->father_doc_number = '';
+        $this->mother_doc_number = '';
+        $this->father_doc_type = '';
+        $this->mother_doc_type = '';
         $this->gender = '';
         $this->fiscal_code = '';
         $this->address = '';
@@ -288,6 +292,8 @@ class Member extends Component
     public function hydrate()
     {
         $this->emit('load-select');
+        // $this->emit('destroy-data-table');
+
     }
 
     public function checkIsItaly()
@@ -366,6 +372,8 @@ class Member extends Component
     public function render()
     {
 
+        // $this->emit('destroy-data-table');
+
         $datas = [];
         if (!$this->advanced)
         {
@@ -386,46 +394,47 @@ class Member extends Component
             if (sizeof($this->filterCard) > 0)
             {
                 $card_ids = \App\Models\MemberCard::whereIn('card_id', $this->filterCard)->pluck('member_id');
-                $this->records->whereIn('id', $card_ids);
-                //$datas = $datas->whereIn('id', $card_ids);
+                //$this->records->whereIn('id', $card_ids);
+                $datas = $datas->whereIn('id', $card_ids);
             }
             if (sizeof($this->filterCategory) > 0)
             {
                 $cats_ids = \App\Models\MemberCategory::whereIn('category_id', $this->filterCategory)->pluck('member_id');
-                $this->records->whereIn('id', $cats_ids);
-                //$datas = $datas->whereIn('id', $cats_ids);
+                //$this->records->whereIn('id', $cats_ids);
+                $datas = $datas->whereIn('id', $cats_ids);
             }
             $certs = [];
 
             if ($this->filterCertNormal > 0)
             {
                 $normal = \App\Models\MemberCertificate::where('type', 'N')->pluck('member_id');
-                $this->records->whereIn('id', $normal);
-                //$datas = $datas->whereIn('id', $normal);;
+                //$this->records->whereIn('id', $normal);
+                $datas = $datas->whereIn('id', $normal);;
             }
             if ($this->filterCertAgonistic > 0)
             {
                 $agonistic = \App\Models\MemberCertificate::where('type', 'A')->pluck('member_id');
-                $this->records->whereIn('id', $agonistic);
-                //$datas = $datas->whereIn('id', $agonistic);
+                //$this->records->whereIn('id', $agonistic);
+                $datas = $datas->whereIn('id', $agonistic);
             }
             if ($this->filterCertScaduto > 0)
             {
                 $scaduto = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
-                $this->records->whereIn('id', $scaduto);
-                //$datas = $datas->whereIn('id', $scaduto);
+                //$this->records->whereIn('id', $scaduto);
+                $datas = $datas->whereIn('id', $scaduto);
             }
             if ($this->filterCertInScadenza > 0)
             {
                 $scaduto = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
-                $this->records->whereIn('id', $scaduto);
-                //$datas = $datas->whereIn('id', $scaduto);
+                //$this->records->whereIn('id', $scaduto);
+                $datas = $datas->whereIn('id', $scaduto);
             }
             if (sizeof($certs) > 0)
             {
-                $this->records->whereIn('id', $certs);
+                $datas = $datas->whereIn('id', $certs);
+                //$this->records->whereIn('id', $certs);
             }
-            $this->records = $this->records->get();
+            $this->records = $datas->get();
 
         }
 
@@ -451,6 +460,9 @@ class Member extends Component
         $this->loadMemberCourses();
         $this->loadMemberCategories();
         $this->loadMemberCertificates();
+
+        $this->emit('load-data-table');
+
         return view('livewire.member', ['datas' => $datas]);
     }
 
@@ -528,6 +540,10 @@ class Member extends Component
                 'mother_phone' => $this->mother_phone,
                 'father_fiscal_code' => $this->father_fiscal_code,
                 'mother_fiscal_code' => $this->mother_fiscal_code,
+                'father_doc_number' => $this->father_doc_number,
+                'father_doc_type' => $this->father_doc_type,
+                'mother_doc_number' => $this->mother_doc_number,
+                'mother_doc_type' => $this->mother_doc_type,
                 'document_type' => $this->document_type,
                 'document_number' => $this->document_number,
                 'document_from' => $this->document_from,
@@ -593,6 +609,10 @@ class Member extends Component
                 $this->mother_phone = $member->mother_phone;
                 $this->father_fiscal_code = $member->father_fiscal_code;
                 $this->mother_fiscal_code = $member->mother_fiscal_code;
+                $this->father_doc_number = $member->father_doc_number;
+                $this->mother_doc_number = $member->mother_doc_number;
+                $this->father_doc_type = $member->father_doc_type;
+                $this->mother_doc_type = $member->mother_doc_type;
                 $this->document_type = $member->document_type;
                 $this->document_number = $member->document_number;
                 $this->document_from = $member->document_from;
@@ -673,6 +693,10 @@ class Member extends Component
                 'mother_phone' => $this->mother_phone,
                 'father_fiscal_code' => $this->father_fiscal_code,
                 'mother_fiscal_code' => $this->mother_fiscal_code,
+                'father_doc_number' => $this->father_doc_number,
+                'father_doc_type' => $this->father_doc_type,
+                'mother_doc_number' => $this->mother_doc_number,
+                'mother_doc_type' => $this->mother_doc_type,
                 'document_type' => $this->document_type,
                 'document_number' => $this->document_number,
                 'document_from' => $this->document_from,

+ 155 - 8
app/Http/Livewire/Record.php

@@ -6,6 +6,10 @@ use DateInterval;
 use DatePeriod;
 use DateTime;
 
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+
+
 class Record extends Component
 {
     public $records, $dataId, $totals;
@@ -15,24 +19,42 @@ class Record extends Component
 
     public $payments = [];
 
+    public $fromDate;
+    public $toDate;
+
+    /*
+    public $days = [];
     public $months = [];
     public $years = [];
+    */
 
     public array $recordDatas = [];
     public array $labels = [];
-
+    /*
+    public $selectedFilterFromDay;
     public $selectedFilterFromMonth;
     public $selectedFilterFromYear;
+    public $selectedFilterToDay;
     public $selectedFilterToMonth;
     public $selectedFilterToYear;
+    */
 
     public function mount()
     {
 
+        $this->fromDate = date("Y-m-01");
+        $this->toDate = date("Y-m-t");
+        /*
+        $this->selectedFilterFromDay = 1;
+        $this->selectedFilterToDay = 31;
         $this->selectedFilterFromMonth = date("n");
         $this->selectedFilterToMonth = date("n");
         $this->selectedFilterFromYear = date("Y");
         $this->selectedFilterToYear = date("Y");
+        for($day = 1; $day <= 31; $day++)
+        {
+            $this->days[] = array('value' => $day, 'text' => $day);
+        }
         for($month = 1; $month <= 12; $month++)
         {
             $this->months[] = array('value' => $month, 'text' => $this->getMonth($month));
@@ -41,7 +63,7 @@ class Record extends Component
         {
             $this->years[] = array('value' => $year, 'text' => $year);
         }
-
+        */
         $this->payments = \App\Models\PaymentMethod::select('id', 'name')->get();
 
     }
@@ -102,22 +124,23 @@ class Record extends Component
         $this->records = array();
         $this->totals = array();
 
+        /*
         $fromDate = '';
         $toDate = '';
 
-        if ($this->selectedFilterFromMonth != '' && $this->selectedFilterFromYear != '')
+        if ($this->selectedFilterFromDay != '' && $this->selectedFilterFromMonth != '' && $this->selectedFilterFromYear != '')
         {
-            $fromDate = date($this->selectedFilterFromYear . "-" . $this->selectedFilterFromMonth . "-01");
+            $fromDate = date($this->selectedFilterFromYear . "-" . $this->selectedFilterFromMonth . "-" . $this->selectedFilterFromDay);
         }
-        if ($this->selectedFilterToMonth != '' && $this->selectedFilterToYear != '')
+        if ($this->selectedFilterToDay != '' && $this->selectedFilterToMonth != '' && $this->selectedFilterToYear != '')
         {
-            $toDate = date($this->selectedFilterToYear . "-" . $this->selectedFilterToMonth . "-t 23:59:59");
+            $toDate = date($this->selectedFilterToYear . "-" . $this->selectedFilterToMonth . "-" . $this->selectedFilterToDay . " 23:59:59");
         }
-
+        */
         $datas = \App\Models\Record::with('member', 'supplier', 'payment_method')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
                     //->where('records_rows.when', 'like', '%' . date("m-Y") . '%')
-                    ->whereBetween('date', [$fromDate, $toDate])
+                    ->whereBetween('date', [$this->fromDate, $this->toDate])
                     ->get();
 
         /*
@@ -376,4 +399,128 @@ class Record extends Component
         return $data;
     }
 
+    public function export()
+    {
+        $letters = array('C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N');
+
+        $spreadsheet = new Spreadsheet();
+        $activeWorksheet = $spreadsheet->getActiveSheet();
+
+        //$activeWorksheet->setCellValue('A1', 'PrimaNota');
+        $activeWorksheet->setCellValue('A1', "Data");
+        $activeWorksheet->setCellValue('B1', "Causale");
+        $idx = 0;
+        foreach($this->payments as $p)
+        {
+            $activeWorksheet->setCellValue($letters[$idx] . '1', $p->name);
+            $idx++;
+            $activeWorksheet->mergeCells($letters[$idx] . '1:' . $letters[$idx] . '1');
+            $idx++;
+        }
+
+        $idx = 0;
+        $activeWorksheet->setCellValue('A2', "");
+        $activeWorksheet->setCellValue('B2', "");
+        foreach($this->payments as $p)
+        {
+            $activeWorksheet->setCellValue($letters[$idx] . '2', "Entrate");
+            $idx++;
+            $activeWorksheet->setCellValue($letters[$idx] . '2', "Uscite");
+            $idx++;
+        }
+
+        $activeWorksheet->getStyle('A1:N1')->getFont()->setBold(true);
+        $activeWorksheet->getStyle('A2:N2')->getFont()->setBold(true);
+        // $activeWorksheet->getStyle('A1:N1')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('00ff00');
+
+        $count = 3;
+
+        $totals = [];
+
+        foreach($this->records as $causal => $record)
+        {
+
+            $check = strpos($causal, "$") ? explode("$", $causal)[1] : $causal;
+            list($d, $c) = explode("§", $check);
+
+            $activeWorksheet->setCellValue('A' . $count, date("d/m/Y", strtotime($d)));
+            $activeWorksheet->setCellValue('B' . $count, $c);
+
+            $idx = 0;
+            foreach($this->payments as $p)
+            {
+                if(isset($record[$p->name]))
+                {
+
+                    if(isset($record[$p->name]["IN"]))
+                    {
+                        $activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($record[$p->name]["IN"]));
+                    }
+                    else
+                    {
+                        $activeWorksheet->setCellValue($letters[$idx] . $count, "");
+                    }
+                    $idx++;
+                    if(isset($record[$p->name]["OUT"]))
+                    {
+                        $activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($record[$p->name]["OUT"]));
+                    }
+                    else
+                    {
+                        $activeWorksheet->setCellValue($letters[$idx] . $count, "");
+                    }
+                    $idx++;
+
+                }
+                else
+                {
+                    $activeWorksheet->setCellValue($letters[$idx] . $count, "");
+                    $idx++;
+                    $activeWorksheet->setCellValue($letters[$idx] . $count, "");
+                    $idx++;
+                }
+            }
+
+            $count += 1;
+
+        }
+
+        $count += 1;
+
+        $idx = 0;
+
+        $activeWorksheet->setCellValue('A' . $count, 'Totale');
+        $activeWorksheet->setCellValue('B' . $count, '');
+        foreach($this->payments as $p)
+        {
+            if(isset($this->totals[$p->name]))
+            {
+                $activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["IN"]));
+                $idx++;
+                $activeWorksheet->setCellValue($letters[$idx] . $count, formatPrice($this->totals[$p->name]["OUT"]));
+                $idx++;
+            }
+            else
+            {
+                $activeWorksheet->setCellValue($letters[$idx] . $count, "0");
+                $idx++;
+                $activeWorksheet->setCellValue($letters[$idx] . $count, "0");
+                $idx++;
+            }
+        }
+
+        $activeWorksheet->getStyle('A' . $count . ':N' . $count)->getFont()->setBold(true);
+
+        $activeWorksheet->getColumnDimension('A')->setWidth(20);
+        $activeWorksheet->getColumnDimension('B')->setWidth(40);
+        foreach($letters as $l)
+            $activeWorksheet->getColumnDimension($l)->setWidth(20);
+
+        $writer = new Xlsx($spreadsheet);
+        $writer->save($path = storage_path('export.xlsx'));
+
+        return response()->download($path)->deleteFileAfterSend();
+
+    }
+
 }

+ 33 - 1
app/Http/Livewire/RecordIN.php

@@ -416,6 +416,8 @@ class RecordIN extends Component
             $this->records = $this->records->sortByDesc('id');
         */
 
+        $this->emit('load-data-table');
+
         return view('livewire.records_in', ['datas' => $datas]);
     }
 
@@ -808,7 +810,8 @@ class RecordIN extends Component
 
     public function delPeriod($idx, $xxx)
     {
-        unset($this->rows[$idx]['when'][$xxx]);
+        array_splice($this->rows[$idx]['when'], $xxx, $xxx);
+        //unset($this->rows[$idx]['when'][$xxx]);
         // $this->emit('load-select');
     }
 
@@ -852,6 +855,30 @@ class RecordIN extends Component
         // $this->emit('load-select');
     }
 
+    public function getVats()
+    {
+        $vats = array();
+        foreach($this->rows as $r)
+        {
+            if ($r["amount"] != null && $r["amount"] != "" && $r["vat_id"] > 0)
+            {
+                $vat = getVatValue($this->currencyToDouble($r["amount"]), $r["vat_id"]);
+                $vatName = "";
+                foreach($this->vats as $v)
+                {
+                    if ($v->id == $r["vat_id"])
+                        $vatName = $v->name;
+                }
+                if (isset($vats[$vatName]))
+                    $vats[$vatName] += $vat;
+                else
+                    $vats[$vatName] = $vat;
+            }
+        }
+        return $vats;
+        // $this->emit('load-select');
+    }
+
     public function setCausal($id, $idx)
     {
         $this->rows[$idx]["causal_id"] = $id;
@@ -889,4 +916,9 @@ class RecordIN extends Component
 
     }
 
+    public function multiPeriodCancel()
+    {
+        $this->multiP = false;
+    }
+
 }

+ 35 - 8
app/Http/Livewire/RecordINOUT.php

@@ -39,9 +39,12 @@ class RecordINOUT extends Component
 
     public $selectedFilter = '';
 
-    public $causals = array();
+    public $causalsIn = array();
+    public $causalsOut = array();
     public $payments = array();
     public $members = array();
+    public $filterCausalsIn = null;
+    public $filterCausalsOut = null;
 
     public function mount()
     {
@@ -56,8 +59,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')->get(), 'IN', 0);
-        $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->get(), 'OUT', 0);
+        $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->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();
 
     }
 
@@ -81,7 +87,7 @@ class RecordINOUT extends Component
 
     public function hydrate()
     {
-        //$this->emit('load-select');
+        $this->emit('load-select');
     }
 
     public function show($m, $y)
@@ -104,10 +110,14 @@ class RecordINOUT extends Component
 
                 $this->columns[] = $filter;
 
+                $f = $filter;
+                if ($m == 'x')
+                    $f = str_replace("x-", "", $filter);
+
                 $records = \App\Models\Record::where('type', 'IN')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
                     ->where('records_rows.causal_id', '<>', $this->borsellino_id)
-                    ->where('records_rows.when', 'like', '%' . $filter . '%')->get();
+                    ->where('records_rows.when', 'like', '%' . $f . '%')->get();
                 //$records = $records->orderBy('date', 'DESC')->get();
 
                 foreach($records as $record)
@@ -132,7 +142,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)
-                    ->where('records_rows.when', 'like', '%' . $filter . '%')->get();
+                    ->where('records_rows.when', 'like', '%' . $f . '%')->get();
                 //$records = $records->orderBy('date', 'DESC')->get();
 
                 foreach($records as $record)
@@ -244,6 +254,9 @@ class RecordINOUT extends Component
         $ret = '';
         list($m, $y) = explode("-", $str);
         switch ($m) {
+            case 'x':
+                $ret = '';
+                break;
             case '01':
                 $ret = 'Gennaio ';
                 break;
@@ -317,9 +330,23 @@ class RecordINOUT extends Component
         $records_in = [];
         $records_out = [];
         $datas = [];
-        for($m=1;$m<=12;$m++)
+        if (env('FISCAL_YEAR_MONTH_FROM', 1) > 1)
         {
-            $datas[] = $m . "-" . $year;
+            for($m=env('FISCAL_YEAR_MONTH_FROM', 1);$m<=12;$m++)
+            {
+                $datas[] = $m . "-" . $year;
+            }
+            for($m=1;$m<=env('FISCAL_YEAR_MONTH_TO', 12);$m++)
+            {
+                $datas[] = $m . "-" . ($year + 1);
+            }
+        }
+        else
+        {
+            for($m=1;$m<=12;$m++)
+            {
+                $datas[] = $m . "-" . $year;
+            }
         }
         foreach($datas as $filter)
         {

+ 1 - 1
app/Http/Livewire/RecordOUT.php

@@ -552,7 +552,7 @@ class RecordOUT extends Component
 
     public function delPeriod($idx, $xxx)
     {
-        unset($this->rows[$idx]['when'][$xxx]);
+        array_splice($this->rows[$idx]['when'], $xxx, $xxx);
         // $this->emit('load-select');
     }
 

+ 2 - 0
app/Http/Livewire/Reminder.php

@@ -132,6 +132,8 @@ class Reminder extends Component
         else
             usort($this->records, function ($a, $b) {return $a[$this->sortField] < $b[$this->sortField];});*/
 
+        $this->emit('load-data-table');
+
         return view('livewire.reminders');
     }
 

+ 4 - 0
app/Models/Member.php

@@ -42,6 +42,10 @@ class Member extends Model
         'mother_mail',
         'mother_phone',
         'mother_fiscal_code',
+        'father_doc_number',
+        'father_doc_type',
+        'mother_doc_number',
+        'mother_doc_type',
         'enabled',
     ];
 

+ 38 - 0
database/migrations/2024_05_22_144500_add_fields_to_members_table.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('members', function (Blueprint $table) {
+            $table->string('father_doc_number')->nullable();
+            $table->string('father_doc_type')->nullable();
+            $table->string('mother_doc_number')->nullable();
+            $table->string('mother_doc_type')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('records_rows', function (Blueprint $table) {
+            $table->dropColumn('father_doc_number');
+            $table->dropColumn('father_doc_type');
+            $table->dropColumn('mother_doc_number');
+            $table->dropColumn('mother_doc_type');
+        });
+    }
+};

+ 4 - 1
resources/views/layouts/app.blade.php

@@ -17,6 +17,9 @@
     background-color: #006099 !important;
     border-color: var(--bs-pagination-active-border-color);
   }
+  .buttons-print, .buttons-csv{
+    background-color: #006099 !important;
+  }
   </style>
 
 </head>
@@ -63,7 +66,7 @@
                     </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">Report</span>
+                            <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Entrate/uscite gestionale</span>
                         </a>
                     </li>
                     <li class="nav-item">

+ 173 - 112
resources/views/livewire/member.blade.php

@@ -199,8 +199,8 @@
 
                             <div class="col-12">
                                 @foreach(getCards() as $card)
-                                    <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                        <input class="form-check-input" type="checkbox" value="{{$card->id}}" wire:model="filterCard">
+                                    <div class="form-check form-check-inline  align-items-center">
+                                        <input class="form-check-input" type="checkbox" value="{{$card->id}}" wire:model="filterCard"  onclick="destroyDataTable()">
                                         <label class="form-check-label ms-2" >{{$card->name}}</label>
                                     </div>
                                 @endforeach
@@ -214,22 +214,22 @@
 
                         <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"  wire:model="filterCertNormal">
+                                <div class="form-check form-check-inline  align-items-center">
+                                    <input class="form-check-input" type="checkbox"  wire:model="filterCertNormal" onclick="destroyDataTable()">
                                     <label class="form-check-label ms-2" >Normale</label>
                                 </div>
-                                <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                    <input class="form-check-input" type="checkbox"  wire:model="filterCertInScadenza">
+                                <div class="form-check form-check-inline  align-items-center">
+                                    <input class="form-check-input" type="checkbox"  wire:model="filterCertInScadenza" onclick="destroyDataTable()">
                                     <label class="form-check-label ms-2" >In Scadenza</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"  wire:model="filterCertAgonistic">
+                                <div class="form-check form-check-inline  align-items-center">
+                                    <input class="form-check-input" type="checkbox"  wire:model="filterCertAgonistic" onclick="destroyDataTable()">
                                     <label class="form-check-label ms-2" >Agonistico</label>
                                 </div>
-                                <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                    <input class="form-check-input" type="checkbox"  wire:model="filterCertScaduto">
+                                <div class="form-check form-check-inline  align-items-center">
+                                    <input class="form-check-input" type="checkbox"  wire:model="filterCertScaduto"  onclick="destroyDataTable()">
                                     <label class="form-check-label ms-2" >Scaduti</label>
                                 </div>
 
@@ -244,8 +244,8 @@
                         <div class="filter--item_formElement row">
                             <div class="col-6">
                                 @foreach(getCategories() as $category)
-                                    <div class="form-check form-check-inline d-inline-flex align-items-center">
-                                        <input class="form-check-input" type="checkbox"  value="{{$category->id}}" wire:model="filterCategory">
+                                    <div class="form-check form-check-inline  align-items-center">
+                                        <input class="form-check-input" type="checkbox"  value="{{$category->id}}" wire:model="filterCategory"  onclick="destroyDataTable()">
                                         <label class="form-check-label ms-2" >{{$category->name}}</label>
                                     </div>
                                 @endforeach
@@ -262,7 +262,7 @@
 
                 <footer>
                     <div class="filter--buttons d-flex align-items-center justify-content-between">
-                        <button class="btn--ui small dark disable"  wire:click.prevent="advancedSearchCancel()">cancella</button><button class="btn--ui small white" wire:click.prevent="advancedSearch()">filtra</button>
+                        <button class="btn--ui small dark disable"  wire:click.prevent="advancedSearchCancel()" onclick="destroyDataTable()">cancella</button><button class="btn--ui small white" onclick="destroyDataTable()" wire:click.prevent="advancedSearch()">filtra</button>
                     </div>
                 </footer>
 
@@ -301,18 +301,20 @@
                         <button type="submit" class="btn--ui" wire:click.prevent="executeMultipleAction()">applica</button>
                     </form>
 
+                    @if(false)
                     <form action="" class="search--form d-flex align-items-center">
                         <div class="input-group mb-3">
                             <input type="text" class="form-control" placeholder="Cerca utente" aria-label="cerca utent" aria-describedby="button-addon2" wire:model="search">
-                            @if(false)
+
                                 @if($showReset)
                                     <button class="btn--ui" type="button" id="button-addon2" wire:click="resetSearch()"><i class="ico--ui search"></i>Reset</button>
                                 @else
                                     <button class="btn--ui" type="button" id="button-addon2" wire:click="search()"><i class="ico--ui search"></i>Cerca</button>
                                 @endif
-                            @endif
+
                         </div>
                     </form>
+                    @endif
                 </section>
 
                 <section id="resume-table">
@@ -516,7 +518,7 @@
                                                         @endif
                                                     </div>
                                                 </div>
-                                                <div class="col-md-6">
+                                                <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">
@@ -527,36 +529,64 @@
                                                 @if($under18)
 
                                                     <div class="col-md-6">
-                                                        <label for="father_name" class="form-label">Nome padre</label>
-                                                        <input class="form-control" type="text" id="father_name" placeholder="Nome padre" wire:model="father_name">
+                                                        <label for="father_name" class="form-label">Nome genitore 1</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 madre</label>
-                                                        <input class="form-control " type="text" id="mother_name" placeholder="Nome madre" wire:model="mother_name">
+                                                        <label for="mother_name" class="form-label">Nome genitore 2</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 padre</label>
-                                                        <input class="form-control" type="text" id="father_email" placeholder="Email padre" wire:model="father_email">
+                                                        <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 madre</label>
-                                                        <input class="form-control " type="text" id="mother_email" placeholder="Email madre" wire:model="mother_email">
+                                                        <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 padre</label>
-                                                        <input class="form-control" type="text" id="father_phone" placeholder="Telefono padre" wire:model="father_phone">
+                                                        <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 madre</label>
-                                                        <input class="form-control " type="text" id="mother_phone" placeholder="Telefono madre" wire:model="mother_phone">
+                                                        <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 padre</label>
-                                                        <input class="form-control" type="text" id="father_fiscal_code" placeholder="Codice fiscale padre" wire:model="father_fiscal_code" maxmaxlength="16">
+                                                        <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 madre</label>
-                                                        <input class="form-control " type="text" id="mother_fiscal_code" placeholder="Codice fiscale madre" wire:model="mother_fiscal_code" maxmaxlength="16">
+                                                        <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="Carta di identità">Carta di identità</option>
+                                                            <option value="Passaporto">Passaporto</option>
+                                                            <option value="Patente">Patente</option>
+                                                            <option value="Permesso di soggiorno">Permesso di soggiorno</option>
+                                                        </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="Carta di identità">Carta di identità</option>
+                                                            <option value="Passaporto">Passaporto</option>
+                                                            <option value="Patente">Patente</option>
+                                                            <option value="Permesso di soggiorno">Permesso di soggiorno</option>
+                                                        </select>
                                                     </div>
 
                                                 @endif
@@ -586,6 +616,14 @@
                                                     </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>
                                                     <div class="col-12">
@@ -602,13 +640,7 @@
                                                     </div>
                                                 </div>-->
 
-                                                <div class="col-md-6">
-                                                    <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"  maxmaxlength="16">
-                                                    @if($this->error_fc)
-                                                        <span style="color:red;font-size:12px">Dati mancanti</span>
-                                                    @endif
-                                                </div>
+
 
                                             </div>
 
@@ -618,75 +650,7 @@
                                         <div class="form--col">
                                             <div class="row g-3" wire:key='reload-{{$selectId}}'>
 
-                                            <span class="title-form primary d-block w-100">Certificato Medico</span>
-
-                                                @if($dataId > -1)
-                                                    @if(!$addCertificate && !$updateCertificate)
-                                                        <table class="table tablesaw tablesaw-stack" >
-                                                            <thead>
-                                                                <tr>
-                                                                    <th scope="col">Tipo</th>
-                                                                    <th scope="col">Scadenza</th>
-                                                                    <th scope="col"></th>
-                                                                    <th scope="col">...</th>
-                                                                </tr>
-                                                            </thead>
-                                                            <tbody >
-                                                                @foreach($member_certificates as $member_certificate)
-                                                                    <tr>
-                                                                        <td>{{$member_certificate->type == 'A' ? 'Agonistico' : 'Non agonistico'}}</td>
-                                                                        <td>{{$member_certificate->expire_date ? date("d/m/Y", strtotime($member_certificate->expire_date)) : ''}}</td>
-                                                                        <td>{!!$member_certificate->filename != '' ? '<a href="/storage/app/public/' . $member_certificate->filename . '" target="_blank">Visualizza</a>' : ''!!}</td>
-                                                                        <td>
-                                                                            <button type="button" class="btn btn-outline-primary btn-sm" wire:click="editCertificate({{ $member_certificate->id }})">Modifica</button>
-                                                                            <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="deleteCertificate({{ $member_certificate->id }})">Elimina</button>
-                                                                        </td>
-                                                                    </tr>
-                                                                @endforeach
-                                                            </tbody>
-                                                        </table>
-                                                        <button class="btn--ui primary"wire:click.prevent="addCertificate()">Aggiungi</button>
-                                                    @else
-
-                                                        <div class="form--wrapper">
-                                                            <form class="form--utente">
-                                                                <div class="row ">
-                                                                    <div class="col-md-6">
-                                                                        <label for="certificate_type" class="form-label">Tipo</label>
-                                                                        <select id="certificate_type" class="form-select certificate_type" aria-label="Tessera" wire:model="certificate_type">
-                                                                            <option value="N">Non agonistico
-                                                                            <option value="A">Agonistico
-                                                                        </select>
-                                                                    </div>
-                                                                    <div class="col-md-6">
-                                                                        <label for="certificate_expire_date" class="form-label">Data scadenza</label>
-                                                                        <input class="form-control @error('certificate_expire_date') is-invalid @enderror" type="date" id="certificate_expire_date" placeholder="Data scadenza" wire:model="certificate_expire_date">
-                                                                    </div>
-                                                                </div>
-                                                                <div class="col-12">
-                                                                    <div class="upload--image_box d-flex align-items-center justify-content-center flex-column">
-                                                                        <input class="form-control" type="file" wire:model="certificate_filename">
-                                                                    </div>
-                                                                    <p class="caption text-center mt-1">Formati consentiti: .jpg, .pdf, .docx</p>
-                                                                    {!!$certificate_filename_old != '' ? '<br><a href="/storage/app/public/' . $certificate_filename_old . '" target="_blank">Visualizza</a>' : ''!!}
-                                                                </div>
-                                                            </form>
-                                                        </div>
-
-                                                        <br>
-                                                        @if($addCertificate)
-                                                            <button class="btn--ui primary" wire:click.prevent="storeCertificate()">Salva</button>
-                                                        @endif
-                                                        @if($updateCertificate)
-                                                            <button class="btn--ui primary" wire:click.prevent="updateCertificate()">Salva</button>
-                                                        @endif
-                                                        <button class="btn--ui primary" wire:click.prevent="cancelCertificate()">Annulla</button>
-
-                                                    @endif
-                                                @else
-                                                    <label for="last_name" class="form-label">Prima di caricare un certificato salva l'utente</label>
 
-                                                @endif
 
                                                 <!--
                                                 <div class="col-12">
@@ -706,7 +670,7 @@
                                                 </div>
                                                 <div class="col-4">
                                                     <label for="zip_code" class="form-label">CAP</label>
-                                                    <input class="form-control" type="number" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5"  >
+                                                    <input class="form-control" type="text" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5"  >
                                                 </div>
                                                 <div class="col-md-12" wire:ignore>
                                                     <label for="nation_id" class="form-label">Nazione</label>
@@ -757,14 +721,92 @@
                                                     <label for="document_expire_date" class="form-label">Scadenza</label>
                                                     <input class="form-control" type="date" id="document_expire_date" placeholder="Scadenza" wire:model="document_expire_date">
                                                 </div>
-                                                <div class="col-6">
+                                                <div class="col-12">
                                                     <label for="document_files" class="form-label">File</label>
                                                     <input class="form-control" type="file" wire:model="documents" multiple><br>
+                                                    <label for="document_files" class="form-label">Caricati</label>
                                                     @foreach ($document_files as $idx => $d)
-                                                        <a href="{{ asset('storage/app/public/'.$d) }}" target="_blank" class="form-label">{{$d}}</a> <a wire:click="removeDocument({{$idx}})" class="form-label">(elimina)</a><br>
+                                                        <div class="row">
+                                                            <div class="col-6">
+                                                                <a href="{{ asset('storage/app/public/'.$d) }}" target="_blank" class="form-label">{{$d}}</a>
+                                                            </div>
+                                                            <div class="col-6">
+                                                                <a wire:click="removeDocument({{$idx}})" class="form-label">(elimina)</a><br>
+                                                            </div>
+                                                        </div>
                                                     @endforeach
                                                 </div>
 
+                                                <span class="title-form primary d-block w-100">Certificato Medico</span>
+
+                                                @if($dataId > -1)
+                                                    @if(!$addCertificate && !$updateCertificate)
+                                                        <table class="table tablesaw tablesaw-stack" >
+                                                            <thead>
+                                                                <tr>
+                                                                    <th scope="col">Tipo</th>
+                                                                    <th scope="col">Scadenza</th>
+                                                                    <th scope="col"></th>
+                                                                    <th scope="col">...</th>
+                                                                </tr>
+                                                            </thead>
+                                                            <tbody >
+                                                                @foreach($member_certificates as $member_certificate)
+                                                                    <tr>
+                                                                        <td>{{$member_certificate->type == 'A' ? 'Agonistico' : 'Non agonistico'}}</td>
+                                                                        <td>{{$member_certificate->expire_date ? date("d/m/Y", strtotime($member_certificate->expire_date)) : ''}}</td>
+                                                                        <td>{!!$member_certificate->filename != '' ? '<a href="/storage/app/public/' . $member_certificate->filename . '" target="_blank">Visualizza</a>' : ''!!}</td>
+                                                                        <td>
+                                                                            <button type="button" class="btn btn-outline-primary btn-sm" wire:click="editCertificate({{ $member_certificate->id }})">Modifica</button>
+                                                                            <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="deleteCertificate({{ $member_certificate->id }})">Elimina</button>
+                                                                        </td>
+                                                                    </tr>
+                                                                @endforeach
+                                                            </tbody>
+                                                        </table>
+                                                        <button class="btn--ui primary"wire:click.prevent="addCertificate()">Aggiungi</button>
+                                                    @else
+
+                                                        <div class="form--wrapper">
+                                                            <form class="form--utente">
+                                                                <div class="row ">
+                                                                    <div class="col-md-6">
+                                                                        <label for="certificate_type" class="form-label">Tipo</label>
+                                                                        <select id="certificate_type" class="form-select certificate_type" aria-label="Tessera" wire:model="certificate_type">
+                                                                            <option value="N">Non agonistico
+                                                                            <option value="A">Agonistico
+                                                                        </select>
+                                                                    </div>
+                                                                    <div class="col-md-6">
+                                                                        <label for="certificate_expire_date" class="form-label">Data scadenza</label>
+                                                                        <input class="form-control @error('certificate_expire_date') is-invalid @enderror" type="date" id="certificate_expire_date" placeholder="Data scadenza" wire:model="certificate_expire_date">
+                                                                    </div>
+                                                                </div>
+                                                                <div class="col-12">
+                                                                    <div class="upload--image_box d-flex align-items-center justify-content-center flex-column">
+                                                                        <input class="form-control" type="file" wire:model="certificate_filename">
+                                                                    </div>
+                                                                    <p class="caption text-center mt-1">Formati consentiti: .jpg, .pdf, .docx</p>
+                                                                    {!!$certificate_filename_old != '' ? '<br><a href="/storage/app/public/' . $certificate_filename_old . '" target="_blank">Visualizza</a>' : ''!!}
+                                                                </div>
+                                                            </form>
+                                                        </div>
+
+                                                        <br>
+                                                        @if($addCertificate)
+                                                            <button class="btn--ui primary" wire:click.prevent="storeCertificate()">Salva</button>
+                                                        @endif
+                                                        @if($updateCertificate)
+                                                            <button class="btn--ui primary" wire:click.prevent="updateCertificate()">Salva</button>
+                                                        @endif
+                                                        <button class="btn--ui primary" wire:click.prevent="cancelCertificate()">Annulla</button>
+
+                                                    @endif
+                                                @else
+                                                    <label for="last_name" class="form-label">Prima di caricare un certificato salva l'utente</label>
+
+                                                @endif
+
                                             </div>
                                     </div>
                                 </form>
@@ -1488,11 +1530,30 @@
         } );
 
         Livewire.on('load-data-table', () => {
-            loadDataTable();
+            setTimeout(function() {loadDataTable()}, 100);
+
+        });
+
+        Livewire.on('destroy-data-table', () => {
+            $('#tablesaw-350').DataTable().destroy();
         });
 
-        function loadDataTable(){
+        function destroyDataTable()
+        {
+            $('#tablesaw-350').DataTable().destroy();
+        }
+
+        function loadDataTable()
+        {
+
+            if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
+                $('#tablesaw-350').DataTable().destroy();
+            }
+
             $('#tablesaw-350').DataTable({
+                //destroy: true,
+                fixedHeader: true,
+                order: [[3, 'asc'], [4, 'asc']],
                 thead: {
                 'th': {'background-color': 'blue'}
                 },

+ 45 - 5
resources/views/livewire/records.blade.php

@@ -8,7 +8,7 @@
 
     </header>
 
-    <section id="subheader" class="d-flex align-items-center justify-content-between">
+    <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" aria-label=".form-select-lg example">
@@ -20,8 +20,17 @@
             <button type="submit" class="btn--ui">applica</button>
         </form>
         -->
-        <form action="" class=" d-flex align-items-center">
-            Da&nbsp;<select class="form-select form-select-lg me-1" wire:model="selectedFilterFromMonth" style="width:150px">
+
+            Dal&nbsp;<input type="date" wire:model="fromDate" class="form-control" style="width:200px;">
+            &nbsp;&nbsp;&nbsp;
+            al&nbsp;<input type="date" wire:model="toDate" class="form-control"  style="width:200px;">
+            @if(false)
+            Da&nbsp;<select class="form-select form-select-lg me-1" wire:model="selectedFilterFromDay" style="width:150px">
+                @foreach($days as $p)
+                    <option value="{{$p["value"]}}">{{$p["text"]}}</option>
+                @endforeach
+            </select>
+            <select class="form-select form-select-lg me-1" wire:model="selectedFilterFromMonth" style="width:150px">
                 @foreach($months as $p)
                     <option value="{{$p["value"]}}">{{$p["text"]}}</option>
                 @endforeach
@@ -32,7 +41,12 @@
                 @endforeach
             </select>
 
-            a&nbsp;&nbsp;<select class="form-select form-select-lg me-1" wire:model="selectedFilterToMonth" style="width:150px">
+            a&nbsp;&nbsp;<select class="form-select form-select-lg me-1" wire:model="selectedFilterToDay" style="width:150px">
+                @foreach($days as $p)
+                    <option value="{{$p["value"]}}">{{$p["text"]}}</option>
+                @endforeach
+            </select>
+            <select class="form-select form-select-lg me-1" wire:model="selectedFilterToMonth" style="width:150px">
                 @foreach($months as $p)
                     <option value="{{$p["value"]}}">{{$p["text"]}}</option>
                 @endforeach
@@ -42,7 +56,10 @@
                     <option value="{{$p["value"]}}">{{$p["text"]}}</option>
                 @endforeach
             </select>
-        </form>
+            @endif
+
+        <button class="btn--ui reset" wire:click="export()" style="margin-left:5px;">esporta</button>
+        <button class="btn--ui reset " style="margin-left:5px;" id="print">stampa</button>
     </section>
 
     <section id="resume-table">
@@ -177,6 +194,29 @@
 
 @push('scripts')
     <script>
+
+        function printData()
+        {
+
+            var divToPrint=document.getElementById("tablesaw-350");
+            newWin= window.open("");
+            var htmlToPrint = '' +
+                '<style type="text/css">' +
+                'table th, table td {' +
+                'border:1px solid #000;' +
+                'padding:0.5em;' +
+                '}' +
+                '</style>';
+            htmlToPrint += divToPrint.outerHTML;
+            newWin.document.write(htmlToPrint);
+            newWin.document.close();
+            newWin.print();
+            newWin.close();
+        }
+
+        document.querySelector("#print").addEventListener("click", function(){
+        printData();
+        });
         /*
         const chart = new Chart(
             document.getElementById('recordChart'), {

+ 77 - 29
resources/views/livewire/records_in.blade.php

@@ -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">
+                            <input class="form-check-input" type="radio" value="0" id="all_commercial" wire:model="filterCommercial" onclick="destroyDataTable()">
                             <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" id="commercial" wire:model="filterCommercial" onclick="destroyDataTable()">
                             <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" id="not_commercial" wire:model="filterCommercial" onclick="destroyDataTable()">
                             <label class="form-check-label ms-2" for="inlineCheckbox1">Non commerciale</label>
                         </div>
                     </div>
@@ -33,7 +33,7 @@
                     <span class="filter--item_title">Persona</span>
 
                     <div class="filter--item_formElement">
-                        <select name="search_member_id" class="form-select filterMember" wire:model="filterMember">
+                        <select name="search_member_id" class="form-select filterMember" wire:model="filterMember" onclick="destroyDataTable()">
                             <option value="">
                             @foreach($members as $member)
                                 <option value="{{$member->id}}">{{$member->last_name}} {{$member->first_name}}
@@ -46,7 +46,7 @@
                     <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">
+                        <select name="search_payment_method_id" class="form-select filterPaymentMethod"  wire:model="filterPaymentMethod" onclick="destroyDataTable()">
                             <option value="">
                             @foreach($payments as $payment)
                                 <option value="{{$payment->id}}">{{$payment->name}}
@@ -60,7 +60,7 @@
                     <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">
+                        <select name="search_causal_id[]" class="form-select filterCausals" multiple="multiple" wire:model="filterCausals"  onclick="destroyDataTable()">
                             <option value="">
                             @foreach($causals as $causal)
                                 <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
@@ -74,10 +74,10 @@
                 <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="date" type="date" class="form-control"  wire:model="filterFrom" style="background-color:white" onclick="destroyDataTable()">
                     </div>
                     <div class="filter--item_formElement">
-                        <input id="date" type="date" class="form-control"  wire:model="filterTo" style="background-color:white">
+                        <input id="date" type="date" class="form-control"  wire:model="filterTo" style="background-color:white" onclick="destroyDataTable()">
                     </div>
 
                 </div>
@@ -130,8 +130,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" wire:click.prevent="disableSearch()" onclick="destroyDataTable()">cancella</button>
+                    <button class="btn--ui small white" wire:click.prevent="search()" onclick="destroyDataTable()">filtra</button>
                 </div>
             </footer>
 
@@ -294,7 +294,7 @@
                                         </div>
                                     </div>
 
-                                    <div class="col-md-6">
+                                    <div class="col-md-6 mt-3">
                                         <span class="title-form d-block w-100">Data pagamento</span>
                                         <div class="input-group mb-3">
                                             <input id="date" type="date" class="form-control"  wire:model="date">
@@ -338,7 +338,7 @@
                                     </div>
                                 </div>
 
-                                <div class="row gx-2 mt-5">
+                                <div class="row gx-2 mt-3">
                                     <span class="title-form d-block w-100">Pagamento</span>
 
                                     <div class="col-md-12" >
@@ -357,7 +357,7 @@
 
                                 @foreach($rows as $idx => $row)
 
-                                    <div class="row gx-2 mt-5" wire:ignore>
+                                    <div class="row gx-2 mt-3" wire:ignore>
                                         <span class="title-form d-block w-100">Causale</span>
                                         <div class="col-md-12">
 
@@ -382,14 +382,14 @@
                                         </div>
                                     </div>
 
-                                    <div class="row gx-2 mt-5">
+                                    <div class="row gx-2 mt-3">
                                         <span class="title-form d-block w-100">Dettaglio causale</span>
                                         <div class="col-md-12">
                                             <input class="form-control " type="text" placeholder="Dettaglio causale" wire:model="rows.{{$idx}}.note">
                                         </div>
                                     </div>
 
-                                    <div class="row gx-2 mt-5 align-items-center">
+                                    <div class="row gx-2 mt-3 align-items-center">
                                         <div class="col-md-6">
                                             <span class="total primary">Importo</span>
                                         </div>
@@ -419,7 +419,7 @@
 
                                     </div>
 
-                                    <div class="row gx-2 mt-5 align-items-center">
+                                    <div class="row gx-2 mt-3 align-items-center">
                                         <div class="col-md-4">
                                             <span class="total primary">Competenza</span>
                                         </div>
@@ -427,7 +427,8 @@
                                             <div class="row">
 
                                                 @if($multiP)
-                                                    <div class="row">
+                                                    <div class="row" style="background-color:lightGrey">
+                                                        <h4>Seleziona inizio e fine multiperiodo</h4>
                                                         <div class="col-md-3">
                                                             <span class="title-form d-block w-100">Dal mese</span>
                                                             <div class="input-group mb-3">
@@ -478,12 +479,20 @@
                                                                 <input type="number" class="form-control"  wire:model="multiYearTo" >
                                                             </div>
                                                         </div>
+                                                        <div class="col-md-6">
+                                                            <button type="button" class="btn--ui primary" wire:click.prevent="multiPeriodCreate({{$idx}})" style="margin-top:20px">
+                                                                Crea multi periodo
+                                                            </button>
+                                                        </div>
+                                                        <div class="col-md-6">
+                                                            <button type="button" class="btn--ui primary" wire:click.prevent="multiPeriodCancel()" style="margin-top:20px">
+                                                                Annulla multi periodo
+                                                            </button>
+                                                        </div>
                                                     </div>
-                                                    <button type="button" class="btn--ui primary" wire:click.prevent="multiPeriodCreate({{$idx}})" style="margin-top:20px">
-                                                        Crea multi periodo
-                                                    </button>
-                                                @else
 
+
+                                                @else
                                                     @foreach($row["when"] as $xxx => $w)
                                                         <div class="col-md-4">
                                                             <span class="title-form d-block w-100">Mese</span>
@@ -512,7 +521,7 @@
                                                         </div>
                                                         <div class="col-md-3">
                                                         <span class="title-form d-block w-100">Valore</span>
-                                                            <span class="netprice_p total--wrapper_netprice"><b>{{$this->currencyToDouble($rows[$idx]["amount"]) > 0 ? formatPrice($this->currencyToDouble($rows[$idx]["amount"]) + getVatValue($this->currencyToDouble($rows[$idx]["amount"]), $rows[$idx]["vat_id"]) / sizeof($rows[$idx]["when"])) : ""}}</b></span>
+                                                            <span class="netprice_p total--wrapper_netprice"><b>{{$this->currencyToDouble($rows[$idx]["amount"]) > 0 ? formatPrice(($this->currencyToDouble($rows[$idx]["amount"]) + getVatValue($this->currencyToDouble($rows[$idx]["amount"]), $rows[$idx]["vat_id"])) / sizeof($rows[$idx]["when"])) : ""}}</b></span>
                                                         </div>
                                                         <div class="col-md-2"><br>
                                                             <button type="button" class="btn--ui primary" wire:click.prevent="delPeriod({{$idx}}, {{$xxx}})" style="float:right">
@@ -580,13 +589,27 @@
                                             <li>
                                                 <span class="evidence_name">{{$this->member->last_name}} {{$this->member->first_name}}</span> ({{$this->member->fiscal_code}})
                                             </li>
-                                            <li><span>Nato/a il {{$this->member->birth_date ? date("d/m/Y", strtotime($this->member->birth_date)) : ''}}</span></li>
+                                            @if  (false)
+                                                <li><span>Nato/a il {{$this->member->birth_date ? date("d/m/Y", strtotime($this->member->birth_date)) : ''}}</span></li>
+                                            @endif
                                         @else
                                             <li>
-                                                <span class="evidence_name">{{$this->member->father_name != '' ? $this->member->father_name : $this->member->mother_name}}</span>
+                                                <span class="evidence_name">
+                                                    @if($this->member->father_name != '' && $this->member->mother_name != '')
+                                                        <select class="form-control">
+                                                            <option value="1">{{$this->member->father_name}}
+                                                            <option value="2">{{$this->member->mother_name}}
+                                                        </select>
+                                                    @else
+                                                        @if($this->member->father_name != '')
+                                                            {{$this->member->father_name}}
+                                                        @else
+                                                            {{$this->member->mother_name}}
+                                                        @endif
+                                                    @endif
+                                                </span>
                                             </li>
                                         @endif
-
                                     </ul>
                                 @endif
                                 <ul class="resume-item date p-0">
@@ -612,9 +635,16 @@
                                     <div class="total--wrapper_amount d-flex align-items-center justify-content-between w-100 mb-3">
                                         <span class="amount_p"><strong>Importo</strong></span><span class="amount_data"><strong>{{$this->getPrice()}}</strong></span>
                                     </div>
-                                    <div class="total--wrapper_amount d-flex align-items-center justify-content-between w-100 mb-3">
-                                        <span class="amount_p"><strong>Iva</strong></span><span class="amount_data"><strong>{{$this->getVat()}}</strong></span>
-                                    </div>
+                                    @if(false)
+                                        <div class="total--wrapper_amount d-flex align-items-center justify-content-between w-100 mb-3">
+                                            <span class="amount_p"><strong>Iva</strong></span><span class="amount_data"><strong>{{$this->getVat()}}</strong></span>
+                                        </div>
+                                    @endif
+                                    @foreach($this->getVats() as $k => $v)
+                                        <div class="total--wrapper_amount d-flex align-items-center justify-content-between w-100 mb-3">
+                                            <span class="amount_p"><strong>{{$k}}</strong></span><span class="amount_data"><strong>{{formatPrice($v)}}</strong></span>
+                                        </div>
+                                    @endforeach
                                     <!--<div class="total--wrapper_tax d-flex align-items-center justify-content-between w-100 mb-2 pb-3">
                                         <span class="taxt_p">Ritenuta d’acconto (20%):</span><span class="tax_data">€ 20,00</span>
                                     </div>-->
@@ -798,6 +828,7 @@
             $('.filterMember').on('change', function (e) {
                 var data = $('.filterMember').select2("val");
                 @this.set('filterMember', data);
+                @this.search();
             });
             $('.filterPaymentMethod').select2();
             $('.filterPaymentMethod').on('change', function (e) {
@@ -830,6 +861,7 @@
         $('.filterMember').on('change', function (e) {
             var data = $('.filterMember').select2("val");
             @this.set('filterMember', data);
+            @this.search();
         });
         $('.filterPaymentMethod').select2();
         $('.filterPaymentMethod').on('change', function (e) {
@@ -859,11 +891,27 @@
         } );
 
         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 loadDataTable(){
+
+            if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
+                $('#tablesaw-350').DataTable().destroy();
+            }
+
             $('#tablesaw-350').DataTable({
+                fixedHeader: true,
                 thead: {
                 'th': {'background-color': 'blue'}
                 },

+ 112 - 47
resources/views/livewire/records_in_out.blade.php

@@ -8,7 +8,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">Report</h2>
+                    <h2 class="primary">Entrate/uscite gestionale</h2>
                 </div>
 
 
@@ -16,9 +16,11 @@
             </header>
 
             <section id="subheader" class="d-flex align-items-center ">
-                <form action="" class=" d-flex align-items-center">
+
+                <form action="" class=" d-flex align-items-center ">
 
                    <select class="form-select form-select-lg me-1 " id="month" style="width:150px !important;">
+                        <option value="x" {{$month == "x" ? 'selected' : ""}}>Anno completo</option>
                         <option value="1" {{$month == "1" ? 'selected' : ""}}>Gennaio</option>
                         <option value="2" {{$month == "2" ? 'selected' : ""}}>Febbraio</option>
                         <option value="3" {{$month == "3" ? 'selected' : ""}}>Marzo</option>
@@ -47,9 +49,12 @@
                 <button class="btn--ui reset" wire:click="clear()" style="margin-left:5px;">reset</button>
                 @if($showData)
                     <button class="btn--ui reset" wire:click="export()" style="margin-left:5px;">esporta</button>
-                    <button class="btn--ui reset exportYear"  style="margin-left:5px;">esporta anno selezionato</button>
+                    <button class="btn--ui reset exportYear"  style="margin-left:5px;">esporta anno fiscale selezionato</button>
                 @endif
 
+
+
+
             </section>
 
 
@@ -62,6 +67,19 @@
 
                             <h1>Entrate</h1>
 
+                            <div class="row ">
+                                <div class="col-md-2">
+                                Filtra per causale
+                                </div>
+                                <div class="col-md-4 m-1">
+                                    <select name="search_causal_id[]" class="form-select filterCausalsIn" multiple="multiple" wire:model="filterCausalsIn">
+                                        @foreach($causalsIn as $causal)
+                                            <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
+                                        @endforeach
+                                    </select>
+                                </div>
+                            </div>
+
                             <table class="table tablesaw tablesaw-stack collaptableIN" >
                                 <thead>
                                     <tr>
@@ -77,23 +95,25 @@
                                 <tbody id="checkall-target">
 
                                     @foreach($rows_in as $in)
-                                        <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)
-                                                <td class="cellBorder" style="text-align:center">
-                                                    @if(isset($records_in[$column][$in["id"]]))
-                                                        <span class="tablesaw-cell-content {{$in["level"] == 0 ? 'primary' : ''}}" {{$in["level"] == 0 ? 'style=""' : 'font-weight:bold;'}}>
-                                                            {{formatPrice($records_in[$column][$in["id"]])}}
-                                                        </span>
-                                                    @else
-                                                        &nbsp;
-                                                    @endif
-                                                </td>
-                                            @endforeach
-                                            @for($j=sizeof($columns);$j<6;$j++)
-                                                <td class="cellBorder">&nbsp;</th>
-                                            @endfor
-                                        </tr>
+                                        @if($filterCausalsIn == null || (sizeof($filterCausalsIn) == 0 || in_array($in["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)
+                                                    <td class="cellBorder" style="text-align:center">
+                                                        @if(isset($records_in[$column][$in["id"]]))
+                                                            <span class="tablesaw-cell-content {{$in["level"] == 0 ? 'primary' : ''}}" {{$in["level"] == 0 ? 'style=""' : 'font-weight:bold;'}}>
+                                                                {{formatPrice($records_in[$column][$in["id"]])}}
+                                                            </span>
+                                                        @else
+                                                            &nbsp;
+                                                        @endif
+                                                    </td>
+                                                @endforeach
+                                                @for($j=sizeof($columns);$j<6;$j++)
+                                                    <td class="cellBorder">&nbsp;</th>
+                                                @endfor
+                                            </tr>
+                                        @endif
                                     @endforeach
                                     <tr>
                                         <td><b>Totale entrate mensili</b></td>
@@ -103,13 +123,15 @@
                                                 $total = 0;
                                                 @endphp
                                                 @foreach($rows_in as $in)
-                                                    @if(isset($records_in[$column][$in["id"]]) && $in["level"] == 0)
-                                                        @php
-                                                        $total += $records_in[$column][$in["id"]];
-                                                        @endphp
+                                                    @if($filterCausalsIn == null || (sizeof($filterCausalsIn) == 0 || in_array($in["id"], $filterCausalsIn)))
+                                                        @if(isset($records_in[$column][$in["id"]]) && $in["level"] == 0)
+                                                            @php
+                                                            $total += $records_in[$column][$in["id"]];
+                                                            @endphp
+                                                        @endif
                                                     @endif
                                                 @endforeach
-                                                <span class="tablesaw-cell-content primary" style="color:green"><b>{{formatPrice($total)}}</b></span>
+                                                <span class="tablesaw-cell-content primary" style="color:green; font-size:18px;"><b>{{formatPrice($total)}}</b></span>
                                             </td>
                                         @endforeach
                                         @for($j=sizeof($columns);$j<6;$j++)
@@ -129,6 +151,19 @@
 
                             <h1>Uscite</h1>
 
+                            <div class="row ">
+                                <div class="col-md-2">
+                                    <label class="form-label">Filtra per causale</label>
+                                </div>
+                                <div class="col-md-4 m-1">
+                                    <select name="search_causal_id_x[]" class="form-select filterCausalsOut" multiple="multiple" wire:model="filterCausalsOut">
+                                        @foreach($causalsOut as $causal)
+                                            <option value="{{$causal["id"]}}">{!!$causal["name"]!!}
+                                        @endforeach
+                                    </select>
+                                </div>
+                            </div>
+
                             <table class="table tablesaw tablesaw-stack collaptableOUT">
                                 <thead>
                                     <tr>
@@ -144,23 +179,25 @@
                                 <tbody id="checkall-target">
 
                                     @foreach($rows_out as $out)
-                                        <tr data-id="{{$out["id"] + 1000}}" data-parent="{{$out["parent_id"] != null ? ($out["parent_id"] + 1000) : 0}}">
-                                            <td>{!!str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $out["level"])!!}{{$out["name"]}}</td>
-                                            @foreach($columns as $column)
-                                                <td class="cellBorder" style="text-align:center">
-                                                    @if(isset($records_out[$column][$out["id"]]))
-                                                        <span class="tablesaw-cell-content {{$out["level"] == 0 ? 'primary' : ''}}"  {{$out["level"] == 0 ? 'style=""' : 'font-weight:bold;'}}>
-                                                        {{formatPrice($records_out[$column][$out["id"]])}}
-                                                        </span>
-                                                    @else
-                                                        &nbsp;
-                                                    @endif
-                                                </td>
-                                            @endforeach
-                                            @for($j=sizeof($columns);$j<6;$j++)
-                                                <td class="cellBorder">&nbsp;</th>
-                                            @endfor
-                                        </tr>
+                                        @if($filterCausalsOut == null || (sizeof($filterCausalsOut) == 0 || in_array($out["id"], $filterCausalsOut)))
+                                            <tr data-id="{{$out["id"] + 1000}}" data-parent="{{$out["parent_id"] != null ? ($out["parent_id"] + 1000) : 0}}">
+                                                <td>{!!str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $out["level"])!!}{{$out["name"]}}</td>
+                                                @foreach($columns as $column)
+                                                    <td class="cellBorder" style="text-align:center">
+                                                        @if(isset($records_out[$column][$out["id"]]))
+                                                            <span class="tablesaw-cell-content {{$out["level"] == 0 ? 'primary' : ''}}"  {{$out["level"] == 0 ? 'style=""' : 'font-weight:bold;'}}>
+                                                            {{formatPrice($records_out[$column][$out["id"]])}}
+                                                            </span>
+                                                        @else
+                                                            &nbsp;
+                                                        @endif
+                                                    </td>
+                                                @endforeach
+                                                @for($j=sizeof($columns);$j<6;$j++)
+                                                    <td class="cellBorder">&nbsp;</th>
+                                                @endfor
+                                            </tr>
+                                        @endif
                                     @endforeach
 
                                     <tr>
@@ -171,13 +208,15 @@
                                                 $total = 0;
                                                 @endphp
                                                 @foreach($rows_out as $out)
-                                                    @if(isset($records_out[$column][$out["id"]]) && $out["level"] == 0)
-                                                        @php
-                                                        $total += $records_out[$column][$out["id"]];
-                                                        @endphp
+                                                    @if($filterCausalsOut == null || (sizeof($filterCausalsOut) == 0 || in_array($out["id"], $filterCausalsOut)))
+                                                        @if(isset($records_out[$column][$out["id"]]) && $out["level"] == 0)
+                                                            @php
+                                                            $total += $records_out[$column][$out["id"]];
+                                                            @endphp
+                                                        @endif
                                                     @endif
                                                 @endforeach
-                                                <span class="tablesaw-cell-content primary" style="color:red"><b>{{formatPrice($total)}}</b></span>
+                                                <span class="tablesaw-cell-content primary" style="color:red; font-size:18px;"><b>{{formatPrice($total)}}</b></span>
                                             </td>
                                         @endforeach
                                         @for($j=sizeof($columns);$j<6;$j++)
@@ -246,6 +285,19 @@
         function load()
         {
             $(document).ready(function(){
+
+                $('.filterCausalsIn').select2();
+                $('.filterCausalsIn').on('change', function (e) {
+                    var data = $('.filterCausalsIn').select2("val");
+                    @this.set('filterCausalsIn', data);
+                });
+
+                $('.filterCausalsOut').select2();
+                $('.filterCausalsOut').on('change', function (e) {
+                    var data = $('.filterCausalsOut').select2("val");
+                    @this.set('filterCausalsOut', data);
+                });
+
                 $('.collaptableIN').aCollapTable({
                     startCollapsed: true,
                     addColumn: false,
@@ -262,6 +314,19 @@
             });
         }
 
+        Livewire.on('load-select', () => {
+            $('.filterCausalsIn').select2();
+            $('.filterCausalsIn').on('change', function (e) {
+                var data = $('.filterCausalsIn').select2("val");
+                @this.set('filterCausalsIn', data);
+            });
+            $('.filterCausalsOut').select2();
+            $('.filterCausalsOut').on('change', function (e) {
+                var data = $('.filterCausalsOut').select2("val");
+                @this.set('filterCausalsOut', data);
+            });
+        });
+
         load();
 
         $(document).on("click", ".show", function () {

+ 1 - 0
resources/views/livewire/records_out.blade.php

@@ -711,6 +711,7 @@
 
         function loadDataTable(){
             $('#tablesaw-350').DataTable({
+                fixedHeader: true,
                 thead: {
                 'th': {'background-color': 'blue'}
                 },

+ 15 - 5
resources/views/livewire/reminders.blade.php

@@ -14,11 +14,11 @@
 
                     <div class="col-12">
                         <div class="form-check form-check-inline d-inline-flex align-items-center">
-                            <input class="form-check-input" type="checkbox" wire:model="filterC">
+                            <input class="form-check-input" type="checkbox" wire:model="filterC" onclick="destroyDataTable()">
                             <label class="form-check-label ms-2" >Certificato</label>
                         </div>
                         <div class="form-check form-check-inline d-inline-flex align-items-center">
-                            <input class="form-check-input" type="checkbox"  wire:model='filterT'>
+                            <input class="form-check-input" type="checkbox"  wire:model='filterT' onclick="destroyDataTable()">
                             <label class="form-check-label ms-2" >Tessera</label>
                         </div>
                     </div>
@@ -41,8 +41,8 @@
 
         <footer>
             <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" wire:click.prevent="disableSearch()" onclick="destroyDataTable()">cancella</button>
+                <button class="btn--ui small white" wire:click.prevent="search()" onclick="destroyDataTable()">filtra</button>
             </div>
         </footer>
 
@@ -131,9 +131,19 @@
         } );
 
         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 loadDataTable(){
             $('#tablesaw-350').DataTable({
                 thead: {

+ 4 - 3
resources/views/livewire/sponsor.blade.php

@@ -158,7 +158,7 @@
                                             <div class="col">
                                                 <div class="form--item">
                                                     <label for="zip_code" class="form-label">CAP</label>
-                                                    <input class="form-control" type="number" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5">
+                                                    <input class="form-control" type="text" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5">
                                                 </div>
                                             </div>
                                         </div>
@@ -193,13 +193,13 @@
                                             <div class="col">
                                                 <div class="form--item">
                                                     <label for="fiscal_code" class="form-label">Codice fiscale</label>
-                                                    <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code"  maxmaxlength="16">
+                                                    <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code"  maxlength="16">
                                                 </div>
                                             </div>
                                             <div class="col">
                                                 <div class="form--item">
                                                     <label for="vat" class="form-label">Partita iva</label>
-                                                    <input class="form-control" type="text" id="vat" placeholder="Partita iva" wire:model="vat" maxmaxlength="11">
+                                                    <input class="form-control" type="text" id="vat" placeholder="Partita iva" wire:model="vat" maxlength="11">
                                                 </div>
                                             </div>
                                         </div>
@@ -487,6 +487,7 @@
 
         function loadDataTable(){
             $('#tablesaw-350').DataTable({
+                fixedHeader: true,
                 thead: {
                 'th': {'background-color': 'blue'}
                 },

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

@@ -110,7 +110,7 @@
                             <div class="col">
                                 <div class="form--item">
                                     <label for="zip_code" class="form-label">CAP</label>
-                                    <input class="form-control" type="number" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5">
+                                    <input class="form-control" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5">
                                 </div>
                             </div>
                         </div>
@@ -145,13 +145,13 @@
                             <div class="col">
                                 <div class="form--item">
                                     <label for="fiscal_code" class="form-label">Codice fiscale</label>
-                                    <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code" maxmaxlength="16">
+                                    <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code" maxlength="16">
                                 </div>
                             </div>
                             <div class="col">
                                 <div class="form--item">
                                     <label for="vat" class="form-label">Partita iva</label>
-                                    <input class="form-control" type="text" id="vat" placeholder="Partita iva" wire:model="vat" maxmaxlength="11">
+                                    <input class="form-control" type="text" id="vat" placeholder="Partita iva" wire:model="vat" maxlength="11">
                                 </div>
                             </div>
                         </div>
@@ -375,6 +375,7 @@
 
         function loadDataTable(){
             $('#tablesaw-350').DataTable({
+                fixedHeader: true,
                 thead: {
                 'th': {'background-color': 'blue'}
                 },