Explorar o código

Fix urgenti per fine agosto

Luca Parisio hai 1 ano
pai
achega
71c6a5508d

BIN=BIN
.DS_Store


BIN=BIN
app/.DS_Store


BIN=BIN
app/Http/.DS_Store


+ 3 - 2
app/Http/Livewire/Causal.php

@@ -6,7 +6,7 @@ use Livewire\Component;
 
 class Causal extends Component
 {
-    public $records, $parent_id,  $name, $enabled, $money, $user_status, $no_first, $no_records, $type, $dataId, $update = false, $add = false;
+    public $recordsIn, $recordsOut, $parent_id,  $name, $enabled, $money, $user_status, $no_first, $no_records, $type, $dataId, $update = false, $add = false;
 
     protected $rules = [
         'name' => 'required',
@@ -30,7 +30,8 @@ class Causal extends Component
 
     public function render()
     {
-        $this->records = \App\Models\Causal::where('parent_id', null)->get();
+        $this->recordsIn = \App\Models\Causal::where('parent_id', null)->where('type', 'IN')->get();
+        $this->recordsOut = \App\Models\Causal::where('parent_id', null)->where('type', 'OUT')->get();
         return view('livewire.causal');
     }
 

+ 78 - 6
app/Http/Livewire/CourseList.php

@@ -12,15 +12,31 @@ class CourseList extends Component
 
     public $courseId = 0;
 
+    public $filterCourse = [];
+    public $filterLevel = [];
+    public $filterFrequency = [];
+    public $filterType = [];
+    public $filterDuration = [];
+
+    public $course_durations = [];
+    public $course_types = [];
+    public $course_frequencies = [];
+    public $course_levels = [];
+
     public $months = array('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic');
 
     public function mount()
     {
 
-        $this->courses = \App\Models\Course::orderBy('name')->get();
+        $this->course_types = \App\Models\CourseType::select('*')->where('enabled', true)->get();
+        $this->course_durations = \App\Models\CourseDuration::select('*')->where('enabled', true)->get();
+        $this->course_levels = \App\Models\CourseLevel::select('*')->where('enabled', true)->get();
+        $this->course_frequencies = \App\Models\CourseFrequency::select('*')->where('enabled', true)->get();
 
-        if (sizeof($this->courses) > 0)
-            $this->courseId = $this->courses[0]->id;
+        $this->courses = \App\Models\Course::orderBy('name')->groupBy('name')->pluck('name');
+
+        //if (sizeof($this->courses) > 0)
+        //    $this->courseId = $this->courses[0]->id;
 
     }
 
@@ -28,10 +44,50 @@ class CourseList extends Component
     {
 
         // Carico tutti i corsi associati
+        /*
         if ($this->courseId > 0)
-            $member_course = \App\Models\MemberCourse::where('course_id', $this->courseId)->with('member')->get();
+            $member_course = \App\Models\MemberCourse::where('course_id', $this->courseId)->with('member'); //->get();
         else
-            $member_course = \App\Models\MemberCourse::with('member')->get();
+            $member_course = \App\Models\MemberCourse::with('member'); //->get();
+        */
+        $member_course = \App\Models\MemberCourse::with('member');
+        if (sizeof($this->filterCourse) > 0)
+        {
+            $course_ids = [];
+            foreach($this->filterCourse as $c)
+            {
+                $all = \App\Models\Course::where('name', 'like', '%' . $c . "%")->get();
+                foreach($all as $a)
+                {
+                    $course_ids[] = $a->id;
+                }
+                //$course_ids = array_merge($course_ids, $a);
+            }
+            //$course_ids = \App\Models\Course::where('name', 'like', '%' . $this->filterCourse . "%")->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+        if (sizeof($this->filterLevel) > 0)
+        {
+            $course_ids = \App\Models\Course::whereIn('course_level_id', $this->filterLevel)->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+        if (sizeof($this->filterFrequency) > 0)
+        {
+            $course_ids = \App\Models\Course::whereIn('course_frequency_id', $this->filterFrequency)->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+        if (sizeof($this->filterType) > 0)
+        {
+            $course_ids = \App\Models\Course::whereIn('course_type_id', $this->filterType)->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+        if (sizeof($this->filterDuration) > 0)
+        {
+            $course_ids = \App\Models\Course::whereIn('course_duration_id', $this->filterDuration)->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+
+        $member_course = $member_course->get();
 
         $this->records = array();
 
@@ -50,10 +106,14 @@ class CourseList extends Component
                 $this->getColor($x->months, 9),
                 $this->getColor($x->months, 10),
                 $this->getColor($x->months, 11),
-                $this->getColor($x->months, 12)
+                $this->getColor($x->months, 12),
+                $x->course_id,
+                $x->id,
             );
         }
 
+        $this->emit('load-data-table');
+
         return view('livewire.course_list');
 
     }
@@ -82,4 +142,16 @@ class CourseList extends Component
         return $class;
     }
 
+    public function search()
+    {
+
+    }
+
+    public function newPayment($course_id, $month, $member_id, $id)
+    {
+        $c = \App\Models\Course::findOrFail($course_id);
+        return redirect()->to('/in?new=1&memberId=' . $member_id . '&causalId=' . $c->causal_id . '&subCausalId=' . $c->sub_causal_id . '&createSubscription=0&months=' . $month . '&price=' . $c->price . '&subscription_price=' . $c->subscription_price . "&courseId=" . $id);
+
+    }
+
 }

+ 42 - 5
app/Http/Livewire/CourseMember.php

@@ -31,6 +31,8 @@ class CourseMember extends Component
     public $chkCertificateScadenza = 0;
     public $chkCard = [];
 
+    public $filter = '';
+
     public function mount()
     {
 
@@ -38,7 +40,7 @@ class CourseMember extends Component
         $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();
+        $this->courses = \App\Models\Course::orderBy('name')->groupBy('name')->pluck('name');
 
     }
 
@@ -46,68 +48,103 @@ class CourseMember extends Component
     {
 
         // Carico tutti i corsi associati
+        $this->filter = '';
         $datas = \App\Models\MemberCourse::with('member');
         if ($this->filterCourse != "")
-            $datas = $datas->where('course_id', $this->filterCourse);
+        {
+            $course_ids = \App\Models\Course::where('name', 'like', '%' . $this->filterCourse . "%")->pluck('id');
+            $datas = $datas->whereIn('course_id', $course_ids);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Corso : " . $this->filterCourse . " ";
+        }
         if ($this->filterLevel != "")
         {
             $course_ids = \App\Models\Course::where('course_level_id', $this->filterLevel)->pluck('id');
             $datas = $datas->whereIn('course_id', $course_ids);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Livello : " . \App\Models\CourseLevel::findOrFail($this->filterLevel)->name . " ";
         }
         if ($this->filterType != "")
         {
             $course_ids = \App\Models\Course::where('course_type_id', $this->filterType)->pluck('id');
             $datas = $datas->whereIn('course_id', $course_ids);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Tipologia : " . \App\Models\CourseType::findOrFail($this->filterType)->name . " ";
         }
         if ($this->filterDuration != "")
         {
             $course_ids = \App\Models\Course::where('course_duration_id', $this->filterDuration)->pluck('id');
             $datas = $datas->whereIn('course_id', $course_ids);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Durata : " . \App\Models\CourseDuration::findOrFail($this->filterDuration)->name . " ";
         }
         if ($this->filterDays != "")
         {
-            $course_ids = \App\Models\Membercourse::where('when', 'like', "%" . $this->filterDays . "%")->pluck('course_id');
+            $course_ids = \App\Models\MemberCourse::where('when', 'like', "%" . $this->filterDays . "%")->pluck('course_id');
             $datas = $datas->whereIn('course_id', $course_ids);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Giorni : " . $this->filterDays . " ";
         }
         if ($this->filterHours != "")
         {
-            $course_ids = \App\Models\Membercourse::where('when', 'like', "%" . $this->filterHours . "%")->pluck('course_id');
+            $course_ids = \App\Models\MemberCourse::where('when', 'like', "%" . $this->filterHours . "%")->pluck('course_id');
             $datas = $datas->whereIn('course_id', $course_ids);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Ore : " . $this->filterHours . " ";
         }
         if ($this->filterSubscription != "")
         {
             $course_ids = \App\Models\MemberCourse::where('subscribed', $this->filterSubscription == 1 ? true : false)->pluck('id');
             $datas = $datas->whereIn('course_id', $course_ids);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Pagata sottoscrizione : " . ($this->filterSubscription == 1 ? "SI" : "NO") . " ";
         }
         if ($this->chkCertificateNormal > 0)
         {
             $normal = \App\Models\MemberCertificate::where('type', 'N')->pluck('member_id');
-            $datas = $datas->whereIn('member_id', $normal);;
+            $datas = $datas->whereIn('member_id', $normal);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Certificato normale : SI ";
         }
         if ($this->chkCertificateAgonistico > 0)
         {
             $agonistic = \App\Models\MemberCertificate::where('type', 'A')->pluck('member_id');
             $datas = $datas->whereIn('member_id', $agonistic);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Certificato agonistico : SI ";
         }
         if ($this->chkCertificateScaduti > 0)
         {
             $scaduto = \App\Models\MemberCertificate::where('expire_date', '<', date("Y-m-d"))->pluck('member_id');
             $datas = $datas->whereIn('member_id', $scaduto);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Certificato scaduto : SI ";
         }
         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);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Certificato in scadenza : SI ";
         }
         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);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Tessera : ";
+            foreach($this->chkCard as $card)
+            {
+                $this->filter .= \App\Models\Card::findOrFail($card)->name . " ";
+            }
+
         }
         if ($this->filterYear != "")
         {
             $course_ids = \App\Models\Course::where('year', $this->filterYear)->pluck('id');
             $datas = $datas->whereIn('course_id', $course_ids);
+            $this->filter .= $this->filter != '' ? ', ' : '';
+            $this->filter .= "Anno : " . $this->filterYear . " ";
         }
 
         $aRet = [];

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

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

