Преглед на файлове

Merge branch 'master' into fabio_develop

FabioFratini преди 10 месеца
родител
ревизия
d19133b03b

+ 47 - 0
app/Http/Livewire/Course.php

@@ -23,6 +23,9 @@ class Course extends Component
         $price,
         $subscription_price,
         $months,
+        $when,
+        $prices,
+        $type,
         $date_from, $date_to;
 
     public $categories = array();
@@ -79,6 +82,10 @@ class Course extends Component
         $this->date_to = null;
         $this->months = array();
         $this->enabled = true;
+        $this->type = 'standard';
+        $this->when = array();
+        $this->when[] = array('day' => array(), 'from' => '', 'to' => '');
+        $this->prices = [];
         $this->emit('load-data-table');
     }
 
@@ -178,6 +185,8 @@ class Course extends Component
                 'price' => currencyToDouble($this->price),
                 'subscription_price' => currencyToDouble($this->subscription_price),
                 'months' => json_encode($this->months),
+                'type' => $this->type,
+                'when' => json_encode($this->when),
                 'enabled' => $this->enabled
             ]);
             session()->flash('success','Corso creato');
@@ -190,6 +199,7 @@ class Course extends Component
     }
 
     public function edit($id){
+        $this->resetFields();
         try {
             $course = \App\Models\Course::findOrFail($id);
             if( !$course) {
@@ -213,6 +223,15 @@ class Course extends Component
                 $this->price = formatPrice($course->price);
                 $this->subscription_price = formatPrice($course->subscription_price);
                 $this->months = json_decode($course->months);
+                $this->when = array();
+                if ($course->when != null)
+                {
+                    foreach(json_decode($course->when) as $z)
+                    {
+                        $this->when[] = array("day" => $z->day, "from" => $z->from, "to" => $z->to);
+                    }
+                }
+                $this->type = $course->type;
                 $this->dataId = $course->id;
                 $this->update = true;
                 $this->add = false;
@@ -245,6 +264,8 @@ class Course extends Component
                 'price' => currencyToDouble($this->price),
                 'subscription_price' => currencyToDouble($this->subscription_price),
                 'months' => json_encode($this->months),
+                'type' => $this->type,
+                'when' => json_encode($this->when),
                 'enabled' => $this->enabled
             ]);
             session()->flash('success','Corso aggiornato');
@@ -313,4 +334,30 @@ class Course extends Component
         return redirect()->to('/courses');
     }
 
+    public function setDay($idx, $d)
+    {
+
+        if (in_array($d, $this->when[$idx]["day"]))
+        {
+            $i = array_search($d, $this->when[$idx]["day"]);
+            array_splice($this->when[$idx]["day"], $i, 1);
+
+        }
+        else
+        {
+            $this->when[$idx]["day"][] = $d;
+        }
+
+    }
+
+    public function addRow()
+    {
+        $this->when[] = array('day' => array(), 'from' => '', 'to' => '');
+    }
+
+    public function delRow($idx)
+    {
+        unset($this->when[$idx]);
+    }
+
 }

+ 705 - 8
app/Http/Livewire/CourseList.php

@@ -6,12 +6,28 @@ use Livewire\Component;
 use App\Models\MemberCourse;
 use Illuminate\Support\Facades\Log;
 
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+
 class CourseList extends Component
 {
 
     public $records = array();
+    public $recordsNoPaginate = array();
     public $courses = array();
 
+    public $start = 0;
+    public $totalRecords = 0;
+    public $pages = 0;
+    public $currentPage = 1;
+    public $pageLength = 10;
+
+    public $totS = [];
+    public $totSExcel = [];
+
+    public $sort = '';
+    public $dir = '';
+
     public $hasFilter = false;
 
     public $courseId = 0;
@@ -54,16 +70,36 @@ class CourseList extends Component
 
     }
 
