From 3c2c2dfe20d509218687249280d8387aad4de43f Mon Sep 17 00:00:00 2001 From: AJITHKUMAR12 <48044092+AJITHKUMAR12@users.noreply.github.com> Date: Fri, 24 Jul 2026 13:19:15 +0530 Subject: [PATCH] implemented coworkspacce report with detailed and performance report --- .../controller/CoworkspaceApicontroller.java | 18 +- .../controller/MainController.java | 5 + .../service/CoworkspaceService.java | 569 +++++++++++++++--- .../templates/modules/communityreport.html | 407 +++++++++++++ .../templates/modules/coworkspace.html | 483 ++++++++++++++- 5 files changed, 1378 insertions(+), 104 deletions(-) create mode 100644 src/main/resources/templates/modules/communityreport.html diff --git a/src/main/java/com/gcc/commissionerreview/controller/CoworkspaceApicontroller.java b/src/main/java/com/gcc/commissionerreview/controller/CoworkspaceApicontroller.java index 27c7997..ab8e0ef 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/CoworkspaceApicontroller.java +++ b/src/main/java/com/gcc/commissionerreview/controller/CoworkspaceApicontroller.java @@ -10,6 +10,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import com.gcc.commissionerreview.service.CommunityHallService; @@ -63,11 +64,22 @@ public class CoworkspaceApicontroller { @GetMapping("/getReport") public ResponseEntity>> getReport( @RequestParam(required = false) String fromDate, - @RequestParam(required = false) String toDate, - @RequestParam(required = false) String filterBy) { + @RequestParam(required = false) String toDate) { return ResponseEntity.ok( - reportService.getReport(fromDate, toDate, filterBy)); + reportService.getReport(fromDate, toDate)); + } + + @GetMapping("/performance") + @ResponseBody + public List> getPerformance( + + @RequestParam String fromDate, + + @RequestParam String toDate) { + + return reportService.getPerformance(fromDate, toDate); + } } diff --git a/src/main/java/com/gcc/commissionerreview/controller/MainController.java b/src/main/java/com/gcc/commissionerreview/controller/MainController.java index e5d0d96..3eeef6a 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/MainController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/MainController.java @@ -368,4 +368,9 @@ public class MainController { return "modules/coworkspace"; } + @GetMapping("/communityhalloverview") + public String communityhalloverview(Model model) { + return "modules/communityreport"; + } + } diff --git a/src/main/java/com/gcc/commissionerreview/service/CoworkspaceService.java b/src/main/java/com/gcc/commissionerreview/service/CoworkspaceService.java index a734f7d..2feddcb 100644 --- a/src/main/java/com/gcc/commissionerreview/service/CoworkspaceService.java +++ b/src/main/java/com/gcc/commissionerreview/service/CoworkspaceService.java @@ -115,38 +115,44 @@ public class CoworkspaceService { if (fromDate != null && !fromDate.isBlank() && toDate != null && !toDate.isBlank()) { - if ("slot_date".equals(filterBy)) { - - sql.append(""" - AND EXISTS ( - SELECT 1 - FROM calendar cl - WHERE cl.bookingid = bk.booking_id - AND DATE(cl.bdate) BETWEEN ? AND ? - ) - """); - - params.add(fromDate); - params.add(toDate); - - } else if ("current_date".equals(filterBy)) { - - sql.append(""" - AND DATE(bk.cdate) BETWEEN ? AND ? - """); - - params.add(fromDate); - params.add(toDate); - - } else { - - sql.append(""" - AND bk.from_date BETWEEN ? AND ? - """); + /* + * if ("slot_date".equals(filterBy)) { + * + * sql.append(""" + * AND EXISTS ( + * SELECT 1 + * FROM calendar cl + * WHERE cl.bookingid = bk.booking_id + * AND DATE(cl.bdate) BETWEEN ? AND ? + * ) + * """); + * + * params.add(fromDate); + * params.add(toDate); + * + * } else if ("current_date".equals(filterBy)) { + * + * sql.append(""" + * AND DATE(bk.cdate) BETWEEN ? AND ? + * """); + * + * params.add(fromDate); + * params.add(toDate); + * + * } else { + * + * sql.append(""" + * AND bk.from_date BETWEEN ? AND ? + * """); + * + * params.add(fromDate); + * params.add(toDate); + * } + */ + sql.append(" AND DATE(bk.cdate) BETWEEN ? AND ? "); + params.add(fromDate); + params.add(toDate); - params.add(fromDate); - params.add(toDate); - } } sql.append(""" @@ -308,6 +314,22 @@ public class CoworkspaceService { sl.name """); + List> locationDetails = jdbcTemplate.queryForList(""" + SELECT + c.cid, + c.display_name, + b.bid, + b.name AS building_name + FROM category c + INNER JOIN buildings b + ON c.bid = b.bid + WHERE b.isactive = 1 + AND b.isdelete = 0 + ORDER BY b.bid + """); + + dashboard.put("locationDetails", locationDetails); + dashboard.put("totalBuildings", totalBuildings); dashboard.put("totalBookings", totalBookings); dashboard.put("totalRevenue", totalRevenue); @@ -321,7 +343,7 @@ public class CoworkspaceService { } // new requirement - public List> getReport(String fromDate, String toDate, String filterBy) { + public List> getReport(String fromDate, String toDate) { StringBuilder sql = new StringBuilder(); @@ -395,55 +417,56 @@ public class CoworkspaceService { """); sql.append(" WHERE 1=1 AND bk.booking_status = 'success' "); - List params = new ArrayList<>(); + // List params = new ArrayList<>(); - if (fromDate != null && !fromDate.isBlank() - && toDate != null && !toDate.isBlank()) { - - if ("slot_date".equals(filterBy)) { - - sql.append(""" - AND EXISTS ( - SELECT 1 - FROM calendar cl - WHERE cl.bookingid = bk.booking_id - AND DATE(cl.bdate) BETWEEN ? AND ? - ) - """); - - params.add(fromDate); - params.add(toDate); - - } else if ("current_date".equals(filterBy)) { - - sql.append(""" - AND DATE(bk.cdate) BETWEEN ? AND ? - """); - - params.add(fromDate); - params.add(toDate); - - } else { - - sql.append(""" - AND bk.from_date BETWEEN ? AND ? - """); - - params.add(fromDate); - params.add(toDate); - } - } /* - * List params = new ArrayList<>(); * if (fromDate != null && !fromDate.isBlank() * && toDate != null && !toDate.isBlank()) { * - * sql.append(" AND bk.from_date BETWEEN ? AND ? "); + * if ("slot_date".equals(filterBy)) { + * + * sql.append(""" + * AND EXISTS ( + * SELECT 1 + * FROM calendar cl + * WHERE cl.bookingid = bk.booking_id + * AND DATE(cl.bdate) BETWEEN ? AND ? + * ) + * """); + * + * params.add(fromDate); + * params.add(toDate); + * + * } else if ("current_date".equals(filterBy)) { + * + * sql.append(""" + * AND DATE(bk.cdate) BETWEEN ? AND ? + * """); + * * params.add(fromDate); * params.add(toDate); + * + * } else { + * + * sql.append(""" + * AND bk.from_date BETWEEN ? AND ? + * """); + * + * params.add(fromDate); + * params.add(toDate); + * } * } */ + List params = new ArrayList<>(); + if (fromDate != null && !fromDate.isBlank() + && toDate != null && !toDate.isBlank()) { + + sql.append(" AND DATE(bk.cdate) BETWEEN ? AND ? "); + params.add(fromDate); + params.add(toDate); + } + sql.append(""" GROUP BY b.bid, @@ -458,4 +481,408 @@ public class CoworkspaceService { return jdbcTemplate.queryForList(sql.toString(), params.toArray()); } + public List> getPerformance(String fromDate, String toDate) { + StringBuilder sql = new StringBuilder(); + sql.append( + """ + SELECT + b.bid, b.name AS building_name, b.inauguration_date, + CASE WHEN DATE(b.inauguration_date) > ? THEN 0 ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 END AS coverage_days, + ( + + CASE + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 + END + ) + * + COALESCE( + ( + SELECT 2 * sc.capacity + FROM category c + INNER JOIN subcategory sc + ON sc.cid = c.cid + INNER JOIN slots sl + ON sl.scid = sc.scid + WHERE c.bid = b.bid + AND c.display_name = 'Desk Space' + AND sl.slotid IN (8,9,110,111,62,61) + AND c.isactive = 1 + AND c.isdelete = 0 + AND sc.isactive = 1 + AND sc.isdelete = 0 + AND sl.isactive = 1 + AND sl.isdelete = 0 + LIMIT 1 + ),0) AS desk_available_slots, + ( + SELECT COALESCE( + SUM( + CASE + WHEN cl.slotid IN (8,9,110,111,62,61) THEN 2 + ELSE 1 + END + ), + 0 + ) + FROM calendar cl + INNER JOIN booking bk + ON bk.booking_id = cl.bookingid + INNER JOIN category c + ON c.cid = bk.cid + AND c.bid = bk.bid + WHERE bk.bid = b.bid + AND c.display_name = 'Desk Space' + AND DATE(cl.bdate) BETWEEN ? AND ? + AND cl.is_active = 1 + AND cl.is_delete = 0 + AND bk.booking_status = 'success' + ) AS desk_booked_slots, + /* ( + SELECT COALESCE(count(cl.bookingid),0) + FROM calendar cl + INNER JOIN booking bk ON bk.booking_id = cl.bookingid + INNER JOIN category c ON c.cid = bk.cid AND c.bid = bk.bid + WHERE bk.bid = b.bid + AND c.display_name = 'Desk Space' + AND DATE(cl.bdate) BETWEEN ? AND ? + AND cl.is_active = 1 AND cl.is_delete = 0 + AND bk.booking_status = 'success' + ) AS desk_booked_slots,*/ + ( + CASE + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 + END + ) + * + ( + SELECT COALESCE(SUM(t.total_capacity), 0) + FROM ( + SELECT + COUNT(sl.slotid) * sc.capacity AS total_capacity + FROM category c + INNER JOIN subcategory sc + ON sc.cid = c.cid + INNER JOIN slots sl + ON sl.scid = sc.scid + WHERE c.bid = b.bid + AND c.display_name = 'Learning Centre' + AND c.isactive = 1 + AND c.isdelete = 0 + AND sc.isactive = 1 + AND sc.isdelete = 0 + AND sl.isactive = 1 + AND sl.isdelete = 0 + GROUP BY sc.scid, sc.capacity + ) t + ) AS learning_available_slots, + ( + SELECT COALESCE(count(cl.bookingid), 0) + FROM calendar cl + INNER JOIN booking bk ON bk.booking_id = cl.bookingid + INNER JOIN category c ON c.cid = bk.cid AND c.bid = bk.bid + WHERE bk.bid = b.bid + AND c.display_name = 'Learning Centre' + AND DATE(cl.bdate) BETWEEN GREATEST(DATE(b.inauguration_date), ?) AND ? + AND cl.is_active = 1 AND cl.is_delete = 0 + AND bk.booking_status = 'success' + ) AS learning_booked_slots, + ( + CASE + WHEN b.bid <> 1 THEN 0 + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 + END * 12 )AS meeting_available_slots, + /* ( + CASE + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 + END + ) + * + ( + SELECT COALESCE(SUM(t.total_capacity), 0) + FROM ( + SELECT + COUNT(sl.slotid) * sc.capacity AS total_capacity + FROM category c + INNER JOIN subcategory sc + ON sc.cid = c.cid + INNER JOIN slots sl + ON sl.scid = sc.scid + WHERE c.bid = b.bid + AND c.display_name = 'Meeting Rooms' + AND c.isactive = 1 + AND c.isdelete = 0 + AND sc.isactive = 1 + AND sc.isdelete = 0 + AND sl.isactive = 1 + AND sl.isdelete = 0 + GROUP BY sc.scid, sc.capacity + ) t + ) AS meeting_available_slots,*/ + ( + SELECT COUNT(cl.calid) + FROM calendar cl + INNER JOIN booking bk ON bk.booking_id = cl.bookingid + INNER JOIN category c ON c.cid = bk.cid AND c.bid = bk.bid + WHERE bk.bid = b.bid + AND c.display_name = 'Meeting Rooms' + AND DATE(cl.bdate) BETWEEN GREATEST(DATE(b.inauguration_date), ?) AND ? + AND cl.is_active = 1 AND cl.is_delete = 0 + AND bk.booking_status = 'success' + ) AS meeting_booked_slots + FROM buildings b + WHERE b.isactive = 1 AND b.isdelete = 0 + ORDER BY b.bid + """); + + List params = new ArrayList<>(); + // COVERAGE DAYS + params.add(toDate); + params.add(toDate); + params.add(fromDate); + // DESK available (CASE for coverage) + params.add(toDate); + params.add(toDate); + params.add(fromDate); + // Desk booked + params.add(fromDate); + params.add(toDate); + // Learning available (CASE) + params.add(toDate); + params.add(toDate); + params.add(fromDate); + // Learning booked + params.add(fromDate); + params.add(toDate); + // Meeting available (CASE) + params.add(toDate); + params.add(toDate); + params.add(fromDate); + // Meeting booked + params.add(fromDate); + params.add(toDate); + + return jdbcTemplate.queryForList(sql.toString(), params.toArray()); + } + + public List> getPerformance1(String fromDate, String toDate) { + StringBuilder sql = new StringBuilder(); + sql.append( + """ + SELECT + b.bid, + b.name AS building_name, + b.inauguration_date, + CASE WHEN DATE(b.inauguration_date) > ? THEN 0 ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 END AS coverage_days, + /* CASE + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF( + ?, + GREATEST(DATE(b.inauguration_date), ?) + ) + 1 + END + * + ( + SELECT COALESCE( + SUM( + CASE + WHEN sl.slotid IN (8,9,110,111,62,61) THEN 2 + ELSE 1 + END + ),0) + FROM category c + INNER JOIN subcategory sc + ON sc.cid = c.cid + INNER JOIN slots sl + ON sl.scid = sc.scid + WHERE c.bid = b.bid + AND c.display_name = 'Desk Space' + AND c.isactive = 1 + AND c.isdelete = 0 + AND sc.isactive = 1 + AND sc.isdelete = 0 + AND sl.isactive = 1 + AND sl.isdelete = 0 + ) AS desk_available_slots, */ + ( + CASE + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 + END + ) + * + ( + SELECT COALESCE( + SUM( + ( + CASE + WHEN sl.slotid IN (8,9,110,111,62,61) THEN 2 + ELSE 1 + END + ) * sc.capacity + ),0) + FROM category c + INNER JOIN subcategory sc + ON sc.cid = c.cid + INNER JOIN slots sl + ON sl.scid = sc.scid + WHERE c.bid = b.bid + AND c.display_name = 'Desk Space' + AND c.isactive = 1 + AND c.isdelete = 0 + AND sc.isactive = 1 + AND sc.isdelete = 0 + AND sl.isactive = 1 + AND sl.isdelete = 0 + ) AS desk_available_slots, + + ( + SELECT COALESCE(count(cl.bookingid),0) + FROM calendar cl + INNER JOIN booking bk ON bk.booking_id = cl.bookingid + INNER JOIN category c ON c.cid = bk.cid AND c.bid = bk.bid + WHERE bk.bid = b.bid + AND c.display_name = 'Desk Space' + AND DATE(cl.bdate) BETWEEN ? AND ? + AND cl.is_active = 1 AND cl.is_delete = 0 + AND bk.booking_status = 'success' + ) AS desk_booked_slots, + ( + CASE + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 + END + ) + * + ( + SELECT COALESCE( + SUM(COUNT(sl.slotid) * sc.capacity),0 + ) + FROM category c + INNER JOIN subcategory sc ON sc.cid = c.cid + INNER JOIN slots sl ON sl.scid = sc.scid + WHERE c.bid = b.bid + AND c.display_name = 'Learning Centre' + AND c.isactive = 1 + AND c.isdelete = 0 + AND sc.isactive = 1 + AND sc.isdelete = 0 + AND sl.isactive = 1 + AND sl.isdelete = 0 + ) AS learning_available_slots, + /* ( + CASE WHEN DATE(b.inauguration_date) > ? THEN 0 ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 END + ) * 5 AS learning_available_slots,*/ + ( + SELECT COALESCE(count(cl.bookingid), 0) + FROM calendar cl + INNER JOIN booking bk ON bk.booking_id = cl.bookingid + INNER JOIN category c ON c.cid = bk.cid AND c.bid = bk.bid + WHERE bk.bid = b.bid + AND c.display_name = 'Learning Centre' + AND DATE(cl.bdate) BETWEEN GREATEST(DATE(b.inauguration_date), ?) AND ? + AND cl.is_active = 1 AND cl.is_delete = 0 + AND bk.booking_status = 'success' + ) AS learning_booked_slots, + ( + + CASE + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 + END + ) + * + ( + SELECT COALESCE( + SUM(sc.capacity),0 + ) + FROM category c + INNER JOIN subcategory sc ON sc.cid = c.cid + INNER JOIN slots sl ON sl.scid = sc.scid + WHERE c.bid = b.bid + AND c.display_name = 'Meeting Rooms' + AND c.isactive = 1 + AND c.isdelete = 0 + AND sc.isactive = 1 + AND sc.isdelete = 0 + AND sl.isactive = 1 + AND sl.isdelete = 0 + ) AS meeting_available_slots, + ( + CASE + WHEN DATE(b.inauguration_date) > ? THEN 0 + ELSE DATEDIFF(?, GREATEST(DATE(b.inauguration_date), ?)) + 1 + END + ) + * + ( + SELECT COUNT(sl.slotid) + FROM category c + INNER JOIN subcategory sc + ON sc.cid = c.cid + INNER JOIN slots sl + ON sl.scid = sc.scid + WHERE c.bid = b.bid + AND c.display_name = 'Meeting Rooms' + AND c.isactive = 1 + AND c.isdelete = 0 + AND sc.isactive = 1 + AND sc.isdelete = 0 + AND sl.isactive = 1 + AND sl.isdelete = 0 + ) AS meeting_available_slots,*/ + ( + SELECT COUNT(cl.calid) + FROM calendar cl + INNER JOIN booking bk ON bk.booking_id = cl.bookingid + INNER JOIN category c ON c.cid = bk.cid AND c.bid = bk.bid + WHERE bk.bid = b.bid + AND c.display_name = 'Meeting Rooms' + AND DATE(cl.bdate) BETWEEN GREATEST(DATE(b.inauguration_date), ?) AND ? + AND cl.is_active = 1 AND cl.is_delete = 0 + AND bk.booking_status = 'success' + ) AS meeting_booked_slots + FROM buildings b + WHERE b.isactive = 1 AND b.isdelete = 0 + ORDER BY b.bid + """); + + List params = new ArrayList<>(); + // COVERAGE DAYS + params.add(toDate); // WHEN DATE(b.inauguration_date) > ? + params.add(toDate); // DATEDIFF end + params.add(fromDate); // GREATEST() + + // DESK SPACE AVAILABLE + + params.add(toDate); + params.add(toDate); + params.add(fromDate); + // Desk Space Booked + params.add(fromDate); + params.add(toDate); + + // Learning Available + params.add(toDate); // WHEN inauguration_date > ? + params.add(toDate); // DATEDIFF(end_date, ...) + params.add(fromDate); // GREATEST(inauguration, fromDate) + + // Learning Centre Booked + params.add(fromDate); // GREATEST(inauguration_date, fromDate) + params.add(toDate); // bdate <= toDate + + // Meeting Available + params.add(toDate); + params.add(toDate); + params.add(fromDate); + + // Meeting Rooms Booked + params.add(fromDate); + params.add(toDate); + + return jdbcTemplate.queryForList(sql.toString(), params.toArray()); + } } diff --git a/src/main/resources/templates/modules/communityreport.html b/src/main/resources/templates/modules/communityreport.html new file mode 100644 index 0000000..664a90e --- /dev/null +++ b/src/main/resources/templates/modules/communityreport.html @@ -0,0 +1,407 @@ + + + + + Coworkspace Report + + + + + + + + + + + + + + + + +
+
+

community Hall report

+
+
+ + +
+
+
+
Community Hall CareTaker Performance Report
+
+
+
+ + +
+
+
+
Community Hall Popularity Report
+
+
+
+ + +
+
+
+
Community Hall Refund Review Report
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/coworkspace.html b/src/main/resources/templates/modules/coworkspace.html index b30293d..b498b7b 100644 --- a/src/main/resources/templates/modules/coworkspace.html +++ b/src/main/resources/templates/modules/coworkspace.html @@ -236,6 +236,28 @@ min-width: 110px; } + #performanceTable thead tr:first-child th { + text-align: center; + vertical-align: middle; + background: #003366; + color: #fff; + } + + #performanceTable thead tr:nth-child(2) th { + text-align: center; + vertical-align: middle; + background: #0d6efd; + color: #fff; + } + + #performanceTable td { + text-align: center; + } + + #performanceTable td:nth-child(2) { + text-align: left; + } + @@ -364,13 +386,21 @@
-
+ +
+ +
@@ -398,33 +428,99 @@
--> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
S.NoMuthalvarpadaippagam NameInauguration DateOperational DaysTotal BookingTotal ReveneueTotal Slot BookedDesk Space BookingsLearning Center BookingsMeeting Room Bookings
+
+
+
+ + `; + + });*/ + + /* $("#totalCategories").html(categoryHtml);*/ let categoryHtml = ""; res.categories.forEach(function (item) { categoryHtml += `
+ ${item.display_name} - ${item.total} + + + + ${item.total} + + +
`; - }); $("#totalCategories").html(categoryHtml); + // Save all location details + locationData = res.locationDetails; + slotData = res.slotDetails; $("#slotCount").text(slotData.length); @@ -647,13 +801,50 @@ }); } + let locationData = []; + + function viewLocation(categoryName) { + + $("#locationTitle").text(categoryName + " Locations"); + + let tbody = ""; + + let list = locationData.filter(function (item) { + return item.display_name === categoryName; + }); + + list.forEach(function (item, index) { + + tbody += ` + + + ${index + 1} + + + ${item.building_name} + + + + + `; + }); + + $("#locationTable tbody").html(tbody); + + $("#locationModal").modal("show"); + } let bookingTable; function viewBookings(bid, cid) { + /* if ($.fn.DataTable.isDataTable('#bookingTable')) { + $('#bookingTable').DataTable().destroy(); + }*/ if ($.fn.DataTable.isDataTable('#bookingTable')) { - $('#bookingTable').DataTable().destroy(); + $('#bookingTable').DataTable().clear().destroy(); } + + $('#bookingTable tbody').empty(); $('#pageLoader').show(); $('#bookingTable').DataTable({ @@ -908,10 +1099,11 @@ } - function loadReport(isUserAction = false) { + // function loadReport(isUserAction = false) { + function loadDetailReport(isUserAction = false) { let fromDate = $("#fromDate").val(); let toDate = $("#toDate").val(); - let filterBy = $("#filterBy").val(); + let filterBy = $("#reportType").val(); if (isUserAction) { if (!fromDate && !toDate) { @@ -966,8 +1158,8 @@ toDate: $("#toDate").val(), filterBy: $("#filterBy").val()*/ fromDate: fromDate, - toDate: toDate, - filterBy: filterBy + toDate: toDate + }, @@ -1088,11 +1280,240 @@ }); } + /* $("#searchBtn").click(function () { + + loadReport(true); + + });*/ $("#searchBtn").click(function () { - loadReport(true); + let reportType = $("#reportType").val(); + + if (reportType == "") { + + Swal.fire({ + icon: "warning", + title: "Validation", + text: "Please select Report Type." + }); + + return; + } + + if (reportType == "DETAIL") { + + $("#detailReportDiv").show(); + $("#performanceReportDiv").hide(); + + loadDetailReport(true); + + } else if (reportType == "PERFORMANCE") { + if ($("#fromDate").val() == "" || $("#toDate").val() == "") { + Swal.fire({ + icon: "warning", + title: "Validation", + text: "Please select From Date and To Date." + }); + return; + } + + + $("#detailReportDiv").hide(); + $("#performanceReportDiv").show(); + + loadPerformanceReport(); + + } }); + function loadPerformanceReport() { + let fromDate = $("#fromDate").val(); + let toDate = $("#toDate").val(); + let filterBy = $("#reportType").val(); + if (!fromDate && !toDate) { + Swal.fire({ + icon: "warning", + title: "Validation", + text: "Please select From Date and To Date." + }); + return; + } + + if (fromDate && !toDate) { + Swal.fire({ + icon: "warning", + title: "Validation", + text: "Please select To Date." + }); + return; + } + + if (!fromDate && toDate) { + Swal.fire({ + icon: "warning", + title: "Validation", + text: "Please select From Date." + }); + return; + } + + if ((fromDate && toDate) && !filterBy) { + Swal.fire({ + icon: "warning", + title: "Validation", + text: "Please select Filter By." + }); + return; + } + + + $('#pageLoader').show(); + + $.ajax({ + + url: "/commissionerreview/api/coworkspace/performance", + + type: "GET", + + data: { + + fromDate: $("#fromDate").val(), + + toDate: $("#toDate").val() + + }, + + success: function (response) { + + $('#pageLoader').hide(); + + if ($.fn.DataTable.isDataTable("#performanceTable")) { + + $("#performanceTable").DataTable().destroy(); + + } + + $("#performanceTable").DataTable({ + + destroy: true, + + paging: false, + + searching: false, + + ordering: false, + + data: response, + + columns: [ + + { + + data: null, + + render: function (data, type, row, meta) { + + return meta.row + 1; + + } + + }, + + { + + data: "building_name" + + }, + + { + + data: "inauguration_date", + + render: function (data) { + + return formatDate(data); + + } + + }, + + { + + data: "coverage_days" + + }, + + { + + data: "desk_available_slots" + + }, + + { + + data: "desk_booked_slots" + + }, + + { + + data: "learning_available_slots" + + }, + + { + + data: "learning_booked_slots" + + }, + + { + + data: "meeting_available_slots" + + }, + + { + + data: "meeting_booked_slots" + + } + + ], + + dom: 'Bfrtip', + + buttons: [ + + 'excel', + + 'pdf' + + ] + + }); + + }, + + error: function () { + + $('#pageLoader').hide(); + + Swal.fire({ + + icon: 'error', + + title: 'Error', + + text: 'Unable to load Performance Report.' + + }); + + } + + }); + + } /*$('#bookingModal').on('hidden.bs.modal', function () { window.location.reload(); });*/ @@ -1100,9 +1521,11 @@ $("#fromDate").val(""); $("#toDate").val(""); - $("#filterBy").val(""); + $("#reportType").val(""); - loadReport(); + loadDetailReport(); + $("#detailReportDiv").show(); + $("#performanceReportDiv").hide(); });