+ 141 - 8
app/Http/Livewire/Member.php

@@ -24,6 +24,16 @@ class Member extends Component
 
     public $groupMsg = '';
 
+    protected $messages = [
+        'birth_nation_id.required' => 'birth_nation_id',
+        'birth_province_id.required' => 'birth_province_id',
+        'birth_city_id.required' => 'birth_city_id',
+        'nation_id.required' => 'nation_id',
+        'province_id.required' => 'province_id',
+        'city_id.required' => 'city_id',
+        'gender' => 'Obbligatorio'
+    ];
+
     public function sortBy($field)
     {
         if($this->sortField === $field)
@@ -66,6 +76,7 @@ class Member extends Component
 
     public $age = '';
 
+    public $disciplines = array();
     public $cards = array();
     public $categories = array();
     public $courses = array();
@@ -88,13 +99,13 @@ class Member extends Component
     public $active;
 
     // Card data
-    public $member_cards = array(), $card_card_id, $card_number, $card_date, $card_accept_date, $card_status, $addCard, $updateCard, $cardDataId;
+    public $member_cards = array(), $card_card_id, $card_number, $card_date, $card_accept_date, $card_status, $card_discipline1_id, $card_discipline2_id, $card_discipline3_id, $addCard, $updateCard, $cardDataId;
 
     // Categories data
     public $member_categories = array(), $category_category_id;
 
     // Courses data
-    public $member_courses = array(), $course_course_id, $course_date_from, $course_date_to, $course_when = array(), $addCourse, $updateCourse, $courseDataId, $course_course_subscription_id, $course_status, $course_note, $course_price, $course_subscription_price, $course_subscribed, $course_months = array();
+    public $member_courses = array(), $course_course_id, $course_date_from, $course_date_to, $course_when = array(), $addCourse, $updateCourse, $courseDataId, $course_course_subscription_id, $course_status, $course_note, $course_price, $course_subscription_price, $course_subscribed, $course_months = array(), $course_exist;
 
     // Certificates data
     public $member_certificates = array(), $certificate_type, $certificate_filename_old, $certificate_filename, $certificate_expire_date, $certificate_status, $addCertificate, $updateCertificate, $certificateDataId;
@@ -109,6 +120,8 @@ class Member extends Component
     protected $rules = [
         'first_name' => 'required',
         'last_name' => 'required',
+        'email' => 'required',
+        'phone' => 'required',
         'birth_date' => 'before_or_equal:today'
     ];
 
@@ -136,7 +149,7 @@ class Member extends Component
         $this->mother_doc_number = '';
         $this->father_doc_type = '';
         $this->mother_doc_type = '';
-        $this->gender = '';
+        $this->gender = null;
         $this->fiscal_code = '';
         $this->address = '';
         $this->zip_code = '';
@@ -172,6 +185,9 @@ class Member extends Component
         $this->card_date = null;
         $this->card_accept_date = null;
         $this->card_status = 0;
+        $this->card_discipline1_id = null;
+        $this->card_discipline2_id = null;
+        $this->card_discipline3_id = null;
     }
 
     public function resetCertificateFields(){
@@ -192,6 +208,7 @@ class Member extends Component
         $this->course_status = 0;
         $this->course_price = 0;
         $this->course_subscription_price = 0;
+        $this->course_exist = false;
         $this->course_subscribed = false;
         $this->course_months = array();
         $this->course_note = '';
@@ -277,6 +294,8 @@ class Member extends Component
 
         $this->cards = \App\Models\Card::select('id', 'name')->get();
 
+        $this->disciplines = \App\Models\Discipline::select('id', 'name')->get();
+
         $this->categories = array();
 
         $this->getCategories(\App\Models\Category::select('id', 'name')->where('parent_id', null)->get(), 0);
@@ -500,11 +519,14 @@ 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);
+            // Controllo se sono già iscritto la corso
+            $this->course_exist = \App\Models\MemberCourse::where('course_id', $this->course_course_id)->where('member_id', $this->dataId)->count() > 0;
         }
         else
         {
             $this->course_price = 0;
             $this->course_subscription_price = 0;
+            $this->course_exist = false;
         }
     }
 