+    public function updatedfilterCourse($value){
+        $this->emit('load-data-table');
+    }
+
+    public function updatedfilterLevel($value){
+        $this->emit('load-data-table');
+    }
+
+    public function updatedfilterFrequency($value){
+        $this->emit('load-data-table');
+    }
+
+    public function updatedfilterType($value){
+        $this->emit('load-data-table');
+    }
+
+    public function updatedfilterDuration($value){
+        $this->emit('load-data-table');
+    }
+
+    public function updatedpageLength($value){
+        $this->emit('load-data-table');
+    }
+
+    
+
     public function render()
     {
 
-        // Carico tutti i corsi associati
         /*
-        if ($this->courseId > 0)
-            $member_course = \App\Models\MemberCourse::where('course_id', $this->courseId)->with('member'); //->get();
-        else
-            $member_course = \App\Models\MemberCourse::with('member'); //->get();
-        */
 
         if ($this->hasFilter)
         {
@@ -238,18 +274,542 @@ class CourseList extends Component
 
         $this->emit('load-data-table');
 
+        */
+
+        $member_course = \App\Models\MemberCourse::with('member')->with('course');
+
+        if ($this->hasFilter)
+        {
+            if (isset($_GET["search"]["value"]))
+            {
+
+                if ($_GET["search"]["value"] != '')
+                {
+                    $v = str_replace("'", "\'", stripcslashes($_GET["search"]["value"]));
+                    $member_ids = \App\Models\Member::where(function ($query) use ($v) {
+                        $query->whereRaw("CONCAT(first_name, ' ', last_name) like '%" . $v . "%'")
+                            ->orWhereRaw("CONCAT(last_name, ' ', first_name) like '%" . $v . "%'");
+                    })->pluck('id');
+                    /*
+                    $v = str_replace("'", "\'", stripcslashes($_GET["search"]["value"]));
+                    $member_ids = \App\Models\Member::where(function ($query) use ($v) {
+                        $query->where('first_name', 'like', '%' . $v . '%')
+                                ->orWhere('last_name', 'like', '%' . $v . '%');
+                    })->pluck('id');*/
+                    $member_course = $member_course->whereIn('member_id', $member_ids);
+                }
+            }
+
+            if (sizeof($this->filterCourse) > 0)
+            {
+                $course_ids = [];
+                $courses = $this->filterCourse;
+                foreach($courses as $c)
+                {
+                    $all = \App\Models\Course::where('name', 'like', '%' . $c . "%")->get();
+                    foreach($all as $a)
+                    {
+                        $course_ids[] = $a->id;
+                    }
+                }
+                $member_course = $member_course->whereIn('course_id', $course_ids);
+            }
+
+            if (sizeof($this->filterLevel) > 0)
+            {
+                $course_ids = \App\Models\Course::whereIn('course_level_id', $this->filterLevel)->pluck('id');
+                $member_course = $member_course->whereIn('course_id', $course_ids);
+            }
+
+            if (sizeof($this->filterFrequency) > 0)
+            {
+                $course_ids = \App\Models\Course::whereIn('course_frequency_id', $this->filterFrequency)->pluck('id');
+                $member_course = $member_course->whereIn('course_id', $course_ids);
+            }
+            if (sizeof($this->filterType) > 0)
+            {
+                $course_ids = \App\Models\Course::whereIn('course_type_id', $this->filterType)->pluck('id');
+                $member_course = $member_course->whereIn('course_id', $course_ids);
+            }
+            if (sizeof($this->filterDuration) > 0)
+            {
+                $course_ids = \App\Models\Course::whereIn('course_duration_id', $this->filterDuration)->pluck('id');
+                $member_course = $member_course->whereIn('course_id', $course_ids);
+            }
+        }
+        /*
+        if ($_GET["filterCourse"] != "null")
+        {
+            $course_ids = [];
+            $courses = explode(",", $_GET["filterCourse"]);
+            foreach($courses as $c)
+            {
+                $all = \App\Models\Course::where('name', 'like', '%' . $c . "%")->get();
+                foreach($all as $a)
+                {
+                    $course_ids[] = $a->id;
+                }
+            }
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+
+        if ($_GET["filterYear"] != "")
+        {
+            $course_ids = \App\Models\Course::where('year', $_GET["filterYear"])->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+
+        if ($_GET["filterLevel"] != "null")
+        {
+            $levels = explode(",", $_GET["filterLevel"]);
+            $course_ids = \App\Models\Course::whereIn('course_level_id', $levels)->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+        if ($_GET["filterFrequency"] != "null")
+        {
+            $frequencies = explode(",", $_GET["filterFrequency"]);
+            $course_ids = \App\Models\Course::whereIn('course_frequency_id', $frequencies)->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+        if ($_GET["filterType"] != "null")
+        {
+            $types = explode(",", $_GET["filterType"]);
+            $course_ids = \App\Models\Course::whereIn('course_type_id', $types)->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+        if ($_GET["filterDuration"] != "null")
+        {
+            $durations = explode(",", $_GET["filterDuration"]);
+            $course_ids = \App\Models\Course::whereIn('course_duration_id', $durations)->pluck('id');
+            $member_course = $member_course->whereIn('course_id', $course_ids);
+        }
+        */
+
+        $totals = [];
+        $totalIsc = [];
+
+        $datas = [];
+
+        $xxx = 1;
+
+        /*
+        $sortColumn = '';
+        if (isset($_GET["order"]))
+        {
+
+        }
+        */
+
+        $column = '';
+        $sort_value = 0;
+        if ($this->sort != '')
+        {
+            $f = $this->sort;
+            $d = $this->dir;
+            if ($f >= 5 && $f <= 16)
+            {
+                $column = 'column_' . ($f - 2);
+                if (session()->get('sort_column'))
+                {
+                    if (session()->get('sort_column') != $f)
+                    {
+                        session()->put('sort_column', $f);
+                        session()->put('sort_order', $d);
+                        session()->put('sort_value', 0);
+                        $sort_value = 0;
+                    }
+                    else
+                    {
+                        if (session()->get('sort_order') == $d)
+                        {
+                            //session()->put('sort_value', 0);
+                            $sort_value = session()->get('sort_value', 0);
+                        }
+                        else
+                        {
+                            if (session()->get('sort_value', 0) == 0)
+                            {
+                                $sort_value = 1;                                
+                            }
+                            if (session()->get('sort_value', 0) == 1)
+                            {
+                                $sort_value = 2;                                
+                            }
+                            if (session()->get('sort_value', 0) == 2)
+                            {
+                                $sort_value = 3;                                
+                            }
+                            if (session()->get('sort_value', 0) == 3)
+                            {
+                                $sort_value = 0;                                
+                            }
+                            session()->put('sort_value', $sort_value);
+                            
+                        }
+                        session()->put('sort_order', $d);
+                    }
+                }
+                else
+                {
+                    session()->put('sort_column', $f);
+                    session()->put('sort_order', $d);
+                    session()->put('sort_value', 0);
+                    $sort_value = 0;
+                }
+
+            }
+        }  
+
+        //print $sort_value;
+
+        $totals = [];
+        $prices = [];
+
+        $member_course_totals = $member_course->get();
+        foreach($member_course_totals as $x)
+        {
+
+            $price = 0;
+            $price = $x->price; // $x->course->price;
+            $subPrice = $x->subscription_price; // $x->course->subscription_price;
+            $records = \App\Models\Record::where('member_course_id', $x->id)->where('deleted', 0)->get();
+            $prices = [];
+            foreach ($records as $record)
+            {
+                foreach ($record->rows as $row)
+                {
+
+                    if ($row->causal_id == $x->course->sub_causal_id) //  || str_contains(strtolower($row->note), 'iscrizione'))
+                    //if (str_contains(strtolower($row->note), 'iscrizione'))
+                    {
+                        $subPrice = $row->amount;
+                    }
+                    if ($row->causal_id == $x->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
+                    {
+                        $tot = sizeof(json_decode($row->when));
+                        foreach(json_decode($row->when) as $m)
+                        {
+                            if (isset($prices[$m->month]))
+                                $prices[$m->month] += $row->amount / $tot;
+                            else
+                                $prices[$m->month] = $row->amount / $tot;
+                        }
+                    }
+                }
+            }
+
+            for($i=1; $i<=12; $i++)
+            {
+
+                $cls = $this->getColor($x->months, $i, isset($prices[$i]) && $prices[$i] == $price);
+                if ($cls != 'wgrey')
+                {
+
+                    if (!isset($totals[$i]))
+                    {
+                        $totals[$i]['green'] = 0;
+                        $totals[$i]['orange'] = 0;
+                        $totals[$i]['yellow'] = 0;
+                    }
+                    if ($cls == 'yellow')
+                    {
+                        $totals[$i][$cls] += 1;
+                    }
+                    else
+                    {
+                        $p = isset($prices[$i]) ? $prices[$i] : $price;
+                        //if (isset($totals[$i][$cls]))
+                            $totals[$i][$cls] += $p;
+                        //else
+                            //$totals[$i][$cls] = $p;
+                    }
+                }
+            }
+
+            $sub = $x->subscribed ? "Y" : "N";
+            if (isset($totalIsc[$sub]))
+                $totalIsc[$sub] += $subPrice;
+            else
+                $totalIsc[$sub] = $subPrice;
+
+            $s = 0;
+            if ($column != '')
+            {
+                $z = 0;
+                switch ($column) {
+                    case 'column_3':
+                        $z = 9;
+                        break;
+                    case 'column_4':
+                        $z = 10;
+                        break;
+                    case 'column_5':
+                        $z = 11;
+                        break;
+                    case 'column_6':
+                        $z = 12;
+                        break;
+                    case 'column_7':
+                        $z = 1;
+                        break;
+                    case 'column_8':
+                        $z = 2;
+                        break;
+                    case 'column_9':
+                        $z = 3;
+                        break;
+                    case 'column_10':
+                        $z = 4;
+                        break;
+                    case 'column_11':
+                        $z = 5;
+                        break;
+                    case 'column_12':
+                        $z = 6;
+                        break;
+                    case 'column_13':
+                        $z = 7;
+                        break;
+                    case 'column_14':
+                        $z = 8;
+                        break;
+                    default:
+                        $z = 0;
+                        break;
+                }
+                $c = getColor($x->months, $z);
+                if ($sort_value == 0)
+                {
+                    switch ($c) {
+                        case 'wgrey':
+                            $s = 0;
+                            break;
+                        case 'orange':
+                            $s = 1;
+                            break;
+                        case 'green':
+                            $s = 2;
+                            break;
+                        case 'yellow':
+                            $s = 3;
+                            break;
+                        default:
+                            $s = 0;
+                            break;
+                    }
+                }
+                if ($sort_value == 1)
+                {
+                    switch ($c) {
+                        case 'wgrey':
+                            $s = 3;
+                            break;
+                        case 'orange':
+                            $s = 0;
+                            break;
+                        case 'green':
+                            $s = 1;
+                            break;
+                        case 'yellow':
+                            $s = 2;
+                            break;
+                        default:
+                            $s = 0;
+                            break;
+                    }
+                }
+                if ($sort_value == 2)
+                {
+                    switch ($c) {
+                        case 'wgrey':
+                            $s = 2;
+                            break;
+                        case 'orange':
+                            $s = 3;
+                            break;
+                        case 'green':
+                            $s = 0;
+                            break;
+                        case 'yellow':
+                            $s = 1;
+                            break;
+                        default:
+                            $s = 0;
+                            break;
+                    }
+                }
+                if ($sort_value == 3)
+                {
+                    switch ($c) {
+                        case 'wgrey':
+                            $s = 1;
+                            break;
+                        case 'orange':
+                            $s = 2;
+                            break;
+                        case 'green':
+                            $s = 3;
+                            break;
+                        case 'yellow':
+                            $s = 0;
+                            break;
+                        default:
+                            $s = 0;
+                            break;
+                    }
+                }
+
+            }
+
+            $datas[] = array(
+                "column_19" => $x->course->name,
+                "column_0" => $x->member->last_name,
+                "column_1" => $x->member->first_name,
+                "column_2" => $x->subscribed . "§" . formatPrice($subPrice),
+                "column_3" => $this->getColor($x->months, 9, isset($prices[9]) && $prices[9] == $price) . "§" . formatPrice(isset($prices[9]) ? $prices[9] : $price) . "§" . (isset($prices[9]) && $prices[9] != $price ? 'X' : ''),
+                "column_4" => $this->getColor($x->months, 10, isset($prices[10]) && $prices[10] == $price) . "§" . formatPrice(isset($prices[10]) ? $prices[10] : $price) . "§" . (isset($prices[10]) && $prices[10] != $price ? 'X' : ''),
+                "column_5" => $this->getColor($x->months, 11, isset($prices[11]) && $prices[11] == $price) . "§" . formatPrice(isset($prices[11]) ? $prices[11] : $price) . "§" . (isset($prices[11]) && $prices[11] != $price ? 'X' : ''),
+                "column_6" => $this->getColor($x->months, 12, isset($prices[12]) && $prices[12] == $price) . "§" . formatPrice(isset($prices[12]) ? $prices[12] : $price) . "§" . (isset($prices[12]) && $prices[12] != $price ? 'X' : ''),
+                "column_7" => $this->getColor($x->months, 1, isset($prices[1]) && $prices[1] == $price) . "§" . formatPrice(isset($prices[1]) ? $prices[1] : $price) . "§" . (isset($prices[1]) && $prices[1] != $price ? 'X' : ''),
+                "column_8" => $this->getColor($x->months, 2, isset($prices[2]) && $prices[2] == $price) . "§" . formatPrice(isset($prices[2]) ? $prices[2] : $price) . "§" . (isset($prices[2]) && $prices[2] != $price ? 'X' : ''),
+                "column_9" => $this->getColor($x->months, 3, isset($prices[3]) && $prices[3] == $price) . "§" . formatPrice(isset($prices[3]) ? $prices[3] : $price) . "§" . (isset($prices[3]) && $prices[3] != $price ? 'X' : ''),
+                "column_10" => $this->getColor($x->months, 4, isset($prices[4]) && $prices[4] == $price) . "§" . formatPrice(isset($prices[4]) ? $prices[4] : $price) . "§" . (isset($prices[4]) && $prices[4] != $price ? 'X' : ''),
+                "column_11" => $this->getColor($x->months, 5, isset($prices[5]) && $prices[5] == $price) . "§" . formatPrice(isset($prices[5]) ? $prices[5] : $price) . "§" . (isset($prices[5]) && $prices[5] != $price ? 'X' : ''),
+                "column_12" => $this->getColor($x->months, 6, isset($prices[6]) && $prices[6] == $price) . "§" . formatPrice(isset($prices[6]) ? $prices[6] : $price) . "§" . (isset($prices[6]) && $prices[6] != $price ? 'X' : ''),
+                "column_13" => $this->getColor($x->months, 7, isset($prices[7]) && $prices[7] == $price) . "§" . formatPrice(isset($prices[7]) ? $prices[7] : $price) . "§" . (isset($prices[7]) && $prices[7] != $price ? 'X' : ''),
+                "column_14" => $this->getColor($x->months, 8, isset($prices[8]) && $prices[8] == $price) . "§" . formatPrice(isset($prices[8]) ? $prices[8] : $price) . "§" . (isset($prices[8]) && $prices[8] != $price ? 'X' : ''),
+                "column_15" => $x->course_id,
+                "column_16" => $x->id,
+                "column_17" => $x->member_id,
+                "column_18" => $xxx++,
+                "column_20" => $s
+            );
+
+        }
+
+        $count = $member_course->count();
+
+        $this->totSExcel = [];
+        $this->totS = [];
+
+        //$js = '';
+        $xx = 4;
+        $str = '';
+        if ($count > 0)
+        {
+            $str .= "<a style='width:100%;float:right; text-align:right; display:block;' class=green><small>" . (isset($totalIsc["Y"]) ? formatPrice($totalIsc["Y"]) : 0) . "</small></a><br>";
+            $str .= "<a style='width:100%;float:right; text-align:right; display:block;' class=orange><small>" . (isset($totalIsc["N"]) ? formatPrice($totalIsc["N"]) : 0) . "</small></a><br>";
+            $str .= "<a style='width:100%;float:right; text-align:right; display:block;' class=yellow><small>0</small></a><br>";
+
+            $this->totSExcel[] = array('green' => (isset($totalIsc["Y"]) ? formatPrice($totalIsc["Y"]) : 0), 'orange' => (isset($totalIsc["N"]) ? formatPrice($totalIsc["N"]) : 0), 'yellow' => 0);
+
+        }
+        
+        $this->totS[] = $str;
+
+        $str = "";
+        foreach($totals as $z => $t)
+        {
+            
+            if ($z == 1) $xx = 5;
+            if ($z == 2) $xx = 6;
+            if ($z == 3) $xx = 7;
+            if ($z == 4) $xx = 8;
+            if ($z == 5) $xx = 9;
+            if ($z == 6) $xx = 10;
+            if ($z == 7) $xx = 11;
+            if ($z == 8) $xx = 12;
+            if ($z == 9) $xx = 1;
+            if ($z == 10) $xx = 2;
+            if ($z == 11) $xx = 3;
+            if ($z == 12) $xx = 4;
+            $str = '';
+            $aaa = [];
+            foreach($t as $x => $c)
+            {
+                $y = $x == 'yellow' ? $c : formatPrice($c);
+                $str .= "<a style='width:100%;float:right; text-align:right; display:block;' class=" . $x . "><small>" . $y . "</small></a><br>";
+                $aaa[$x] = $y;
+            }
+
+            $this->totSExcel[$xx] = $aaa;
+            
+            $this->totS[$xx] = $str;
+            //$js .= $xx . "§" . $str . "_";
+
+            $xx += 1;
+        }
+
+        for($e=sizeof($this->totS);$e<=12;$e++)
+        {
+            $this->totS[] = '';
+        }
+
+        if ($this->sort != '')
+        {
+            $s = $this->sort;
+            if ($s == 1) $s = 21;
+            if ($column != '')
+                array_multisort(array_column($datas, 'column_20'), SORT_ASC, SORT_NATURAL|SORT_FLAG_CASE, $datas);
+            else
+                array_multisort(array_column($datas, 'column_' . ($s - 2)), $this->dir == "ASC" ? SORT_ASC : SORT_DESC, SORT_NATURAL|SORT_FLAG_CASE, $datas);
+        }
+
+        $xxx = 1;
+        foreach($datas as $yyy => $d)
+        {
+            $datas[$yyy]["column_18"] = $xxx++;
+        }
+
+        $this->totalRecords = sizeof($datas);
+
+        //$start = 0;
+
+        $this->recordsNoPaginate = [];
+        $this->recordsNoPaginate = $datas;
+        
+        //if (isset($_GET["start"]))
+        $datas = array_slice($datas, $this->start, $this->pageLength);
+
+        $this->pages = ceil($this->totalRecords / $this->pageLength);
+        
+        $this->records = [];
+        $this->records = $datas;
+
+        //$this->totS = $js;
+
         return view('livewire.course_list');
 
     }
 
+    public function setPage($page)
+    {
+        $this->currentPage = $page;
+        $this->start = $this->pageLength * ($page - 1);
+        $this->emit('load-data-table');
+    }
+
+    public function setSort($sort)
+    {
+        $this->sort = $sort;
+        if ($this->dir == '')
+            $this->dir = 'ASC';
+        else
+            $this->dir = $this->dir == 'ASC' ? 'DESC' : 'ASC';
+        $this->emit('load-data-table');
+    }
+
     public function search()
     {
+        $this->currentPage = 1;
+        $this->start = 0;
         $this->hasFilter = true;
+        $this->emit('load-data-table');
     }
 
-    public function getColor($months, $m)
+    public function getColor($months, $m, $all)
     {
-        $class = "grey";
+        $class = "wgrey";
         foreach(json_decode($months) as $mm)
         {
             if ($mm->m == $m)
@@ -266,6 +826,10 @@ class CourseList extends Component
                 {
                     $class = "yellow";
                 }
+                if (!$all)
+                {
+                    $class = "orange";
+                }
             }
         }
         return $class;
@@ -428,4 +992,137 @@ class CourseList extends Component
         $this->hasFilter = false;
 
     }
+
+    public function export()
+    {
+
+        $letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
+       
+        $spreadsheet = new Spreadsheet();
+        $activeWorksheet = $spreadsheet->getActiveSheet();
+
+        //$activeWorksheet->setCellValue('A1', 'PrimaNota');
+        $activeWorksheet->setCellValue('A1', "Corso");
+        $activeWorksheet->setCellValue('B1', "Cognome");
+        $activeWorksheet->setCellValue('C1', "Nome");
+        $activeWorksheet->setCellValue('D1', "Iscrizione");
+        $activeWorksheet->setCellValue('E1', "Settembre");
+        $activeWorksheet->setCellValue('F1', "Ottobre");
+        $activeWorksheet->setCellValue('G1', "Novembre");
+        $activeWorksheet->setCellValue('H1', "Dicembre");
+        $activeWorksheet->setCellValue('I1', "Gennaio");
+        $activeWorksheet->setCellValue('J1', "Febbraio");
+        $activeWorksheet->setCellValue('K1', "Marzo");
+        $activeWorksheet->setCellValue('L1', "Aprile");
+        $activeWorksheet->setCellValue('M1', "Maggio");
+        $activeWorksheet->setCellValue('N1', "Giugno");
+        $activeWorksheet->setCellValue('O1', "Luglio");
+        $activeWorksheet->setCellValue('P1', "Agosto");
+
+        $count = 2;
+        foreach($this->recordsNoPaginate as $idx => $record)
+        {
+
+            $activeWorksheet->setCellValue('A' . $count, $record["column_19"]);
+            $activeWorksheet->setCellValue('B' . $count, $record["column_0"]);
+            $activeWorksheet->setCellValue('C' . $count, $record["column_1"]);
+            
+            list($color, $value) = explode("§", $record["column_2"]);
+            $activeWorksheet->setCellValue('D' . $count, $value);
+            $c = '#FFFFFF';
+            if($color == 0)
+                $c = 'ffa500';
+            if($color == 1)
+                $c = '00ff00';
+
+                
+            $activeWorksheet->getStyle('D' . $count . ':D' . $count)
+                ->getFill()
+                ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
+                ->getStartColor()
+                ->setARGB($c);
+
+            for($ii=3; $ii<=14; $ii++)
+            {
+                list($color, $value) = explode("§", $record["column_" . $ii]);
+                
+                $c = 'FFFFFF';
+                if($color == 'orange')
+                    $c = 'ffa500';
+                if($color == 'green')
+                    $c = '00ff00';
+                if($color == 'yellow')
+                {
+                    $c = '5088bf';
+                    $activeWorksheet->getStyle($letters[$ii + 1] . $count . ':' . $letters[$ii + 1] . $count)
+                    ->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_WHITE);;
+                }
+                if($color == 'wgrey')
+                    $value = '';
+
+                $activeWorksheet->setCellValue($letters[$ii + 1] . $count, $value);
+
+                $activeWorksheet->getStyle($letters[$ii + 1] . $count . ':' . $letters[$ii + 1] . $count)
+                    ->getFill()
+                    ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
+                    ->getStartColor()
+                    ->setARGB($c);
+                /*$activeWorksheet->cells($letters[$ii + 1] . $count . ':' . $letters[$ii + 1] . $count, function ($cells) use ($c)
+                {
+                    $cells->setBackground($c);
+                    //$cells->setAlignment('center');
+                });*/
+                
+            }
+
+            $activeWorksheet->getStyle("A1:P1")->getFont()->setBold( true );
+
+            $count++;
+        }
+
+        // Totali
+        $activeWorksheet->setCellValue('A' . (1 + $count), '');
+        $activeWorksheet->setCellValue('B' . (1 + $count), '');
+        $activeWorksheet->setCellValue('C' . (1 + $count), '');
+        
+        for($x=0; $x<=sizeof($this->totSExcel); $x++)
+        {
+
+            if (isset($this->totSExcel[$x]))
+            {
+
+                $activeWorksheet->setCellValue($letters[$x + 3] . (1 + $count), isset($this->totSExcel[$x]['green']) ? $this->totSExcel[$x]['green'] : 0);
+                $activeWorksheet->getStyle($letters[$x + 3] . (1 + $count) . ':' . $letters[$x + 3] . (1 + $count))
+                        ->getFill()
+                        ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
+                        ->getStartColor()
+                        ->setARGB('00ff00');
+
+                $activeWorksheet->setCellValue($letters[$x + 3] . (2 + $count), isset($this->totSExcel[$x]['orange']) ? $this->totSExcel[$x]['orange'] : 0);
+                $activeWorksheet->getStyle($letters[$x + 3] . (2 + $count) . ':' . $letters[$x + 3] . (2 + $count))
+                        ->getFill()
+                        ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
+                        ->getStartColor()
+                        ->setARGB('ffa500');
+
+                $activeWorksheet->setCellValue($letters[$x + 3] . (3 + $count), isset($this->totSExcel[$x]['yellow']) ? $this->totSExcel[$x]['yellow'] : 0);
+                $activeWorksheet->getStyle($letters[$x + 3] . (3 + $count) . ':' . $letters[$x + 3] . (3 + $count))
+                        ->getFill()
+                        ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
+                        ->getStartColor()
+                        ->setARGB('5088bf');
+                $activeWorksheet->getStyle($letters[$x + 3] . (3 + $count) . ':' . $letters[$x + 3] . (3 + $count))
+                        ->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_WHITE);;
+            }
+            
+        }        
+
+        $writer = new Xlsx($spreadsheet);
+        $writer->save($path = storage_path('pagamento_corsi_' . date("YmdHis") . '.xlsx'));
+
+        $this->emit('load-data-table');
+
+        return response()->download($path)->deleteFileAfterSend();
+
+    }
 }

