Parcourir la source

Ultimi fix corsi

Luca Parisio il y a 1 an
Parent
commit
eaabb40809

+ 7 - 6
app/Http/Livewire/Causals.php

@@ -12,6 +12,7 @@ class Causals extends Component
     public $level_3_id = 0;
 
     public $type = '';
+    public $emit = 'setCausal';
     public $idx = -1;
     public $causal_id = null;
 
@@ -44,19 +45,19 @@ class Causals extends Component
     }
 
     public function updatedLevel1Id() {
-        $this->emit('setCausal', null, $this->idx);
+        $this->emit($this->emit, null, $this->idx);
         $this->level_2_id = 0;
         $this->level_2 = [];
         $this->level_3_id = 0;
         $this->level_3 = [];
     }
     public function updatedLevel2Id() {
-        $this->emit('setCausal', null, $this->idx);
+        $this->emit($this->emit, null, $this->idx);
         $this->level_3_id = 0;
         $this->level_3 = [];
     }
     public function updatedLevel3Id() {
-        $this->emit('setCausal', null, $this->idx);
+        $this->emit($this->emit, null, $this->idx);
     }
 
     public function render()
@@ -67,7 +68,7 @@ class Causals extends Component
             $this->level_2 = \App\Models\Causal::where('parent_id', $this->level_1_id)->where('type', $this->type)->orderBy('name')->get();
             if (sizeof($this->level_2) == 0)
             {
-                $this->emit('setCausal', $this->level_1_id, $this->idx);
+                $this->emit($this->emit, $this->level_1_id, $this->idx);
                 $reset = true;
             }
         }
@@ -76,13 +77,13 @@ class Causals extends Component
             $this->level_3 = \App\Models\Causal::where('parent_id', $this->level_2_id)->where('type', $this->type)->orderBy('name')->get();
             if (sizeof($this->level_3) == 0)
             {
-                $this->emit('setCausal', $this->level_2_id, $this->idx);
+                $this->emit($this->emit, $this->level_2_id, $this->idx);
                 $reset = true;
             }
         }
         if ($this->level_3_id > 0)
         {
-            $this->emit('setCausal', $this->level_3_id, $this->idx);
+            $this->emit($this->emit, $this->level_3_id, $this->idx);
             $reset = true;
         }
         $this->level_1 = \App\Models\Causal::where('parent_id', null)->where('type', $this->type)->orderBy('name')->get();

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