@@ -556,10 +578,60 @@ class Member extends Component
 
         $rules = [
             'first_name' => 'required',
-            'last_name' => 'required'
+            'last_name' => 'required',
+            'email' => 'required',
+            'phone' => 'required',
+            'birth_nation_id' => 'required',
+            //'birth_place' => 'required',
+            'address' => 'required',
+            'zip_code' => 'required',
+            'nation_id' => 'required',
+            'fiscal_code' => 'required',
+            'birth_date' => 'before_or_equal:today',
+            'gender' => 'required'
         ];
 
+        if ($this->isBirthItaly)
+        {
+            $rules['birth_province_id'] = 'required';
+            $rules['birth_city_id'] = 'required';
+        }
+        else
+        {
+            $rules['birth_place'] = 'required';
+        }
+
+        if ($this->isItaly)
+        {
+            $rules['province_id'] = 'required';
+            $rules['city_id'] = 'required';
+        }
+
+        $zzz = [];
+        if ($this->birth_nation_id == null)
+            $zzz[] = 'birth_nation_id='.$this->birth_nation_id;
+        if ($this->isBirthItaly)
+        {
+            if ($this->birth_province_id == null)
+                $zzz[] = 'birth_province_id='.$this->birth_province_id;
+            if ($this->birth_city_id == null)
+                $zzz[] = 'birth_city_id='.$this->birth_city_id;
+        }
+        if ($this->nation_id == null)
+            $zzz[] = 'nation_id='.$this->nation_id;
+        if ($this->isItaly)
+        {
+            if ($this->province_id == null)
+                $zzz[] = 'province_id='.$this->province_id;
+            if ($this->city_id == null)
+                $zzz[] = 'city_id='.$this->city_id;
+        }
+
+        $this->emit('setErrorMsg', $zzz);
+
         $this->validate($rules);
+            //$this->emit('setErrors');
+
         try {
 
             $name = '';
@@ -714,7 +786,59 @@ class Member extends Component
     {
         $this->emit('load-select');
 
-        $this->validate();
+        $rules = [
+            'first_name' => 'required',
+            'last_name' => 'required',
+            'email' => 'required',
+            'phone' => 'required',
+            'birth_nation_id' => 'required',
+            //'birth_place' => 'required',
+            'address' => 'required',
+            'zip_code' => 'required',
+            'nation_id' => 'required',
+            'fiscal_code' => 'required',
+            'birth_date' => 'before_or_equal:today'
+        ];
+
+        if ($this->isBirthItaly)
+        {
+            $rules['birth_province_id'] = 'required';
+            $rules['birth_city_id'] = 'required';
+        }
+        else
+        {
+            $rules['birth_place'] = 'required';
+        }
+
+        if ($this->isItaly)
+        {
+            $rules['province_id'] = 'required';
+            $rules['city_id'] = 'required';
+        }
+
+        $zzz = [];
+        if ($this->birth_nation_id == null)
+            $zzz[] = 'birth_nation_id='.$this->birth_nation_id;
+        if ($this->isBirthItaly)
+        {
+            if ($this->birth_province_id == null)
+                $zzz[] = 'birth_province_id='.$this->birth_province_id;
+            if ($this->birth_city_id == null)
+                $zzz[] = 'birth_city_id='.$this->birth_city_id;
+        }
+        if ($this->nation_id == null)
+            $zzz[] = 'nation_id='.$this->nation_id;
+        if ($this->isItaly)
+        {
+            if ($this->province_id == null)
+                $zzz[] = 'province_id='.$this->province_id;
+            if ($this->city_id == null)
+                $zzz[] = 'city_id='.$this->city_id;
+        }
+
+        $this->emit('setErrorMsg', $zzz);
+
+        $this->validate($rules);
         try {
 
             $name = '';
@@ -878,7 +1002,10 @@ class Member extends Component
                 'date' => $this->card_date,
                 'accept_date' => $this->card_accept_date != '' ? $this->card_accept_date : $this->card_date,
                 'expire_date' => $expire_date,
-                'status' => $this->card_status
+                'status' => $this->card_status,
+                'discipline1_id' => $this->card_discipline1_id,
+                'discipline2_id' => $this->card_discipline2_id,
+                'discipline3_id' => $this->card_discipline3_id,
             ]);
             session()->flash('success, Tesserato creato');
             $this->resetCardFields();
@@ -899,6 +1026,9 @@ class Member extends Component
                 $this->card_date = $memberCard->date;
                 $this->card_accept_date = $memberCard->accept_date;
                 $this->card_status = $memberCard->status;
+                $this->card_discipline1_id = $memberCard->discipline1_id;
+                $this->card_discipline2_id = $memberCard->discipline2_id;
+                $this->card_discipline3_id = $memberCard->discipline3_id;
                 $this->cardDataId = $memberCard->id;
                 $this->updateCard = true;
                 $this->addCard = false;
@@ -949,7 +1079,10 @@ class Member extends Component
                 'date' => $this->card_date,
                 'accept_date' => $this->card_accept_date != '' ? $this->card_accept_date : $this->card_date,
                 'expire_date' => $expire_date,
-                'status' => $this->card_status
+                'status' => $this->card_status,
+                'discipline1_id' => $this->card_discipline1_id,
+                'discipline2_id' => $this->card_discipline2_id,
+                'discipline3_id' => $this->card_discipline3_id,
             ]);
             session()->flash('success','Tesserato aggiornato');
             $this->resetCardFields();
