Luca Parisio 3 months ago
parent
commit
b877e95087

+ 30 - 5
app/Http/Livewire/CourseList.php

@@ -275,6 +275,11 @@ class CourseList extends Component
         $totals = [];
         $prices = [];
 
+        $tot158 = 0;
+        $tot158X = 0;
+        $ids = '';
+        $ccc = 0;
+
         $member_course_totals = $member_course->get();
         foreach($member_course_totals as $x)
         {
@@ -289,12 +294,13 @@ class CourseList extends Component
                 foreach ($record->rows as $row)
                 {
 
-                    if (($row->causal_id == $x->course->sub_causal_id) && (str_contains(strtolower($row->note), 'iscrizione'))) //  || str_contains(strtolower($row->note), 'iscrizione'))
+                    //if (($row->causal_id == $x->course->sub_causal_id) && (str_contains(strtolower($row->note), 'iscrizione'))) //  || str_contains(strtolower($row->note), 'iscrizione'))
                     //if (str_contains(strtolower($row->note), 'iscrizione'))
+                    if ($row->causal_id == $x->course->sub_causal_id)
                     {
                         $subPrice = $row->amount;
                     }
-                    if ($row->causal_id == $x->course->causal_id && !str_contains(strtolower($row->note), 'iscrizione'))
+                    if ($row->causal_id == $x->course->causal_id)
                     {
                         $tot = sizeof(json_decode($row->when));
                         foreach(json_decode($row->when) as $m)
@@ -302,7 +308,13 @@ class CourseList extends Component
                             if (isset($prices[$m->month]))
                                 $prices[$m->month] += $row->amount / $tot;
                             else
-                                $prices[$m->month] = $row->amount / $tot;
+                                $prices[$m->month] = $row->amount / $tot;                            
+                            if ($row->causal_id == 159 && $m->month == 11)
+                            {
+                                $ids .= $row->id . ",";
+                                $ccc += 1;
+                                $tot158 += $row->amount / $tot;
+                            }
                         }
                     }
                 }
@@ -310,11 +322,12 @@ class CourseList extends Component
 
             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;
@@ -332,7 +345,14 @@ class CourseList extends Component
                             $totals[$i][$cls] += $p;
                         //else
                             //$totals[$i][$cls] = $p;
+
+                        if ($i == 10 && $cls == 'green')
+                        {
+                            $tot158X += isset($prices[$i]) ? $prices[$i] : $price;
+                            //print $cls."<br>";
+                        }
                     }
+                    
                 }
                 else
                 {
@@ -343,6 +363,7 @@ class CourseList extends Component
                         $totals[$i]['yellow'] = 0;
                     }
                 }
+                
             }
 
             $sub = $x->subscribed ? "Y" : "N";
@@ -595,6 +616,10 @@ class CourseList extends Component
         $this->records = $datas;
 
         //$this->totS = $js;
+        //print $tot158 . " ";
+        //print $tot158X;
+        //print $ccc . "-";
+        //print $ids;
 
         return view('livewire.course_list');
 

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

@@ -924,7 +924,7 @@ class Member extends Component
         // Manuali (recuperi)
         $calendar_recuperi = \App\Models\Calendar::where('manual', 1)->pluck('name')->toArray();
         
-        $this->presenceYears = \App\Models\Course::whereIn('id', $course_ids)->orderBy('year')->groupBy('year')->pluck('year')->toArray();
+        $this->presenceYears = \App\Models\Course::where('created_at', '>', '2025-08-01')->whereIn('id', $course_ids)->orderBy('year')->groupBy('year')->pluck('year')->toArray();
         $this->presenceTitle = \App\Models\Course::whereIn('id', $course_ids)->orderBy('name')->groupBy('name')->pluck('name')->toArray();
 
         foreach($calendar_recuperi as $cr)

+ 13 - 4
app/Http/Livewire/Record.php

