From 435c3217345dc768695b3a207336e035892e459d Mon Sep 17 00:00:00 2001 From: mohammedthaqi Date: Tue, 9 Jan 2024 11:30:13 +0530 Subject: [PATCH] changes in feedback Form --- .../component/UserSessionInterceptor.java | 5 +- .../controller/FeedbackAPIController.java | 116 +++ .../controller/FeedbackController.java | 2 +- src/main/resources/application.properties | 4 +- .../templates/community/communityhall.html | 266 +++++-- .../templates/feedback/RequestForm.html | 674 ++++-------------- 6 files changed, 455 insertions(+), 612 deletions(-) create mode 100644 src/main/java/com/metro/feedback/controller/FeedbackAPIController.java diff --git a/src/main/java/com/metro/component/UserSessionInterceptor.java b/src/main/java/com/metro/component/UserSessionInterceptor.java index bd43c2d..ed030ba 100644 --- a/src/main/java/com/metro/component/UserSessionInterceptor.java +++ b/src/main/java/com/metro/component/UserSessionInterceptor.java @@ -16,14 +16,15 @@ public class UserSessionInterceptor implements HandlerInterceptor { @Autowired private UserSession userSession; - private static final List EXCLUDED_URLS = Arrays.asList("/login", "/", "/api","/community","/feedback"); + private static final List EXCLUDED_URLS = Arrays.asList("/login", "/", "/api","/community","/support","/feedback"); @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { // Get the current request URL String requestUrl = request.getRequestURI(); // Exclude static resources from the check - if (requestUrl.startsWith("/assets/") || requestUrl.startsWith("/css/") || requestUrl.startsWith("/js/") || requestUrl.startsWith("/images/") || requestUrl.startsWith("/api/") || requestUrl.startsWith("/community/") ||requestUrl.startsWith("/feedback/")) { + if (requestUrl.startsWith("/assets/") || requestUrl.startsWith("/css/") || requestUrl.startsWith("/js/") || requestUrl.startsWith("/images/") + || requestUrl.startsWith("/api/") || requestUrl.startsWith("/community/") ||requestUrl.startsWith("/support/")||requestUrl.startsWith("/feedback/")) { return true; // Allow the request to proceed without checking the login status } diff --git a/src/main/java/com/metro/feedback/controller/FeedbackAPIController.java b/src/main/java/com/metro/feedback/controller/FeedbackAPIController.java new file mode 100644 index 0000000..64c2315 --- /dev/null +++ b/src/main/java/com/metro/feedback/controller/FeedbackAPIController.java @@ -0,0 +1,116 @@ +package com.metro.feedback.controller; + +import java.util.List; + +import org.hibernate.mapping.Map; +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.RestController; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; + + +@RestController +@RequestMapping("/feedback/api") +public class FeedbackAPIController { + +// @GetMapping("/user") +// public ResponseEntity getUser(@RequestParam String mobile){ +// System.out.println("1 croce "); +// RestTemplate rest =new RestTemplate(); +// +// String s="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getProfileNew&serviceinput={Username:"+mobile+"}"; +// System.out.println(s); +// Object forObject = rest.getForObject(s, Object.class); +// return ResponseEntity.ok(forObject); +// } + +// @GetMapping("/deactive") +// public ResponseEntity getDeactive(@RequestParam String mobile){ +// RestTemplate rest =new RestTemplate(); +// +// String s="https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=profileDeactivate&serviceinput={Username:"+mobile+"}"; +// ResponseEntity forEntity = rest.getForEntity(s, Map.class); +// return ResponseEntity.ok(forEntity); +// } + + @GetMapping("/user") + public ResponseEntity getUser(@RequestParam String mobile) { + StringBuilder content = new StringBuilder(); + + try { + String urlString = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=getProfileNew&serviceinput={Username:" + mobile + "}"; + + URL url = new URL(urlString); + + URLConnection urlConnection = url.openConnection(); + + try (BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()))) { + String inputLine; + + while ((inputLine = in.readLine()) != null) { + content.append(inputLine); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + // Convert the content to a JSON object using Jackson + ObjectMapper objectMapper = new ObjectMapper(); + try { + JsonNode jsonNode = objectMapper.readTree(content.toString()); + if(jsonNode==null) { + return ResponseEntity.ok(""); + } + return ResponseEntity.ok(jsonNode); + } catch (IOException e) { + e.printStackTrace(); + return ResponseEntity.status(500).body("Error parsing JSON response"); + } + } + + @GetMapping("/deactive") + public ResponseEntity getDeactive(@RequestParam String mobile){ + StringBuilder content = new StringBuilder(); + + try { + String urlString = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice?serviceId=profileDeactivate&serviceinput={Username:"+mobile+"}"; + + URL url = new URL(urlString); + + URLConnection urlConnection = url.openConnection(); + + try (BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()))) { + String inputLine; + + while ((inputLine = in.readLine()) != null) { + content.append(inputLine); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + // Convert the content to a JSON object using Jackson + ObjectMapper objectMapper = new ObjectMapper(); + try { + JsonNode jsonNode = objectMapper.readTree(content.toString()); + return ResponseEntity.ok(jsonNode); + } catch (IOException e) { + e.printStackTrace(); + return ResponseEntity.status(500).body("Error parsing JSON response"); + } + } + +} diff --git a/src/main/java/com/metro/feedback/controller/FeedbackController.java b/src/main/java/com/metro/feedback/controller/FeedbackController.java index 5bc9ede..289f919 100644 --- a/src/main/java/com/metro/feedback/controller/FeedbackController.java +++ b/src/main/java/com/metro/feedback/controller/FeedbackController.java @@ -3,7 +3,7 @@ package com.metro.feedback.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; -@RequestMapping("/feedback") +@RequestMapping("/support") @Controller public class FeedbackController { @RequestMapping(value={"/",""}) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index dcc14f2..9cc7b9b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -3,8 +3,8 @@ server.port=8068 # Database connection properties spring.datasource.url=jdbc:mysql://localhost:3306/metro spring.datasource.username=root -#spring.datasource.password=gccroot -spring.datasource.password=root +spring.datasource.password=gccroot +#spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # Connection pool properties diff --git a/src/main/resources/templates/community/communityhall.html b/src/main/resources/templates/community/communityhall.html index ce792b1..75a8c4a 100644 --- a/src/main/resources/templates/community/communityhall.html +++ b/src/main/resources/templates/community/communityhall.html @@ -17,7 +17,7 @@ body { background-color: #f8f9fa; } - + .card { border-radius: 15px; box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); @@ -72,7 +72,7 @@
- +
-
+
@@ -115,7 +115,6 @@
-
@@ -182,8 +181,8 @@ 1
-     -
Mor   Eve +     +
Mor   Eve
@@ -191,8 +190,8 @@
2 -
   
Mor   Eve +
   
Mor   Eve
@@ -200,8 +199,8 @@
3 -
   
Mor   Eve +
   
Mor   Eve
@@ -210,8 +209,8 @@
4 -
   
Mor   Eve +
   
Mor   Eve
@@ -219,8 +218,8 @@
5 -
   
Mor   Eve +
   
Mor   Eve
@@ -431,7 +430,7 @@ type="checkbox" id="eveningHalf28" name="chkbox28e30">
Mor   Eve - +
29 @@ -439,7 +438,7 @@ type="checkbox" id="eveningHalf29" name="chkbox29e30">
Mor   Eve
- +
30 @@ -447,10 +446,21 @@ type="checkbox" id="eveningHalf30" name="chkbox30e30">
Mor   Eve
+ + + +
+ + 31 +
   
Mor   Eve +
+ + @@ -531,7 +541,7 @@ RENTAL - :: @@ -599,36 +609,29 @@ @@ -697,9 +703,9 @@ // Call the functions to populate months and years populateYears(); + - - function getdivision() { + function getdivision(zone) { var z = document.getElementById("zone").value; $.ajax({ url: '/community/api/getHall', // Replace with the actual URL to retrieve division data @@ -713,12 +719,14 @@ } }); } + + var hallIndex=0; var hallInfo; - var hallIndex; function setDivisionAndHall(data) { var string = ""; hallInfo=data; console.log(data); + string= string + ""; for (let i = 0; i < data.length; i++) { string = string + ""; @@ -726,34 +734,36 @@ document.getElementById("divs").innerHTML = string; var hallName = ""; + hallName= hallName + ""; + for (let i = 0; i < data.length; i++) { hallName = hallName + ""; } document.getElementById("hall").innerHTML = hallName; - + } function getHall() { var z = document.getElementById("zone").value; - var d = document.getElementById("divs").value; + var d = document.getElementById("divs").value; for(let i=0;i 14) { + alert("You can only select checkboxes in sequence."); + $(this).prop("checked", false); + } else { + lastClickedIndex = currentIndex; + } + } else { + alert("Please select checkboxes in sequences of 14 Days."); + $(this).prop("checked", false); + } + } + }); + + + function isConsecutive(currentIndex, lastClickedIndex) { + return Math.abs(currentIndex - lastClickedIndex) === 1; + } + + + function showRemoveConfirmation(currentIndex) { + if (confirm("Do you want to remove this checkbox and uncheck subsequent checkboxes?")) { + // Uncheck subsequent checkboxes + $(":checkbox:enabled:gt(" + currentIndex + "):checked").prop("checked", false); + + // Enable previous checkboxes to be unchecked + $(":checkbox:enabled:lt(" + currentIndex + ")").prop("disabled", false); + } else { + // Revert the checkbox state to checked if the user cancels the removal + $(":checkbox:enabled:eq(" + currentIndex + ")").prop("checked", true); + } + } +}); + + function setHallAmount(i){ let fa =hallInfo[i].COMMUNITYHALLFULLDAYRATE; let ha =hallInfo[i].COMMUNITYHALLHALFDAYRATE; @@ -773,6 +834,7 @@ function setHallAmount(i){ let eh =hallInfo[i].EB_HALF; let cf =hallInfo[i].CLEAN_CHRG_FULL; let ch =hallInfo[i].CLEAN_CHRG_HALF; + let r =hallInfo[i].COMMUNITYHALLHALFDAYRATE; document.getElementById("fulldayamt").value=fa; document.getElementById("halfdayamt").value=ha; @@ -785,37 +847,85 @@ function setHallAmount(i){ document.getElementById("eb_pa_half_amt").value=eh; document.getElementById("eb_pa_full_serv").value=cf; document.getElementById("eb_pa_halft_serv").value=ch; - + document.getElementById("rental").value=0; + } - - function setHall(data) { - var string = ""; - - if (data.length == 0) { - alert("OOps!! \nThere Is No Community Hall In This Division") + +function IncrementOrDecHallAmt() { + let l = hallInfo[hallIndex].COMMUNITYHALLFULLSURCHARGE; + let f = hallInfo[hallIndex].COMMUNITYHALLFULLDAYRATE; + let m = hallInfo[hallIndex].COMMUNITYHALLHALFDAYRATE; + let n = hallInfo[hallIndex].COMMUNITYHALLHALFSURCHARGE; + let r = hallInfo[hallIndex].COMMUNITYHALLFULLDAYRATE; + if(count>=0) + if(count%2==0){ + document.getElementById("rental").value =[f * (count / 2)+f * (count / 2)]/2 // Set to 0 if count is 0 or odd + } + else if(count%2==1){ + document.getElementById("rental").value =f*Math.floor(count/2)+m; // Set to 0 if count is 0 or odd + } + } + + /* if (count % 2 === 0 && count !== 0) { + document.getElementById("fulldayamt").value = f * (count / 2); + } else { + document.getElementById("fulldayamt").value =[f * (count / 2)+f * (count / 2)]/2 // Set to 0 if count is 0 or odd + } + document.getElementById("fulldaysurcharge").value = l * (count / 2); + document.getElementById("rental").value =[f * (count / 2)+f * (count / 2)]/2 // Set to 0 if count is 0 or odd + + + if (count % 2 === 0 && count !== 0) { + document.getElementById("halfdayamt").value =m * (count / 2); + } else { + document.getElementById("halfdayamt").value =[m * (count / 2)+ m * (count/2)]/2 ; // Set to 0 if count is 0 or odd + } + document.getElementById("halfdaysurcharge").value = n * (count / 2); + */ + + function getDaysInMonth(year, month) { + return new Date(year, month, 0).getDate(); + } +function displayCheckboxes(ld) { + for (var i = 1; i <= 31; i++) { + var morningHalf31 = "morningHalf" + i; + var eveningHalf31 = "eveningHalf" + i; + var rowId = "row" + i; + + + // Check if the current day exceeds the last day of the month + if (i > ld) { + // If it does, hide the checkboxes + $("#" + morningHalf31).hide(); + $("#" + eveningHalf31).hide(); } else { - for (let i = 0; i < data.length; i++) { + // If it doesn't, show the checkboxes + $("#" + morningHalf31).show(); + $("#" + eveningHalf31).show(); + } + if (ld === 28) { + $("#row29").hide(); + $("#row30").hide(); + $("#row31").hide(); + + } else { + $("#row29").show(); + $("#row30").show(); + $("#row31").show(); - string = string + ""; } - document.getElementById("hall").innerHTML = string; - } - console.log(data); + // Show or hide the 31st row based on whether the last day is 31 + $("#row31").toggle(ld === 31); + } } + + + -} - var count=0; - function calcAmount(checked){ - alert(checked.id); - fa=document.getElementById("fulldayamt").value; - ha=document.getElementById("halfdayamt").value; - fa=fa+hallInfo[hallIndex].COMMUNITYHALLHALFDAYRATE; - } - diff --git a/src/main/resources/templates/feedback/RequestForm.html b/src/main/resources/templates/feedback/RequestForm.html index 7274b13..d293e3f 100644 --- a/src/main/resources/templates/feedback/RequestForm.html +++ b/src/main/resources/templates/feedback/RequestForm.html @@ -6,9 +6,9 @@ - GCC Grabage Collection Request + GCC Feedback - + @@ -26,11 +26,11 @@ - + -