@@ -988,7 +1121,7 @@ class Member extends Component
     public function storeCourse()
     {
 
-        $this->validate(['course_course_id' => 'required', 'course_course_subscription_id' => 'required']);
+        $this->validate(['course_course_id' => 'required']);
         try {
 
             \App\Models\MemberCourse::create([

+ 7 - 4
app/Http/Livewire/RecordIN.php

@@ -57,7 +57,7 @@ class RecordIN extends Component
 
     public $currentReceip;
 
-    public $filterMember = 0, $filterPaymentMethod = 0, $filterCausals = [], $filterFrom = '', $filterTo = '', $filterCommercial = 0;
+    public $filterMember = 0, $filterPaymentMethod = 0, $filterCausals = 0, $filterFrom = '', $filterTo = '', $filterCommercial = 0;
 
     public $hasFilter = false;
 
@@ -331,7 +331,7 @@ class RecordIN extends Component
     {
         $this->filterMember = 0;
         $this->filterPaymentMethod = 0;
-        $this->filterCausals = [];
+        $this->filterCausals = 0;
         $this->filterTo = '';
         $this->filterFrom = '';
         $this->filterCommercial = 0;
@@ -382,7 +382,7 @@ class RecordIN extends Component
         }
         if ($f)
             $rules["member_id"] = 'required';*/
-        if($this->commercial)
+        if(!$this->commercial)
             $rules["member_id"] = 'required';
         //dd($this->getErrorBag());
         $this->validate($rules);
@@ -527,7 +527,7 @@ class RecordIN extends Component
         }
         if ($f)
             $rules["member_id"] = 'required';*/
-        if($this->commercial)
+        if(!$this->commercial)
             $rules["member_id"] = 'required';
 
         $this->validate($rules);
@@ -743,6 +743,9 @@ class RecordIN extends Component
 
             $this->currentReceip = $receipt;
 
+            // Apro la ricevuta
+            $this->emit('showReceipt', $this->currentReceip->id);
+
         }
 
 

+ 2 - 2
app/Http/Livewire/RecordINOUT.php

@@ -73,8 +73,8 @@ class RecordINOUT extends Component
         $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get(), 'IN', 0);
         $this->getCausale(\App\Models\Causal::select('id', 'name')->where('parent_id', null)->where('type', 'OUT')->whereNotIn('id', $this->excludeCausals)->get(), 'OUT', 0);
 
-        $this->causalsIn = \App\Models\Causal::where('parent_id', null)->where('type', 'IN')->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get();
-        $this->causalsOut = \App\Models\Causal::where('parent_id', null)->where('type', 'OUT')->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get();
+        $this->causalsIn = \App\Models\Causal::where('parent_id', null)->where('type', 'IN')->whereNotIn('id', $this->excludeCausals)->get();
+        $this->causalsOut = \App\Models\Causal::where('parent_id', null)->where('type', 'OUT')->whereNotIn('id', $this->excludeCausals)->get();
 
     }
 

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

@@ -109,7 +109,7 @@ class RecordOUT extends Component
         $this->type = 'OUT';
         //$this->note = '';
         //$this->amount = null;
-        $this->commercial = 0;
+        $this->commercial = 1;
         $this->rows = array();
         $this->rows[] = array('causal_id' => null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')),  'amount' => null, 'note' => '', 'commercial' => 0);
         $this->emit('load-data-table');

+ 22 - 0
app/Models/Discipline.php

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

+ 3 - 0
app/Models/MemberCard.php

@@ -17,6 +17,9 @@ class MemberCard extends Model
         'accept_date',
         'expire_date',
         'status',
+        'discipline1_id',
+        'discipline2_id',
+        'discipline3_id',
     ];
 
     public function member()

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

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('disciplines', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->integer('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('disciplines');
+    }
+};

+ 39 - 0
database/migrations/2024_08_22_112300_add_disciplines_to_member_cards_table.php

@@ -0,0 +1,39 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('member_cards', function (Blueprint $table) {
+            $table->unsignedBigInteger('discipline1_id')->nullable();
+            $table->foreign('discipline1_id')->nullable()->references('id')->on('disciplines')->onUpdate('cascade')->onDelete('cascade');
+            $table->unsignedBigInteger('discipline2_id')->nullable();
+            $table->foreign('discipline2_id')->nullable()->references('id')->on('disciplines')->onUpdate('cascade')->onDelete('cascade');
+            $table->unsignedBigInteger('discipline3_id')->nullable();
+            $table->foreign('discipline3_id')->nullable()->references('id')->on('disciplines')->onUpdate('cascade')->onDelete('cascade');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('member_cards', function (Blueprint $table) {
+            $table->dropColumn('discipline1_id');
+            $table->dropColumn('discipline2_id');
+            $table->dropColumn('discipline3_id');
+        });
+    }
+};

BIN=BIN
public/.DS_Store


BIN=BIN
public/assets/.DS_Store


BIN=BIN
resources/.DS_Store


BIN=BIN
resources/views/.DS_Store


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

@@ -38,12 +38,27 @@
     {
         margin-top:10px;
     }
+    .was-validated .form-control:invalid, .form-control.is-invalid
+    {
+        border-width:3px !important;
+    }
   </style>
 
 </head>
 
 <body>
   <div class="container-fluid">
+
+    @if(false)
+        <div class="row" style="background-color:blue">
+            <div class="col-md-3">
+                <a href="/dashboard" class="d-flex align-items-center pb-3 mb-md-0 me-md-auto text-white text-decoration-none">
+                    <img src="{{env('LOGO', '')}}" class="fs-5 d-none d-sm-inline img-fluid" alt="logo madonnella"  style="max-width:200px"/>
+                </a>
+            </div>
+        </div>
+    @endif
+
     <div class="row flex-nowrap">
 
         <!-- sidebar menu -->

+ 36 - 1
resources/views/livewire/causal.blade.php

@@ -22,6 +22,41 @@
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
+            <h1>Entrata</h1>
+
+            <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
+                <thead>
+                    <tr>
+                        <th scope="col">Nome</th>
+                        <th scope="col">Tipologia</th>
+                        <th scope="col">Abilitato</th>
+                        <th scope="col">...</th>
+                    </tr>
+                </thead>
+                <tbody id="checkall-target" wire:sortable="reorder" wire:sortable.options="{ animation: 100 }" wire:sortable-group="reorderGroup">
+                    @foreach($recordsIn as $record)
+                        <tr wire:sortable.item="{{ $record->id }}" wire:sortable.triggers="reorder">
+                            <td>{{$record->name}}</td>
+                            <td>{{$record->type == 'IN' ? 'Entrata' : 'Uscita'}}</td>
+                            <td> <span class="tablesaw-cell-content"><span class="badge tessera-badge {{$record->enabled ? 'active' : 'suspended'}}">{{$record->enabled ? 'attivo' : 'disattivo'}}</span></span></td>
+                            <td>
+                                <button type="button" class="btn btn-outline-success btn-sm" wire:click="addLevel({{ $record->id }})">Aggiungi livello</button>
+                                <button type="button" class="btn btn-outline-success btn-sm" wire:click="duplicate({{ $record->id }})">Duplica</button>
+                                <button type="button" class="btn btn-outline-primary btn-sm" wire:click="edit({{ $record->id }})">Modifica</button>
+                                <button type="button" class="btn btn-outline-danger btn-sm" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="delete({{ $record->id }})">Elimina</button>
+                            </td>
+                        </tr>
+                        @if(count($record->childs))
+                            @include('livewire/causal_child',['records' => $record->childs, 'indentation' => 1])
+                        @endif
+                    @endforeach
+
+                </tbody>
+            </table>
+
+            <br>
+            <h1>Uscita</h1>
+
             <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
                 <thead>
                     <tr>
@@ -32,7 +67,7 @@
                     </tr>
                 </thead>
                 <tbody id="checkall-target" wire:sortable="reorder" wire:sortable.options="{ animation: 100 }" wire:sortable-group="reorderGroup">
