FabioFratini пре 1 година
родитељ
комит
7b60238a8b
2 измењених фајлова са 23 додато и 11 уклоњено
  1. 22 10
      resources/views/calendar_archive.blade.php
  2. 1 1
      routes/web.php

+ 22 - 10
resources/views/calendar_archive.blade.php

@@ -214,18 +214,30 @@ $(document).ready(function() {
         const seasonId = $('#season').val();
         const categoryId = $('#category').val();
         const groupId = $('#group').val();
+        const type = $('#type').val();
 
-        const selectedCategory = categories.find(c => c.id === parseInt(categoryId));
-        if (selectedCategory) {
-            const selectedGroup = groupId ? groups.find(g => g.id === parseInt(groupId)) : null;
-
-            let urlName = selectedCategory.name;
-            if (selectedGroup) {
-                urlName += `-${selectedGroup.name}`;
-            }
+        const calendar = archivedCalendars.find(cal =>
+            cal.season_id === parseInt(seasonId) &&
+            cal.category_id === parseInt(categoryId) &&
+            (!groupId || cal.group_id === parseInt(groupId)) &&
+            cal.category?.type === type
+        );
 
-            const calendarId = groupId || categoryId;
-            const url = `/calendario/${urlName}/${calendarId}`;
+        if (calendar) {
+            const categorySlug = calendar.category.name.toLowerCase()
+                .normalize('NFD')
+                .replace(/[\u0300-\u036f]/g, '')
+                .replace(/[^\w\s-]/g, '')
+                .replace(/\s+/g, '-');
+
+            const groupSlug = calendar.group ? calendar.group.name.toLowerCase()
+                .normalize('NFD')
+                .replace(/[\u0300-\u036f]/g, '')
+                .replace(/[^\w\s-]/g, '')
+                .replace(/\s+/g, '-')
+                : '';
+
+            const url = `/calendario/${categorySlug}-${groupSlug}/${calendar.id}`;
             window.location.href = url;
         }
     });

+ 1 - 1
routes/web.php

@@ -752,7 +752,7 @@ Route::get('/archivio', function() {
 
     }
 
-    $seasons = Season::orderBy('name')->get();
+    $seasons = Season::where('default', false)->orderBy('name', 'desc')->get();
     $sections = Section::where('type', '=', 'section')
         ->orderBy('position')
         ->get();