+ 4 - 1
app/Models/Course.php

@@ -28,7 +28,10 @@ class Course extends Model
         'subscription_price',
         'sub_causal_id',
         'category_id',
-        'active'
+        'active',
+        'type',
+        'when',
+        'prices'
     ];
 
     public function parent()

+ 36 - 0
database/migrations/2025_03_07_173000_add_fields_to_courses_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('courses', function (Blueprint $table) {
+            $table->json('when')->nullable();
+            $table->json('prices')->nullable();
+            $table->enum('type', ['standard', 'custom']);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('courses', function (Blueprint $table) {
+            $table->dropColumn('when');
+            $table->dropColumn('prices');
+            $table->dropColumn('type');
+        });
+    }
+};

+ 118 - 1
resources/views/livewire/course.blade.php

@@ -113,7 +113,12 @@
 
                     <form action="">
 
-                        <div class="row mb-3">
+                        <div class="row mb-3 ">
+                            <div class="col-12 mt-2">
+                                <input type="radio" name="chkType" value="standard" wire:model="type">&nbsp;Standard
+                                &nbsp;&nbsp;&nbsp;
+                                <input type="radio" name="chkType" value="custom" wire:model="type">&nbsp;Personalizzato
+                            </div>
                             <div class="col-6 mt-2">
                                 <div class="form--item">
                                     <label for="inputName" class="form-label">Nome</label>
