diff --git a/src/main/java/com/gcc/commissionerreview/controller/VphApiController.java b/src/main/java/com/gcc/commissionerreview/controller/VphApiController.java index 177673d..7f13c66 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/VphApiController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/VphApiController.java @@ -1,5 +1,7 @@ package com.gcc.commissionerreview.controller; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; @@ -42,4 +44,15 @@ public class VphApiController { return vphservice.getHallBookings(fromDate, toDate); } + @GetMapping("/visitor-details-by-date") + public List> getVisitorDetailsByDate( + @RequestParam String visitDate) { + + // visitDate comes as dd-MM-yyyy + DateTimeFormatter uiFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + LocalDate localDate = LocalDate.parse(visitDate, uiFormatter); + + return vphservice.getVisitorDetailsByDate(localDate); + } + } diff --git a/src/main/java/com/gcc/commissionerreview/service/VphService.java b/src/main/java/com/gcc/commissionerreview/service/VphService.java index 8fb0037..ae1a22e 100644 --- a/src/main/java/com/gcc/commissionerreview/service/VphService.java +++ b/src/main/java/com/gcc/commissionerreview/service/VphService.java @@ -1,5 +1,6 @@ package com.gcc.commissionerreview.service; +import java.time.LocalDate; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -159,4 +160,50 @@ public class VphService { return jdbcTemplate.queryForObject(sql, Integer.class); } + + // query for modal + public List> getVisitorDetailsByDate(LocalDate visitDate) { + + String sql = """ + SELECT + rd.ref_id, + rd.mob_no, + rd.email, + DATE(rd.visit_date) AS visitDate, + rd.no_of_people, + rd.total_amount AS amountPaid, + rd.id_details AS IdCardNumber, + tm.timing AS time, + tsm.timing AS slot, + tm.time_id, + tsm.language + FROM reg_details rd + LEFT JOIN time_master tm + ON rd.time_id = tm.time_id + LEFT JOIN avslot_reg_det ard + ON rd.ref_id = ard.ref_id + LEFT JOIN time_slot_master tsm + ON ard.slot_id = tsm.slot_id + LEFT JOIN visitor_count_details vcd + ON rd.ref_id = vcd.ref_id + WHERE DATE(rd.visit_date) = ? + AND rd.booking_flag = 'B' + GROUP BY + rd.ref_id, + rd.mob_no, + rd.email, + DATE(rd.visit_date), + rd.no_of_people, + rd.total_amount, + rd.id_details, + tm.timing, + tm.time_id, + tsm.timing, + tsm.language + ORDER BY tm.time_id ASC, + tsm.timing ASC + """; + + return jdbcTemplate.queryForList(sql, visitDate); + } } \ No newline at end of file diff --git a/src/main/resources/templates/modules/vphreport.html b/src/main/resources/templates/modules/vphreport.html index 2862b89..b42bc69 100644 --- a/src/main/resources/templates/modules/vphreport.html +++ b/src/main/resources/templates/modules/vphreport.html @@ -23,8 +23,25 @@ color: #ffffff !important; border-color: #002244; } + + + + /* Wrap long email text */ + .email-wrap { + max-width: 170px; + white-space: nowrap; + word-break: break-word; + line-height: 1.3; + } + + /* Keep date/time compact */ + .nowrap { + white-space: nowrap; + } + +
@@ -52,13 +69,13 @@
-
+
@@ -66,7 +83,7 @@
-
Total Visitors
+
Total Visitors Booked

Registered count : 0 @@ -80,7 +97,7 @@

-
Senior Citizen
+
Senior Citizen

Registered count : 0 @@ -96,7 +113,7 @@

-
Adult
+
Adult

Registered count : 0

@@ -110,7 +127,7 @@
-
Children
+
Children

Registered count : 0 @@ -128,7 +145,7 @@

-
Students
+
Students

Registered count : 0

@@ -142,7 +159,7 @@
-
Foreigner
+
Foreigner

Registered count : 0

@@ -156,7 +173,7 @@
-
Physically Challenged
+
Physically Challenged

Registered count : 0 @@ -171,15 +188,27 @@ -

+ +
+
+
Hall Bookings
+ +

Registered count : + 1 +

+ +

 

+
+
@@ -266,7 +295,19 @@ -
Visitor Booking Details – Category Wise
+ +
+
Visitor Booking Details – Category Wise
+ + * Note:Visitor bookings are not available on Tuesdays. + + +
+ + + +
+
@@ -282,6 +323,7 @@ +
Total
@@ -318,6 +360,46 @@
+ + + @@ -373,7 +455,7 @@ } /* ================= TABLE 1 ================= */ - function loadVisitorCategory(fromDate, toDate) { + /*function loadVisitorCategory(fromDate, toDate) { if ($.fn.DataTable.isDataTable('#visitorTable')) { $('#visitorTable').DataTable().clear().destroy(); @@ -390,17 +472,17 @@ $.each(data, function (i, r) { $("#visitorTable tbody").append(` - - ${r.visitDate} - ${r.Adult} - ${r.Children} - ${r.SeniorCitizen} - ${r.Students} - ${r.Foreigner} - ${r.PhysicallyChallenged} - ${r.TotalCount} - - `); + + ${r.visitDate} + ${r.Adult} + ${r.Children} + ${r.SeniorCitizen} + ${r.Students} + ${r.Foreigner} + ${r.PhysicallyChallenged} + ${r.TotalCount} + + `); }); $('#visitorTable').DataTable({ @@ -420,8 +502,189 @@ }).buttons().container().appendTo('#t1Export'); } }); + }*/ + function formatDate(dateStr) { + if (!dateStr) return '-'; + const [y, m, d] = dateStr.split('-'); + return `${d}-${m}-${y}`; } + + //modal for visitor details + function openVisitorModal(visitDate) { + console.log(visitDate); + + $("#modalVisitDate").text(visitDate); + $("#visitorModal").modal("show"); + + if ($.fn.DataTable.isDataTable('#visitorDetailTable')) { + $('#visitorDetailTable').DataTable().clear().destroy(); + $("#visitorModalExport").empty(); + } + + $("#visitorDetailTable tbody").empty(); + + $.ajax({ + url: "/commissionerreview/api/visitor-details-by-date", + method: "GET", + data: { visitDate: visitDate }, + success: function (data) { + + + $.each(data, function (i, r) { + const emailVal = r.email ? r.email : '-'; + const mobileVal = r.mob_no ? r.mob_no : '-'; + $("#visitorDetailTable tbody").append(` + + ${r.ref_id} + ${mobileVal} + + + + + + ${formatDate(r.visitDate)} + ${r.no_of_people} + ${r.amountPaid} + ${r.IdCardNumber} + ${r.time} + ${r.slot} + ${r.language} + + `); + }); + + $('#visitorDetailTable').DataTable({ + paging: true, + pageLength: 10, + lengthMenu: [10, 25, 50, 100], + searching: true, + ordering: true, + dom: 'Bfrtip', + info: false, + buttons: [ + { extend: 'excelHtml5', text: 'Download Excel' } + /*{ + extend: 'pdfHtml5', + text: 'Download PDF', + orientation: 'landscape', // ✅ MUST + pageSize: 'A4', + exportOptions: { + columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] // ✅ INCLUDE Time, Slot, Language + }, + customize: function (doc) { + + // Font sizes + doc.defaultStyle.fontSize = 8; + doc.styles.tableHeader.fontSize = 9; + + // Margins + doc.pageMargins = [20, 20, 20, 20]; + + // Force equal column widths + const table = doc.content[1].table; + table.widths = Array(table.body[0].length).fill('*'); + } + }*/ + + ] + }).buttons().container().appendTo('#visitorModalExport'); + } + }); + } + + + function loadVisitorCategory(fromDate, toDate) { + + if ($.fn.DataTable.isDataTable('#visitorTable')) { + $('#visitorTable').DataTable().clear().destroy(); + $("#t1Export").empty(); + } + + $("#visitorTable tbody").empty(); + + $.ajax({ + url: "/commissionerreview/api/visitor-category", + method: "GET", + data: { fromDate, toDate }, + success: function (data) { + + // ✅ TOTAL VARIABLES + let totalAdult = 0; + let totalChildren = 0; + let totalSenior = 0; + let totalStudents = 0; + let totalForeigner = 0; + let totalPhysical = 0; + let grandTotal = 0; + + // ✅ LOOP RESPONSE + $.each(data, function (i, r) { + + totalAdult += Number(r.Adult) || 0; + totalChildren += Number(r.Children) || 0; + totalSenior += Number(r.SeniorCitizen) || 0; + totalStudents += Number(r.Students) || 0; + totalForeigner += Number(r.Foreigner) || 0; + totalPhysical += Number(r.PhysicallyChallenged) || 0; + grandTotal += Number(r.TotalCount) || 0; + + $("#visitorTable tbody").append(` + + ${r.visitDate} + ${r.Adult} + ${r.Children} + ${r.SeniorCitizen} + ${r.Students} + ${r.Foreigner} + ${r.PhysicallyChallenged} + + + + ${r.TotalCount} + + + + + `); + }); + + // ✅ APPEND GRAND TOTAL ROW + $("#visitorTable tbody").append(` + + Grand Total + ${totalAdult} + ${totalChildren} + ${totalSenior} + ${totalStudents} + ${totalForeigner} + ${totalPhysical} + ${grandTotal} + + `); + + // ✅ INITIALIZE DATATABLE + $('#visitorTable').DataTable({ + paging: true, + pageLength: 10, + lengthMenu: [10, 25, 50, 100], + searching: true, + ordering: true, + dom: 'Bfrtip', + buttons: [ + { extend: 'excelHtml5', footer: true, text: 'Download Excel' }, + { extend: 'pdfHtml5', footer: true, text: 'Download PDF' } + ] + }).buttons().container().appendTo('#t1Export'); + } + }); + } + + /* ================= TABLE 2 ================= */ function loadTotalVisitors(fromDate, toDate) {