-                    @foreach($records as $record)
+                    @foreach($recordsOut as $record)
                         <tr wire:sortable.item="{{ $record->id }}" wire:sortable.triggers="reorder">
                             <td>{{$record->name}}</td>
                             <td>{{$record->type == 'IN' ? 'Entrata' : 'Uscita'}}</td>

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

@@ -27,14 +27,11 @@
                 <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">N° partecipanti</th>
                         <th scope="col">...</th>
                     </tr>
                 </thead>
@@ -42,14 +39,11 @@
                     @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>{{$record->getCount()}}</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>

+ 224 - 11
resources/views/livewire/course_list.blade.php

@@ -1,3 +1,81 @@
+<div class="col">
+    <div class="row h-100">
+<div class="col-auto filterWrapper" id="filter--section"  wire:ignore.self>
+    <aside>
+        <header>
+            <h2>Filtra</h2>
+        </header>
+
+        <form action="" id="filter--form" class="dark-form row">
+            <div class="filter--item">
+                <span class="filter--item_title">Corso</span>
+
+                <div class="filter--item_formElement">
+                    <select class="form-select filterMultiple" wire:model="filterCourse" onchange="destroyDataTable()" multiple="multiple">
+                        @foreach($courses as $c)
+                            <option value="{{$c}}">{{$c}}
+                        @endforeach
+                    </select>
+                </div>
+            </div>
+            <div class="filter--item">
+                <span class="filter--item_title">Livello</span>
+
+                <div class="filter--item_formElement">
+                    <select class="form-select filterMultiple" wire:model="filterLevel" onchange="destroyDataTable()"  multiple="multiple">
+                        @foreach($course_levels as $c)
+                            <option value="{{$c->id}}">{{$c->name}}
+                        @endforeach
+                    </select>
+                </div>
+            </div>
+            <div class="filter--item">
+                <span class="filter--item_title">Frequenza</span>
+
+                <div class="filter--item_formElement">
+                    <select class="form-select" wire:model="filterFrequency" onchange="destroyDataTable()" multiple="multiple">
+                        @foreach($course_frequencies as $c)
+                            <option value="{{$c->id}}">{{$c->name}}
+                        @endforeach
+                    </select>
+                </div>
+            </div>
+            <div class="filter--item">
+                <span class="filter--item_title">Tipologia</span>
+
+                <div class="filter--item_formElement">
+                    <select class="form-select" wire:model="filterType" onchange="destroyDataTable()" multiple="multiple">
+                        @foreach($course_types as $c)
+                            <option value="{{$c->id}}">{{$c->name}}
+                        @endforeach
+                    </select>
+                </div>
+            </div>
+
+            <div class="filter--item">
+                <span class="filter--item_title">Durata</span>
+
+                <div class="filter--item_formElement">
+                    <select class="form-select" wire:model="filterDuration" onchange="destroyDataTable()" multiple="multiple">
+                        @foreach($course_durations as $c)
+                            <option value="{{$c->id}}">{{$c->name}}
+                        @endforeach
+                    </select>
+                </div>
+            </div>
+
+        </form>
+
+        <footer>
+            <div class="filter--buttons d-flex align-items-center justify-content-between">
+                <button class="btn--ui small dark disable" wire:click.prevent="disableSearch()" onclick="destroyDataTable()">cancella</button>
+                <button class="btn--ui small white" wire:click.prevent="search()" onclick="destroyDataTable()">filtra</button>
+            </div>
+        </footer>
+
+    </aside>
+</div>
+
 <div class="col card--ui" id="card--dashboard">
 
     <header id="title--section" class="d-flex align-items-center justify-content-between">
@@ -8,17 +86,21 @@
 
     </header>
 
-    <section id="subheader" class="d-flex align-items-center ">
-        <form action="" class="group--action d-flex align-items-center">
-            <select class="form-select form-select-lg me-1" wire:model='courseId'>
-                <option value="0">Tutti
-                @foreach($courses as $c)
-                    <option value="{{$c->id}}">{{$c->name}} - {{$c->level->name ?? ""}} - {{$c->type->name ?? ""}} - {{$c->frequency->name ?? ""}}
-                @endforeach
-            </select>
-        </form>
+    <button id="open-filter" onclick="pcsh1()"></button>
+    <button id="close-filter" onclick="pcsh2()"></button>
 
-    </section>
+    @if(false)
+        <section id="subheader" class="d-flex align-items-center ">
+            <form action="" class="group--action d-flex align-items-center">
+                <select class="form-select form-select-lg me-1" wire:model='courseId'>
+                    <option value="0">Tutti
+                    @foreach($courses as $c)
+                        <option value="{{$c->id}}">{{$c->name}} - {{$c->level->name ?? ""}} - {{$c->type->name ?? ""}} - {{$c->frequency->name ?? ""}}
+                    @endforeach
+                </select>
+            </form>
+        </section>
+    @endif
 
     <section id="resume-table">
         <div class="compare--chart_wrapper d-none"></div>
@@ -40,7 +122,13 @@
                         @endphp
                         <td><a href="/members?member_detail={{$id}}">{{$name}}</a></td>
                         @for($x=1; $x<=12; $x++)
-                            <td><a class="{{$record[$x]}}">&nbsp;</a></td>
+                            <td>
+                                @if($record[$x] == 'orange')
+                                    <a class="{{$record[$x]}}" wire:click="newPayment({{$record[13]}}, {{$x}}, {{$id}}, {{$record[14]}})">&nbsp;</a>
+                                @else
+                                    <a class="{{$record[$x]}}">&nbsp;</a>
+                                @endif
+                            </td>
                         @endfor
                     </tr>
                 @endforeach
@@ -171,3 +259,128 @@
         }
     </style>
 @endpush
+
+
+@push('scripts')
+    <link href="/css/datatables.css" rel="stylesheet" />
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+
+
+    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
+    <style>
+        .select2-container--default .select2-selection--single{
+            background-color: #E9F0F5;
+            border: 0.0625rem solid #DFE5EB;
+            font-size: 0.75rem;
+        }
+        .select2-selection
+        {
+            height: 38px !important;
+        }
+        .select2-selection__rendered
+        {
+            padding-top:3px;
+        }
+        .select2 {
+            width:100% !important;
+        }
+        .select2-selection--multiple{
+            overflow: hidden !important;
+            height: auto !important;
+        }
+        .select2-container {
+            box-sizing: border-box;
+            display: inline-block;
+            margin: 0;
+            position: relative;
+            vertical-align: middle;
+        }
+        .select2-container .select2-selection--single {
+            box-sizing: border-box;
+            cursor: pointer;
+            display: block;
+            height: 38px;
+            user-select: none;
+            -webkit-user-select: none;
+        }
+        .select2-container .select2-selection--single .select2-selection__rendered {
+            display: block;
+            padding-left: 8px;
+            padding-right: 20px;
+            overflow: hidden;
+            text-overflow: ellipsis;
+            white-space: nowrap;
+        }
+        .select2-selection__choice__display{
+            color:#000000 !important;
+        }
+    </style>
+    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
+    <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
+    <script src="/assets/js/datatables.js"></script>
+    <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
+@endpush
+
+@push('scripts')
+    <script>
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        Livewire.on('load-data-table', () => {
+            loadDataTable();
+        });
+
+        Livewire.on('destroy-data-table', () => {
+            $('#tablesaw-350').DataTable().destroy();
+        });
+
+        function destroyDataTable()
+        {
+            $('#tablesaw-350').DataTable().destroy();
+        }
+
+        function loadDataTable(){
+
+            //$('.filterMultiple').select2();
+
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart: {
+                        buttons: [
+                            {
+                                extend: 'excelHtml5',
+                                title: 'Iscritti corsi'
+                            },
+                            {
+                                extend: 'pdfHtml5',
+                                title: 'Iscritti corsi'
+                            },
+                            {
+                                extend: 'print',
+                                text: 'Stampa',
+                                title: 'Iscritti corsi'
+                            }
+                        ]
+                    }
+                },
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#EDF0F2");
+
+        }
+
+    </script>
+@endpush
+