@@ -224,6 +229,7 @@
                                     @enderror
                                 </div>
                             </div>
+                            
                             <div class="col-6 mt-2">
                                 <div class="form--item">
                                     <label for="inputName" class="form-label">Istruttore</label>
@@ -258,6 +264,7 @@
                                     </select>
                                 </div>
                             </div>
+
                             <div class="col">
                                 <div class="form--item">
                                     <label for="enabled" class="form-label">Abilitato</label>
@@ -265,6 +272,51 @@
                                 </div>
                             </div>
 
+                            
+                            @foreach($when as $idW => $w)
+                                
+                                <div class="col-12">
+                                    <div class="day durata--corso d-flex">
+                                        <label for="" class="form-label">Giorno</label>
+                                        <div class="durata--corso_days mb-3">
+                                            <a class="{{in_array('lun', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'lun')">Lun</a>
+                                            <a class="{{in_array('mar', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'mar')">Mar</a>
+                                            <a class="{{in_array('mer', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'mer')">Mer</a>
+                                            <a class="{{in_array('gio', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'gio')">Gio</a>
+                                            <a class="{{in_array('ven', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'ven')">Ven</a>
+                                            <a class="{{in_array('sab', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'sab')">Sab</a>
+                                            <a class="{{in_array('dom', $when[$idW]["day"]) ? 'selected' : 'notSelected'}}" wire:click="setDay({{$idW}}, 'dom')">Dom</a>
+                                        </div>
+
+                                        <div class="durata--corso_select">
+                                            <div class="from--h me-3">
+                                                <label for="" class="form-label">Dalle</label>
+                                                <select class="form-select" wire:model="when.{{$idW}}.from">
+                                                    <option value="">--Seleziona--
+                                                    @for($c=6;$c<=23;$c++)
+                                                        <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00
+                                                        <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30
+                                                    @endfor
+                                                </select>
+                                            </div>
+                                            <div class="to--h">
+                                                <label for="" class="form-label">Alle</label>
+                                                <select class="form-select" wire:model="when.{{$idW}}.to">
+                                                    <option value="">--Seleziona--
+                                                    @for($c=6;$c<=23;$c++)
+                                                        <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:00
+                                                        <option value="{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30">{{str_pad($c, 2, "0", STR_PAD_LEFT)}}:30
+                                                    @endfor
+                                                </select>
+                                            </div>
+                                        </div>
+
+                                        <button class="btn--ui primary remove--day position-absolute" wire:click.prevent="delRow({{$idW}})"><i class="fa-solid fa-minus"></i></button>
+                                        <button class="btn--ui primary add--day position-absolute" wire:click.prevent="addRow()"><i class="fa-solid fa-plus"></i></button>
+                                    </div>
+                                </div>
+                                
+                            @endforeach
 
                             <!--<div class="col-6">
                                 <div class="form--item">
@@ -293,6 +345,8 @@
                             @endif
                         </div>
 
+                        
+
                         <div class="form--item">
                             <button type="button" class="btn--ui lightGrey" onclick="annulla()">Annulla</button>
                             @if($add)
@@ -313,6 +367,69 @@
 
 @push('scripts')
     <link href="/css/datatables.css" rel="stylesheet" />
+    <style>
+        a.notSelected
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #006099;
+            background-color: #d3dce1 !important;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        a.selected
+        {
+            display: flex;
+            margin-right:10px;
+            float:left;
+            height: 2.5rem !important;
+            width:50px;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            background-color: #006099 !important;
+            padding: 0 1.25rem;
+            font-size: 0.875rem;
+            font-family: greycliff-cf, sans-serif;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: none;
+        }
+        div.day
+        {
+            margin-top:20px;
+            color: #006099;
+            background-color: #ffffff !important;
+            padding: 20px;
+            border-radius: 1.875rem !important;
+            -webkit-border-radius: 1.875rem !important;
+            -moz-border-radius: 1.875rem !important;
+            -webkit-transition: all 0.3s ease-in-out;
+            -moz-transition: all 0.3s ease-in-out;
+            -o-transition: all 0.3s ease-in-out;
+            transition: all 0.3s ease-in-out;
+            border: 2px solid #d3dce1;
+        }
+    </style>
     <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
     <script src="/assets/js/datatables.js"></script>
     <script src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>

+ 161 - 57
resources/views/livewire/course_list.blade.php

@@ -8,7 +8,38 @@
 
     </header>
 
-    <div class="showFilter" style="display:none"  wire:ignore.self>
+
+    <div class="row" style="margin-top: 10px; margin-bottom:10px;">
+        <div class="col-md-4">
+            <div class="col-md ">
+                <div class="dt-buttons btn-group flex-wrap">
+                    <div class="btn-group">
+                        <button class="btn btn-secondary buttons-collection" wire:click="export()" style="color:black !important">ESPORTA</button>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="col-md-4">
+            <div class="row">
+                <div class="col-md-4" style="text-align:right">Visualizza</div>
+                <div class="col-md-4">
+                    <select name="tablesaw-350_length" aria-controls="tablesaw-350" class="form-select form-select-sm" id="dt-length-0" wire:model="pageLength">
+                        <option value="10">10</option>
+                        <option value="25">25</option>
+                        <option value="50">50</option>
+                        <option value="100">100</option>
+                        <option value="100000">Tutti</option>
+                    </select>
+                </div>
+                <div class="col-md-3">elementi</div>
+            </div>
+        </div>
+        <div class="col-md-4" style="text-align:right">
+            <a href="#" class="showHideFilter btn--ui" ><i class="fa-solid fa-sliders"></i></a><br>
+        </div>
+    </div>
+
+    <div class="showFilter" style="display:none; margin-top:10px;"  wire:ignore.self>
         <hr size="1">
         <div class="row g-3">
             <div class="col-md-2">
@@ -43,7 +74,7 @@
                         <b>Corso</b>
                     </div>
                     <div class="col-12" >
-                        <select class="form-select filterCourse" multiple="multiple">
+                        <select class="form-select filterCourse" multiple="multiple" wire:model="filterCourse">
                             @foreach($courses as $c)
                                 <option value="{{$c}}">{{$c}}
                             @endforeach
@@ -57,7 +88,7 @@
                         <b>Livello</b>
                     </div>
                     <div class="col-12">
-                        <select class="form-select filterLevel"  multiple="multiple">
+                        <select class="form-select filterLevel"  multiple="multiple" wire:model="filterLevel">
                             @foreach($course_levels as $c)
                                 <option value="{{$c->id}}">{{$c->name}}
                             @endforeach
@@ -71,7 +102,7 @@
                         <b>Frequenza</b>
                     </div>
                     <div class="col-12">
-                        <select class="form-select filterFrequency" multiple="multiple">
+                        <select class="form-select filterFrequency" multiple="multiple" wire:model="filterFrequency">
                             @foreach($course_frequencies as $c)
                                 <option value="{{$c->id}}">{{$c->name}}
                             @endforeach
@@ -85,7 +116,7 @@
                         <b>Tipologia</b>
                     </div>
                     <div class="col-12">
-                        <select class="form-select filterType"  multiple="multiple">
+                        <select class="form-select filterType"  multiple="multiple" wire:model="filterType">
                             @foreach($course_types as $c)
                                 <option value="{{$c->id}}">{{$c->name}}
                             @endforeach
@@ -99,7 +130,7 @@
                         <b>Durata</b>
                     </div>
                     <div class="col-12">
-                        <select class="form-select filterDuration"  multiple="multiple">
+                        <select class="form-select filterDuration"  multiple="multiple" wire:model="filterDuration">
                             @foreach($course_durations as $c)
                                 <option value="{{$c->id}}">{{$c->name}}
                             @endforeach
@@ -111,8 +142,8 @@
         </div>
         <div class="row g-3" style="margin-top:20px;">
             <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>
+                <button class="btn--ui_outline light" onclick="reset()">CANCELLA</button>
+                <button class="btn--ui" wire:click="search()">FILTRA</button>
             </div>
         </div>
         <hr size="1">
@@ -127,7 +158,7 @@
         </div>
     </div>
 
-    <section id="resume-table" class="scrollTable">
+    <section id="resume-table" class="scrollTable" style="margin-top:10px;">
         <div class="compare--chart_wrapper d-none"></div>
 
 
@@ -135,23 +166,69 @@
                 <thead>
                     <tr>
                         <th scope="col" class="sticky-col-header first-zero"></th>
-                        <th scope="col" class="sticky-col-header first-col" style="background-color:#f6f8fa !important">Corso</th>
-                        <th scope="col" class="sticky-col-header second-col">Cognome</th>
-                        <th scope="col" class="sticky-col-header third-col">Nome</th>
-                        <th scope="col">Iscrizione</th>
-                        @foreach($months as $m)
-                            <th scope="col">&nbsp;&nbsp;&nbsp;&nbsp;{{$m}}</th>
+                        <th scope="col" class="sticky-col-header first-col" >Corso</th>
+                        <th scope="col" class="sticky-col-header second-col"><a wire:click="setSort(2)" style="cursor:pointer">Cognome</a></th>
+                        <th scope="col" class="sticky-col-header third-col"><a wire:click="setSort(3)" style="cursor:pointer">Nome</a></th>
+                        <th scope="col"><a wire:click="setSort(4)" style="cursor:pointer">Iscrizione</a></th>
+                        @foreach($months as $idx => $m)
+                            <th scope="col"><a wire:click="setSort({{$idx + 5}})" style="cursor:pointer">&nbsp;&nbsp;&nbsp;&nbsp;{{$m}}</a></th>
                         @endforeach
                     </tr>
                 </thead>
                 <tbody id="checkall-target">
 
