Ver Fonte

Merge branch 'master' into fabio_develop

FabioFratini há 9 meses atrás
pai
commit
98c514bb31

+ 75 - 24
app/Http/Livewire/Course.php

@@ -144,7 +144,7 @@ class Course extends Component
         if (isset($_GET["year"]))
             $this->selectedYear = $_GET["year"];
         else
-            $this->selectedYear = $this->course_years[0];
+            $this->selectedYear =  sizeof($this->course_years) > 0 ? $this->course_years[0] : '';
             //$this->selectedYear = date("Y") . "-" . (date("Y") + 1);
         $this->records = \App\Models\Course::where('parent_id', null)->where('year', $this->selectedYear)->with('type', 'duration')->get();
         return view('livewire.course');
@@ -172,29 +172,80 @@ class Course extends Component
     {
         $this->validate();
         try {
-            \App\Models\Course::create([
-                'name' => $this->name,
-                'parent_id' => $this->parent_id,
-                'course_type_id' => $this->course_type_id,
-                'course_duration_id' => $this->course_duration_id,
-                'course_frequency_id' => $this->course_frequency_id,
-                'course_level_id' => $this->course_level_id,
-                'date_from' => $this->date_from,
-                'date_to' => $this->date_to,
-                'category_id' => $this->category_id,
-                'causal_id' => $this->causal_id,
-                'sub_causal_id' => $this->sub_causal_id,
-                'max_members' => $this->max_members,
-                'instructor_id' => $this->instructor_id,
-                'year' => $this->year,
-                'price' => currencyToDouble($this->price),
-                'subscription_price' => currencyToDouble($this->subscription_price),
-                'months' => json_encode($this->months),
-                'type' => $this->type,
-                'when' => json_encode($this->when),
-                'prices' => json_encode($this->prices),
-                'enabled' => $this->enabled
-            ]);
+            $course = new \App\Models\Course();
+
+            $course->name = $this->name;
+            $course->parent_id = $this->parent_id;
+            $course->course_type_id = $this->course_type_id;
+            $course->course_duration_id = $this->course_duration_id;
+            $course->course_frequency_id = $this->course_frequency_id;
+            $course->course_level_id = $this->course_level_id;
+            $course->date_from = $this->date_from;
+            $course->date_to = $this->date_to;
+            $course->category_id = $this->category_id;
+            //$course->causal_id = $this->causal_id;
+            //$course->sub_causal_id = $this->sub_causal_id;
+            $course->max_members = $this->max_members;
+            $course->instructor_id = $this->instructor_id;
+            $course->year = $this->year;
+            $course->price = currencyToDouble($this->price);
+            $course->subscription_price = currencyToDouble($this->subscription_price);
+            $course->months = json_encode($this->months);
+            $course->type = $this->type;
+            $course->when = json_encode($this->when);
+            $course->prices = json_encode($this->prices);
+            $course->enabled = $this->enabled;
+            $course->save();
+
+            $lev = '';
+            if ($this->course_level_id > 0)
+                $lev = \App\Models\CourseLevel::findOrFail($this->course_level_id)->name;
+
+            $freq = '';
+            if ($this->course_frequency_id > 0)
+                $freq = \App\Models\CourseLevel::findOrFail($this->course_frequency_id)->name;
+
+            // Creo le causali di pagamento
+            $causal = "Pagamento rata " . $this->name . " - " . $lev . " - " . $freq . " - " . $this->year;
+            $cp = \App\Models\Causal::where('name', $causal)->first();
+            if (!$cp)
+            {
+                $cp = new \App\Models\Causal();
+                $cp->name = $causal;
+                $cp->type = "IN";
+                $cp->parent_id = null;
+                $cp->money = false;
+                $cp->corrispettivo_fiscale = false;
+                $cp->no_receipt = false;
+                $cp->user_status = false;
+                $cp->no_first = false;
+                $cp->no_records = false;
+                $cp->enabled = true;
+                $cp->save();
+            }
+            $course->causal_id = $cp->id;
+
+            $causal = "Pagamento iscrizione " . $this->name . " - " . $lev . " - " . $freq . " - " . $this->year;
+            $ci = \App\Models\Causal::where('name', $causal)->first();
+            if (!$ci)
+            {
+                $ci = new \App\Models\Causal();
+                $ci->name = $causal;
+                $ci->type = "IN";
+                $ci->parent_id = null;
+                $ci->money = false;
+                $ci->corrispettivo_fiscale = false;
+                $ci->no_receipt = false;
+                $ci->user_status = false;
+                $ci->no_first = false;
+                $ci->no_records = false;
+                $ci->enabled = true;
+                $ci->save();
+            }
+            $course->sub_causal_id = $ci->id;
+
+            $course->save();
+            
             session()->flash('success','Corso creato');
             $this->resetFields();
             $this->add = false;

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

@@ -41,6 +41,7 @@ class CourseMember extends Component
     public $chkCard = [];
 
     public $filter = '';
+    public $type = '';
 
     public $filterFromPrevious = '';
 
@@ -50,6 +51,7 @@ class CourseMember extends Component
         if (isset($_GET["id"]))
         {
             $this->filterFromPrevious = $_GET["id"];
+            $this->type = \App\Models\Course::findOrFail($_GET["id"])->type;
         }
 
         $this->course_types = \App\Models\CourseType::select('*')->where('enabled', true)->get();

+ 122 - 31
app/Http/Livewire/Member.php

@@ -278,12 +278,10 @@ class Member extends Component
         $this->image_old = '';
     }
 
-    /*
     public function updatedCourseName()
     {
         $this->course_course_id = null;
         $this->course_level_id = '';
-        $this->course_type_id = '';
         $this->course_frequency_id = '';
         $levels_ids = [];
         if ($this->course_name != '') {
@@ -295,28 +293,26 @@ class Member extends Component
             }
         }
         $this->course_levels = \App\Models\CourseLevel::select('*')->where('enabled', true)->whereIn('id', $levels_ids)->get();
-        $this->course_types = [];
         $this->course_frequencies = [];
     }
 
     public function updatedCourseLevelId()
     {
         $this->course_course_id = null;
-        $this->course_type_id = '';
         $this->course_frequency_id = '';
-        $types_ids = [];
+        $frequencies_ids = [];
         if ($this->course_level_id != '') {
             list($n, $y) = explode("(", $this->course_name);
             $y = trim(str_replace(")", "", $y));
             $all = \App\Models\Course::where('name', 'like', '%' . trim($n) . "%")->where('year', $y)->where('enabled', true)->where('course_level_id', $this->course_level_id)->get();
             foreach ($all as $a) {
-                $types_ids[] = $a->course_type_id;
+                $frequencies_ids[] = $a->course_frequency_id;
             }
         }
-        $this->course_types = \App\Models\CourseType::select('*')->where('enabled', true)->whereIn('id', $types_ids)->get();
-        $this->course_frequencies = [];
+        $this->course_frequencies = \App\Models\CourseFrequency::select('*')->where('enabled', true)->whereIn('id', $frequencies_ids)->get();
     }
 
+    /*
     public function updatedCourseTypeId()
     {
         $this->course_course_id = null;
@@ -331,7 +327,7 @@ class Member extends Component
             }
         }
         $this->course_frequencies = \App\Models\CourseFrequency::select('*')->where('enabled', true)->whereIn('id', $frequencies_ids)->get();
-    }
+    }*/
 
     public function updatedCourseFrequencyId()
     {
@@ -339,7 +335,39 @@ class Member extends Component
         if ($this->course_frequency_id != '') {
             list($n, $y) = explode("(", $this->course_name);
             $y = trim(str_replace(")", "", $y));
-            $this->course_course_id = \App\Models\Course::where('name', 'like', '%' . trim($n) . "%")->where('year', $y)->where('course_level_id', $this->course_level_id)->where('course_type_id', $this->course_type_id)->where('course_frequency_id', $this->course_frequency_id)->first()->id;
+            $this->course_course_id = \App\Models\Course::where('name', 'like', '%' . trim($n) . "%")->where('year', $y)->where('course_level_id', $this->course_level_id)->where('course_frequency_id', $this->course_frequency_id)->first()->id;
+
+            $c = \App\Models\Course::findOrFail($this->course_course_id);
+            $this->course_price = formatPrice($c->price);
+            $this->course_subscription_price = formatPrice($c->subscription_price);
+            $this->course_date_from = $c->date_from;
+            $this->course_date_to = $c->date_to;
+            // 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;
+
+            // Carico gli abbonamenti e i mesi
+            $period = \Carbon\CarbonPeriod::create($c->date_from, '1 month', $c->date_to);
+            $this->course_months_list = [];
+            foreach ($period as $dt) 
+            {
+                $this->course_months_list[] = $dt->format("m");
+            }
+            
+            $course_subscription_ids = [];
+            $this->course_price_list = [];
+            if ($c->prices != null)
+            {
+                foreach(json_decode($c->prices) as $z)
+                {
+                    $this->course_price_list[$z->course_subscription_id] = $z->price;
+                    if ($z->price > 0)
+                        $course_subscription_ids[] = $z->course_subscription_id;
+                }
+            }
+
+            $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->whereIn('id', $course_subscription_ids)->where('enabled', true)->get();
+
+            /*
 
             if ($this->course_course_id > 0) {
                 $c = \App\Models\Course::findOrFail($this->course_course_id);
@@ -351,16 +379,18 @@ class Member extends Component
                 $this->course_price = 0;
                 $this->course_subscription_price = 0;
                 $this->course_exist = false;
-            }
+            }*/
         } else {
             $this->course_price = 0;
             $this->course_subscription_price = 0;
             $this->course_exist = false;
         }
-    }*/
+    }
 
     public function updatedCourseCourseType()
     {
+        $this->course_level_id = '';
+        $this->course_frequency_id = '';
         $this->course_course_id = null;
     }
 