@@ -115,7 +115,10 @@ class Record extends Component
                 'records_rows.updated_at as row_updated_at'
             )
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
-            ->where('records.deleted', false)
+            //->where('records.deleted', false)
+            ->where(function ($query) {
+                $query->where('records.deleted', false)->orWhereNull('records.deleted');
+            })
             ->whereBetween('date', [$fromDate, $toDate])
             ->where(function ($query) {
                 $query->where('type', 'OUT')
@@ -339,7 +342,10 @@ class Record extends Component
                 'records_rows.vat_id',
             )
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
-            ->where('records.deleted', false)
+            //->where('records.deleted', false)
+            ->where(function ($query) {
+                $query->where('records.deleted', false)->orWhereNull('records.deleted');
+            })
             ->whereBetween('date', [$fromDate, $toDate])
             ->where(function ($query) {
                 $query->where('type', 'OUT')
@@ -574,8 +580,11 @@ class Record extends Component
                 'records_rows.vat_id',
             )
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
-            ->where('records.deleted', false)
-            ->whereBetween('date', [$this->appliedFromDate, $this->appliedToDate])
+            //->where('records.deleted', false)
+            ->where(function ($query) {
+                $query->where('records.deleted', false)->orWhereNull('records.deleted');
+            })
+            ->whereBetween('date', [$this->appliedFromDate . " 00:00:00", $this->appliedToDate . " 23:59:59"])
             ->where(function ($query) {
                 $query->where('type', 'OUT')
                     ->orWhere(function ($query) {

+ 22 - 1
app/Http/Livewire/RecordINOUT.php

@@ -223,6 +223,9 @@ class RecordINOUT extends Component
                     ->get();
                 //$records = $records->orderBy('date', 'DESC')->get();
 
+                $ccc = 0;
+                $ids = '';
+
                 foreach($records as $record)
                 {
                     $amount = $record->amount;
@@ -238,9 +241,20 @@ class RecordINOUT extends Component
                         $this->records_in[$filter][$record->causal_id] += $amount;
                     else
                         $this->records_in[$filter][$record->causal_id] = $amount;
+
+                    //if ($record->causal_id == 158)
+                    //    print "ID = " . $record->id . "<br>";
+
                     // Aggiorno i dati del padre
                     $this->updateParent("IN", $record->causal_id, $amount, $filter);
+
+                    if ($record->causal_id == 159 && $filter == '11-2025')
+                    {
+                        $ccc += 1;
+                        $ids .= $record->id . ",";
+                    }
                 }
+                //die;
 
                 $records = \App\Models\Record::where('type', 'OUT')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
@@ -276,6 +290,8 @@ class RecordINOUT extends Component
             }
         }
 
+        //print $ccc."-";
+        //print $ids;
         //$this->showData = true;
         $this->emit('load-table');
 
@@ -516,7 +532,7 @@ class RecordINOUT extends Component
                 if ($when > 1)
                 {
                     $amount = $amount / $when;
-                    $record->amount = $amount;
+                    //$record->amount = $amount;
                 }
                 // Aggiungo/aggiorno i dati
                 if (isset($records_in[$filter][$record->causal_id]))
@@ -525,6 +541,9 @@ class RecordINOUT extends Component
                     $records_in[$filter][$record->causal_id] = $amount;
                 // Aggiorno i dati del padre
                 $this->updateParentYear("IN", $record->causal_id, $amount, $filter, $records_in, $records_out);
+
+                
+
             }
 
             $records = \App\Models\Record::where('type', 'OUT')
@@ -559,6 +578,8 @@ class RecordINOUT extends Component
 
         }
 
+
+
         $path = $this->generateExcel($columns, $this->rows_in, $records_in, $this->rows_out, $records_out, true);
         return response()->download($path)->deleteFileAfterSend();
 

+ 1 - 0
resources/views/livewire/member.blade.php

@@ -1144,6 +1144,7 @@
                                             </div>
                                             <div class="col-md-6">
                                                 <select class="form-control"  wire:model="presenceTitleFilter">
+                                                    <option value="0"></option>
                                                     @foreach($presenceTitle as $t)
                                                         <option value="{{$t}}">{{$t}}</option>
                                                     @endforeach

+ 46 - 7
routes/web.php

@@ -615,25 +615,38 @@ Route::get('/get_record_in', function () {
     if ($_GET["filterCausals"] != "null")
         $causals = explode(",", $_GET["filterCausals"]);
 
+    $count = 0;
     $aIds = [];
     foreach ($y->get() as $r) {
 
         if (!in_array($r->payment_method_id, $moneys)) {
-            //if ((!in_array($r->member_id, $exclude_from_records) || in_array($r->causal_id, $moneysCausal)) && (!$r->deleted || $r->deleted == null) && (!in_array($r->causal_id, $excludeCausals) || in_array($r->causal_id, $moneysCausal)) && (!$r->financial_movement || $r->financial_movement == null) && (!$r->corrispettivo_fiscale || $r->corrispettivo_fiscale == null) && !$r->commercial) {
-            //if ((!in_array($r->member_id, $exclude_from_records) || in_array($r->causal_id, $moneysCausal)) && (!$r->deleted || $r->deleted == null) && (!in_array($r->causal_id, $excludeCausals) || in_array($r->causal_id, $moneysCausal)) && (!$r->financial_movement || $r->financial_movement == null)) {
-            if ((!in_array($r->member_id, $exclude_from_records) || in_array($r->causal_id, $moneysCausal)) && (!$r->deleted || $r->deleted == null) && (!in_array($r->causal_id, $excludeCausals) || in_array($r->causal_id, $moneysCausal)) && (!$r->financial_movement || $r->financial_movement == null) && (!$r->corrispettivo_fiscale || $r->corrispettivo_fiscale == null)) {
-                if (sizeof($causals) == 0 || in_array($r->causal_id, $causals)) {
+            
+            if (
+                (!in_array($r->member_id, $exclude_from_records) || in_array($r->causal_id, $moneysCausal)) 
+                 && 
+                 (!$r->deleted || $r->deleted == null) 
+                 && 
+                 (!in_array($r->causal_id, $excludeCausals) || in_array($r->causal_id, $moneysCausal)) 
+                 && 
+                 (!$r->financial_movement || $r->financial_movement == null) 
+                 && 
+                 (!$r->corrispettivo_fiscale || $r->corrispettivo_fiscale == null)
+                 ) {
+            //    if (sizeof($causals) == 0 || in_array($r->causal_id, $causals)) {
                     $total += $r->amount;
                     if ($r->vat_id > 0)
                         $total += getVatValue($r->amount, $r->vat_id);
 
-                    $aIds[] = array('id' => $r->record_id, 'amount' => $r->amount);
-                }
+                    //$aIds[] = array('id' => $r->record_id, 'amount' => $r->amount);
+                    $aIds[] = $r->record_id;
+            //    }
             }
         }
 
-        
+        $count += 1;
     }
+    //print $count;
+    //print implode(",",$aIds);
     
     $count = $x->count();
 
@@ -1663,3 +1676,29 @@ Route::get('/send_sms', function () {
     }
 
 });
+
+Route::get('/fix', function () {
+    $datas = \App\Models\MemberCourse::whereNotNull('date_from')->get();
+    foreach($datas as $data)
+    {
+        $data->date_from = date("Y-m-d", strtotime($data->created_at));
+        $date_to = '';
+        $months = json_decode($data->months);
+        foreach($months as $m)
+        {
+            if ($m->m >= 9)
+            {
+                $check = "2025-" . $m->m . "-01";
+                $date_to = date("Y-m-t", strtotime($check));
+            }
+            else
+            {
+                $check = "2026-" . $m->m . "-01";
+                $date_to = date("Y-m-t", strtotime($check));
+            }
+        }
+        $data->date_to = $date_to;
+        $data->save();
+        
+    }    
+});