Quellcode durchsuchen

creazione corsi - fix creazione calendari

ferrari vor 1 Monat
Ursprung
Commit
aaaf0e41d2
2 geänderte Dateien mit 46 neuen und 23 gelöschten Zeilen
  1. 44 21
      app/Http/Livewire/Course.php
  2. 2 2
      resources/views/livewire/course.blade.php

+ 44 - 21
app/Http/Livewire/Course.php

@@ -14,9 +14,9 @@ class Course extends Component
         $course_duration_id,
         $course_frequency_id,
         $course_level_id,
-        $causal_id,
+        // $causal_id,
         $category_id,
-        $sub_causal_id,
+        // $sub_causal_id,
         $max_members,
         $instructor_id,
         $year,
@@ -50,6 +50,8 @@ class Course extends Component
     public $typeIN = 'IN';
     public $setSubscriptionCausal = 'setSubscriptionCausal';
 
+    public $festivita = [];
+
     // public $selectedMonthList = [];
 
     protected $rules = [
@@ -86,8 +88,8 @@ class Course extends Component
         $this->course_frequency_id = null;
         $this->course_level_id = null;
         $this->category_id = null;
-        $this->causal_id = null;
-        $this->sub_causal_id = null;
+        // $this->causal_id = null;
+        // $this->sub_causal_id = null;
         $this->max_members = 0;
         $this->instructor_id = null;
         $this->year = null;
@@ -150,6 +152,27 @@ class Course extends Component
 
         $this->course_years = \App\Models\Course::select('year')->where('year', '<>', '')->groupBy('year')->pluck('year');
 
+        
+        // Anni dal 2025 al 2037
+        for ($anno = 2025; $anno <= 2037; $anno++) {
+            // Festività fisse
+            $this->festivita[] = "$anno-01-01"; // Capodanno
+            $this->festivita[] = "$anno-01-06"; // Epifania
+            $this->festivita[] = "$anno-04-25"; // Festa della Liberazione
+            $this->festivita[] = "$anno-05-01"; // Festa del Lavoro
+            $this->festivita[] = "$anno-06-02"; // Festa della Repubblica
+            $this->festivita[] = "$anno-08-15"; // Ferragosto
+            $this->festivita[] = "$anno-11-01"; // Ognissanti
+            $this->festivita[] = "$anno-12-08"; // Immacolata Concezione
+            $this->festivita[] = "$anno-12-25"; // Natale
+            $this->festivita[] = "$anno-12-26"; // Santo Stefano
+
+            // Calcolo Pasqua e Pasquetta
+            $pasqua = date("Y-m-d", easter_date($anno));
+            $pasquetta = date("Y-m-d", strtotime("$pasqua +1 day"));
+            $this->festivita[] = $pasqua;     // Domenica di Pasqua
+            $this->festivita[] = $pasquetta;  // Lunedì dell'Angelo
+        }
     }
 
     public function render()
@@ -217,8 +240,8 @@ class Course extends Component
                 $course->date_from = $this->date_from;
                 $course->date_to = $this->date_to;
                 $course->category_id = $this->category_id;
-                $course->causal_id = $this->causal_id;
-                $course->sub_causal_id = $this->sub_causal_id;
+                // $course->causal_id = $this->causal_id;
+                // $course->sub_causal_id = $this->sub_causal_id;
                 $course->max_members = $this->max_members;
                 $course->instructor_id = $this->instructor_id;
                 $course->year = $this->year;
@@ -248,6 +271,8 @@ class Course extends Component
                 $from = date("Y-m-d", strtotime($this->date_from));
                 $to = date("Y-m-d", strtotime($this->date_to));
 
+                $days = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
+
                 $endDate = strtotime($to);
 
                 foreach($this->when as $d)
@@ -297,7 +322,7 @@ class Course extends Component
 
                                     // Creo il calendario del corso
                                     $calendar = new \App\Models\Calendar();
-                                    $calendar->course_id = $this->course->id;
+                                    $calendar->course_id = $course->id;
                                     $calendar->court_id = null;
                                     $calendar->name = $course_name;
                                     $calendar->course_type_id = null;
@@ -321,7 +346,6 @@ class Course extends Component
                 // Creo le causali di pagamento
                 //$causal = "PAGAMENTO CORSO [nome corso]-LIVELLO-FREQUENZA-ANNO-[tipo abbonamento]-[mese inizio]/[mese fine]
 
-                /*
                 // $causal = "PAGAMENTO CORSO " . $this->name . " - " . $lev . " - " . $freq . " - " . $this->year . " - " . $mFrom . "/" . $mTo;
                 $causal = "PAGAMENTO CORSO";
                 $cp = \App\Models\Causal::where('name', $causal)->first();
@@ -361,7 +385,6 @@ class Course extends Component
                     $ci->save();
                 }
                 $course->sub_causal_id = $ci->id;
-                */
 
                 $course->save();
 
@@ -392,8 +415,8 @@ class Course extends Component
                 $this->date_from = $course->date_from;
                 $this->date_to = $course->date_to;
                 $this->category_id = $course->category_id;
-                $this->causal_id = $course->causal_id;
-                $this->sub_causal_id = $course->sub_causal_id;
+                // $this->causal_id = $course->causal_id;
+                // $this->sub_causal_id = $course->sub_causal_id;
                 $this->max_members = $course->max_members;
                 $this->instructor_id = $course->instructor_id;
                 $this->year = $course->year;
@@ -468,8 +491,8 @@ class Course extends Component
                     'date_from' => $this->date_from,
                     'date_to' => $this->date_to,
                     'category_id' => $this->category_id,
-                    'causal_id' => $this->causal_id,
-                    'sub_causal_id' => $this->sub_causal_id,
+                    // 'causal_id' => $this->causal_id,
+                    // 'sub_causal_id' => $this->sub_causal_id,
                     'max_members' => $this->max_members,
                     'instructor_id' => $this->instructor_id,
                     'year' => $this->year,
@@ -510,15 +533,15 @@ class Course extends Component
         }
     }
 
-    public function setCausal($id, $idx)
-    {
-        $this->causal_id = $id;
-    }
+    // public function setCausal($id, $idx)
+    // {
+    //     $this->causal_id = $id;
+    // }
 
-    public function setSubscriptionCausal($id, $idx)
-    {
-        $this->sub_causal_id = $id;
-    }
+    // public function setSubscriptionCausal($id, $idx)
+    // {
+    //     $this->sub_causal_id = $id;
+    // }
 
     public function setCategory($id)
     {

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

@@ -223,7 +223,7 @@
                                 </div>
                             @endif
 
-                            <div class="col-6 mt-2">
+                            {{-- <div class="col-6 mt-2">
                                 <div class="form--item">
                                     <label for="inputName" class="form-label">Causale</label>
                                     <livewire:causals :type="$typeIN" :idx="0" :show_hidden=0 :causal_id="$causal_id" :wire:key="0" />
@@ -240,7 +240,7 @@
                                         <span style="argin-top: 0.25rem; font-size: 0.875em; color: var(--bs-form-invalid-color);">{{ $message }}</span>
                                     @enderror
                                 </div>
-                            </div>
+                            </div> --}}
 
                             <div class="col-6 mt-2">
                                 <div class="form--item">