@@ -630,7 +660,7 @@ class Member extends Component
     {
 
         $this->course_names = [];
-        $allC = \App\Models\Course::orderBy('name')->get();
+        $allC = \App\Models\Course::where('type', $this->course_course_type)->orderBy('name')->get();
         foreach ($allC as $c) {
             $cN = $c->name . " (" . $c->year . ")";
             if (!in_array($cN, $this->course_names))
@@ -724,7 +754,7 @@ class Member extends Component
         $this->loadMemberCertificates();
 
         $this->courses = \App\Models\Course::select('id', 'name')->where('type', $this->course_course_type)->get();
-        $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->where('enabled', true)->get();
+        // $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->where('enabled', true)->get();
 
         return view('livewire.member', ['datas' => $datas]);
     }
@@ -735,6 +765,8 @@ 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);
+            $this->course_date_from = $c->date_from;
+            $this->course_date_to = $c->date_to;
             // 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;
 
@@ -746,15 +778,20 @@ class Member extends Component
                 $this->course_months_list[] = $dt->format("m");
             }
 
+            $course_subscription_ids = [];
             $this->course_price_list = [];
             if ($c->prices != null)
             {
                 foreach(json_decode($c->prices) as $z)
                 {
                     $this->course_price_list[$z->course_subscription_id] = $z->price;
+                    if ($z->price > 0)
+                        $course_subscription_ids[] = $z->course_subscription_id;
                 }
             }
 
+            $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->whereIn('id', $course_subscription_ids)->where('enabled', true)->get();
+
         } else {
             $this->course_price = 0;
             $this->course_subscription_price = 0;
@@ -871,10 +908,9 @@ class Member extends Component
                 return;
             }
         }
-
+        
         $this->validate($rules);
-        //$this->emit('setErrors');
-
+        
         try {
 
             $name = '';
@@ -889,6 +925,8 @@ class Member extends Component
 
             $mother_docs = implode("|", $this->mother_document_files);
 
+            
+
             $member = \App\Models\Member::create([
                 'first_name' => strtoupper($this->first_name),
                 'last_name' => strtoupper($this->last_name),
@@ -934,6 +972,7 @@ class Member extends Component
                 'to_complete' => false,
                 'enabled' => $this->enabled
             ]);
+            
             session()->flash('success, Tesserato creato');
             updateMemberData($member->id);
             $this->resetFields();
@@ -1448,20 +1487,21 @@ class Member extends Component
         $this->validate(['course_course_id' => 'required']);
         try {
 
-            \App\Models\MemberCourse::create([
-                'member_id' => $this->dataId,
-                'course_id' => $this->course_course_id,
-                'date_from' => $this->course_date_from,
-                'date_to' => $this->course_date_to,
-                'course_subscription_id' => $this->course_course_subscription_id,
-                'status' => $this->course_status,
-                'subscribed' => false, // default non iscritto
-                'price' => currencyToDouble($this->course_price),
-                'subscription_price' => currencyToDouble($this->course_subscription_price),
-                'notes' => $this->course_note,
-                'months' => json_encode($this->course_months),
-                'when' => json_encode($this->course_when)
-            ]);
+            $mc = new \App\Models\MemberCourse();
+            $mc->member_id = $this->dataId;
+            $mc->course_id = $this->course_course_id;
+            $mc->date_from = $this->course_date_from;
+            $mc->date_to = $this->course_date_to;
+            $mc->course_subscription_id = $this->course_course_subscription_id;
+            $mc->status = $this->course_status;
+            $mc->subscribed = false;
+            $mc->price = currencyToDouble($this->course_price);
+            $mc->subscription_price = currencyToDouble($this->course_subscription_price);
+            $mc->notes = $this->course_note;
+            $mc->months = json_encode($this->course_months);
+            $mc->when = json_encode($this->course_when);
+            $mc->save();
+            
             // Se il corso ha associato una categoria iscrivo anche al gruppo
             $c = \App\Models\Course::findOrFail($this->course_course_id);
             if ($c) {
@@ -1473,6 +1513,56 @@ class Member extends Component
                     ]);
                 }
             }
+
+            // Creo i pagamenti in base alla tipologia
+            $r = \App\Models\CourseSubscription::findOrFail($this->course_course_subscription_id);
+
+            $start = $this->course_date_from;
+
+            // Creo il pagamento per l'iscrizione
+            $rate = new \App\Models\Rate();
+            $rate->member_id = $this->dataId;
+            $rate->member_course_id = $mc->id;
+            $rate->course_subscription_id = null;
+            $rate->price = currencyToDouble($this->course_subscription_price);
+            $rate->date = $start;
+            $rate->months = json_encode([]);
+            $rate->note = '';
+            $rate->status = 0;
+            $rate->is_subscription = true;
+            $rate->save();
+
+            $go = true;
+            while($go)
+            {
+
+                $mms = [];
+                $mms[] = date("n", strtotime($start));
+                for($jj=1; $jj<$r->months;$jj++)
+                {
+                    $mms[] = date('n', strtotime("+" . $jj . " months", strtotime($start)));
+                }
+
+                $rate = new \App\Models\Rate();
+                $rate->member_id = $this->dataId;
+                $rate->member_course_id = $mc->id;
+                $rate->course_subscription_id = $this->course_course_subscription_id;
+                $rate->price = currencyToDouble($this->course_price);
+                $rate->date = $start;
+                $rate->months = json_encode($mms);
+                $rate->note = '';
+                $rate->status = 0;
+                $rate->save();
+                
+                $start = date('Y-m-d', strtotime("+" . $r->months . " months", strtotime($start)));
+
+                if ($start > $this->course_date_to)
+                {
+                    $go = false;
+                    break;
+                }
+            }
+
             session()->flash('success, Corso creato');
             $this->resetCourseFields();
             $this->addCourse = false;
@@ -1496,6 +1586,7 @@ class Member extends Component
                 $c = \App\Models\Course::findOrFail($this->course_course_id);
                 $this->course_name = $c->name . " (" . $c->year . ")";
                 $this->course_level_id = $c->course_level_id;
+                $this->course_course_type = $c->type;
                 $this->course_type_id = $c->course_type_id;
                 $this->course_frequency_id = $c->course_frequency_id;
 

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