+                    @foreach($records as $idx => $record)
+                        <tr>
+                            <td class="sticky-col-header first-zero">{{$record["column_18"]}}</td>
+                            <td class="sticky-col-header first-col">{{$record["column_19"]}}</td>
+                            <td class="sticky-col-header second-col">{{$record["column_0"]}}</td>
+                            <td class="sticky-col-header third-col">{{$record["column_1"]}}</td>
+                            <td>
+                                @php
+                                list($color, $value) = explode("§", $record["column_2"]);
+                                @endphp
+                                @if($color == 0)
+                                    <a style="width:100%;float:right; text-align:right; display:block;{{$color == 1 ? '' : 'cursor:pointer;'}}" class="{{$color == 1 ? 'green' : 'orange'}} sub_{{$record["column_16"]}}" onclick="setSubscription('{{$record["column_15"]}}', '{{$record["column_17"]}}', '{{$record["column_16"]}}')" style="cursor: pointer;"><small>{{$value}}</small></a>
+                                @else
+                                    <a style="width:100%;float:right; text-align:right; display:block;" class="{{$color == 1 ? 'green' : 'orange'}}"><small>{{$value}}</small></a>
+                                @endif
+                            </td>
+                            @for($ii=3; $ii<=14; $ii++)
+                                @php
+                                list($color, $value, $diff) = explode("§", $record["column_" . $ii]);
+                                @endphp
+                                <td>
+
+                                    @if ($color == 'orange')
+                                        <a style="{{$diff == 'X' ? 'background-color:#d9ad86' : ''}};width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="{{$color}} lnk_{{$record["column_16"]}}" id="lnk_{{$record["column_15"]}}_{{$ii - 2}}_{{$record["column_17"]}}" onclick="setPayMonth('{{$record["column_15"]}}', {{$ii - 2}}, '{{$record["column_17"]}}', '{{$record["column_16"]}}')" style="cursor: pointer;"><small>{{$value}}</small></a>
+                                    @else
+                                        @if ($color != 'wgrey')
+                                            <a style="width:100%;float:right; text-align:right; display:block;" class="{{$color}}"><small>{{$value}}</small></a>
+                                        @endif
+                                    @endif
+
+                                </td>
+                            @endfor
+
+                        </tr>
+                    @endforeach
 
                 </tbody>
                 <tfoot id="checkall-target">
                     <tr>
                         <th class="sticky-col-header first-zero"></th>
                         <th class="sticky-col-header first-col"></th>
+                        <th class="sticky-col-header second-col"></th>
+                        <th class="sticky-col-header third-col"></th>
+                        @foreach($totS as $yyy)
+                            @if (isset($yyy))
+                                <th style="padding-left:5px !important;padding-right:5px !important;">{!!$yyy!!}</th>
+                            @else
+                                <th style="padding-left:5px !important;padding-right:5px !important;">aa</th>
+                            @endif
+                        @endforeach
+
+                        <!--<th style="padding-left:5px !important;padding-right:5px !important;"></th>
                         <th style="padding-left:5px !important;padding-right:5px !important;"></th>
                         <th style="padding-left:5px !important;padding-right:5px !important;"></th>
                         <th style="padding-left:5px !important;padding-right:5px !important;"></th>
@@ -165,12 +242,41 @@
                         <th style="padding-left:5px !important;padding-right:5px !important;"></th>
                         <th style="padding-left:5px !important;padding-right:5px !important;"></th>
                         <th style="padding-left:5px !important;padding-right:5px !important;"></th>
-                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
-                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>-->
                     </tr>
                 </tfoot>
             </table>
 
+            <div class="row">
+                <div class="col-md-6">
+                    Vista da {{(($currentPage - 1) * $pageLength) + 1}} a {{$currentPage * $pageLength}} di {{$totalRecords}} elementi
+                </div>
+                <div class="col-md-6" style="text-align:right">
+                        <ul class="pagination" style="margin:0px !important;float:right">
+                            @if($pages < 10)
+                                @for($p=1; $p<=$pages;$p++)
+                                    <li class="page-item {{$p == $currentPage ? 'active' : ''}}"><a class="page-link" wire:click="setPage({{$p}})" href="#">{{$p}}</a></li>
+                                @endfor
+                            @else
+                                <li class="page-item {{1 == $currentPage ? 'active' : ''}}"><a class="page-link" wire:click="setPage(1)" href="#">1</a></li>
+                                @if($currentPage > 4)
+                                    <li class="page-item "><a class="page-link" href="#">...</a></li>
+                                @endif
+                                @for($p=2; $p<=$pages - 1;$p++)
+                                    @if($p > $currentPage - 3 && $p < $currentPage + 3)
+                                        <li class="page-item {{$p == $currentPage ? 'active' : ''}}"><a class="page-link" wire:click="setPage({{$p}})" href="#">{{$p}}</a></li>
+                                    @endif
+                                @endfor
+                                @if($currentPage < ($pages - 3))
+                                    <li class="page-item "><a class="page-link" href="#">...</a></li>
+                                @endif
+                                <li class="page-item {{$pages == $currentPage ? 'active' : ''}}"><a class="page-link" wire:click="setPage({{$pages}})" href="#">{{$pages}}</a></li>
+                            @endif
+                        </ul>
+
+                </div>
+            </div>
+
 
 
 
@@ -186,14 +292,20 @@
     <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
     <style>
 
+        @media (min-width: 992px) {
+            .sidebar--ui ~ div.col {
+                max-height: 100vh;
+            }
+        }
+
     .scrollTable {
 
             padding: 15px;
-            /*max-width: 800px !important;*/
-            /*overflow-x: auto;
+            max-width: 100% !important;
+            overflow-x: auto;
             overflow-y: auto;
-            white-space: nowrap;*/
-            /*border: 1px solid #ddd;*/
+            white-space: nowrap;
+            border: 1px solid #ddd;
         }
 
         ::-webkit-scrollbar-thumb {
@@ -266,7 +378,7 @@
         /* Important */
             position: sticky;
             z-index: 100;
-            top: 35px;
+            top: -17px;
         }
 
         table thead {
@@ -382,44 +494,44 @@
         $('.filterYear').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
         $('.filterYear').val('{{date("Y")-1}}-{{date("Y")}}').trigger("change");
         $('.filterCourse').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
-        /*$('.filterCourse').on('change', function (e) {
+        $('.filterCourse').on('change', function (e) {
             var data = $('.filterCourse').select2("val");
             if (data == null) data = [];
             @this.set('filterCourse', data);
             //@this.search();
-        });*/
+        });
 
         $('.filterLevel').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
-        /*$('.filterLevel').on('change', function (e) {
+        $('.filterLevel').on('change', function (e) {
             var data = $('.filterLevel').select2("val");
             if (data == null) data = [];
-            //@this.set('filterLevel', data);
+            @this.set('filterLevel', data);
             //@this.search();
-        });*/
+        });
 
         $('.filterFrequency').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
-        /*$('.filterFrequency').on('change', function (e) {
+        $('.filterFrequency').on('change', function (e) {
             var data = $('.filterFrequency').select2("val");
             if (data == null) data = [];
             @this.set('filterFrequency', data);
             //@this.search();
-        });*/
+        });
 
         $('.filterType').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
-        /*$('.filterType').on('change', function (e) {
+        $('.filterType').on('change', function (e) {
             var data = $('.filterType').select2("val");
             if (data == null) data = [];
             @this.set('filterType', data);
             //@this.search();
-        });*/
+        });
 
         $('.filterDuration').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
-        /*$('.filterDuration').on('change', function (e) {
+        $('.filterDuration').on('change', function (e) {
             var data = $('.filterDuration').select2("val");
             if (data == null) data = [];
             // @this.set('filterDuration', data);
             //@this.search();
-        });*/
+        });
 
         Livewire.on('load-data-table', () => {
             $('.filterYear').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
@@ -429,6 +541,10 @@
             $('.filterType').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
             $('.filterDuration').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
             loadDataTable();
+            setTimeout(() => {
+                setMaxWidth();
+                setMaxHeight();
+            }, 1);
         });
 
         Livewire.on('destroy-data-table', () => {
@@ -513,6 +629,7 @@
 
         function loadDataTable(){
 
+            /*
             if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
                 $('#tablesaw-350').DataTable().destroy();
             }
@@ -534,6 +651,8 @@
 
             var filterType = $('.filterType').val();
             localStorage.setItem("filterTypeCourseList", filterType);
+            */
+            /*
 
             var output_table = $('#tablesaw-350').DataTable({
                 //scrollX: true,
@@ -952,16 +1071,7 @@
                                                 }
                                             }
                                         }
-                                    }/*,
-                                    {
-                                        extend: 'print',"action":newexportaction,
-                                        text: 'Stampa',
-                                        title: 'Pagamento corsi',
-                                        exportOptions: {
-                                            columns: ":not(':last')"
-                                        },
-                                        footer:false
-                                    }*/
+                                    }
                                 ],
                                 dropup: true
                             }
@@ -1010,19 +1120,15 @@
 
                     }
 
-                }/*,
-                fixedColumns: {
-                    start: 1,
-                    end: 1
-                },
-                scrollX: true*/
+                }
             });
+
             $('#tablesaw-350 thead tr th').addClass('col');
             $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
             $('#tablesaw-350').on('draw.dt', function() {
                 $('[data-bs-toggle="popover"]').popover()
             });