+ 12 - 6
resources/views/livewire/course_member.blade.php

@@ -14,7 +14,7 @@
                     <select class="form-select" wire:model="filterCourse" onchange="destroyDataTable()">
                         <option value="">--Seleziona--
                         @foreach($courses as $c)
-                            <option value="{{$c->id}}">{{$c->name}}
+                            <option value="{{$c}}">{{$c}}
                         @endforeach
                     </select>
                 </div>
@@ -203,11 +203,12 @@
     <section id="resume-table">
         <div class="compare--chart_wrapper d-none"></div>
 
+        <div id="filter">{{$filter}}</div>
+
         <table class="table tablesaw tablesaw-stack" id="tablesaw-350">
             <thead>
                 <tr>
                     <th scope="col">#</th>
-                    <th scope="col">Corso</th>
                     <th scope="col">Cognome</th>
                     <th scope="col">Nome</th>
                     <th scope="col">Età</th>
@@ -219,7 +220,6 @@
                 @foreach($records as $idx => $record)
                     <tr>
                         <td>{{$idx +1}}</td>
-                        <td>{{$record->course->name}}</td>
                         <td>{{$record->member->last_name}}</td>
                         <td>{{$record->member->first_name}}</td>
                         <td>{{$record->member->getAge() . " (" . date("Y", strtotime($record->member->birth_date)) . ")"}}</td>
@@ -247,6 +247,8 @@
 @push('scripts')
     <script>
 
+        var t = '{{$filter}}';
+
         $(document).ready(function() {
             loadDataTable();
         } );