@@ -36,7 +36,7 @@ class PaymentMethod extends Component
     public function resetFields(){
         $this->name = '';
         $this->money = false;
-        $this->type = '';
+        $this->type = 'ALL';
         $this->corrispettivo_fiscale = false;
         $this->enabled = true;
         $this->emit('load-data-table');

+ 163 - 0
app/Http/Livewire/Rate.php

@@ -0,0 +1,163 @@
+<?php
+
+namespace App\Http\Livewire;
+
+use Livewire\Component;
+use Barryvdh\DomPDF\Facade\Pdf;
+use App\Models\Member;
+
+
+class Rate extends Component
+{
+    public $records;
+
+    public $member_id = 0;
+    public $member_course_id = 0;
+
+    public $mc = null;
+
+    public $filterStatus = '';
+    public $hasFilter = false;
+    public $filterFrom = '', $filterTo = '';
+    public $filteredMemberId = '';
+    public $members = [];
+    public $detail = '';
+
+    public $course_subscription_id;
+    public $price;
+    public $date;
+    public $months = [];
+    public $couse_subscriptions = [];
+    public $price_list = [];
+
+    public function mount()
+    {
+        // Load members for the dropdown
+        $this->member_id = isset($_GET["member_id"]) ? $_GET["member_id"] : 0;
+        $this->member_course_id = isset($_GET["member_course_id"]) ? $_GET["member_course_id"] : 0;
+        if ($this->member_id > 0 && $this->member_course_id > 0)
+        {
+            $this->mc = \App\Models\MemberCourse::findOrFail($this->member_course_id);
+            $this->detail = 'Riepilogo rate ' . $this->mc->course->name . ' di ' . $this->mc->member->first_name . " " . $this->mc->member->last_name;
+
+            $this->price_list = [];
+            $c = $this->mc->course;
+            if ($c->prices != null)
+            {
+                foreach(json_decode($c->prices) as $z)
+                {
+                    $this->price_list[$z->course_subscription_id] = $z->price;
+                }
+            }
+            
+        }
+        $this->course_subscriptions = \App\Models\CourseSubscription::select('*')->where('enabled', true)->get();
+
+        
+    }
+
+    public function render()
+    {
+
+        /*if ($this->hasFilter)
+        {
+            $r = \App\Models\Receipt::with('member');
+            if ($this->filterStatus != '')
+                $r = $r->where('status', $this->filterStatus);
+            if ($this->filterFrom != '')
+                $r = $r->where('date', '>=', $this->filterFrom);
+            if ($this->filterTo != '')
+                $r = $r->where('date', '<=', $this->filterTo);
+            if ($this->filteredMemberId != '')
+                $r = $r->where('member_id', $this->filteredMemberId);
+
+            $this->records = $r->get();
+        }
+        else
+        {*/
+            $this->records = \App\Models\Rate::with('member')->where('member_course_id', $this->member_course_id)->get();
+        //}
+
+        //$this->emit('load-data-table');
+
+        return view('livewire.rate');
+    }
+
+    public function updatedCourseSubscriptionId()
+    {
+        $this->price = 0;
+        if (isset($this->price_list[$this->course_subscription_id]))
+            $this->price = $this->price_list[$this->course_subscription_id];
+    }
+
+    public function add()
+    {
+
+        $rate = new \App\Models\Rate();
+        $rate->member_id = $this->member_id;
+        $rate->member_course_id = $this->member_course_id;
+        $rate->course_subscription_id = $this->course_subscription_id;
+        $rate->price = currencyToDouble($this->price);
+        $rate->date = $this->date;
+        $rate->months = json_encode($this->months);
+        $rate->note = '';
+        $rate->status = 0;
+        $rate->save();
+
+        $this->course_subscription_id = null;
+        $this->price = 0;
+        $this->date = null;
+        $this->months = [];
+
+        $this->emit('close-popup');
+
+    }
+
+    public function printReceipt($id)
+    {
+        $this->emit('load-data-table');
+        $receipt = \App\Models\Receipt::findOrFail($id);
+        //$pdf = PDF::loadView('pdf/receipt', array('datas' => $datas, 'from' => $x, 'to' => $y, 'who' => '', 'matricola' => $matricola));
+        $pdf = PDF::loadView('receipt', array('receipt' => $receipt));//->output();
+        return $pdf->stream('aaa.pdf');
+
+    }
+
+    public function search()
+    {
+        $this->hasFilter = true;
+    }
+
+    public function disableSearch()
+    {
+        $this->filterStatus = "";
+        $this->filterTo = '';
+        $this->filterFrom = '';
+        $this->filteredMemberId = '';
+        $this->hasFilter = false;
+    }
+
+    public function delete($id)
+    {
+        try{
+            \App\Models\Rate::find($id)->delete();
+            //$this->emit('load-data-table');
+            session()->flash('success',"Rata eliminata");
+        }catch(\Exception $e){
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function addDeleteMonth($m)
+    {
+        if (!in_array($m, $this->months))
+        {
+            $this->months[] = $m;
+        }
+        else
+        {
+
+        }
+    }
+
+}

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

@@ -47,6 +47,7 @@ class RecordIN extends Component
     }
 
     public $courseId = 0;
+    public $rateId = 0;
     public $months = array();
 
     public $records, $dataId, $member_id, $supplier_id,
@@ -231,6 +232,7 @@ class RecordIN extends Component
         $this->currentReceip = null;
         $this->parent = '';
         $this->courseId = 0;
+        $this->rateId = 0;
         $this->months = array();
         $this->rows = array();
         $this->rows[] = array('causal_id' => isset($_GET["causalId"]) ? $_GET["causalId"] : null, 'when' => array(array('month' => date("n"), 'year' => date("Y"), 'period' => '')),  'amount' => null, 'vat_id' => null, 'note' => '', 'commercial' => 0);
@@ -372,7 +374,11 @@ class RecordIN extends Component
                 $mc = \App\Models\MemberCourse::findOrFail($this->courseId);
                 $course = \App\Models\Course::findOrFail($mc->course_id);
             }
-            if (isset($_GET["months"]))
+            if (isset($_GET["rateId"]))
+            {
+                $this->rateId = $_GET["rateId"];
+            }
+            if (isset($_GET["months"]) && $_GET["months"] != '')
             {
 
                 $price = $_GET["price"] / 100 * 100;
@@ -408,6 +414,7 @@ class RecordIN extends Component
 
                 $this->createSubscription = 1;
                 $this->courseId = $_GET["courseId"];
+                $this->rateId = $_GET["rateId"];
                 $price = $_GET["subscription_price"] / 100 * 100;
                 $this->refreshAfter = 1;
                 if ($count == 1)
@@ -571,6 +578,7 @@ class RecordIN extends Component
                 'corrispettivo_fiscale' => $this->corrispettivo_fiscale,
                 'date' => $this->date,
                 'type' => $this->type,
+                'amount' => 0,
                 'financial_movement' => $this->financial_movement,
                 'deleted' => $this->deleted,
                 'numero_fattura' => '',
@@ -625,7 +633,7 @@ class RecordIN extends Component
             $record->save();
 
             // se sto pagando un corso, aggiorno lo status dei mesi
-            if ($this->courseId > 0)
+            /*if ($this->courseId > 0)
             {
                 $record->months = json_encode($this->months);
                 $record->member_course_id = $this->courseId;
@@ -643,7 +651,7 @@ class RecordIN extends Component
                 if ($this->createSubscription == 1)
                     $c->subscribed = true;
                 $c->save();
-            }
+            }*/
 
             if (!$this->financial_movement)
             {
@@ -655,6 +663,15 @@ class RecordIN extends Component
                 }
             }
 
+            // Se sto pagamento una rata aggiorno lo stato della rata
+            if ($this->rateId > 0)
+            {
+                $rate = \App\Models\Rate::findOrFail($this->rateId);
+                $rate->status = 1;
+                $rate->record_id = $record->id;
+                $rate->save();
+            }
+
             session()->flash('success','Movimento creato');
             $this->resetFields();
             $this->add = false;

+ 15 - 0
app/Models/MemberCourse.php

@@ -40,4 +40,19 @@ class MemberCourse extends Model
     {
         return $this->belongsTo(CourseSubscription::class);
     }
+
+    public function getStatus()
+    {
+        $status = 0;
+        $rates = \App\Models\Rate::where('member_course_id', $this->id)->orderBy('date')->get();
+        foreach($rates as $rate)
+        {
+            if ($rate->date > date("Y-m-d"))
+            {
+                break;
+            }
+            $status = $rate->status;
+        }
+        return $status;
+    }
 }