@@ -7,7 +7,7 @@ use Livewire\Component;
 class Course extends Component
 {
 
-    protected $listeners = ['setCausal' => 'setCausal'];
+    protected $listeners = ['setCausal' => 'setCausal', 'setSubscriptionCausal' => 'setSubscriptionCausal'];
 
     public $records, $parent_id, $name, $enabled, $dataId, $update = false, $add = false;
     public $course_type_id,
@@ -15,10 +15,12 @@ class Course extends Component
         $course_frequency_id,
         $course_level_id,
         $causal_id,
+        $sub_causal_id,
         $max_members,
         $instructor,
         $year,
         $price,
+        $subscription_price,
         $months,
         $date_from, $date_to;
 
@@ -31,6 +33,7 @@ class Course extends Component
     public $monthList = [];
 
     public $typeIN = 'IN';
+    public $setSubscriptionCausal = 'setSubscriptionCausal';
 
     // public $selectedMonthList = [];
 
@@ -40,11 +43,14 @@ class Course extends Component
         'course_duration_id' => 'required',
         'course_frequency_id' => 'required',
         'course_level_id' => 'required',
-        'causal_id' => 'required'
+        'causal_id' => 'required',
+        'sub_causal_id' => 'required',
     ];
 
     protected $messages = [
-        'name.required' => 'Il nome è obbligatorio'
+        'name.required' => 'Il nome è obbligatorio',
+        'causal_id' => 'Campo obbligatorio',
+        'sub_causal_id' => 'Campo obbligatorio',
     ];
 
     public function resetFields(){
@@ -55,10 +61,12 @@ class Course extends Component
         $this->course_frequency_id = null;
         $this->course_level_id = null;
         $this->causal_id = null;
+        $this->sub_causal_id = null;
         $this->max_members = 0;
         $this->instructor = '';
         $this->year = date("Y");
         $this->price = 0;
+        $this->subscription_price = 0;
         $this->date_from = null;
         $this->date_to = null;
         $this->months = array();
@@ -100,6 +108,7 @@ class Course extends Component
         $this->resetFields();
         $this->add = true;
         $this->update = false;
+        $this->emit('setEdit', true);
     }
 
     /*
@@ -125,16 +134,19 @@ class Course extends Component
                 'date_from' => $this->date_from,
                 'date_to' => $this->date_to,
                 'causal_id' => $this->causal_id,
+                'sub_causal_id' => $this->sub_causal_id,
                 'max_members' => $this->max_members,
                 'instructor' => $this->instructor,
                 'year' => $this->year,
                 'price' => currencyToDouble($this->price),
+                'subscription_price' => currencyToDouble($this->subscription_price),
                 'months' => json_encode($this->months),
                 'enabled' => $this->enabled
             ]);
             session()->flash('success','Corso creato');
             $this->resetFields();
             $this->add = false;
+            $this->emit('setEdit', false);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
@@ -156,15 +168,18 @@ class Course extends Component
                 $this->date_from = $course->date_from;
                 $this->date_to = $course->date_to;
                 $this->causal_id = $course->causal_id;
+                $this->sub_causal_id = $course->sub_causal_id;
                 $this->max_members = $course->max_members;
                 $this->instructor = $course->instructor;
                 $this->year = $course->year;
                 $this->price = formatPrice($course->price);
+                $this->subscription_price = formatPrice($course->subscription_price);
                 $this->months = json_decode($course->months);
                 $this->dataId = $course->id;
                 $this->update = true;
                 $this->add = false;
             }
+            $this->emit('setEdit', true);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
@@ -184,16 +199,19 @@ class Course extends Component
                 'date_from' => $this->date_from,
                 'date_to' => $this->date_to,
                 'causal_id' => $this->causal_id,
+                'sub_causal_id' => $this->sub_causal_id,
                 'max_members' => $this->max_members,
                 'instructor' => $this->instructor,
                 'year' => $this->year,
                 'price' => currencyToDouble($this->price),
+                'subscription_price' => currencyToDouble($this->subscription_price),
                 'months' => json_encode($this->months),
                 'enabled' => $this->enabled
             ]);
             session()->flash('success','Corso aggiornato');
             $this->resetFields();
             $this->update = false;
+            $this->emit('setEdit', false);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
@@ -204,6 +222,7 @@ class Course extends Component
         $this->add = false;
         $this->update = false;
         $this->resetFields();
+        $this->emit('setEdit', false);
     }
 
     public function delete($id)
@@ -221,4 +240,9 @@ class Course extends Component
         $this->causal_id = $id;
     }
 
+    public function setSubscriptionCausal($id, $idx)
+    {
+        $this->sub_causal_id = $id;
+    }
+
 }

+ 62 - 1
app/Http/Livewire/CourseMember.php

@@ -13,6 +13,7 @@ class CourseMember extends Component
     public $course_durations = [];
     public $course_types = [];
     public $course_levels = [];
+    public $course_years = [];
 
     public $filterCourse = "";
     public $filterLevel = "";
@@ -21,6 +22,14 @@ class CourseMember extends Component
     public $filterDays = "";
     public $filterHours = "";
     public $filterSubscription = "";
+    public $filterStatus = "";
+    public $filterYear = "";
+
+    public $chkCertificateNormal = 0;
+    public $chkCertificateAgonistico = 0;
+    public $chkCertificateScaduti = 0;
+    public $chkCertificateScadenza = 0;
+    public $chkCard = [];
 
     public function mount()
     {
@@ -28,6 +37,7 @@ class CourseMember extends Component
         $this->course_types = \App\Models\CourseType::select('*')->where('enabled', true)->get();
         $this->course_durations = \App\Models\CourseDuration::select('*')->where('enabled', true)->get();
         $this->course_levels = \App\Models\CourseLevel::select('*')->where('enabled', true)->get();
+        $this->course_years = \App\Models\Course::select('year')->where('year', '<>', '')->groupBy('year')->pluck('year');
         $this->courses = \App\Models\Course::select('*')->orderBy('name', 'ASC')->get();
 
     }
@@ -69,7 +79,52 @@ class CourseMember extends Component
             $course_ids = \App\Models\MemberCourse::where('subscribed', $this->filterSubscription == 1 ? true : false)->pluck('id');
             $datas = $datas->whereIn('course_id', $course_ids);
         }
-        $this->records = $datas->get();
+        if ($this->chkCertificateNormal > 0)
+        {
+            $normal = \App\Models\MemberCertificate::where('type', 'N')->pluck('member_id');
+            $datas = $datas->whereIn('member_id', $normal);;
+        }
+        if ($this->chkCertificateAgonistico > 0)
+        {
+            $agonistic = \App\Models\MemberCertificate::where('type', 'A')->pluck('member_id');
+            $datas = $datas->whereIn('member_id', $agonistic);
+        }
+        if ($this->chkCertificateScaduti > 0)
+        {
+            $scaduto = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
+            $datas = $datas->whereIn('member_id', $scaduto);
+        }
+        if ($this->chkCertificateScadenza > 0)
+        {
+            $scadenza = \App\Models\MemberCertificate::whereBetween('expire_date', [date("Y-m-d"), date("Y-m-d", strtotime("+1 month"))])->pluck('member_id');
+            $datas = $datas->whereIn('member_id', $scadenza);
+        }
+        if (sizeof($this->chkCard) > 0)
+        {
+            $card_ids = \App\Models\MemberCard::whereIn('card_id', $this->chkCard)->pluck('member_id');
+            $datas = $datas->whereIn('member_id', $card_ids);
+        }
+        if ($this->filterYear != "")
+        {
+            $course_ids = \App\Models\Course::where('year', $this->filterYear)->pluck('id');
+            $datas = $datas->whereIn('course_id', $course_ids);
+        }
+
+        $aRet = [];
+        if ($this->filterStatus != "")
+        {
+            foreach($datas->get() as $aaa)
+            {
+
+                $state = \App\Models\Member::findOrFail($aaa->member_id)->isActive();
+                if ($state["status"] == $this->filterStatus)
+                    $aRet[] = $aaa;
+            }
+        }
+        else
+            $aRet = $datas->get();
+
+        $this->records = $aRet;;
 
         $this->emit('load-data-table');
 
@@ -91,6 +146,12 @@ class CourseMember extends Component
         $this->filterDays = "";
         $this->filterHours = "";
         $this->filterSubscription = "";
+        $this->filterStatus = "";
+        $this->chkCertificateNormal = 0;
+        $this->chkCertificateAgonistico = 0;
+        $this->chkCertificateScaduti = 0;
+        $this->chkCertificateScadenza = 0;
+        $this->chkCard = [];
 
     }
 

+ 9 - 2
app/Http/Livewire/Member.php

@@ -499,10 +499,12 @@ class Member extends Component
         {
             $c = \App\Models\Course::findOrFail($this->course_course_id);
             $this->course_price = formatPrice($c->price);
+            $this->course_subscription_price = formatPrice($c->subscription_price);
         }
         else
         {
             $this->course_price = 0;
+            $this->course_subscription_price = 0;
         }
     }
 
@@ -545,6 +547,7 @@ class Member extends Component
         $this->resetFields();
         $this->add = true;
         $this->update = false;
+        $this->emit('setEdit', true);
     }
 
     public function store($close)
@@ -618,6 +621,7 @@ class Member extends Component
             {
                 $this->edit($member->id);
             }
+            $this->emit('setEdit', false);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
@@ -632,6 +636,7 @@ class Member extends Component
 
     public function edit($id){
         $this->showDetail = false;
+        $this->emit('setEdit', true);
         $this->emit('hide-search');
         try {
             $member = \App\Models\Member::findOrFail($id);
@@ -767,6 +772,7 @@ class Member extends Component
                 $this->resetFields();
                 $this->update = false;
             }
+            $this->emit('setEdit', false);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
@@ -778,6 +784,7 @@ class Member extends Component
         $this->update = false;
         $this->showDetail = false;
         $this->resetFields();
+        $this->emit('setEdit', false);
     }
 
     public function delete($id)
@@ -981,7 +988,7 @@ class Member extends Component
     public function storeCourse()
     {
 
-        $this->validate(['course_course_id' => 'required', 'course_status' => 'required', 'course_course_subscription_id' => 'required']);
+        $this->validate(['course_course_id' => 'required', 'course_course_subscription_id' => 'required']);
         try {
 
             \App\Models\MemberCourse::create([
@@ -1374,7 +1381,7 @@ class Member extends Component
     public function newPayment($course)
     {
         $c = \App\Models\Course::findOrFail($course["course_id"]);
-        return redirect()->to('/in?new=1&memberId=' . $this->dataId . '&causalId=' . $c->causal_id . '&createSubscription=' . $this->createSubscription .  (sizeof($this->payMonths) > 0 ? '&months=' . implode("|", $this->payMonths) : "") . '&price=' . $course["price"] . '&subscription_price=' . $course["subscription_price"] . "&courseId=" . $course["id"]);
+        return redirect()->to('/in?new=1&memberId=' . $this->dataId . '&causalId=' . $c->causal_id . '&subCausalId=' . $c->sub_causal_id . '&createSubscription=' . $this->createSubscription .  (sizeof($this->payMonths) > 0 ? '&months=' . implode("|", $this->payMonths) : "") . '&price=' . $course["price"] . '&subscription_price=' . $course["subscription_price"] . "&courseId=" . $course["id"]);
 
     }
 

+ 16 - 3
app/Http/Livewire/RecordIN.php

@@ -274,9 +274,12 @@ class RecordIN extends Component
                 $this->edit($_GET["id"]);
             }
             $count = 0;
-            $this->courseId = $_GET["courseId"];
-            $mc = \App\Models\MemberCourse::findOrFail($this->courseId);
-            $course = \App\Models\Course::findOrFail($mc->course_id);
+            if (isset($_GET["courseId"]))
+            {
+                $this->courseId = $_GET["courseId"];
+                $mc = \App\Models\MemberCourse::findOrFail($this->courseId);
+                $course = \App\Models\Course::findOrFail($mc->course_id);
+            }
             if (isset($_GET["months"]))
             {
 
@@ -308,6 +311,11 @@ class RecordIN extends Component
                 $this->rows[$count]["causal_id"] = null;
                 $this->rows[$count]["amount"] = formatPrice($price);
                 $this->rows[$count]["note"] = "Pagamento iscrizione " . $course->name;
+                if (isset($_GET["subCausalId"]))
+                {
+                    $this->refreshAfter = 1;
+                    $this->rows[$count]["causal_id"] = $_GET["subCausalId"];
+                }
             }
         }
         $this->first = false;
@@ -353,6 +361,7 @@ class RecordIN extends Component
         $this->resetFields();
         $this->add = true;
         $this->update = false;
+        $this->emit('setEdit', true);
     }
 
     public function store($generate)
@@ -441,6 +450,7 @@ class RecordIN extends Component
             $this->resetFields();
             $this->add = false;
             $this->isDuplicate = false;
+            $this->emit('setEdit', false);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
@@ -462,6 +472,7 @@ class RecordIN extends Component
     }
 
     public function edit($id){
+        $this->emit('setEdit', true);
         //if ($this->hasFilter)
             $this->emit('hide-search');
         $this->emit('load-select');
@@ -566,6 +577,7 @@ class RecordIN extends Component
             $this->resetFields();
             $this->update = false;
             $this->isDuplicate = false;
+            $this->emit('setEdit', false);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
@@ -588,6 +600,7 @@ class RecordIN extends Component
         $this->add = false;
         $this->update = false;
         $this->resetFields();
+        $this->emit('setEdit', false);
     }
 
     public function delete($id)

+ 5 - 0
app/Http/Livewire/RecordOUT.php

@@ -295,6 +295,7 @@ class RecordOUT extends Component
         $this->resetFields();
         $this->add = true;
         $this->update = false;
+        $this->emit('setEdit', true);
     }
 
     public function store()
@@ -341,12 +342,14 @@ class RecordOUT extends Component
             session()->flash('success','Movimento creato');
             $this->resetFields();
             $this->add = false;
+            $this->emit('setEdit', false);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
     }
 
     public function edit($id){
+        $this->emit('setEdit', true);
         $this->emit('load-select');
         //if ($this->hasFilter)
             $this->emit('hide-search');
@@ -431,6 +434,7 @@ class RecordOUT extends Component
             session()->flash('success','Movimento aggiornato');
             $this->resetFields();
             $this->update = false;
+            $this->emit('setEdit', false);
         } catch (\Exception $ex) {
             session()->flash('error','Errore (' . $ex->getMessage() . ')');
         }
@@ -440,6 +444,7 @@ class RecordOUT extends Component
     {
         $this->add = false;
         $this->update = false;
+        $this->emit('setEdit', false);
         $this->resetFields();
     }
 

+ 8 - 1
app/Models/Course.php

@@ -24,7 +24,9 @@ class Course extends Model
         'course_frequency_id',
         'course_level_id',
         'enabled',
-        'year'
+        'year',
+        'subscription_price',
+        'sub_causal_id'
     ];
 
     public function parent()
@@ -109,4 +111,9 @@ class Course extends Model
         }
     }
 
+    public function getCount()
+    {
+        return \App\Models\MemberCourse::where('course_id', $this->id)->count();
+    }
+
 }

+ 1 - 1
database/migrations/2024_07_26_164400_add_year_to_courses_table.php

@@ -14,7 +14,7 @@ return new class extends Migration
     public function up()
     {
         Schema::table('courses', function (Blueprint $table) {
-            $table->integer('year')->nullable();
+            $table->string('year')->nullable();
         });
     }
 

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

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('courses', function (Blueprint $table) {
+            $table->decimal('subscription_price', $precision = 8, $scale = 2);
+            $table->unsignedBigInteger('sub_causal_id')->nullable(true);
+            $table->foreign('sub_causal_id')->references('id')->on('causals')->onUpdate('cascade')->onDelete('cascade');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('courses', function (Blueprint $table) {
+            $table->dropColumn('subscription_price');
+            $table->dropColumn('sub_causal_id');
+        });
+    }
+};

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

@@ -64,11 +64,13 @@
                             <i class="ico--ui ico--ui_menu fornitori"></i> <span class="ms-3 d-none d-md-inline">Fornitori</span>
                         </a>
                     </li>
+                    <!--
                     <li class="nav-item sponsors">
                         <a href="/sponsors" 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">Sponsor</span>
                         </a>
                     </li>
+                    -->
                 </ul>
 
                 <ul class="nav nav-pills flex-column align-items-center align-items-sm-start w-100" id="menu-contabilita">

+ 47 - 4
resources/views/livewire/course.blade.php

@@ -27,8 +27,14 @@
                 <thead>
                     <tr>
                         <th scope="col">Nome</th>
-                        <th scope="col">Tipologia</th>
+                        <th scope="col">Livello</th>
+                        <th scope="col">Frequenza</th>
                         <th scope="col">Durata</th>
+                        <th scope="col">Data inizio/fine</th>
+                        <th scope="col">Istruttore</th>
+                        <th scope="col">N° partecipanti</th>
+                        <th scope="col">Prezzo mensile</th>
+                        <th scope="col">Causale</th>
                         <th scope="col">...</th>
                     </tr>
                 </thead>
@@ -36,8 +42,14 @@
                     @foreach($records as $record)
                         <tr>
                             <td>{{$record->name}}</td>
-                            <td>{{$record->type->name ?? ""}}</td>
+                            <td>{{$record->level->name ?? ""}}</td>
+                            <td>{{$record->frequency->name ?? ""}}</td>
                             <td>{{$record->duration->name ?? ""}}</td>
+                            <td>{{$record->date_from != null ? date("d/m/Y", strtotime($record->date_from)) : ""}} - {{$record->date_to != null ? date("d/m/Y", strtotime($record->date_to)) : ""}}</td>
+                            <td>{{$record->instructor ?? ""}}</td>
+                            <td>{{$record->getCount()}}</td>
+                            <td>{{formatPrice($record->price)}}</td>
+                            <td></td>
                             <td>
                                 <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
                                 <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
@@ -140,6 +152,15 @@
                                     @enderror
                                 </div>
                             </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Prezzo iscrizione</label>
+                                    <input class="form-control js-keyupTitle @error('subscription_price') is-invalid @enderror" type="text" id="subscription_price" onkeyup="onlyNumberAmount(this)" placeholder="€ 0,00" wire:model="subscription_price">
+                                    @error('subscription_price')
+                                        <div class="invalid-feedback">{{ $message }}</div>
+                                    @enderror
+                                </div>
+                            </div>
                             <div class="col-6">
                                 <div class="form--item">
                                     <label for="inputName" class="form-label">Causale</label>
@@ -147,7 +168,15 @@
                                     @error('causal_id')
                                         <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
                                     @enderror
-
+                                </div>
+                            </div>
+                            <div class="col-6">
+                                <div class="form--item">
+                                    <label for="inputName" class="form-label">Causale iscrizione</label>
+                                    <livewire:causals :type="$typeIN" :idx="0" :causal_id="$sub_causal_id" :wire:key="0" :emit="$setSubscriptionCausal" />
+                                    @error('sub_causal_id')
+                                        <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
+                                    @enderror
                                 </div>
                             </div>
                             <div class="col-6">
@@ -171,7 +200,7 @@
                             <div class="col-6">
                                 <div class="form--item">
                                     <label for="inputName" class="form-label">Anno</label>
-                                    <input class="form-control js-keyupTitle @error('year') is-invalid @enderror" type="number" id="year" placeholder="Anno" wire:model="year">
+                                    <input class="form-control js-keyupTitle @error('year') is-invalid @enderror" type="text" id="year" placeholder="Anno" wire:model="year">
                                     @error('year')
                                         <div class="invalid-feedback">{{ $message }}</div>
                                     @enderror
@@ -232,6 +261,20 @@
             input.value = "€ " + v.replace(/(\d)(\d\d)$/, "$1,$2").replace(/(^\d{1,3}|\d{3})(?=(?:\d{3})+(?:,|$))/g, '$1.');
         }
 
+        var isEdit = false;
+
+        Livewire.on('setEdit', (x) =>
+        {
+            isEdit = x;
+            console.log(isEdit);
+        });
+
+        window.onbeforeunload = function(){
+            if (isEdit)
+                return 'Cambiando pagina le eventuali modifiche andranno perse';
+
+        };
+
     </script>
 
 @endpush

+ 13 - 11
resources/views/livewire/course_duration.blade.php

@@ -21,7 +21,7 @@
             <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
-                        <th scope="col">Nome</th>
+                        <th scope="col">Durata</th>
                         <th scope="col">Mesi</th>
                         <th scope="col">Abilitato</th>
                         <th scope="col">...</th>
@@ -63,22 +63,24 @@
                         <div class="row mb-3">
                             <div class="col">
                                 <div class="form--item">
-                                    <label for="inputName" class="form-label">Nome</label>
-                                    <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
+                                    <label for="inputName" class="form-label">Durata</label>
+                                    <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Durata" wire:model="name">
                                     @error('name')
                                         <div class="invalid-feedback">{{ $message }}</div>
                                     @enderror
                                 </div>
                             </div>
-                            <div class="col">
-                                <div class="form--item">
-                                    <label for="inputDuration" class="form-label">Durata</label>
-                                    <input class="form-control js-keyupTitle @error('duration') is-invalid @enderror" type="text" id="duration" placeholder="Valore" wire:model="duration" type="number">
-                                    @error('duration')
-                                        <div class="invalid-feedback">{{ $message }}</div>
-                                    @enderror
+                            @if(false)
+                                <div class="col">
+                                    <div class="form--item">
+                                        <label for="inputDuration" class="form-label">Durata</label>
+                                        <input class="form-control js-keyupTitle @error('duration') is-invalid @enderror" type="text" id="duration" placeholder="Valore" wire:model="duration" type="number">
+                                        @error('duration')
+                                            <div class="invalid-feedback">{{ $message }}</div>
+                                        @enderror
+                                    </div>
                                 </div>
-                            </div>
+                            @endif
                             <div class="col">
                                 <div class="form-check form-check-inline">
                                     <input class="form-check-input" type="checkbox" id="enabled" wire:model="enabled">

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

@@ -89,6 +89,20 @@
                 </div>
             </div>
 
+            <div class="filter--item">
+                <span class="filter--item_title">Anno</span>
+
+                <div class="filter--item_formElement">
+                    <select class="form-select" wire:model="filterYear" onchange="destroyDataTable()">
+                        <option value="">--Seleziona--
+                        @foreach($course_years as $c)
+                            <option value="{{$c}}">{{$c}}
+                        @endforeach
+                    </select>
+                </div>
+
+            </div>
+
             <div class="filter--item">
                 <span class="filter--item_title">Pagamento iscrizione</span>
 
@@ -101,6 +115,65 @@
                 </div>
             </div>
 
+            <div class="filter--item">
+                <span class="filter--item_title">Tipologia di Tesseramento</span>
+
+                <div class="filter--item_formElement row">
+
+                    <div class="col-12">
+                        @foreach(getCards() as $card)
+                            <div class="form-check form-check-inline  align-items-center">
+                                <input class="form-check-input chkCard" type="checkbox" value="{{$card->id}}" wire:model="chkCard" onclick="destroyDataTable()">
+                                <label class="form-check-label ms-2" >{{$card->name}}</label>
+                            </div>
+                        @endforeach
+                    </div>
+                </div>
+            </div>
+            <!-- filter item -->
+
+            <div class="filter--item">
+                <span class="filter--item_title">Stato tesseramento</span>
+
+                <div class="filter--item_formElement">
+                    <select class="form-select" wire:model="filterStatus" onchange="destroyDataTable()">
+                        <option value="">--Seleziona--
+                        <option value="2">Attivo
+                        <option value="1">Sospeso
+                        <option value="0">Non tesserato
+                    </select>
+                </div>
+
+            </div>
+
+            <div class="filter--item">
+                <span class="filter--item_title">Certificato Medico</span>
+
+                <div class="filter--item_formElement row">
+                    <div class="col-6">
+                        <div class="form-check form-check-inline  align-items-center">
+                            <input class="form-check-input chkCertificateNormal" type="checkbox" wire:model="chkCertificateNormal" onclick="destroyDataTable()" value="1">
+                            <label class="form-check-label ms-2" >Normale</label>
+                        </div>
+                        <div class="form-check form-check-inline  align-items-center">
+                            <input class="form-check-input chkCertificateScadenza" type="checkbox" wire:model="chkCertificateScadenza" onclick="destroyDataTable()"  value="1">
+                            <label class="form-check-label ms-2" >In Scadenza</label>
+                        </div>
+                    </div>
+                    <div class="col-6">
+                        <div class="form-check form-check-inline  align-items-center">
+                            <input class="form-check-input chkCertificateAgonistico" type="checkbox" wire:model="chkCertificateAgonistico" onclick="destroyDataTable()" value="1">
+                            <label class="form-check-label ms-2" >Agonistico</label>
+                        </div>
+                        <div class="form-check form-check-inline  align-items-center">
+                            <input class="form-check-input chkCertificateScaduti" type="checkbox" wire:model="chkCertificateScaduti" onclick="destroyDataTable()" value="1">
+                            <label class="form-check-label ms-2" >Scaduti</label>
+                        </div>
+
+                    </div>
+                </div>
+            </div>
+
         </form>
 
         <footer>

+ 20 - 3
resources/views/livewire/member.blade.php

@@ -187,7 +187,7 @@
 
             <div class="service--button d-md-flex align-items-center ">
                 <button class="btn--ui lightGrey"  type="submit" wire:click.prevent="cancel()" style="margin-right:10px">annulla</button>
-                <button class="btn--ui_outline btn-large" style="margin-right:10px"><i class="ico--ui utenti"></i>stampa profilo</button>
+                <!--<button class="btn--ui_outline btn-large" style="margin-right:10px"><i class="ico--ui utenti"></i>stampa profilo</button>-->
                 <div class="payment_btn">
                     <a href="/in?new=1&memberId={{$currentMember->id}}" class="btn--ui btn-large primary me-md-2"><i class="ico--ui tessera"></i>nuovo pagamento</a>
                     <!--<button class="btn--ui btn-large primary"><i class="ico--ui corsi"></i>pagamento corso</button>-->
@@ -1024,10 +1024,10 @@
                                                             <b>{{$member_course->course->name}}</b><br>
                                                         </td>
                                                         <td style="width:10%">
-                                                            {{$member_course->course->type->name}}<br>
+                                                            {{$member_course->course->type->name ?? ""}}<br>
                                                         </td>
                                                         <td style="width:10%">
-                                                            {{$member_course->course->level->name}}<br>
+                                                            {{$member_course->course->level->name ?? ""}}<br>
                                                         </td>
                                                         <td style="width:20%">
                                                             @foreach(json_decode($member_course->when) as $xx => $x)
@@ -1123,11 +1123,13 @@
 
                                                     </div>
                                                 </div>
+
                                                 <div class="row ">
                                                     <div class="col-md-6">
                                                         <label for="course_price" class="form-label">Costo mensile</label>
                                                         <input class="form-control" type="text" id="course_price" placeholder="Costo mensile" wire:model="course_price" onkeyup="onlyNumberAmount(this)">
                                                     </div>
+                                                    @if(false)
                                                     <div class="col-md-6">
                                                         <label for="course_status" class="form-label">Stato iscrizione</label>
                                                         <select id="course_status" class="form-select  @error('course_status') is-invalid @enderror" aria-label="Stato" wire:model="course_status">
@@ -1137,7 +1139,9 @@
                                                             <option value="3">Sospesa
                                                         </select>
                                                     </div>
+                                                    @endif
                                                 </div>
+
                                                 <div class="row ">
                                                     <div class="col-md-12">
                                                         <label for="duration" class="form-label">Durata del corso</label><br>
@@ -2063,6 +2067,19 @@
 
         }
 
+        var isEdit = false;
+
+        Livewire.on('setEdit', (x) =>
+        {
+            isEdit = x;
+            console.log(isEdit);
+        });
+
+        window.onbeforeunload = function(){
+            if (isEdit)
+                return 'Cambiando pagina le eventuali modifiche andranno perse';
+
+        };
 
     </script>
 @endpush

+ 16 - 1
resources/views/livewire/records_in.blade.php

@@ -83,7 +83,6 @@
                 </div>
 
             </form>
-
             <footer>
                 <div class="d-flex align-items-center totalDiv">
 
@@ -147,6 +146,8 @@
                         </tbody>
                     </table>
 
+                    <br><b class="totalDiv"></b>
+
                 </section>
 
             @else
@@ -976,6 +977,20 @@
 
         }
 
+        var isEdit = false;
+
+        Livewire.on('setEdit', (x) =>
+        {
+            isEdit = x;
+            console.log(isEdit);
+        });
+
+        window.onbeforeunload = function(){
+            if (isEdit)
+                return 'Cambiando pagina le eventuali modifiche andranno perse';
+
+        };
+
     </script>
 
 @endpush

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

@@ -168,6 +168,8 @@
                         <tbody id="checkall-target">
                         </tbody>
                     </table>
+
+                    <br><b class="totalDiv"></b>
                     <!--
                     <div class="paginator d-flex justify-content-center">
                         <nav aria-label="Page navigation example">
@@ -780,7 +782,7 @@
                             if (data == "")
                                 return "";
                             const j = data.split("|");
-                            //$(".totalDiv").html('Totale&nbsp;:&nbsp;<b>' + j[1] + '</b>');
+                            $(".totalDiv").html('Totale&nbsp;:&nbsp;<b>' + j[1] + '</b>');
                             var ret = '<button type="button" class="btn btn-outline-primary btn-sm" onclick="editData(' + j[0] + ')">Modifica</button>&nbsp;';
                             ret += '<button type="button" class="btn btn-outline-danger btn-sm" onclick="deleteData(' + j[0] + ')">Elimina</button>';
                             return ret;
@@ -830,6 +832,20 @@
 
         }
 
+        var isEdit = false;
+
+        Livewire.on('setEdit', (x) =>
+        {
+            isEdit = x;
+            console.log(isEdit);
+        });
+
+        window.onbeforeunload = function(){
+            if (isEdit)
+                return 'Cambiando pagina le eventuali modifiche andranno perse';
+
+        };
+
     </script>
 
 @endpush