Browse Source

general and button

master
farhan 3 months ago
parent
commit
c52c0e1a5a
3 changed files with 23 additions and 3 deletions
  1. 19
    1
      app/Http/Controllers/MainController.php
  2. 2
    1
      resources/views/attendance.blade.php
  3. 2
    1
      routes/web.php

+ 19
- 1
app/Http/Controllers/MainController.php View File

74
 
74
 
75
         $csvData = "\xEF\xBB\xBF" . "Nama,Bilangan,No Tel\n";
75
         $csvData = "\xEF\xBB\xBF" . "Nama,Bilangan,No Tel\n";
76
         foreach ($vips as $vip) {
76
         foreach ($vips as $vip) {
77
-            $csvData .= "{$vip->name},{$vip->member},\t{$vip->phone}\n";
77
+            $csvData .= "\t{$vip->name},{$vip->member},\t{$vip->phone}\n";
78
         }
78
         }
79
 
79
 
80
         $fileName = "vip_data.csv";
80
         $fileName = "vip_data.csv";
85
 
85
 
86
         return Response::make($csvData, 200, $headers);
86
         return Response::make($csvData, 200, $headers);
87
     }
87
     }
88
+
89
+    public function downloadGeneralCsv()
90
+    {
91
+        $generals = RSVP::where('is_vip', false)->get();
92
+
93
+        $csvData = "\xEF\xBB\xBF" . "Nama,Bilangan,No Tel\n";
94
+        foreach ($generals as $general) {
95
+            $csvData .= "\t{$general->name},{$general->member},\t{$general->phone}\n";
96
+        }
97
+
98
+        $fileName = "general_data.csv";
99
+        $headers = [
100
+            'Content-Type' => 'text/csv',
101
+            'Content-Disposition' => "attachment; filename=\"$fileName\"",
102
+        ];
103
+
104
+        return Response::make($csvData, 200, $headers);
105
+    }
88
 }
106
 }

+ 2
- 1
resources/views/attendance.blade.php View File

30
                 @endforeach
30
                 @endforeach
31
                 </tbody>
31
                 </tbody>
32
             </table>
32
             </table>
33
-            <a href="{{ route('download.vip.csv') }}" class="btn">Download VIP Data</a>
33
+            <a href="{{ route('download.vip.csv') }}" class="rounded-full border-solid border-2 border-navbarcolor py-1 px-3 font-medium text-gray-600">Download VIP Data</a>
34
         </div>
34
         </div>
35
         
35
         
36
         <div>
36
         <div>
53
                 @endforeach
53
                 @endforeach
54
                 </tbody>
54
                 </tbody>
55
             </table>
55
             </table>
56
+            <a href="{{ route('download.general.csv') }}" class="rounded-full border-solid border-2 border-navbarcolor py-1 px-3 font-medium text-gray-600">Download General Data</a>
56
         </div>
57
         </div>
57
     </div>
58
     </div>
58
 </body>
59
 </body>

+ 2
- 1
routes/web.php View File

20
 Route::get('/guestbook', [MainController::class, 'fetchGuestbook'])->name('guestbook.ajax');
20
 Route::get('/guestbook', [MainController::class, 'fetchGuestbook'])->name('guestbook.ajax');
21
 
21
 
22
 Route::get('/admin/attendance', [MainController::class, 'attendance']);
22
 Route::get('/admin/attendance', [MainController::class, 'attendance']);
23
-Route::get('/download-vip-csv', [MainController::class, 'downloadVipCsv'])->name('download.vip.csv');
23
+Route::get('/download-vip-csv', [MainController::class, 'downloadVipCsv'])->name('download.vip.csv');
24
+Route::get('/download-vip-csv', [MainController::class, 'downloadGeneralCsv'])->name('download.general.csv');

Loading…
Cancel
Save