@@ -266,6 +268,7 @@
 
         function loadDataTable(){
             $('#tablesaw-350').DataTable({
+                // caption : $("#filter").html(),
                 thead: {
                 'th': {'background-color': 'blue'}
                 },
@@ -274,16 +277,19 @@
                         buttons: [
                             {
                                 extend: 'excelHtml5',
-                                title: 'Iscritti corsi'
+                                title: 'Iscritti corsi',
+                                messageTop: $("#filter").html()
                             },
                             {
                                 extend: 'pdfHtml5',
-                                title: 'Iscritti corsi'
+                                title: 'Iscritti corsi',
+                                messageTop: $("#filter").html()
                             },
                             {
                                 extend: 'print',
                                 text: 'Stampa',
-                                title: 'Iscritti corsi'
+                                title: 'Iscritti corsi',
+                                messageTop: $("#filter").html()
                             }
                         ]
                     }

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

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

+ 71 - 16
resources/views/livewire/member.blade.php

@@ -524,11 +524,11 @@
                                                 </div>
                                                 <div class="col-md-6">
                                                     <label for="email" class="form-label">Email</label>
-                                                    <input class="form-control" type="text" id="email" placeholder="Email" wire:model="email">
+                                                    <input class="form-control @error('email') is-invalid @enderror" type="text" id="email" placeholder="Email" wire:model="email">
                                                 </div>
                                                 <div class="col-md-6">
                                                     <label for="phone" class="form-label">Telefono/Cellulare</label>
-                                                    <input class="form-control" type="text" id="phone" placeholder="Telefono" wire:model="phone">
+                                                    <input class="form-control @error('phone') is-invalid @enderror" type="text" id="phone" placeholder="Telefono" wire:model="phone">
                                                 </div>
                                                 <div class="col-md-6">
                                                     <label for="phone2" class="form-label">Telefono 2</label>
@@ -551,6 +551,9 @@
                                                         <input class="form-check-input" type="radio" name="gender" value="O" wire:model="gender">
                                                         <label class="form-check-label" for="inlineCheckbox3">&nbsp;&nbsp;Altro</label>
                                                     </div>
+                                                    @error('gender')
+                                                        <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
+                                                    @enderror
                                                 </div>
                                                 <div class="col-6">
                                                     <div class="upload-file">
@@ -576,33 +579,33 @@
 
                                                 <div class="col-md-12">
                                                     <label for="birth_nation_id" class="form-label">Nazione di Nascita</label>
-                                                    <select id="birth_nation_id" class="form-select nationBirthClass" aria-label="Nazione di nascita" wire:model="birth_nation_id">
+                                                    <select id="birth_nation_id" class="form-select nationBirthClass @error('birth_nation_id') is-invalid @enderror" aria-label="Nazione di nascita" wire:model="birth_nation_id">
                                                         <option value="{{$birth_nation_id}}">{{$this->getNation($birth_nation_id)}}
                                                     </select>
                                                 </div>
                                                 @if($isBirthItaly)
                                                     <div class="col-md-12">
                                                         <label for="birth_province_id" class="form-label">Provincia di Nascita</label>
-                                                        <select id="birth_province_id" class="form-select provinceBirthClass" aria-label="Provincia di nascita" wire:model="birth_province_id">
+                                                        <select id="birth_province_id" class="form-select provinceBirthClass @error('birth_province_id') is-invalid @enderror" aria-label="Provincia di nascita" wire:model="birth_province_id">
                                                             <option value="{{$birth_province_id}}">{{$this->getProvince($birth_province_id)}}
                                                         </select>
                                                     </div>
                                                     <div class="col-md-12">
                                                         <label for="birth_city_id" class="form-label">Comune di Nascita</label>
-                                                        <select id="birth_city_id" class="form-select cityBirthClass" aria-label="Comune di nascita" wire:model="birth_city_id" >
+                                                        <select id="birth_city_id" class="form-select cityBirthClass @error('birth_city_id') is-invalid @enderror" aria-label="Comune di nascita" wire:model="birth_city_id" >
                                                             <option value="{{$birth_city_id}}">{{$this->getCity($birth_city_id)}}
                                                         </select>
                                                     </div>
                                                 @else
-                                                    <div class="col-md-6">
+                                                    <div class="col-md-12">
                                                         <label for="birth_place" class="form-label">Paese di nascita</label>
-                                                        <input class="form-control " type="text" id="birth_place" placeholder="Paese di nascita" wire:model="birth_place">
+                                                        <input class="form-control @error('birth_place') is-invalid @enderror" type="text" id="birth_place" placeholder="Paese di nascita" wire:model="birth_place">
                                                     </div>
                                                 @endif
 
                                                 <div class="col-md-12">
                                                     <label for="fiscal_code" class="form-label">Codice fiscale (<a wire:click="getFiscalCode()" href="#" style="font-size:18px;color: #006099;font-weight: bold;">calcola</a>)</label>
-                                                    <input class="form-control" type="text" id="fiscal_code" placeholder="Codice fiscale" wire:model="fiscal_code"  maxlength="16">
+                                                    <input class="form-control  @error('fiscal_code') is-invalid @enderror" 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
@@ -705,28 +708,28 @@
                                                 <span class="title-form primary d-block w-100">Residenza</span>
                                                 <div class="col-8">
                                                     <label for="address" class="form-label">Indirizzo</label>
-                                                    <input class="form-control" type="text" id="address" placeholder="Indirizzo" wire:model="address" style="text-transform:uppercase">
+                                                    <input class="form-control @error('address') is-invalid @enderror" type="text" id="address" placeholder="Indirizzo" wire:model="address" style="text-transform:uppercase">
                                                 </div>
                                                 <div class="col-4">
                                                     <label for="zip_code" class="form-label">CAP</label>
-                                                    <input class="form-control" type="text" id="zip_code" placeholder="CAP" wire:model="zip_code" maxlength="5"  >
+                                                    <input class="form-control @error('zip_code') is-invalid @enderror" 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>
-                                                    <select id="nation_id" class="form-select nationClass" aria-label="Nazione" wire:model="nation_id">
+                                                    <select id="nation_id" class="form-select nationClass @error('nation_id') is-invalid @enderror" aria-label="Nazione" wire:model="nation_id">
                                                         <option value="{{$nation_id}}">{{$this->getNation($nation_id)}}
                                                     </select>
                                                 </div>
                                                 @if($isItaly)
                                                     <div class="col-md-12">
                                                         <label for="province_id" class="form-label">Provincia</label>
-                                                        <select id="province_id" class="form-select provinceClass" aria-label="Provincia" wire:model="province_id">
+                                                        <select id="province_id" class="form-select provinceClass @error('province_id') is-invalid @enderror" aria-label="Provincia" wire:model="province_id">
                                                             <option value="{{$province_id}}">{{$this->getProvince($province_id)}}
                                                         </select>
                                                     </div>
                                                     <div class="col-md-12">
                                                         <label for="city_id" class="form-label">Comune</label>
-                                                        <select id="city_id" class="form-select cityClass" aria-label="Comune" wire:model="city_id">
+                                                        <select id="city_id" class="form-select cityClass @error('city_id') is-invalid @enderror" aria-label="Comune" wire:model="city_id">
                                                             <option value="{{$city_id}}">{{$this->getCity($city_id)}}
                                                         </select>
                                                     </div>
@@ -914,7 +917,39 @@
                                                         <input class="form-control" type="date" id="card_accept_date" placeholder="Data accettazione" wire:model="card_accept_date">
                                                     </div>
                                                 </div>
-
+                                                <div class="row ">
+                                                    <div class="col-md-6">
+                                                        <label for="card_date" class="form-label">Disciplina 1</label>
+                                                        <select id="card_discipline1_id" class="form-select " aria-label="Disciplina 1" wire:model="card_discipline1_id">
+                                                            <option value="">--Seleziona--
+                                                            @foreach($disciplines as $d)
+                                                                <option value="{{$d->id}}">{{$d->name}}
+                                                            @endforeach
+                                                        </select>
+                                                    </div>
+                                                    <div class="col-md-6">
+                                                        <label for="card_date" class="form-label">Disciplina 2</label>
+                                                        <select id="card_discipline2_id" class="form-select " aria-label="Disciplina 2" wire:model="card_discipline2_id">
+                                                            <option value="">--Seleziona--
+                                                            @foreach($disciplines as $d)
+                                                                <option value="{{$d->id}}">{{$d->name}}
+                                                            @endforeach
+                                                        </select>
+                                                    </div>
+                                                </div>
+                                                @if($card_discipline2_id > 0)
+                                                    <div class="row ">
+                                                        <div class="col-md-6">
+                                                            <label for="card_date" class="form-label">Disciplina 3</label>
+                                                            <select id="card_discipline3_id" class="form-select " aria-label="Disciplina 3" wire:model="card_discipline3_id">
+                                                                <option value="">--Seleziona--
+                                                                @foreach($disciplines as $d)
+                                                                    <option value="{{$d->id}}">{{$d->name}}
+                                                                @endforeach
+                                                            </select>
+                                                        </div>
+                                                    </div>
+                                                @endif
 
                                             </form>
                                         </div>
@@ -1108,9 +1143,12 @@
                                                         <select id="course_course_id" class="form-select  @error('course_course_id') is-invalid @enderror" aria-label="Corso" wire:model="course_course_id" >
                                                             <option value="">
                                                             @foreach($courses as $course)
-                                                                <option value="{{$course["id"]}}">{{$course["name"]}}
+                                                                <option value="{{$course->id}}">{{$course->name}} - {{$course->level->name ?? ""}} - {{$course->type->name ?? ""}} - {{$course->frequency->name ?? ""}}
                                                             @endforeach
                                                         </select>
+                                                        @if($course_exist)
+                                                            <small style="color:red">Attenzione : il corso selezionato è già associato all'utente</small>
+                                                        @endif
                                                     </div>
                                                     <div class="col-md-6">
                                                         <label for="course_course_subscription_id" class="form-label">Abbonamento</label>
@@ -1228,7 +1266,9 @@
 
                                         <br>
                                         @if($addCourse)
-                                            <button class="btn--ui primary" wire:click.prevent="storeCourse()">Salva</button>
+                                            @if(!$course_exist)
+                                                <button class="btn--ui primary" wire:click.prevent="storeCourse()">Salva</button>
+                                            @endif
                                         @endif
                                         @if($updateCourse)
                                             <button class="btn--ui primary" wire:click.prevent="updateCourse()">Salva</button>
@@ -1415,6 +1455,7 @@
                     <button class="btn--ui lightGrey"  type="submit" wire:click.prevent="cancel()">annulla</button>
                 </section>
 
+
             @endif
 
         </div>
@@ -2075,6 +2116,20 @@
             console.log(isEdit);
         });
 