-
+            */
             jQuery.fn.dataTable.Api.register( 'sum()', function ( ) {
                 return this.flatten().reduce( function ( a, b ) {
                     if ( typeof a === 'string') {
@@ -1184,21 +1290,19 @@
             $( window ).bind( "resize", setMaxWidth );
             $( window ).bind( "resize", setMaxHeight );
 
+        });
 
-            function setMaxWidth() {
+        function setMaxWidth() {
                  $("#resume-table").width( Math.round( $(window ).width() - size ) ) ;
-                 $(".justify-content-between").css({"width": Math.round( $(window ).width() - size) + "px;"}); //.width( Math.round( $(window ).width() - size ) ) ;
+                 //$(".justify-content-between").css({"width": Math.round( $(window ).width() - size) + "px;"}); //.width( Math.round( $(window ).width() - size ) ) ;
 
             }
             function setMaxHeight() {
                 console.log('height:' + $(window ).height() + 'px !important');
-                 $("div.row.h-100").attr('style', 'height:' + ($(window ).height() + 50) + 'px !important');
-                 $("#resume-table").height( Math.round( $(window ).height() - 150 ) ) ;
+                 //$("div.row.h-100").attr('style', 'height:' + ($(window ).height() + 50) + 'px !important');
+                 $("#resume-table").height( Math.round( $(window ).height() - 220 ) ) ;
             }
 
-
-        });
-
     </script>
 @endpush
 

+ 1094 - 0
resources/views/livewire/course_list_original.blade.php

@@ -0,0 +1,1094 @@
+<div class="col card--ui" id="card--dashboard" style="padding-top: 0px !important;">
+
+    <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">Pagamento corsi</h2>
+        </div>
+
+    </header>
+
+    <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>Anno</b>
+                    </div>
+                    <div class="col-12">
+                        <select class="form-select filterYear" >
+                            <option value="">--Seleziona--
+                            @foreach($course_years as $c)
+                                @php
+                                $selected = '';
+                                try 
+                                {
+                                    list($f, $t) = explode("-", $c);
+                                    if ($f == date("Y"))
+                                        $selected = 'selected';
+                                } catch (Exception $e) {
+                                
+                                }                                
+                                @endphp
+                                <option value="{{$c}}" {{$selected}}>{{$c}}
+                            @endforeach
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-2">
+                <div class="row">
+                    <div class="col-md-12" style="margin-bottom:10px;">
+                        <b>Corso</b>
+                    </div>
+                    <div class="col-12" >
+                        <select class="form-select filterCourse" multiple="multiple">
+                            @foreach($courses as $c)
+                                <option value="{{$c}}">{{$c}}
+                            @endforeach
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-2">
+                <div class="row">
+                    <div class="col-md-12" style="margin-bottom:10px;">
+                        <b>Livello</b>
+                    </div>
+                    <div class="col-12">
+                        <select class="form-select filterLevel"  multiple="multiple">
+                            @foreach($course_levels as $c)
+                                <option value="{{$c->id}}">{{$c->name}}
+                            @endforeach
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-2">
+                <div class="row">
+                    <div class="col-md-12" style="margin-bottom:10px;">
+                        <b>Frequenza</b>
+                    </div>
+                    <div class="col-12">
+                        <select class="form-select filterFrequency" multiple="multiple">
+                            @foreach($course_frequencies as $c)
+                                <option value="{{$c->id}}">{{$c->name}}
+                            @endforeach
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-2">
+                <div class="row">
+                    <div class="col-md-12" style="margin-bottom:10px;">
+                        <b>Tipologia</b>
+                    </div>
+                    <div class="col-12">
+                        <select class="form-select filterType"  multiple="multiple">
+                            @foreach($course_types as $c)
+                                <option value="{{$c->id}}">{{$c->name}}
+                            @endforeach
+                        </select>
+                    </div>
+                </div>
+            </div>
+            <div class="col-md-2">
+                <div class="row">
+                    <div class="col-md-12" style="margin-bottom:10px;">
+                        <b>Durata</b>
+                    </div>
+                    <div class="col-12">
+                        <select class="form-select filterDuration"  multiple="multiple">
+                            @foreach($course_durations as $c)
+                                <option value="{{$c->id}}">{{$c->name}}
+                            @endforeach
+                        </select>
+                    </div>
+                </div>
+            </div>
+
+        </div>
+        <div class="row g-3" style="margin-top:20px;">
+            <div class="col-md-12" style="text-align:right">
+                <button class="btn--ui_outline light" onclick="reset()">CANCELLA</button>
+                <button class="btn--ui" onclick="loadDataTable()">FILTRA</button>
+            </div>
+        </div>
+        <hr size="1">
+    </div>
+
+    <div class="row text-right">
+        <div class="col-md-12" style="text-align:right">
+            <button style="display:none; width:200px;" class="btn--ui btNewPayment" onclick="newPayment()">NUOVA ENTRATA</button>
+        </div>
+    </div>
+
+    <section id="resume-table" class="scrollTable">
+        <div class="compare--chart_wrapper d-none"></div>
+
+
+            <table class="table tablesaw tableHead tablesaw-stack pagamento--corsi display nowrap" id="tablesaw-350" width="100%">
+                <thead>
+                    <tr>
+                        <th scope="col" class="sticky-col-header first-zero"></th>
+                        <th scope="col" class="sticky-col-header first-col" style="background-color:#f6f8fa !important">Corso</th>
+                        <th scope="col" class="sticky-col-header second-col">Cognome</th>
+                        <th scope="col" class="sticky-col-header third-col">Nome</th>
+                        <th scope="col">Iscrizione</th>
+                        @foreach($months as $m)
+                            <th scope="col">&nbsp;&nbsp;&nbsp;&nbsp;{{$m}}</th>
+                        @endforeach
+                    </tr>
+                </thead>
+                <tbody id="checkall-target">
+
+
+                </tbody>
+                <tfoot id="checkall-target">
+                    <tr>
+                        <th class="sticky-col-header first-zero"></th>
+                        <th class="sticky-col-header first-col"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                        <th style="padding-left:5px !important;padding-right:5px !important;"></th>
+                    </tr>
+                </tfoot>
+            </table>
+
+
+
+
+    </section>
+
+</div>
+
+@push('scripts')
+
+@endpush
+
+@push('scripts')
+    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
+    <style>
+
+    .scrollTable {
+            
+            padding: 15px;
+            /*max-width: 800px !important;*/
+            /*overflow-x: auto;
+            overflow-y: auto;
+            white-space: nowrap;*/
+            /*border: 1px solid #ddd;*/
+        }
+
+        ::-webkit-scrollbar-thumb {
+            background: #e4e4e4;
+            border-radius: 10px;
+        }
+
+        .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;
+        }
+        tfoot #checkall-target > tr > th
+        {
+            padding-right:5px !important;
+        }
+        /*.container-fluid
+        {
+            display: table-row !important;
+        }
+        .row.row.header--gestionale
+        {
+            padding-left:20px !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>
+
+        #tablesaw-350_wrapper > div.justify-content-between
+        {
+            background-color: white;
+            position: sticky;
+            z-index: 100000;
+            padding-top:10px;
+            top: -15px;
+            left: 0px;
+            
+        }
+
+
+        /*.table-v-scroll > div, #checkall-target
+        {
+            overflow-x: auto !important;
+            overflow-y: hidden !important;
+        }*/
+
+        table.tableHead thead {
+        /* Important */
+            position: sticky;
+            z-index: 100;
+            top: 35px;
+        }
+
+        table thead {
+        /* Important */
+            position: sticky;
+            z-index: 100;
+            top: 0;
+        }
+        .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;
+        }
+        .sticky-col-header {
+            position: -webkit-sticky !important;
+            position: sticky !important;
+            background-color: '#f6f8fa' !important;
+        }
+        .sticky-col {
+            position: -webkit-sticky !important;
+            position: sticky !important;
+            background-color: white;
+        }
+        .first-zero {
+            width: 20px;
+            min-width: 20px;
+            max-width: 20px;
+            left: 0px;
+            z-index:99;
+        }
+        .first-col {
+            width: 100px;
+            min-width: 100px;
+            max-width: 100px;
+            left: 0px;
+            z-index:99;
+        }
+
+        .second-col {
+            width: 150px;
+            min-width: 150px;
+            max-width: 150px;
+            left: 100px;
+            z-index:99;
+        }
+        .third-col {
+            width: 150px;
+            min-width: 150px;
+            max-width: 150px;
+            left: 250px;
+            z-index:99;
+        }
+    </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>
+
+        var totals = '';
+
+        $(document).ready(function() {
+            loadDataTable();
+        } );
+
+        $('.filterYear').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+        $('.filterYear').val('{{date("Y")-1}}-{{date("Y")}}').trigger("change");
+        $('.filterCourse').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+        /*$('.filterCourse').on('change', function (e) {
+            var data = $('.filterCourse').select2("val");
+            if (data == null) data = [];
+            @this.set('filterCourse', data);
+            //@this.search();
+        });*/
+
+        $('.filterLevel').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+        /*$('.filterLevel').on('change', function (e) {
+            var data = $('.filterLevel').select2("val");
+            if (data == null) data = [];
+            //@this.set('filterLevel', data);
+            //@this.search();
+        });*/
+
+        $('.filterFrequency').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+        /*$('.filterFrequency').on('change', function (e) {
+            var data = $('.filterFrequency').select2("val");
+            if (data == null) data = [];
+            @this.set('filterFrequency', data);
+            //@this.search();
+        });*/
+
+        $('.filterType').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+        /*$('.filterType').on('change', function (e) {
+            var data = $('.filterType').select2("val");
+            if (data == null) data = [];
+            @this.set('filterType', data);
+            //@this.search();
+        });*/
+
+        $('.filterDuration').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+        /*$('.filterDuration').on('change', function (e) {
+            var data = $('.filterDuration').select2("val");
+            if (data == null) data = [];
+            // @this.set('filterDuration', data);
+            //@this.search();
+        });*/
+
+        Livewire.on('load-data-table', () => {
+            $('.filterYear').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+            $('.filterCourse').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+            $('.filterLevel').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+            $('.filterFrequency').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+            $('.filterType').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+            $('.filterDuration').select2({"language": {"noResults": function(){return "Nessun risultato";}}});
+            loadDataTable();
+        });
+
+        Livewire.on('destroy-data-table', () => {
+            $('#tablesaw-350').DataTable().destroy();
+        });
+
+        function destroyDataTable()
+        {
+            $('#tablesaw-350').DataTable().destroy();
+        }
+
+        var isFilter = false;
+        $(document).ready(function() {
+            $(document).on("click",".showHideFilter",function() {
+                if (isFilter)
+                {
+                    isFilter = false;
+                    $(".showFilter").hide();
+                }
+                else
+                {
+                    isFilter = true;
+                    $(".showFilter").show();
+                }
+            });
+        } );
+
+        function searchAction()
+        {
+            //destroyDataTable();
+            //@this.search();
+        }
+
+        @if(isset($_GET["showFilters"]))
+            var filterYear = localStorage.getItem("filterYearCourseList");
+            if (filterYear)
+            {
+                $('.filterYear').val(filterYear).trigger('change');
+            }
+            var filterCourse = localStorage.getItem("filterCourseCourseList");
+            if (filterCourse)
+            {
+                $('.filterCourse').val(filterCourse).trigger('change');
+            }
+            var filterLevel = localStorage.getItem("filterLevelCourseList");
+            if (filterLevel)
+            {
+                $('.filterLevel').val(filterLevel).trigger('change');
+            }
+            var filterFrequency = localStorage.getItem("filterFrequencyCourseList");
+            if (filterFrequency)
+            {
+                $('.filterFrequency').val(filterFrequency).trigger('change');
+            }
+            var filterDuration = localStorage.getItem("filterDurationCourseList");
+            if (filterDuration)
+            {
+                $('.filterDuration').val(filterDuration).trigger('change');
+            }
+            var filterType = localStorage.getItem("filterTypeCourseList");
+            if (filterType)
+            {
+                $('.filterType').val(filterType).trigger('change');
+            }
+        @endif
+
+        function reset()
+        {
+            $('.filterYear').val(null).trigger("change");
+            $('.filterCourse').val(null).trigger("change");
+            $('.filterLevel').val(null).trigger("change");
+            $('.filterFrequency').val(null).trigger("change");
+            $('.filterDuration').val(null).trigger("change");
+            $('.filterType').val(null).trigger("change");
+
+            destroyDataTable();
+
+            //localStorage.clear();
+
+            loadDataTable();
+        }
+
+        function loadDataTable(){
+
+            if ( $.fn.DataTable.isDataTable('#tablesaw-350') ) {
+                $('#tablesaw-350').DataTable().destroy();
+            }
+
+            var filterYear = $('.filterYear').val();
+            localStorage.setItem("filterYearCourseList", filterYear);
+
+            var filterCourse = $('.filterCourse').val();
+            localStorage.setItem("filterCourseCourseList", filterCourse);
+
+            var filterLevel = $('.filterLevel').val();
+            localStorage.setItem("filterLevelCourseList", filterLevel);
+
+            var filterDuration = $('.filterDuration').val();
+            localStorage.setItem("filterDurationCourseList", filterDuration);
+
+            var filterFrequency = $('.filterFrequency').val();
+            localStorage.setItem("filterFrequencyCourseList", filterFrequency);
+
+            var filterType = $('.filterType').val();
+            localStorage.setItem("filterTypeCourseList", filterType);
+
+            var output_table = $('#tablesaw-350').DataTable({
+                //scrollX: true,
+                //scrollY: true,
+                //scrollCollapse: true,
+                scrollY: '400px',
+                serverSide: true,
+                ajax: {
+                    url : '/get_course_list?filterCourse=' + filterCourse + '&filterDuration=' + filterDuration + '&filterLevel=' + filterLevel + '&filterType=' + filterType + '&filterFrequency=' + filterFrequency + '&filterYear=' + filterYear,
+                    dataSrc: function (json){
+                        if(json.totals){
+                            totals = json.totals;
+                        }
+                        return json.data;
+                    }
+                },
+                thead: {
+                'th': {'background-color': 'blue'}
+                },
+                columns: [
+                    {
+                        data: 'column_18',
+                        "orderable": false,
+                        className: 'red',
+                        render: function (data, type, row, meta){
+                            return data;
+                        }
+                    },
+                    {
+                        data: 'column_19',
+                        className: 'red',
+                        className: 'sticky-col  first-col'
+                    },
+                    {
+                        data: 'column_0',
+                        className: 'red',
+                        className: 'sticky-col second-col',
+                        render: function (data, type, row){
+                            var ret = '<a href="/members?member_detail=' + row["column_17"] + '&from=course_list">' + data + '</a>';
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_1',
+                        className: 'sticky-col third-col',
+                        render: function (data, type, row){
+                            const x = data.split("§");
+                            var ret = '<a href="/members?member_detail=' + row["column_17"] + '&from=course_list">' + data + '</a>';
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_2',
+                        orderSequence: ['asc', 'desc'],
+                        className: 'ciccio',
+                        render: function (data, type, row){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 0)
+                            {
+                                var ret = '<a style="width:100%;float:right; text-align:right; display:block; ' + (x[0] == 1 ? '' : 'cursor:pointer;') + '" class="' + (x[0] == 1 ? 'green' : 'orange') + ' sub_' + row["column_16"] + '" onclick="setSubscription(' + row["column_15"] + ', ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + (x[0] == 1 ? 'green' : 'orange') + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_3',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_1_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 1, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_4',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_2_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 2, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_5',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_3_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 3, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_6',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_4_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 4, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_7',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_5_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 5, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_8',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_6_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 6, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_9',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_7_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 7, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_10',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_8_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 8, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_11',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_9_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 9, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_12',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_10_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 10, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_13',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_11_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 11, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    },
+                    {
+                        data: 'column_14',
+                        orderSequence: ['asc', 'desc'],
+                        render: function (data, type, row, meta){
+                            const x = data.split("§");
+                            var ret = '';
+                            if (x[0] == 'orange')
+                            {
+                                ret = '<a style="width:100%;float:right; text-align:right; display:block; cursor:pointer;" class="' + x[0] + ' lnk_' + row["column_16"] + '" id="lnk_' + row["column_15"] + '_12_' + row["column_17"] + '" onclick="setPayMonth(' + row["column_15"] + ', 12, ' + row["column_17"] + ', ' + row["column_16"] + ')" style="cursor: pointer;"><small>' + x[1] + '</small></a>';
+                            }
+                            else
+                            {
+                                if (x[0] != 'wgrey')
+                                    ret = '<a style="width:100%;float:right; text-align:right; display:block;" class="' + x[0] + '"><small>' + x[1] + '</small></a>';
+                            }
+                            return ret;
+                        }
+                    }
+                ],
+                layout: {
+                    topStart : null,
+                    topEnd : null,
+                    top1A: {
+                        buttons: [
+                            {
+                                extend: 'collection',
+                                text: 'Esporta',
+                                buttons: [
+                                    {
+                                        extend: 'excelHtml5',"action":newexportaction,
+                                        title: 'Pagamento corsi',
+                                        orientation: 'landscape',
+                                        exportOptions: {
+                                            columns: ":not(':last')"
+                                        },
+                                        footer:false,
+                                        customize: function(xlsx) {
+                                            var sheet = xlsx.xl.worksheets['sheet1.xml'];
+                                            const letters = ["E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q"];
+
+                                            for(y=0; y<letters.length; y++)
+                                            {
+                                                z = y + 4;
+                                                var c = output_table.column(z).data().toArray();
+                                                //console.log(c);
+                                                for (var i = 0; i < c.length; i++) 
+                                                {
+                                                    var j = c[i].split("§");
+                                                    if (j[0] == '0' || j[0] == 'orange') 
+                                                    {
+                                                        $('row:nth-child('+(i+3)+') [r^="' + letters[y] + '"]', sheet).attr('s', '10');
+                                                        //sheet.table.body[i+1][z].fillColor = 'orange';
+                                                    }
+                                                    if (j[0] == '1' || j[0] == 'green') 
+                                                    {
+                                                        $('row:nth-child('+(i+3)+') [r^="' + letters[y] + '"]', sheet).attr('s', '40');
+                                                        //doc.content[1].table.body[i+1][z].fillColor = 'green';
+                                                    }
+                                                    if (j[0] == 'yellow') 
+                                                    {
+                                                        $('row:nth-child('+(i+3)+') [r^="' + letters[y] + '"]', sheet).attr('s', '20');
+                                                        //doc.content[1].table.body[i+1][z].fillColor = 'blue';
+                                                    }
+                                                }
+                                            }
+                                        },
+                                        
+
+                                    },
+                                    {
+                                        extend: 'pdfHtml5',"action":newexportaction,
+                                        title: 'Pagamento corsi',
+                                        orientation: 'landscape',
+                                        exportOptions: {
+                                            columns: ":not(':last')"
+                                        },
+                                        footer:false,
+                                        customize: function(doc) {
+                                            for(z=4; z<=16; z++)
+                                            {
+                                                var c = output_table.column(z).data().toArray();
+                                                for (var i = 0; i < c.length; i++) 
+                                                {
+                                                    var j = c[i].split("§");
+                                                    if (j[0] == '0' || j[0] == 'orange') 
+                                                    {
+                                                        doc.content[1].table.body[i+1][z].fillColor = 'orange';
+                                                    }
+                                                    if (j[0] == '1' || j[0] == 'green') 
+                                                    {
+                                                        doc.content[1].table.body[i+1][z].fillColor = 'green';
+                                                    }
+                                                    if (j[0] == 'yellow') 
+                                                    {
+                                                        doc.content[1].table.body[i+1][z].fillColor = 'blue';
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }/*,
+                                    {
+                                        extend: 'print',"action":newexportaction,
+                                        text: 'Stampa',
+                                        title: 'Pagamento corsi',
+                                        exportOptions: {
+                                            columns: ":not(':last')"
+                                        },
+                                        footer:false
+                                    }*/
+                                ],
+                                dropup: true
+                            }
+                        ]
+                    },
+                    top1B : {
+                        pageLength: {
+                            menu: [[10, 25, 50, 100, 100000], [10, 25, 50, 100, "Tutti"]]
+                        }
+                    },
+                    top1C :'search',
+                },
+                order: [[2, 'asc'], [3, 'asc']],
+                pagingType: 'numbers',
+                "language": {
+                    "url": "/assets/js/Italian.json"
+                },
+                "fnInitComplete": function (oSettings, json) {
+                    var html = '&nbsp;<a href="#" class="showHideFilter btn--ui"><i class="fa-solid fa-sliders"></i></a>';
+                    $(".dt-search").append(html);
+                },
+                "footerCallback": function (row, data, start, end, display) {
+                    let api = this.api();
+
+                    api.column(0).footer().innerHTML = '';
+                    api.column(1).footer().innerHTML = '';
+                    api.column(2).footer().innerHTML = '';
+                    api.column(3).footer().innerHTML = '';
+
+                    for(var i=4; i<=15; i++)
+                    {
+                        api.column(i).footer().innerHTML = '';
+                    }
+
+                    if (totals != '')
+                    {
+
+                        totals.split("_").forEach(function (item)
+                        {
+                            var x = item.split("§");
+                            if (x[1] != undefined)
+                                api.column(x[0]).footer().innerHTML = x[1];
+                            else
+                                api.column(x[0]).footer().innerHTML = '';
+                        });
+
+                    }
+
+                }/*,
+                fixedColumns: {
+                    start: 1,
+                    end: 1
+                },
+                scrollX: true*/
+            });
+            $('#tablesaw-350 thead tr th').addClass('col');
+            $('#tablesaw-350 thead tr th').css("background-color", "#f6f8fa");
+            $('#tablesaw-350').on('draw.dt', function() {
+                $('[data-bs-toggle="popover"]').popover()
+            });
+
+            jQuery.fn.dataTable.Api.register( 'sum()', function ( ) {
+                return this.flatten().reduce( function ( a, b ) {
+                    if ( typeof a === 'string') {
+                        start = a.indexOf("€");
+                        a = a.substr(start + 2).replace("</small></a>", "").replace(",",".") * 1;
+                    }
+                    if ( typeof b === 'string' && b.indexOf('green') > 0) {
+                        start = b.indexOf("€");
+                        b = b.substr(start + 2).replace("</small></a>", "").replace(",",".") * 1;
+                    }
+                    else
+                    {
+                        b = 0;
+                    }
+
+                    return a + b;
+                }, 0 );
+                } );
+
+        }
+
+        Livewire.on('setTotals', (tot) =>
+        {
+            totals = tot;
+            console.log(totals);
+        });
+
+        var subscription = false;
+        var months = [];
+        var selectedCourseId = 0;
+        var selectedMemberId = 0;
+        var selectedMemberCourseId = 0;
+        function setPayMonth(course_id, month, member_id, id)
+        {
+            if (selectedMemberId > 0 && selectedMemberId != member_id)
+            {
+                months = [];
+                subscription = false;
+            }
+            if (selectedMemberCourseId != id)
+            {
+                $(".sub_" + selectedMemberCourseId).addClass("orange").removeClass("blue").removeClass("selected");
+                $(".lnk_" + selectedMemberCourseId).addClass("orange").removeClass("blue").removeClass("selected");
+            }
+            selectedCourseId = course_id;
+            selectedMemberId = member_id;
+            selectedMemberCourseId = id;
+
+            if(!months.includes(month))
+            {
+                months.push(month);
+                $("#lnk_" + course_id + "_" + month + "_" + member_id).addClass("blue").addClass("selected").removeClass("orange");
+            }
+            else
+            {
+                months.splice(months.indexOf(months), 1);
+                $("#lnk_" + course_id + "_" + month + "_" + member_id).addClass("orange").removeClass("blue").removeClass("selected");
+            }
+            if (months.length > 0)
+            {
+                $(".btNewPayment").show();
+            }
+            else
+            {
+                $(".btNewPayment").hide();
+            }
+        }
+
+        function setSubscription(course_id, member_id, id)
+        {
+            if (selectedMemberCourseId != id)
+            {
+                $(".sub_" + selectedMemberCourseId).addClass("orange").removeClass("blue").removeClass("selected");
+                $(".lnk_" + selectedMemberCourseId).addClass("orange").removeClass("blue").removeClass("selected");
+                months = [];
+                subscription = false;
+            }
+            selectedCourseId = course_id;
+            selectedMemberId = member_id;
+            selectedMemberCourseId = id;
+            if (subscription)
+            {
+                $(".sub_" + selectedMemberCourseId).addClass("orange").removeClass("blue").removeClass("selected");
+                subscription = false;
+                $(".btNewPayment").hide();
+            }
+            else
+            {
+                $(".sub_" + selectedMemberCourseId).addClass("blue").addClass("selected").removeClass("orange");
+                subscription = true;
+                $(".btNewPayment").show();
+            }
+        }
+
+        function newPayment()
+        {
+            @this.newPayment(selectedCourseId, months.toString(), selectedMemberId, selectedMemberCourseId, subscription);
+        }
+
+        $( document ).ready( function(){
+
+            setMaxWidth();
+            setMaxHeight();
+            $( window ).bind( "resize", setMaxWidth );
+            $( window ).bind( "resize", setMaxHeight );
+            
+
+            function setMaxWidth() {
+                 $("#resume-table").width( Math.round( $(window ).width() - size ) ) ;
+                 $(".justify-content-between").css({"width": Math.round( $(window ).width() - size) + "px;"}); //.width( Math.round( $(window ).width() - size ) ) ;
+                 
+            }
+            function setMaxHeight() {
+                console.log('height:' + $(window ).height() + 'px !important');
+                 $("div.row.h-100").attr('style', 'height:' + ($(window ).height() + 50) + 'px !important');
+                 $("#resume-table").height( Math.round( $(window ).height() - 150 ) ) ;
+            }
+
+
+        });
+
+    </script>
+@endpush
+

+ 4 - 4
resources/views/livewire/member.blade.php

@@ -731,10 +731,10 @@
                                                         <input class="form-control" type="date" id="document_expire_date" placeholder="Scadenza" wire:model="document_expire_date">
                                                     </div>
                                                     <div class="col-12">
-                                                        <label for="document_files" class="form-label">File</label>
-                                                        <input class="form-control" type="file" wire:model="documents" multiple><br>
-                                                        <label for="document_files" class="form-label">Caricati</label>
-                                                        @foreach ($document_files as $idx => $d)
+                                                        <label for="mother_documents" class="form-label">File</label>
+                                                        <input class="form-control" type="file" wire:model="mother_documents" multiple><br>
+                                                        <label for="mother_documents" class="form-label">Caricati</label>
+                                                        @foreach ($mother_document_files as $idx => $d)
                                                             <div class="row">
                                                                 <div class="col-6">
                                                                     <a href="{{ asset('storage/app/public/'.$d) }}" target="_blank" class="form-label">{{$d}}</a>

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

@@ -41,7 +41,7 @@
                 <div class="col-md-2">
                     <div class="row">
                         <div class="col-md-12" style="margin-bottom:10px;">
-                            <b>Periodo</b>
+                            <b>Data di pagamento</b>
                         </div>
                         <div class="col-12 mb-2">
                             <input id="dateFrom" type="date" class="form-control filterFrom">
@@ -131,7 +131,7 @@
                 <thead>
                     <tr>
                         <!--<th scope="col"></th>-->
-                        <th scope="col">Data</th>
+                        <th scope="col">Data di pagamento</th>
                         <th scope="col">Importo</th>
                         <th scope="col">Cognome</th>
                         <th scope="col">Nome</th>

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

@@ -20,7 +20,7 @@
 <body>
     <img src="{{public_path() . env('LOGO')}}" width="200">
     <br><br><br>
-    <div align="right"><b>RICEVUTA DI PAGAMENTO N. {{$receipt->number . "/" . $receipt->year}} del {{date("d/m/Y", strtotime($receipt->date))}}</b></div><br><br>
+    <div align="right"><b>RICEVUTA DI PAGAMENTO N. {{$receipt->number . "/" . $receipt->year}} del {{date("d/m/Y", strtotime($receipt->created_at))}}</b></div><br><br>
     @if($receipt->status == 99)
         <div align="right"><b style="color:red">ANNULLATA</b></div><br><br>
     @endif
@@ -85,7 +85,7 @@
     <br><br>
     <b>Totale</b>: {{formatPrice($total)}}
     <footer>
-        <small>{{env('LOCALITA', '')}} ({{env('PROVINCIA', '')}}) li {{date("d/m/Y", strtotime($receipt->date))}}</small>
+        <small>{{env('LOCALITA', '')}} ({{env('PROVINCIA', '')}}) li {{date("d/m/Y", strtotime($receipt->created_at))}}</small>
     </footer>
 
 </body>

+ 6 - 3
routes/web.php

@@ -369,7 +369,6 @@ Route::group(['middleware' => 'auth'],function(){
 
                 $y = $status . "|" . date("d/m/Y", strtotime($r->certificate_date));
             }
-
             /*
             if($has_certificate["date"] != '')
             {
@@ -414,6 +413,7 @@ Route::group(['middleware' => 'auth'],function(){
                 ->leftJoin('receipts', 'records.id', '=', 'receipts.record_id')
                 ->where('records.type', 'IN');
 
+        //$y = \App\Models\Record::select('records_rows.amount', 'records.member_id', 'records.corrispettivo_fiscale', 'records.deleted', 'records.financial_movement', 'records_rows.causal_id', 'records.payment_method_id', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name')) // , \DB::raw('SUM(records.id) As total'))
         $y = \App\Models\Record::select('records_rows.amount', 'records.member_id', 'records.corrispettivo_fiscale', 'records.deleted', 'records.financial_movement', 'records_rows.causal_id', \DB::raw('members.first_name as first_name'), \DB::raw('members.last_name as last_name')) // , \DB::raw('SUM(records.id) As total'))
         ->leftJoin('members', 'records.member_id', '=', 'members.id')
         ->leftJoin('records_rows', 'records.id', '=', 'records_rows.record_id')
@@ -537,11 +537,12 @@ Route::group(['middleware' => 'auth'],function(){
             $excludeCausals[] = $borsellino->id;*/
 
         // Aggiungo
+        /*
         $excludes = \App\Models\Causal::where('no_records', true)->get();
         foreach($excludes as $e)
         {
             $excludeCausals[] = $e->id;
-        }
+        }*/
 
         $exclude_from_records = \App\Models\Member::where('exclude_from_records', true)->pluck('id')->toArray();
 
@@ -1412,6 +1413,7 @@ Route::group(['middleware' => 'auth'],function(){
             $date1 = new DateTime($r->birth_date);
             $date2 = new DateTime("now");
             $interval = $date1->diff($date2);
+
             $certificate = \App\Models\MemberCertificate::where('member_id', $r->member_id)
             ->orderBy('expire_date', 'desc')
             ->first();
@@ -1445,6 +1447,7 @@ Route::group(['middleware' => 'auth'],function(){
                 "column_4" => date("Y", strtotime($r->birth_date)),
                 "column_5" => $r->phone,
                 "column_6" => $certificateInfo,
+                "column_6" => $certificateInfo,
                 "column_7" => $r->member_id
             );
         }
@@ -1519,7 +1522,7 @@ Route::group(['middleware' => 'auth'],function(){
                 'last_name' => $r->member->last_name,
                 'first_name' => $r->member->first_name,
                 'status' => $r->status,
-                'date' => date("d/m/Y", strtotime($r->date)),
+                'date' => date("d/m/Y", strtotime($r->created_at)),
                 'totals' => formatPrice($r->rows->sum('amount')),
                 'action' => $ids
             );