瀏覽代碼

filter protoype

master
azri 1 天之前
父節點
當前提交
d6a0242515
共有 2 個檔案被更改,包括 43 行新增10 行删除
  1. 40
    9
      resources/views/project.blade.php
  2. 3
    1
      routes/web.php

+ 40
- 9
resources/views/project.blade.php 查看文件

44
 
44
 
45
             <div class="relative w-fit">
45
             <div class="relative w-fit">
46
                 <select
46
                 <select
47
-                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500">
47
+                    id="selectProjectStatus"
48
+                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"
49
+                    onchange="renderFDITable()">
48
                     <option value="all" selected>Status</option>
50
                     <option value="all" selected>Status</option>
49
-                    <option value="final">Perjanjian Muktamad</option>
50
-                    <option value="draft">Deraf Perjanjian</option>
51
+                    <option value="1">Perjanjian Muktamad</option>
52
+                    <option value="0">Deraf Perjanjian</option>
51
                 </select>
53
                 </select>
52
             </div>
54
             </div>
53
 
55
 
54
             <div class="relative w-fit">
56
             <div class="relative w-fit">
55
                 <select
57
                 <select
56
-                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500">
58
+                    id="selectProjectArea"
59
+                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"
60
+                    onchange="renderFDITable()">
57
                     <option value="all" selected>Daerah</option>
61
                     <option value="all" selected>Daerah</option>
58
-                    <option value="1">Gambang</option>
59
-                    <option value="2">Pekan</option>
62
+                    <option value="Gambang">Gambang</option>
63
+                    <option value="Pekan">Pekan</option>
60
                 </select>
64
                 </select>
61
             </div>
65
             </div>
62
 
66
 
63
             <div class="relative w-fit">
67
             <div class="relative w-fit">
64
                 <select
68
                 <select
65
-                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500">
69
+                    id="selectProjectYear"
70
+                    class="appearance-none w-full pl-4 pr-10 py-1 px-5 border border-gray-300 rounded-lg text-sm text-gray-700 cursor-pointer bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"
71
+                    onchange="renderFDITable()">
66
                     <option value="all" selected>Tahun</option>
72
                     <option value="all" selected>Tahun</option>
67
                     <option value="2026">2026</option>
73
                     <option value="2026">2026</option>
68
                     <option value="2025">2025</option>
74
                     <option value="2025">2025</option>
236
 
242
 
237
 @section('scripts')
243
 @section('scripts')
238
     <script>
244
     <script>
245
+
246
+        var FDIProject = [];
247
+        var DDIProject = [];
248
+
239
         async function fetchAndRenderProjects() {
249
         async function fetchAndRenderProjects() {
240
 
250
 
241
             const selectedType = document.getElementById('selectProjectType').value;
251
             const selectedType = document.getElementById('selectProjectType').value;
247
 
257
 
248
                 if (!data.FDIProject || !data.DDIProject) return
258
                 if (!data.FDIProject || !data.DDIProject) return
249
 
259
 
250
-                renderFDITable(data.FDIProject)
260
+                FDIProject = data.FDIProject
261
+                renderFDITable()
251
 
262
 
252
             } catch (error) {
263
             } catch (error) {
253
                 console.error('Error fetching projects:', error);
264
                 console.error('Error fetching projects:', error);
254
             }
265
             }
255
         }
266
         }
256
 
267
 
257
-        function renderFDITable(data) {
268
+        function renderFDITable() {
258
 
269
 
259
             const tbody = document.getElementById('FDItableBody');
270
             const tbody = document.getElementById('FDItableBody');
260
             tbody.innerHTML = ''; // Clear existing content
271
             tbody.innerHTML = ''; // Clear existing content
261
 
272
 
273
+            data = filterData(FDIProject)
274
+
262
             data.forEach((project, index) => {
275
             data.forEach((project, index) => {
263
                 const statusHTML = (() => {
276
                 const statusHTML = (() => {
264
                     switch (project.status) {
277
                     switch (project.status) {
294
 
307
 
295
         }
308
         }
296
 
309
 
310
+        function filterData(data){
311
+
312
+            const status = document.getElementById("selectProjectStatus").value
313
+            const area = document.getElementById("selectProjectArea").value
314
+            const year = document.getElementById("selectProjectYear").value
315
+
316
+            // filter by status
317
+            data = data.filter(project => (status === "all" || parseInt(status) === parseInt(project.status)))
318
+
319
+            // filter by area
320
+            data = data.filter(project => (area === "all" || area === project.area))
321
+
322
+            // filter by year
323
+            data = data.filter(project => (year === "all" || parseInt(year) === parseInt(project.year)))
324
+
325
+            return data
326
+        }
327
+
297
         document.addEventListener('DOMContentLoaded', fetchAndRenderProjects);
328
         document.addEventListener('DOMContentLoaded', fetchAndRenderProjects);
298
     </script>
329
     </script>
299
 @endsection
330
 @endsection

+ 3
- 1
routes/web.php 查看文件

315
                 "type" => "Data Center",
315
                 "type" => "Data Center",
316
                 "status" => 1,
316
                 "status" => 1,
317
                 "note" => "Dalam Proses Submit",
317
                 "note" => "Dalam Proses Submit",
318
-                "moa_date" => "22-02-2025",
318
+                "moa_date" => "22-02-2026",
319
+                "year" => "2026",
319
                 "area" => "Gambang",
320
                 "area" => "Gambang",
320
                 "invesment_approx" => 100000000,
321
                 "invesment_approx" => 100000000,
321
                 "labour_approx" => 50,
322
                 "labour_approx" => 50,
328
                 "status" => 0,
329
                 "status" => 0,
329
                 "note" => "Loi Ditandatangani pada 14-03-2025",
330
                 "note" => "Loi Ditandatangani pada 14-03-2025",
330
                 "moa_date" => "22-02-2025",
331
                 "moa_date" => "22-02-2025",
332
+                "year" => "2025",
331
                 "area" => "Pekan",
333
                 "area" => "Pekan",
332
                 "invesment_approx" => 100000000,
334
                 "invesment_approx" => 100000000,
333
                 "labour_approx" => 50,
335
                 "labour_approx" => 50,

Loading…
取消
儲存