Luca Parisio 9 meses atrás
pai
commit
10282fbb0c

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

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

+ 3 - 3
app/Http/Livewire/Member.php

@@ -1499,10 +1499,10 @@ class Member extends Component
             {
 
                 $mms = [];
-                $mms[] = date("m", strtotime($start));
-                for($jj=2; $jj<=$r->months;$jj++)
+                $mms[] = date("n", strtotime($start));
+                for($jj=1; $jj<$r->months;$jj++)
                 {
-                    $mms[] = date('m', strtotime("+" . $jj . " months", strtotime($start)));
+                    $mms[] = date('n', strtotime("+" . $jj . " months", strtotime($start)));
                 }
 
                 $rate = new \App\Models\Rate();

+ 4 - 2
app/Http/Livewire/Rate.php

@@ -14,6 +14,8 @@ class Rate extends Component
     public $member_id = 0;
     public $member_course_id = 0;
 
+    public $mc = null;
+
     public $filterStatus = '';
     public $hasFilter = false;
     public $filterFrom = '', $filterTo = '';
@@ -28,8 +30,8 @@ class Rate extends Component
         $this->member_course_id = isset($_GET["member_course_id"]) ? $_GET["member_course_id"] : 0;
         if ($this->member_id > 0 && $this->member_course_id > 0)
         {
-            $mc = \App\Models\MemberCourse::findOrFail($this->member_course_id);
-            $this->detail = 'Riepilogo rate ' . $mc->course->name . ' di ' . $mc->member->first_name . " " . $mc->member->last_name;
+            $this->mc = \App\Models\MemberCourse::findOrFail($this->member_course_id);
+            $this->detail = 'Riepilogo rate ' . $this->mc->course->name . ' di ' . $this->mc->member->first_name . " " . $this->mc->member->last_name;
         }
     }
 

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

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

+ 17 - 10
resources/views/livewire/course_member.blade.php

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

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

@@ -9,8 +9,6 @@
 
     </header>
 
-    <a class="btn--ui lightGrey" href="/settings?type=corsi"><i class="fa-solid fa-arrow-left"></i></a><br>
-
     <section id="resume-table">
         <div class="compare--chart_wrapper d-none"></div>
 
@@ -26,7 +24,7 @@
                     <tr>
                         <td>{{$record["name"]}}</td>
                         <td>
-                            <a href="/course_member_two?type={{$record["type"]}}" type="button" class="btn" >></button>
+                            <a href="/course_member_two?type={{$record["type"]}}" type="button" class="btn" ><b>></b></button>
                         </td>
                     </tr>
                 @endforeach

+ 13 - 3
resources/views/livewire/course_member_two.blade.php

@@ -32,11 +32,21 @@
                         <td>{{$record->name}}</td>
                         <td>{{$record->frequency->name ?? ""}}</td>
                         <td>{{$record->level->name ?? ""}}</td>
-                        <td></td>                            
-                        <td></td>                            
+                        <td>{{date("d/m/Y", strtotime($record->date_from))}} - {{date("d/m/Y", strtotime($record->date_to))}}                                                                </td>                            
+                        <td>
+                            @foreach(json_decode($record->when) as $xx => $x)
+                                @if($xx > 0)
+                                    <br>
+                                @endif
+                                @foreach($x->day as $zz => $d)
+                                    {{$zz > 0 ? '-' : ''}}{{$d}}
+                                @endforeach
+                                h {{$x->from}} - {{$x->to}}
+                            @endforeach
+                        </td>                            
                         <td>{{$record->getins->name ?? ""}}</td>
                         <td>
-                            <a href="/course_member?id={{$record->id}}" type="button" class="btn" >></button>
+                            <a href="/course_member?id={{$record->id}}" type="button" class="btn" ><b>></b></button>
                         </td>
                     </tr>
                 @endforeach

+ 11 - 1
resources/views/livewire/rate.blade.php

@@ -17,6 +17,8 @@
 
     </header>
 
+    <a class="btn--ui lightGrey" href="/course_member?id={{$mc->course_id}}"><i class="fa-solid fa-arrow-left"></i></a><br>
+
     <div class="showFilter" style="display:none" wire:ignore.self>
         <hr size="1">
         <div class="row g-3">
@@ -104,7 +106,15 @@
                         <td></td>
                         <td>{{date("d/m/Y", strtotime($record->date))}}</td>
                         <td>{{$record->course_subscription ? $record->course_subscription->name : 'Iscrizione'}}</td>
-                        <td></td>
+                        <td>
+                            @if(sizeof(json_decode($record->months)) > 1)
+                                {{getMonthName(json_decode($record->months)[0])}} - {{getMonthName(json_decode($record->months)[sizeof(json_decode($record->months)) - 1])}}
+                            @else
+                                @if(sizeof(json_decode($record->months)) > 0)
+                                    {{getMonthName(json_decode($record->months)[0])}}
+                                @endif
+                            @endif
+                        </td>
                         <td>{{formatPrice($record->price)}}</td>
                         <td>
                             <span class="tablesaw-cell-content">

+ 12 - 0
routes/web.php

@@ -1414,6 +1414,17 @@ Route::get('/get_course_members', function () {
             $genderDisplay = "N/A";
         }
 
+        $status = 0;
+        $rates = \App\Models\Rate::where('member_course_id', $r->id)->orderBy('date')->get();
+        foreach($rates as $rate)
+        {
+            if ($rate->date > date("Y-m-d"))
+            {
+                break;
+            }
+            $status = $rate->status;
+        }
+
         $ret[] = array(
             "column_0" => $idx + 1,
             "column_8" => $r->course_name,
@@ -1426,6 +1437,7 @@ Route::get('/get_course_members', function () {
             "column_6" => $certificateInfo,
             "column_7" => $r->member_id,
             "column_10" => $r->id,
+            "column_11" => $status,
         );
     }