+        Livewire.on('setErrorMsg', (errors) =>
+        {
+            errors.forEach(msg);
+
+            function msg(value)
+            {
+                const myArray = value.split("=");
+                if (myArray[1] == '0' || myArray[1] == '')
+                    $("span").find("[aria-controls='select2-" + myArray[0] + "-container']").css('border', 'solid 3px #dc3545');
+            }
+            console.log(errors);
+            //$("span").find(`[aria-controls='select2-birth_nation_id-container']`).css('border', 'solid 3px red');
+        });
+
         window.onbeforeunload = function(){
             if (isEdit)
                 return 'Cambiando pagina le eventuali modifiche andranno perse';

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

@@ -260,7 +260,7 @@
                                     <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">
+                                            <input class="form-control " id="causal_detail_{{$idx}}" type="text" placeholder="Dettaglio causale" wire:model="rows.{{$idx}}.note">
                                         </div>
                                     </div>
 
@@ -418,10 +418,12 @@
                                     </div>
 
                                     <br><br>
-                                    <button type="button" class="btn--ui primary" wire:click.prevent="delRow({{$idx}})" style="float:right">
-                                        Rimuovi causale
-                                    </button>
-                                    <br><br>
+                                    @if($idx > 0)
+                                        <button type="button" class="btn--ui primary" wire:click.prevent="delRow({{$idx}})" style="float:right">
+                                            Rimuovi causale
+                                        </button>
+                                        <br><br>
+                                    @endif
                                     <hr size="1">
 
                                 @endforeach
@@ -436,7 +438,13 @@
                                     <button class="btn--ui lightGrey"  type="submit" wire:click.prevent="cancel()">annulla</button>
                                     @if($canSave)
                                         @if($add)
-                                            <button class="btn--ui primary"  type="submit" wire:click.prevent="store(false)">inserisci</button>
+
+                                            @if($commercial)
+                                                <button class="btn--ui primary"  type="submit" wire:click.prevent="store(false)">inserisci</button>
+                                            @else
+                                                <button class="btn--ui primary sendInvoice mt-5 d-flex ms-auto" wire:click.prevent="store(true)"><i class="ico--ui sendingBtn"></i>inserisci e genera ricevuta</button>
+                                            @endif
+
                                         @endif
                                         @if($update)
                                             <button class="btn--ui primary"  type="submit" wire:click.prevent="update(false)">salva</button>
@@ -502,7 +510,10 @@
                                         </tr>
                                         @foreach($rows as $row)
                                             <tr>
-                                                <td>{{$this->getCausal($row["causal_id"])}}</td>
+                                                <td>
+                                                    {{$this->getCausal($row["causal_id"])}}<br>
+                                                    {{$row["note"]}}
+                                                </td>
                                                 @php
                                                 $vat_value = 0;
                                                 @endphp
@@ -552,9 +563,6 @@
                                     </div>
                                 </div>
 
-                                @if($add)
-                                    <button class="btn--ui primary sendInvoice mt-5 d-flex ms-auto" wire:click.prevent="store(true)"><i class="ico--ui sendingBtn"></i>inserisci e genera ricevuta</button>
-                                @endif
                                 @if($update)
                                     @if($currentReceip)
                                         @if($currentReceip->status == 99)
@@ -676,7 +684,12 @@
                         return matchStart(params, data);
                     }
                 });
-            }, 100)
+            }, 100);
+            setTimeout(() => {
+                var element = document.getElementById('causal_detail_0');
+                element.dispatchEvent(new Event('input'));
+                console.log("ASDASDSA");
+            }, 1000);
         @endif
         window.livewire.on('refresh', () => {
             // $('.causalClass').select2();
@@ -979,6 +992,11 @@
 
         var isEdit = false;
 
+        Livewire.on('showReceipt', (id) =>
+        {
+            window.open("{{env('APP_URL', '')}}/receipt/" + id, '_blank').focus();
+        });
+
         Livewire.on('setEdit', (x) =>
         {
             isEdit = x;

+ 6 - 4
resources/views/livewire/records_out.blade.php

@@ -441,10 +441,12 @@
                                     </div>
 
                                     <br><br>
-                                    <button type="button" class="btn--ui primary" wire:click.prevent="delRow({{$idx}})" style="float:right">
-                                        Rimuovi causale
-                                    </button>
-                                    <br><br>
+                                    @if($idx > 0)
+                                        <button type="button" class="btn--ui primary" wire:click.prevent="delRow({{$idx}})" style="float:right">
+                                            Rimuovi causale
+                                        </button>
+                                        <br><br>
+                                    @endif
                                     <hr size="1">
 
                                 @endforeach

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

@@ -26,6 +26,11 @@
                     <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Tessere</span>
                 </a>
             </div>
+            <div class="col-md-3 p-3">
+                <a href="/disciplines" 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">Discipline</span>
+                </a>
+            </div>
             <div class="col-md-3 p-3">
                 <a href="/nations_list" class="nav-link d-flex align-items-center">
                     <i class="ico--ui ico--ui_menu primanota"></i> <span class="ms-3 d-none d-md-inline">Nazioni</span>

+ 1 - 1
resources/views/receipt.blade.php

@@ -40,7 +40,7 @@
     $total = 0;
     @endphp
     @foreach($receipt->rows as $row)
-        <b>Descrizione</b>: {{@$row->causal->getTree()}}<br><br>
+        <b>Descrizione</b>: {{@$row->causal->getTree()}} ({{$row->note}})<br><br>
         <b>Importo</b>: {{formatPrice($row->amount)}}<br><br>
         @php
         $total += $row->amount;

+ 12 - 0
routes/web.php

@@ -1,6 +1,7 @@
 <?php
 
 use Illuminate\Support\Facades\Route;
+use Barryvdh\DomPDF\Facade\Pdf;
 
 /*
 |--------------------------------------------------------------------------
@@ -27,6 +28,7 @@ Route::get('/provinces', \App\Http\Livewire\Province::class);
 Route::get('/cities', \App\Http\Livewire\City::class);
 Route::get('/banks', \App\Http\Livewire\Bank::class);
 Route::get('/vats', \App\Http\Livewire\Vat::class);
+Route::get('/disciplines', \App\Http\Livewire\Discipline::class);
 Route::get('/course_types', \App\Http\Livewire\CourseType::class);
 Route::get('/course_subscriptions', \App\Http\Livewire\CourseSubscription::class);
 Route::get('/course_durations', \App\Http\Livewire\CourseDuration::class);
@@ -47,6 +49,16 @@ Route::get('/in', \App\Http\Livewire\RecordIN::class);
 Route::get('/out', \App\Http\Livewire\RecordOUT::class);
 Route::get('/records_in_out', \App\Http\Livewire\RecordINOUT::class);
 
+Route::get('/receipt/{id}', function($id){
+    $receipt = \App\Models\Receipt::findOrFail($id);
+    $pdf = PDF::loadView('receipt', array('receipt' => $receipt));
+    return $pdf->stream();
+    /*return response()->streamDownload(
+        fn () => print($pdf),
+        "ricevuta_" . $receipt->number . "_" . $receipt->year . ".pdf"
+    );*/
+});
+
 Route::get('/nations', function(){
     if (isset($_GET["q"]))
         $datas = \App\Models\Nation::where('name', 'like', $_GET["q"] . '%')->orderBy('name')->get();