+ 40 - 0
app/Models/Rate.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Rate extends Model
+{
+    use HasFactory;
+
+    protected $fillable = [
+        'member_id',
+        'member_course_id',
+        'course_subscription_id',
+        'price',
+        'date',
+        'months',
+        'note',
+        'status',
+        'record_id',
+        'is_subscription'
+    ];
+
+    public function member()
+    {
+        return $this->belongsTo(Member::class);
+    }
+
+    public function member_course()
+    {
+        return $this->belongsTo(MemberCourse::class, 'member_course_id');
+    }
+
+    public function course_subscription()
+    {
+        return $this->belongsTo(CourseSubscription::class, 'course_subscription_id');
+    }
+
+}

+ 1 - 1
app/Providers/AppServiceProvider.php

@@ -24,6 +24,6 @@ class AppServiceProvider extends ServiceProvider
      */
     public function boot()
     {
-            URL::forceScheme('https');
+            //URL::forceScheme('https');
     }
 }

+ 1 - 1
database/migrations/2023_03_17_132306_create_categories_table.php

@@ -15,7 +15,7 @@ return new class extends Migration
     {
         Schema::create('categories', function (Blueprint $table) {
             $table->id();
-            $table->unsignedBigInteger('parent_id');
+            $table->unsignedBigInteger('parent_id')->nullable();
             $table->foreign('parent_id')->nullable()->references('id')->on('categories')->onUpdate('cascade')->onDelete('cascade');
             $table->string('name');
             $table->integer('enabled')->default(1);

+ 2 - 2
database/migrations/2023_03_20_212903_create_members_table.php

@@ -41,11 +41,11 @@ return new class extends Migration
             $table->string('email')->nullable();
             $table->string('image')->nullable();
             $table->string('father_name')->nullable();
-            $table->string('father_mail')->nullable();
+            $table->string('father_email')->nullable();
             $table->string('father_phone')->nullable();
             $table->string('father_fiscal_code')->nullable();
             $table->string('mother_name')->nullable();
-            $table->string('mother_mail')->nullable();
+            $table->string('mother_email')->nullable();
             $table->string('mother_phone')->nullable();
             $table->string('mother_fiscal_code')->nullable();
             $table->string('birth_place')->nullable();

+ 1 - 1
database/migrations/2023_03_24_150306_create_causals_table.php

@@ -15,7 +15,7 @@ return new class extends Migration
     {
         Schema::create('causals', function (Blueprint $table) {
             $table->id();
-            $table->unsignedBigInteger('parent_id');
+            $table->unsignedBigInteger('parent_id')->nullable();
             $table->foreign('parent_id')->nullable()->references('id')->on('causals')->onUpdate('cascade')->onDelete('cascade');
             $table->string('name');
             $table->enum('type', ['IN', 'OUT']);

+ 1 - 1
database/migrations/2023_03_24_150349_create_records_table.php

@@ -27,7 +27,7 @@ return new class extends Migration
             //$table->integer('month');
             //$table->integer('year');
             $table->enum('type', ['IN', 'OUT']);
-            //$table->decimal('amount', $precision = 8, $scale = 2);
+            $table->decimal('amount', $precision = 8, $scale = 2);
             $table->integer('commercial')->default(1);
 
             //$table->string('note')->nullable();

+ 2 - 2
database/migrations/2023_12_11_110000_create_courses_table.php

@@ -15,9 +15,9 @@ return new class extends Migration
     {
         Schema::create('courses', function (Blueprint $table) {
             $table->id();
-            $table->unsignedBigInteger('parent_id');
+            $table->unsignedBigInteger('parent_id')->nullable();
             $table->foreign('parent_id')->nullable()->references('id')->on('courses')->onUpdate('cascade')->onDelete('cascade');
-            $table->unsignedBigInteger('category_id');
+            $table->unsignedBigInteger('category_id')->nullable();
             $table->foreign('category_id')->nullable()->references('id')->on('categories')->onUpdate('cascade')->onDelete('cascade');
             $table->string('name');
             $table->integer('enabled')->default(1);

+ 43 - 0
database/migrations/2025_04_08_125700_create_rates_table.php

@@ -0,0 +1,43 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('rates', function (Blueprint $table) {
+            $table->id();
+            $table->unsignedBigInteger('member_id')->nullable();
+            $table->foreign('member_id')->nullable()->references('id')->on('members')->onUpdate('cascade')->onDelete('cascade');
+            $table->unsignedBigInteger('member_course_id')->nullable();
+            $table->foreign('member_course_id')->nullable()->references('id')->on('member_courses')->onUpdate('cascade')->onDelete('cascade');
+            $table->unsignedBigInteger('course_subscription_id')->nullable();
+            $table->foreign('course_subscription_id')->nullable()->references('id')->on('course_subscriptions')->onUpdate('cascade')->onDelete('cascade');
+            $table->decimal('price', $precision = 8, $scale = 2);
+            $table->datetime('date')->nullable();
+            $table->string('months')->nullable();
+            $table->string('note')->nullable();
+            $table->integer('status')->default(0);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('rates');
+    }
+};

+ 1 - 1
database/migrations/2025_04_09_000001_add_fields_and_foreign_key_to_records_table.php

@@ -14,7 +14,7 @@ return new class extends Migration{
     {
         Schema::table('records', function (Blueprint $table) {
             $table->date('data_pagamento')->nullable()->after('date');
-            $table->string('numero_fattura');
+            $table->string('numero_fattura')->nullable();
             $table->string('tipo_documento')->nullable()->after('type');
             $table->string('BIC')->nullable()->after('tipo_documento');
             $table->string('IBAN')->nullable()->after('BIC');

+ 35 - 0
database/migrations/2025_04_09_093800_add_fields_to_rates_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('rates', function (Blueprint $table) {
+            $table->boolean('is_subscription')->nullable();
+            $table->unsignedBigInteger('record_id')->nullable();
+            $table->foreign('record_id')->nullable()->references('id')->on('records')->onUpdate('cascade')->onDelete('set null');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('rates', function (Blueprint $table) {
+            $table->dropColumn('record_id');
+            $table->dropColumn('is_subscription');
+        });
+    }
+};

BIN
public/img/leezard.png


+ 9 - 5
resources/views/layouts/app.blade.php

@@ -176,6 +176,8 @@
                 print "Discipline";
             if (Request::is('cards'))
                 print "Tesseramenti";
+            if (Request::is('rates'))
+                print "Corsi - Rate";
             if (Request::is('course_subscriptions'))
                 print "Corsi - Abbonamenti";
             if (Request::is('courses'))
@@ -316,11 +318,13 @@
                                             <span class="ms-3 d-md-inline">Iscritti</span>
                                         </a>
                                     </li>
-                                    <li class="nav-item" style="{{Request::is('course_list') ? 'background-color: #c5d9e6;' : ''}}">
-                                        <a href="/course_list" class="nav-link d-flex align-items-center linkMenu">
-                                            <span class="ms-3 d-md-inline">Pagamenti</span>
-                                        </a>
-                                    </li>
+                                    @if(false)
+                                        <li class="nav-item" style="{{Request::is('course_list') ? 'background-color: #c5d9e6;' : ''}}">
+                                            <a href="/course_list" class="nav-link d-flex align-items-center linkMenu">
+                                                <span class="ms-3 d-md-inline">Pagamenti</span>
+                                            </a>
+                                        </li>
+                                    @endif
                                 </ul>
                             </div>
                         </div>

+ 23 - 7
resources/views/livewire/course_member.blade.php

@@ -10,6 +10,8 @@
 
     </header>
 
+    <a class="btn--ui lightGrey" href="/course_member_two?type={{$type}}"><i class="fa-solid fa-arrow-left"></i></a><br>
+
     <div class="showFilter" style="display:none" wire:ignore.self>
         <hr size="1">
         <div class="row g-3">
@@ -272,12 +274,10 @@
                     <th scope="col">#</th>
                     <th scope="col">Corso</th>
                     <th scope="col">Cognome</th>
-                    <th scope="col">Nome</th>
-                    <th scope="col">Età</th>
-                    <th scope="col">Anno di nascita</th>
-                    <th scope="col">Sesso</th>
-                    <th scope="col">Telefono</th>
+                    <th scope="col">Nome</th>                    
                     <th scope="col">Certificato</th>
+                    <th scope="col">Stato</th>
+                    <th scope="col">...</th>
                 </tr>
             </thead>
             <tbody id="checkall-target">
@@ -663,10 +663,10 @@
                             return ret;
                         }
                     },
-                    { data: 'column_3' },
+                    /*{ data: 'column_3' },
                     { data: 'column_4' },
                     { data: 'column_9'  },
-                    { data: 'column_5' },
+                    { data: 'column_5' },*/
                     {
                         data: 'column_6',
                         render: function (data, type, row) {
@@ -693,6 +693,22 @@
                             html += '</span>';
                             return html;
                         }
+                    },
+                    { 
+                        data: 'column_11',
+                        render: function (data, type, row) {
+                            var html = '<span class="badge tessera-badge ' + (data == 0 ? 'due' : (data == 1 ? 'active' : 'suspended')) + '">' + (data == 0 ? 'Da pagare' : (data == 1 ? 'Pagato' : 'Sospeso')) + '</span>';
+                            return html;
+                        }
+                    },
+
+                    
+
+                    { data: 'column_10',
+                        render: function (data, type, row) {
+                            var html = '<a href="/rates?member_id=' + row["column_7"] + '&member_course_id=' + data + '"><b> > </b></a>';
+                            return html;
+                        }  
                     }],
                 layout: {
                     topStart: null,

+ 3 - 5
resources/views/livewire/course_member_one.blade.php

@@ -9,8 +9,6 @@
 
     </header>
 
-    <a class="btn--ui lightGrey" href="/settings?type=corsi"><i class="fa-solid fa-arrow-left"></i></a><br>
-
     <section id="resume-table">
         <div class="compare--chart_wrapper d-none"></div>
 
@@ -26,7 +24,7 @@
                     <tr>
                         <td>{{$record["name"]}}</td>
                         <td>
-                            <a href="/course_member_two?type={{$record["type"]}}" type="button" class="btn" >></button>
+                            <a href="/course_member_two?type={{$record["type"]}}" type="button" class="btn" ><b>></b></button>
                         </td>
                     </tr>
                 @endforeach
@@ -113,11 +111,11 @@
                 pagingType: 'numbers',
                 "language": {
                     "url": "/assets/js/Italian.json"
-                },
+                }/*,
                 "fnInitComplete": function (oSettings, json) {
                     var html = '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
                     $(".dt-search").append(html);
-                }
+                }*/
             });
             $('#tablesaw-350 thead tr th').addClass('col');
             $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");

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

@@ -32,11 +32,21 @@
                         <td>{{$record->name}}</td>
                         <td>{{$record->frequency->name ?? ""}}</td>
                         <td>{{$record->level->name ?? ""}}</td>
-                        <td></td>                            
-                        <td></td>                            
+                        <td>{{date("d/m/Y", strtotime($record->date_from))}} - {{date("d/m/Y", strtotime($record->date_to))}}                                                                </td>                            
+                        <td>
+                            @foreach(json_decode($record->when) as $xx => $x)
+                                @if($xx > 0)
+                                    <br>
+                                @endif
+                                @foreach($x->day as $zz => $d)
+                                    {{$zz > 0 ? '-' : ''}}{{$d}}
+                                @endforeach
+                                h {{$x->from}} - {{$x->to}}
+                            @endforeach
+                        </td>                            
                         <td>{{$record->getins->name ?? ""}}</td>
                         <td>
-                            <a href="/course_member?id={{$record->id}}" type="button" class="btn" >></button>
+                            <a href="/course_member?id={{$record->id}}" type="button" class="btn" ><b>></b></button>
                         </td>
                     </tr>
                 @endforeach
@@ -123,11 +133,11 @@
                 pagingType: 'numbers',
                 "language": {
                     "url": "/assets/js/Italian.json"
-                },
+                }/*,
                 "fnInitComplete": function (oSettings, json) {
                     var html = '&nbsp;<a href="#" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
                     $(".dt-search").append(html);
-                }
+                }*/
             });
             $('#tablesaw-350 thead tr th').addClass('col');
             $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");

+ 1 - 1
resources/views/livewire/course_subscription.blade.php

@@ -78,7 +78,7 @@
                                 <div class="form--item">
                                     <label for="months" class="form-label">Mesi</label>
                                     <select class="form-control" id="months" wire:model="months">
-                                        @for($i=1;$i<=12;$i++)
+                                        @for($i=0;$i<=12;$i++)
                                             <option value="{{$i}}">{{$i}}</option>
                                         @endfor
                                     </select>

+ 104 - 86
resources/views/livewire/member.blade.php

@@ -1143,13 +1143,18 @@
                                                                 <b>{{$member_course->course->name}}</b><br>
                                                             </td>
                                                             <td style="width:10%">
-                                                                {{$member_course->course->type->name ?? ""}}<br>
+                                                                {{$member_course->course->frequency->name ?? ""}}<br>
                                                             </td>
                                                             <td style="width:10%">
                                                                 {{$member_course->course->level->name ?? ""}}<br>
                                                             </td>
                                                             <td style="width:30%">
-                                                                @foreach(json_decode($member_course->when) as $xx => $x)
+                                                                @php
+                                                                $when = $member_course->when;
+                                                                if ($when == '[{"to": "", "day": [], "from": ""}]')
+                                                                    $when = $member_course->course->when;
+                                                                @endphp
+                                                                @foreach(json_decode($when) as $xx => $x)
                                                                     @if($xx > 0)
                                                                         <br>
                                                                     @endif
@@ -1159,51 +1164,56 @@
                                                                     h {{$x->from}} - {{$x->to}}
                                                                 @endforeach
                                                             </td>
-                                                            <td style="width:25%">
+                                                            <td style="width:15%">
+                                                                {{date("d/m/Y", strtotime($member_course->date_from))}} <br> {{date("d/m/Y", strtotime($member_course->date_to))}}                                                                
+                                                            </td>
+                                                            <td style="text-align:right;width:10%">
+                                                                <div class="row">
+                                                                    <div class="col-6">
+                                                                        <button style="float:left;" type="button" class="btn" wire:click="editCourse({{ $member_course->id }})" data-bs-toggle="popover"  data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Modifica"><i class="fa-regular fa-pen-to-square"></i></button>
+                                                                    </div>
+                                                                    <div class="col-6">
+                                                                        <button type="button" class="btn" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="deleteCourse({{ $member_course->id }})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>
+                                                                    </div>
+                                                                </div>
+                                                            </td>
+                                                            <td style="text-align:right;width:5%">
                                                                 @php
-                                                                $aMo = json_decode($member_course->months);
-                                                                if (sizeof($aMo) == 1)
-                                                                {
-                                                                    print($this->getMonth($aMo[0]->m));
-                                                                }
-                                                                if (sizeof($aMo) > 1)
-                                                                {
-                                                                    print($this->getMonth($aMo[0]->m) . " - " . $this->getMonth($aMo[sizeof($aMo) - 1]->m));
-                                                                }
+                                                                $status = $member_course->getStatus();
                                                                 @endphp
+                                                                <a href="/rates?member_id={{$member_course->member_id}}&member_course_id={{$member_course->id}}"><span class="badge tessera-badge {{$status == 0 ? 'due' : ($status == 1 ? 'active' : 'suspended')}}">{{$status == 0 ? 'Da pagare' : ($status == 1 ? 'Pagato' : 'Sospeso')}}</span></a>
+                                                                @if($member_course->notes != '')
+                                                                    <button type="button" class="btn" wire:click="showHideCourse({{ $member_course->id }})"><i class="fa-solid fa-chevron-down"></i></button>&nbsp;
+                                                                @endif
                                                             </td>
-                                                            @if(false)
-                                                                <td style="width:10%">Iscrizione:<br><b>{{$member_course->status == 1 ? 'Pagata' : ($member_course->status == 2 ? 'Da pagare' : 'Sospesa')}}</b></td>
-                                                            @endif
-                                                            <td style="text-align:right;width:15%">
-                                                                <button type="button" class="btn" wire:click="showHideCourse({{ $member_course->id }})"><i class="fa-solid fa-chevron-down"></i></button>&nbsp;
-                                                            </td>
-
+                                                            
                                                         </tr>
                                                         @if(in_array($member_course->id, $showCourse))
-                                                            <tr>
-                                                                <td colspan="5">
-                                                                    <a class="{{$this->getSubscriptionStatus($member_course->subscribed, $member_course->id)}}" wire:click="setCreateSubscription({{$member_course->subscribed}}, {{$member_course->id}})" style="float:none; width:150px;{{$this->getSubscriptionStatus($member_course->subscribed,$member_course->id) == 'blue' || $this->getSubscriptionStatus($member_course->subscribed,$member_course->id) == 'orange' || $this->getSubscriptionStatus($member_course->subscribed,$member_course->id) == 'yellow' ? 'cursor:pointer' : ''}}">Iscrizione</a><br>
-                                                                    <a class="{{$this->getMonthStatus(9, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(9, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(9, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Set</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(10, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(10, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(10, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Ott</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(11, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(11, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(11, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Nov</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(12, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(12, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(12, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Dic</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(1, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(1, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(1, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Gen</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(2, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(2, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(2, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Feb</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(3, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(3, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(3, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Mar</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(4, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(4, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(4, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Apr</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(5, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(5, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(5, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Mag</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(6, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(6, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(6, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Giu</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(7, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(7, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(7, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Lug</a>&nbsp;
-                                                                    <a class="{{$this->getMonthStatus(8, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(8, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(8, $member_course->months, $member_course->id) , ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Ago</a>&nbsp;
-                                                                </td>
-                                                                <td>
-                                                                    <button type="button" class="btn" wire:click="editCourse({{ $member_course->id }})" data-bs-toggle="popover"  data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Modifica"><i class="fa-regular fa-pen-to-square"></i></button>&nbsp;
-                                                                    <button type="button" class="btn" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="deleteCourse({{ $member_course->id }})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>
-                                                                </td>
-                                                            </tr>
-                                                            <tr>
-                                                                <td colspan="6">
+                                                            @if(false)
+                                                                <tr>
+                                                                    <td colspan="5">
+                                                                        <a class="{{$this->getSubscriptionStatus($member_course->subscribed, $member_course->id)}}" wire:click="setCreateSubscription({{$member_course->subscribed}}, {{$member_course->id}})" style="float:none; width:150px;{{$this->getSubscriptionStatus($member_course->subscribed,$member_course->id) == 'blue' || $this->getSubscriptionStatus($member_course->subscribed,$member_course->id) == 'orange' || $this->getSubscriptionStatus($member_course->subscribed,$member_course->id) == 'yellow' ? 'cursor:pointer' : ''}}">Iscrizione</a><br>
+                                                                        <a class="{{$this->getMonthStatus(9, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(9, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(9, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Set</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(10, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(10, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(10, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Ott</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(11, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(11, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(11, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Nov</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(12, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(12, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(12, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Dic</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(1, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(1, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(1, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Gen</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(2, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(2, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(2, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Feb</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(3, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(3, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(3, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ?  'style=cursor:pointer' : ''}}>Mar</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(4, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(4, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(4, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Apr</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(5, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(5, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(5, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Mag</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(6, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(6, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(6, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Giu</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(7, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(7, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(7, $member_course->months, $member_course->id), ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Lug</a>&nbsp;
+                                                                        <a class="{{$this->getMonthStatus(8, $member_course->months, $member_course->id)}}" wire:click="setPayMonth(8, '{{ $member_course->months }}', {{$member_course->id}})" {{in_array($this->getMonthStatus(8, $member_course->months, $member_course->id) , ['blue', 'orange', 'yellow', 'orange half']) ? 'style=cursor:pointer' : ''}}>Ago</a>&nbsp;
+                                                                    </td>
+                                                                    <td>
+                                                                        <button type="button" class="btn" wire:click="editCourse({{ $member_course->id }})" data-bs-toggle="popover"  data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Modifica"><i class="fa-regular fa-pen-to-square"></i></button>&nbsp;
+                                                                        <button type="button" class="btn" onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()" wire:click="deleteCourse({{ $member_course->id }})" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="bottom" data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>
+                                                                    </td>
+                                                                </tr>
+                                                            @endif
+                                                            <tr >
+                                                                <td  colspan="7">
                                                                     @if($selectedCourseMember == $member_course->id)
                                                                         @if(sizeof($payMonths) > 0 || $createSubscription)
                                                                             <button class="btn--ui primary" style="color:white" wire:click="newPayment({{$member_course}})">Nuova entrata</button>&nbsp;
@@ -1219,6 +1229,7 @@
                                                                     @endif
                                                                 </td>
                                                             </tr>
+                                                        
                                                         @endif
 
                                                     @endforeach
@@ -1231,21 +1242,34 @@
                                             <div class="form--wrapper">
                                                 <form class="form--utente">
                                                     <div class="row ">
-                                                        <div class="col-6 mt-2">
+                                                        <div class="col-12 mt-2">
                                                             <label for="course_name" class="form-label">Tipo corso</label><br>
                                                             <input type="radio" name="chkType" value="standard" wire:model="course_course_type">&nbsp;Standard
                                                             &nbsp;&nbsp;&nbsp;
                                                             <input type="radio" name="chkType" value="custom" wire:model="course_course_type">&nbsp;Personalizzato
                                                         </div>
-                                                        <div class="col-md-6">
-                                                            <label for="course_name" class="form-label">Corso</label>
+                                                        <div class="row">
 
-                                                            <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 $c)
-                                                                    <option value="{{$c->id}}">{{$c->name}}
-                                                                @endforeach
-                                                            </select>
+                                                            <div class="col-md-4">
+                                                                <label for="course_name" class="form-label">Corso</label>
+                                                                <select id="course_name" class="form-select" aria-label="Livello" wire:model="course_name" >
+                                                                    <option value="">
+                                                                    @foreach($course_names as $cn)
+                                                                        <option value="{{$cn}}">{{$cn}}
+                                                                    @endforeach
+                                                                </select>
+                                                            </div>
+
+                                                            @if(false)
+                                                                <label for="course_name" class="form-label">Corso</label>
+
+                                                                <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 $c)
+                                                                        <option value="{{$c->id}}">{{$c->name}}
+                                                                    @endforeach
+                                                                </select>
+                                                            @endif
 
                                                             @error('course_course_id')
                                                                 <div class="invalid-feedback">Devi selezionare un corso</div>
@@ -1254,10 +1278,9 @@
                                                             @if($course_exist)
                                                                 <small style="color:red">Attenzione : il corso selezionato è già associato all'utente</small>
                                                             @endif
-                                                        </div>
-                                                        @if(false)
+
                                                             @if($course_name != '')
-                                                                <div class="col-md-3">
+                                                                <div class="col-md-4">
                                                                     <label for="course_level_id" class="form-label">Livello</label>
                                                                     <select id="course_level_id" class="form-select" aria-label="Livello" wire:model="course_level_id" >
                                                                         <option value="">
@@ -1268,18 +1291,7 @@
                                                                 </div>
                                                             @endif
                                                             @if($course_level_id != '')
-                                                                <div class="col-md-3">
-                                                                    <label for="course_type_id" class="form-label">Tipologia</label>
-                                                                    <select id="course_type_id" class="form-select" aria-label="Tipologia" wire:model="course_type_id" >
-                                                                        <option value="">
-                                                                        @foreach($course_types as $t)
-                                                                            <option value="{{$t->id}}">{{$t->name}}
-                                                                        @endforeach
-                                                                    </select>
-                                                                </div>
-                                                            @endif
-                                                            @if($course_type_id != '')
-                                                                <div class="col-md-3">
+                                                                <div class="col-md-4">
                                                                     <label for="course_frequency_id" class="form-label">Frequenza</label>
                                                                     <select id="course_frequency_id" class="form-select" aria-label="Tipologia" wire:model="course_frequency_id" >
                                                                         <option value="">
@@ -1289,7 +1301,9 @@
                                                                     </select>
                                                                 </div>
                                                             @endif
-                                                        @endif
+                                                            
+                                                        </div>
+                                                        
                                                     </div>
                                                     @if($course_course_id > 0)
                                                         <div class="row mt-4">
@@ -1308,29 +1322,33 @@
                                                                 <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">
-                                                                    <option value="">
-                                                                    <option value="1">Pagata
-                                                                    <option value="2">Da pagare
-                                                                    <option value="3">Sospesa
-                                                                </select>
-                                                            </div>
-                                                            @endif
+                                                            
                                                         </div>
-
-                                                        <div class="row mt-4 course--duration">
-                                                            <div class="col-md-12">
-                                                                <label for="duration" class="form-label">Durata del corso</label>
-                                                                <div class="d-flex course--duration_mounth">
-                                                                    @foreach($course_months_list as $cm)
-                                                                        <a class="{{$this->checkMonth($cm) ? 'selected' : 'notSelected'}}" wire:click="setMonth({{$cm}})">{{getMonthName($cm, true)}}</a>
-                                                                    @endforeach
+                                                    
+                                                        @if(false)
+                                                            <div class="row mt-4 course--duration">
+                                                                <div class="col-md-12">
+                                                                    <label for="duration" class="form-label">Durata del corso</label>
+                                                                    <div class="d-flex course--duration_mounth">
+                                                                        @foreach($course_months_list as $cm)
+                                                                            <a class="{{$this->checkMonth($cm) ? 'selected' : 'notSelected'}}" wire:click="setMonth({{$cm}})">{{getMonthName($cm, true)}}</a>
+                                                                        @endforeach
+                                                                    </div>
                                                                 </div>
                                                             </div>
+                                                        @endif
+
+                                                        <div class="row mt-4">
+                                                            <div class="col-md-6">
+                                                                <label for="course_date_from" class="form-label">Data inizio</label>
+                                                                <input class="form-control" type="date" id="course_date_from" wire:model="course_date_from">
+                                                            </div>
+                                                            <div class="col-md-6">
+                                                                <label for="course_date_to" class="form-label">Data fine</label>
+                                                                <input class="form-control" type="date" id="course_date_to" wire:model="course_date_to">
+                                                            </div>
                                                         </div>
+
                                                         <div class="row mt-4">
                                                             <div class="col-md-6">
                                                                 <label for="course_subscription_price" class="form-label">Costo iscrizione</label>

+ 407 - 0
resources/views/livewire/rate.blade.php

@@ -0,0 +1,407 @@
+<div class="col card--ui" id="card--dashboard">
+
+    <header id="title--section" style="display:none !important"
+        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">Rate</h2>
+        </div>
+    </header>
+
+    <a class="btn--ui lightGrey" href="/course_member?id={{$mc->course_id}}"><i class="fa-solid fa-arrow-left"></i></a><br>
+
+    <div class="showFilter" style="display:none" wire:ignore.self>
+        <hr size="1">
+        <div class="row g-3">
+            <div class="col-md-2">
+                <div class="row">
+                    <div class="col-md-12" style="margin-bottom:10px;">
+                        <b>Periodo</b>
+                    </div>
+                    <div class="col-12 mb-2">
+                        <input id="dateFrom" type="date" class="form-control filterFrom" name="txtFrom">
+                    </div>
+                    <div class="col-12">
+                        <input id="dateTo" type="date" class="form-control filterTo" name="txtTo">
+                    </div>
+                    <div class="col-6 mt-2">
+                        <button class="btn--ui lightGrey todayButton" style="width:100%"
+                            onclick="setToday('{{date("Y-m-d")}}')">OGGI</button>
+                    </div>
+                    <div class="col-6 mt-2">
+                        <button class="btn--ui lightGrey yesterdayButton" style="width:100%"
+                            onclick="setYesterday('{{date("Y-m-d", strtotime("-1 days"))}}')">IERI</button>
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-2">
+                <div class="row">
+                    <div class="col-md-12" style="margin-bottom:10px;">
+                        <b>Stato</b>
+                    </div>
+                    <div class="col-12">
+                        <select class="form-select filterStatus">
+                            <option value="">--Seleziona--
+                            <option value="1">Attiva
+                            <option value="99">Annullata
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-3">
+                <div class="row">
+                    <div class="col-md-12" style="margin-bottom:10px;">
+                        <b>Cerca Utente</b>
+                    </div>
+                    <div class="col-12">
+                        <select class="form-select filterMember" wire:model="filteredMemberId">
+                            <option value="">--Seleziona Utente--</option>
+                            @foreach($members as $member)
+                                <option value="{{ $member->id }}">{{ $member->last_name }} {{ $member->first_name }}
+                                </option>
+                            @endforeach
+                        </select>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="row g-3">
+            <div class="col-md-12" style="text-align:right">
+                <button class="btn--ui_outline light" onclick="reset()">RESET</button>
+                <button class="btn--ui" onclick="loadDataTable()">FILTRA</button>
+            </div>
+        </div>
+        <hr size="1">
+    </div>
+
+    <section id="resume-table">
+        <div class="compare--chart_wrapper d-none"></div>
+
+        <h3>{{$detail}}</h3><br>
+
+        <table class="table tablesaw tableHead tablesaw-stack table--lista_ricevute" id="tablesaw-350" width="100%">
+            <thead>
+                <tr>
+                    <th scope="col"></th>
+                    <th scope="col">Data scadenza</th>
+                    <th scope="col">Rata</th>
+                    <th scope="col">Competenza</th>
+                    <th scope="col">Prezzo</th>
+                    <th scope="col">Stato pagamento</th>
+                    <th scope="col">...</th>
+                </tr>
+            </thead>
+            <tbody id="checkall-target">
+                @foreach($records as $record)
+                    <tr>
+                        <td></td>
+                        <td>{{date("d/m/Y", strtotime($record->date))}}</td>
+                        <td>{{$record->course_subscription ? $record->course_subscription->name : 'Iscrizione'}}</td>
+                        <td>
+                            @if(sizeof(json_decode($record->months)) > 1)
+                                {{getMonthName(json_decode($record->months)[0])}} - {{getMonthName(json_decode($record->months)[sizeof(json_decode($record->months)) - 1])}}
+                            @else
+                                @if(sizeof(json_decode($record->months)) > 0)
+                                    {{getMonthName(json_decode($record->months)[0])}}
+                                @endif
+                            @endif
+                        </td>
+                        <td>{{formatPrice($record->price)}}</td>
+                        <td>
+                            <span class="tablesaw-cell-content">
+                                <span class="badge tessera-badge {{$record->status == 0 ? 'due' : ($record->status == 1 ? 'active' : 'suspended')}}">{{$record->status == 0 ? 'Da pagare' : ($record->status == 1 ? 'Pagato' : 'Sospeso')}}</span>
+                            </span>
+                        </td>
+                        <td>
+                            @if($record->status == 1)
+                                <button type="button" class="btn u"
+                                    onclick="document.location.href='/in?id={{$record->record_id}}'" data-bs-toggle="popover"
+                                    data-bs-trigger="hover focus" data-bs-placement="bottom"
+                                    data-bs-content="Visualizza ricevuta"><i class="fa-regular fa-eye"></i></button>
+                            @endif
+                            @if($record->status == 0)
+                                <a class="btn  u" href="/in?new=1&memberId={{$record->member_id}}&causalId={{!$record->is_subscription ? $record->member_course->course->causal_id : ''}}&subCausalId={{$record->is_subscription ? $record->member_course->course->sub_causal_id : ''}}&createSubscription={{$record->is_subscription ? '1' : ''}}&months={{implode("|", json_decode($record->months))}}&price={{!$record->is_subscription ? $record->price : ''}}&subscription_price={{$record->is_subscription ? $record->price : ''}}&courseId={{$record->member_course_id}}&rateId={{$record->id}}" data-bs-toggle="popover"
+                                data-bs-trigger="hover focus" data-bs-placement="bottom"
+                                data-bs-content="Crea entrata"><i class="fa-regular fa-file-lines"></i></a>
+                                <a class="btn u" onclick="confirmDelete({{$record->id}})" data-bs-toggle="popover"
+                                    data-bs-trigger="hover focus" data-bs-placement="bottom"
+                                    data-bs-content="Elimina"><i class="fa-regular fa-trash-can"></i></button>
+                            @endif
+                        </td>
+                    </tr>
+                @endforeach
+            </tbody>
+        </table>
+
+    </section>
+
+    <div  wire:ignore.self class="modal fade" id="rateModal" tabindex="-1" aria-labelledby="rateModalLabel" aria-hidden="true">
+        <div class="modal-dialog">
+            <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title" id="rateModalLabel">Inserimento nuova rata</h5>
+                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
+            </div>
+            <div class="modal-body">
+                <div class="row">
+                    <div class="col-md-6">
+                        <label for="course_subscription_id" class="form-label">Abbonamento</label>
+                        <select id="course_subscription_id" class="form-select  @error('course_subscription_id') is-invalid @enderror" aria-label="Abbonamento" wire:model="course_subscription_id">
+                            <option value="">
+                            @foreach($course_subscriptions as $t)
+                                <option value="{{$t["id"]}}">{{$t["name"]}}
+                            @endforeach
+                        </select>
+                    </div>
+                    <div class="col-md-6">
+                        <label for="price" class="form-label">Prezzo</label>
+                        <input class="form-control" type="text" id="price" placeholder="Costo mensile" wire:model="price" onkeyup="onlyNumberAmount(this)">
+                    </div>
+                </div>
+                <div class="row mt-2">
+                    <div class="col-md-6">
+                        <label for="date" class="form-label">Scadenza</label>
+                        <input class="form-control @error('date') is-invalid @enderror" type="date" id="date" placeholder="Email" wire:model="date">
+                    </div>
+                <div>
+                <div class="row mt-2">
+                    <div class="col-md-12">
+                        <label for="months" class="form-label">Mesi</label><br>
+                        <input type="checkbox" value="1" class="chkMonth">&nbsp;Gennaio
+                        <input type="checkbox"  value="2" class="chkMonth">&nbsp;Febbraio
+                        <input type="checkbox"  value="3" class="chkMonth">&nbsp;Marzo
+                        <input type="checkbox"  value="4" class="chkMonth">&nbsp;Aprile<br>
+                        <input type="checkbox"  value="5" class="chkMonth">&nbsp;Maggio
+                        <input type="checkbox"  value="6" class="chkMonth">&nbsp;Giugno
+                        <input type="checkbox"  value="7" class="chkMonth">&nbsp;Luglio
+                        <input type="checkbox"  value="8" class="chkMonth">&nbsp;Agosto<br>
+                        <input type="checkbox"  value="9" class="chkMonth">&nbsp;Settembre
+                        <input type="checkbox"  value="10" class="chkMonth">&nbsp;Ottobre
+                        <input type="checkbox"  value="11" class="chkMonth">&nbsp;Novembre
+                        <input type="checkbox"  value="12" class="chkMonth">&nbsp;Dicembre
+                    </div>
+                </div>
+                
+            </div>
+            <div class="modal-footer">
+                <button class="btn--ui lightGrey" onclick="annulla()">annulla</a>
+                <button type="button" class="btn--ui btn-primary" wire:click.prevent="add()">Inserisci</button>
+            </div>
+            </div>
+        </div>
+    </div>
+
+</div>
+
+
+@push('scripts')
+    <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;
+        }
+    </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>
+@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>
+
+        function annulla()
+        {
+            $('.btn-close').trigger('click') ;
+            setTimeout(() => {
+                location.reload();    
+            }, 200);                
+        }
+
+        function confirmDelete(id)
+        {
+            if (confirm('Confermi di voler eliminare la rata?'))
+            {
+                @this.delete(id);
+                setTimeout(() => {
+                    location.reload();    
+                }, 200);                
+            }
+        }
+
+        $(document).ready(function() {
+            loadDataTable();
+
+            $('.chkMonth').change(function() {
+                let val = ($(this).val());
+                @this.addDeleteMonth(val);
+                
+            });
+
+        } );
+
+        Livewire.on('close-popup', () => {
+            annulla();            
+        });
+
+        Livewire.on('load-data-table', () => {
+            loadDataTable();
+        });
+
+        function loadDataTable(){
+            if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
+                $('#tablesaw-350').DataTable().destroy();
+            }
+            $('#tablesaw-350').DataTable({
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                layout: {
+                    topStart : null,
+                    topEnd : null,
+                    top1A: {
+                        buttons: [
+                            {
+                                extend: 'collection',
+                                text: 'ESPORTA',
+                                buttons: [
+                                    {
+                                    extend: 'excelHtml5',
+                                        title: 'Metodi di pagamento',
+                                        exportOptions: {
+                                            columns: ":not(':last')"
+                                        }
+                                    },
+                                    {
+                                        extend: 'pdfHtml5',
+                                        title: 'Metodi di pagamento',
+                                        exportOptions: {
+                                            columns: ":not(':last')"
+                                        }
+                                    },
+                                    {
+                                        extend: 'print',
+                                        text: 'Stampa',
+                                        title: 'Metodi di pagamento',
+                                        exportOptions: {
+                                            columns: ":not(':last')"
+                                        }
+                                    }
+                                ],
+                                dropup: true
+                            }
+                        ]
+                    },
+                    top1B : {
+                        pageLength: {
+                            menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
+                        }
+                    },
+                    top1C :'search',
+                },
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                },
+                "fnInitComplete": function (oSettings, json) {
+                    var html = '&nbsp;<a href="#" data-bs-toggle="modal" data-bs-target="#rateModal" class="addData btn--ui"><i class="fa-solid fa-plus"></i></a>';
+                    $(".dt-search").append(html);
+                }
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
+
+            $(document).ready(function() {
+                $(document).on("click",".addData",function() {
+                    $(".title--section_addButton").trigger("click")
+                });
+            } );
+
+        }
+
+    </script>
+@endpush

+ 14 - 1
routes/web.php

@@ -1,5 +1,4 @@
 <?php
-
 use Illuminate\Support\Facades\Route;
 use Barryvdh\DomPDF\Facade\Pdf;
 use Illuminate\Support\Facades\Redirect;
@@ -81,6 +80,7 @@ Route::group(['middleware' => 'auth'], function () {
     Route::get('/records_in_out', \App\Http\Livewire\RecordINOUT::class);
     Route::get('/users', \App\Http\Livewire\User::class);
     Route::get('/profile', \App\Http\Livewire\Profile::class);
+    Route::get('/rates', \App\Http\Livewire\Rate::class);
     Route::get('/reports', \App\Http\Livewire\Reports::class);
     Route::get('/azienda', \App\Http\Livewire\Azienda::class);
 });
@@ -1423,6 +1423,17 @@ Route::get('/get_course_members', function () {
             $genderDisplay = "N/A";
         }
 
+        $status = 0;
+        $rates = \App\Models\Rate::where('member_course_id', $r->id)->orderBy('date')->get();
+        foreach($rates as $rate)
+        {
+            if ($rate->date > date("Y-m-d"))
+            {
+                break;
+            }
+            $status = $rate->status;
+        }
+
         $ret[] = array(
             "column_0" => $idx + 1,
             "column_8" => $r->course_name,
@@ -1434,6 +1445,8 @@ Route::get('/get_course_members', function () {
             "column_5" => $r->phone,
             "column_6" => $certificateInfo,
             "column_7" => $r->member_id,
+            "column_10" => $r->id,
+            "column_11" => $status,
         );
     }