From 84dda1969589fb574ac5f9b770b3e991d2d9e8ea Mon Sep 17 00:00:00 2001 From: "kirubaasagar.R" Date: Thu, 12 Sep 2024 13:12:07 +0530 Subject: [PATCH] for patch --- .../PublicgrievanceApplication.java | 2 +- .../controller/ComplaintController.java | 364 ++-- .../controller/UserController.java | 31 +- .../templates/Tradelicence/tradelicence.html | 1505 ----------------- .../checklistofficer/checklistofficer.html | 180 +- .../checklistuser/checklistuser.html | 275 --- .../templates/officer/officercomplaint.html | 685 -------- .../resources/templates/staff/appoinment.html | 217 --- .../templates/staff/appoinmentscreen.html | 251 --- .../templates/staff/createorder.html | 230 --- .../templates/staff/schemegroup.html | 186 -- .../templates/staff/staffenrollment.html | 316 ---- 12 files changed, 344 insertions(+), 3898 deletions(-) delete mode 100644 src/main/resources/templates/Tradelicence/tradelicence.html delete mode 100644 src/main/resources/templates/checklistuser/checklistuser.html delete mode 100644 src/main/resources/templates/officer/officercomplaint.html delete mode 100644 src/main/resources/templates/staff/appoinment.html delete mode 100644 src/main/resources/templates/staff/appoinmentscreen.html delete mode 100644 src/main/resources/templates/staff/createorder.html delete mode 100644 src/main/resources/templates/staff/schemegroup.html delete mode 100644 src/main/resources/templates/staff/staffenrollment.html diff --git a/src/main/java/com/gcc/publicgrievance/PublicgrievanceApplication.java b/src/main/java/com/gcc/publicgrievance/PublicgrievanceApplication.java index e9b6dde..8e35054 100644 --- a/src/main/java/com/gcc/publicgrievance/PublicgrievanceApplication.java +++ b/src/main/java/com/gcc/publicgrievance/PublicgrievanceApplication.java @@ -7,7 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; public class PublicgrievanceApplication { public static void main(String[] args) { - System.out.println("ready....."); + System.out.println("ready........."); SpringApplication.run(PublicgrievanceApplication.class, args); } diff --git a/src/main/java/com/gcc/publicgrievance/controller/ComplaintController.java b/src/main/java/com/gcc/publicgrievance/controller/ComplaintController.java index 50034ea..4c8eb02 100644 --- a/src/main/java/com/gcc/publicgrievance/controller/ComplaintController.java +++ b/src/main/java/com/gcc/publicgrievance/controller/ComplaintController.java @@ -1,6 +1,5 @@ package com.gcc.publicgrievance.controller; -import java.util.Base64; import java.util.List; import java.util.Map; @@ -13,9 +12,11 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; - +import org.springframework.web.multipart.MultipartFile; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.*; import java.io.BufferedReader; @@ -25,10 +26,18 @@ import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; +import org.springframework.http.*; - - +import java.util.Base64; +import java.util.HashMap; import com.gcc.publicgrievance.Service.ComplaintService; +import org.springframework.web.multipart.MultipartFile; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import javax.imageio.ImageIO; +import java.util.Base64; @CrossOrigin @RestController @@ -60,59 +69,233 @@ public class ComplaintController { @GetMapping("/api/getComplaintDetailsByMobile") public List> getComplaintDetailsByMobile(@RequestParam String mobileNo) { - return complaintService.fetchComplaintDetailsByMobile(mobileNo); + return complaintService.fetchComplaintDetailsByMobile(mobileNo); } + @PostMapping("/register") public ResponseEntity registerComplaint( - @RequestParam(value = "ComplainantName", required = false) String complainantName, - @RequestParam(value = "ComplainantAddr", required = false) String complainantAddr, - @RequestParam(value = "MobileNo", required = false) String mobileNo, - @RequestParam(value = "Email", required = false) String email, - @RequestParam(value = "ComplaintType", required = false) String complaintType, - @RequestParam(value = "ComplaintTitle", required = false) String complaintTitle, - @RequestParam(value = "ComplaintDetails", required = false) String complaintDetails, - @RequestParam(value = "StreetId", required = false) String streetId, - @RequestParam(value = "Comp_Image", required = false) String compImage, - @RequestParam(value = "latitude", required = false) String latitude, - @RequestParam(value = "longtitude", required = false) String longtitude, - @RequestParam(value = "Landmark", required = false) String landmark, - @RequestParam(value = "gender", required = false) String gender) { + @RequestParam(value = "ComplainantName", required = false) String complainantName, + @RequestParam(value = "ComplainantAddr", required = false) String complainantAddr, + @RequestParam(value = "MobileNo", required = false) String mobileNo, + @RequestParam(value = "Email", required = false) String email, + @RequestParam(value = "ComplaintType", required = false) String complaintType, + @RequestParam(value = "ComplaintTitle", required = false) String complaintTitle, + @RequestParam(value = "ComplaintDetails", required = false) String complaintDetails, + @RequestParam(value = "StreetId", required = false) String streetId, + @RequestParam(value = "Comp_Image", required = false) String compImage, + @RequestParam(value = "latitude", required = false) String latitude, + @RequestParam(value = "longtitude", required = false) String longtitude, + @RequestParam(value = "Landmark", required = false) String landmark, + @RequestParam(value = "gender", required = false) String gender) { + + String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; + + try { + // Create the URL object + URL url = new URL(externalUrl); + + // Create the HttpURLConnection object + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + conn.setDoOutput(true); + + // Create the parameters string, handling null values + String params = "serviceId=RegComplaint" + "&ComplainantName=" + + URLEncoder.encode(complainantName != null ? complainantName : "", "UTF-8") + "&ComplainantAddr=" + + URLEncoder.encode(complainantAddr != null ? complainantAddr : "", "UTF-8") + "&MobileNo=" + + URLEncoder.encode(mobileNo != null ? mobileNo : "", "UTF-8") + "&Email=" + + URLEncoder.encode(email != null ? email : "", "UTF-8") + "&ComplaintType=" + + URLEncoder.encode(complaintType != null ? complaintType : "", "UTF-8") + "&ComplaintTitle=" + + URLEncoder.encode(complaintTitle != null ? complaintTitle : "", "UTF-8") + "&ComplaintDetails=" + + URLEncoder.encode(complaintDetails != null ? complaintDetails : "", "UTF-8") + "&StreetId=" + + URLEncoder.encode(streetId != null ? streetId : "", "UTF-8") + "&Comp_Image=" + + URLEncoder.encode(compImage != null ? compImage : "", "UTF-8") + "&latitude=" + + URLEncoder.encode(latitude != null ? latitude : "", "UTF-8") + "&longtitude=" + + URLEncoder.encode(longtitude != null ? longtitude : "", "UTF-8") + "&Landmark=" + + URLEncoder.encode(landmark != null ? landmark : "", "UTF-8") + "&gender=" + + URLEncoder.encode(gender != null ? gender : "", "UTF-8"); + + // Write parameters to request body + try (OutputStream os = conn.getOutputStream()) { + byte[] input = params.getBytes("UTF-8"); + os.write(input, 0, input.length); + } + + // Read the response + int responseCode = conn.getResponseCode(); + BufferedReader reader; + if (responseCode == HttpURLConnection.HTTP_OK) { + reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + } else { + reader = new BufferedReader(new InputStreamReader(conn.getErrorStream())); + } + + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + + // Return the response from the external API + return ResponseEntity.status(responseCode).body(response.toString()); + + } catch (IOException e) { + e.printStackTrace(); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body("An error occurred while processing the request."); + } + } + +// @PostMapping("/updateComplaint") +// public ResponseEntity updateComplaint(@RequestParam("ComplaintId") String complaintId, +// @RequestParam(value = "Message", required = false) String message, +// @RequestParam(value = "UserType", required = false) String userType, +// @RequestParam(value = "Status", required = false) String status, +// @RequestParam(value = "Comp_Image", required = false) String compImage) { +// +// // Print for debugging +// System.out.println("ComplaintId: " + complaintId); +// System.out.println("Message: " + message); +// System.out.println("Status: " + status); +// +// // External API URL +// String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; +// +// // Create the request body as MultiValueMap for form-encoded data +// MultiValueMap requestBody = new LinkedMultiValueMap<>(); +// requestBody.add("serviceId", "UpdateComplaint"); +// requestBody.add("ComplaintId", complaintId != null ? complaintId : ""); +// requestBody.add("Message", message != null ? message : ""); +// requestBody.add("UserType", userType != null ? userType : ""); +// requestBody.add("Status", status != null ? status : ""); +// requestBody.add("Comp_Image", compImage != null ? compImage : ""); +// requestBody.add("Token", "718333469976265947044293"); +//// MultiValueMap requestBody = new LinkedMultiValueMap<>(); +//// requestBody.add("serviceId", "UpdateComplaint"); +//// requestBody.add("ComplaintId", "2024-516FGB"); +//// requestBody.add("Message","test"); +//// requestBody.add("UserType", "Public"); +//// requestBody.add("Status","8"); +//// requestBody.add("Comp_Image","null"); +//// requestBody.add("Token", "718333469976265947044293"); +// System.out.println(requestBody); +// +// // Set headers to indicate form data +// HttpHeaders headers = new HttpHeaders(); +// headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); +// +// // Build the request entity with headers and body +// HttpEntity> entity = new HttpEntity<>(requestBody, headers); +// +// try { +// // Make the POST request using RestTemplate +// ResponseEntity response = restTemplate.exchange(externalUrl, // External API endpoint +// HttpMethod.GET, // HTTP Method +// entity, // The request entity containing body and headers +// String.class // Expected response type +// ); +// System.out.println(response.getBody()); +// +// // Return the response from the external API +// return new ResponseEntity<>(response.getBody(), response.getStatusCode()); +// +// } catch (Exception e) { +// e.printStackTrace(); +// return ResponseEntity.status(500).body("An error occurred while processing the request."); +// } +// } + + /* + * @PostMapping("/updateComplaint") public ResponseEntity + * updateComplaint(@RequestParam("ComplaintId") String complaintId, + * + * @RequestParam(value = "Message", required = false) String message, + * + * @RequestParam(value = "Status") String status, + * + * @RequestParam(value = "Comp_Image", required = false) String compImage) { + * String userType = "Public"; + * System.out.println("message:-"+message+"\n UserType:-"+userType+"\n Status:-" + * +status); String externalUrl = + * "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; + * + * try { // Create the URL object URL url = new URL(externalUrl); + * + * // Create the HttpURLConnection object HttpURLConnection conn = + * (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); + * conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + * conn.setDoOutput(true); + * + * // Create the parameters string, handling null values String params = + * "serviceId=UpdateComplaint" + "&ComplaintId=" + URLEncoder.encode(complaintId + * != null ? complaintId : "", "UTF-8") + "&Message=" + + * URLEncoder.encode(message != null ? message : "", "UTF-8") + "&UserType=" + + * URLEncoder.encode(userType , "UTF-8") + "&Status=" + URLEncoder.encode(status + * != null ? status : "", "UTF-8") + "&Comp_Image=" + + * URLEncoder.encode(compImage != null ? compImage : "", "UTF-8") + + * "&Token=718333469976265947044293"; System.out.println(params); // Write + * parameters to request body try (OutputStream os = conn.getOutputStream()) { + * byte[] input = params.getBytes("UTF-8"); os.write(input, 0, input.length); } + * + * // Read the response int responseCode = conn.getResponseCode(); + * BufferedReader reader; if (responseCode == HttpURLConnection.HTTP_OK) { + * reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); } + * else { reader = new BufferedReader(new + * InputStreamReader(conn.getErrorStream())); } + * + * StringBuilder response = new StringBuilder(); String line; while ((line = + * reader.readLine()) != null) { response.append(line); } reader.close(); + * System.out.println(response.toString()); // Return the response from the + * external API return + * ResponseEntity.status(responseCode).body(response.toString()); + * + * } catch (IOException e) { e.printStackTrace(); return + * ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + * .body("An error occurred while processing the request."); } } + */ + @PostMapping("/updateComplaint") + public ResponseEntity updateComplaint( + @RequestParam("ComplaintId") String complaintId, + @RequestParam(value = "Message", required = false) String message, + @RequestParam(value = "Status") String status, + @RequestPart(value = "Comp_Image", required = false) MultipartFile compImage) { + + String userType = "Public"; + System.out.println("message:-" + message + "\n UserType:-" + userType + "\n Status:-" + status); String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; try { - // Create the URL object - URL url = new URL(externalUrl); + // Convert and compress the image to base64 if provided + String base64Image = null; + if (compImage != null && !compImage.isEmpty()) { + base64Image = compressAndEncodeToBase64(compImage); + } + + // Construct the POST body with parameters + String params = "serviceId=UpdateComplaint" + + "&ComplaintId=" + URLEncoder.encode(complaintId != null ? complaintId : "", "UTF-8") + + "&Message=" + URLEncoder.encode(message != null ? message : "", "UTF-8") + + "&UserType=" + URLEncoder.encode(userType, "UTF-8") + + "&Status=" + URLEncoder.encode(status != null ? status : "", "UTF-8") + + "&Token=718333469976265947044293"; - // Create the HttpURLConnection object + // Open connection and send POST request + URL url = new URL(externalUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); conn.setDoOutput(true); + conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - // Create the parameters string, handling null values - String params = "serviceId=RegComplaint" + - "&ComplainantName=" + URLEncoder.encode(complainantName != null ? complainantName : "", "UTF-8") + - "&ComplainantAddr=" + URLEncoder.encode(complainantAddr != null ? complainantAddr : "", "UTF-8") + - "&MobileNo=" + URLEncoder.encode(mobileNo != null ? mobileNo : "", "UTF-8") + - "&Email=" + URLEncoder.encode(email != null ? email : "", "UTF-8") + - "&ComplaintType=" + URLEncoder.encode(complaintType != null ? complaintType : "", "UTF-8") + - "&ComplaintTitle=" + URLEncoder.encode(complaintTitle != null ? complaintTitle : "", "UTF-8") + - "&ComplaintDetails=" + URLEncoder.encode(complaintDetails != null ? complaintDetails : "", "UTF-8") + - "&StreetId=" + URLEncoder.encode(streetId != null ? streetId : "", "UTF-8") + - "&Comp_Image=" + URLEncoder.encode(compImage != null ? compImage : "", "UTF-8") + - "&latitude=" + URLEncoder.encode(latitude != null ? latitude : "", "UTF-8") + - "&longtitude=" + URLEncoder.encode(longtitude != null ? longtitude : "", "UTF-8") + - "&Landmark=" + URLEncoder.encode(landmark != null ? landmark : "", "UTF-8") + - "&gender=" + URLEncoder.encode(gender != null ? gender : "", "UTF-8"); - - // Write parameters to request body - try (OutputStream os = conn.getOutputStream()) { - byte[] input = params.getBytes("UTF-8"); - os.write(input, 0, input.length); - } + // Send parameters + OutputStream os = conn.getOutputStream(); + os.write(params.getBytes()); + os.flush(); + os.close(); - // Read the response + // Handle the response int responseCode = conn.getResponseCode(); BufferedReader reader; if (responseCode == HttpURLConnection.HTTP_OK) { @@ -128,78 +311,37 @@ public class ComplaintController { } reader.close(); - // Return the response from the external API return ResponseEntity.status(responseCode).body(response.toString()); } catch (IOException e) { e.printStackTrace(); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("An error occurred while processing the request."); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body("An error occurred while processing the request."); } } - - - @PostMapping("/updateComplaint") - public ResponseEntity updateComplaint( - @RequestParam("ComplaintId") String complaintId, - @RequestParam(value = "Message", required = false) String message, - @RequestParam(value = "UserType", required = false) String userType, - @RequestParam(value = "Status", required = false) String status, - @RequestParam(value = "Comp_Image", required = false) String compImage) { - - String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/external/mobileservice"; - - try { - // Create the URL object - URL url = new URL(externalUrl); - - // Create the HttpURLConnection object - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - conn.setDoOutput(true); - - // Create the parameters string, handling null values - String params = "serviceId=UpdateComplaint"+ - "&ComplaintId=" + URLEncoder.encode(complaintId != null ? complaintId : "", "UTF-8") + - "&Message=" + URLEncoder.encode(message != null ? message : "", "UTF-8") + - "&UserType=" + URLEncoder.encode(userType != null ? userType : "", "UTF-8") + - "&Status=" + URLEncoder.encode(status != null ? status : "", "UTF-8") + - "&Comp_Image=" + URLEncoder.encode(compImage != null ? compImage : "", "UTF-8") + - "&Token=718333469976265947044293"; - - // Write parameters to request body - try (OutputStream os = conn.getOutputStream()) { - byte[] input = params.getBytes("UTF-8"); - os.write(input, 0, input.length); - } - - // Read the response - int responseCode = conn.getResponseCode(); - BufferedReader reader; - if (responseCode == HttpURLConnection.HTTP_OK) { - reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); - } else { - reader = new BufferedReader(new InputStreamReader(conn.getErrorStream())); - } - - StringBuilder response = new StringBuilder(); - String line; - while ((line = reader.readLine()) != null) { - response.append(line); - } - reader.close(); - - // Return the response from the external API - return ResponseEntity.status(responseCode).body(response.toString()); - - } catch (IOException e) { - e.printStackTrace(); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("An error occurred while processing the request."); - } - } - - - - + + + private String compressAndEncodeToBase64(MultipartFile file) throws IOException { + // Convert MultipartFile to BufferedImage + BufferedImage originalImage = ImageIO.read(file.getInputStream()); + + // Resize/Compress the image + int targetWidth = 800; // You can adjust the width as needed + int targetHeight = (int) (originalImage.getHeight() * (800.0 / originalImage.getWidth())); // Preserve aspect + // ratio + + BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB); + Graphics2D g = resizedImage.createGraphics(); + g.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null); + g.dispose(); + + // Compress the image by writing it to a ByteArrayOutputStream in JPEG format + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ImageIO.write(resizedImage, "jpg", baos); // You can change the format to "png" or "jpg" + byte[] compressedBytes = baos.toByteArray(); + + // Convert the compressed image to base64 + return Base64.getEncoder().encodeToString(compressedBytes); + } } diff --git a/src/main/java/com/gcc/publicgrievance/controller/UserController.java b/src/main/java/com/gcc/publicgrievance/controller/UserController.java index 411ed10..3b3f5ac 100644 --- a/src/main/java/com/gcc/publicgrievance/controller/UserController.java +++ b/src/main/java/com/gcc/publicgrievance/controller/UserController.java @@ -7,9 +7,9 @@ import org.springframework.web.bind.annotation.GetMapping; @Controller public class UserController { - @GetMapping("/home") + @GetMapping({"/", "/home"}) public String home(Model model) { - return "User/home"; + return "User/home"; } @GetMapping("/registercomplaints") public String registercomplaints(Model model) { @@ -27,30 +27,5 @@ public class UserController { public String checklistuser(Model model) { return "checklistuser/checklistuser"; } - //staff - @GetMapping("/createorder") - public String createorder(Model model) { - return "staff/createorder"; - } - @GetMapping("/staffenrollment") - public String staffenrollment(Model model) { - return "staff/staffenrollment"; - } - @GetMapping("/appoinmentscreen") - public String appoinmentscreen(Model model) { - return "staff/appoinmentscreen"; - } - @GetMapping("/schemegroup") - public String schemegroup(Model model) { - return "staff/schemegroup"; - } - @GetMapping("/appoinment") - public String appoinment(Model model) { - return "staff/appoinment"; - } - //tradelicence - @GetMapping("/tradelicence") - public String tradelicence(Model model) { - return "Tradelicence/tradelicence"; - } + } diff --git a/src/main/resources/templates/Tradelicence/tradelicence.html b/src/main/resources/templates/Tradelicence/tradelicence.html deleted file mode 100644 index 5ebbc81..0000000 --- a/src/main/resources/templates/Tradelicence/tradelicence.html +++ /dev/null @@ -1,1505 +0,0 @@ - - - - - - Main Page - - - - - - - - - - - - -
-
- Greater Chennai Corporation Logo - -
-
-

Trade License New Registration

-
- -
- Tamil Nadu Logo - bonton Logo -
-
- - - -
- -
-
- - -

Today Date:

-
-
-
-
-
1. Applicant Details:
-
-
- - -
- -
- - -
-
- - -
-
- - -
-
- - -
-
-
Address of the Applicant:
-
-
- - -
- -
- - -
-
- - -
-
- - -
- -
-
2. Trade Details:
-
- -
- - -
- -
- - -
-
- - -
- - -
- - - - - - - - - - - - - - - - - -
3. Trade Location Details:
-
-
- - -
- -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
- - - - -
- - - - -
- - - - -
- - - - - -
- -
- - -
4. Trade License Fee Details:
-
-
- - -
-
- -
-
- - -
-
- - -
-
-
-
- - -
- - -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- - -
- - - -
-
- - - - -
- - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/checklistofficer/checklistofficer.html b/src/main/resources/templates/checklistofficer/checklistofficer.html index d37ab8d..af4d125 100644 --- a/src/main/resources/templates/checklistofficer/checklistofficer.html +++ b/src/main/resources/templates/checklistofficer/checklistofficer.html @@ -8,9 +8,7 @@ - + @@ -183,7 +181,7 @@
Complaint Action
- +
Complaint Closed Date: @@ -194,11 +192,10 @@ Official Name:
- +
Status: -
@@ -227,7 +224,7 @@ - +
@@ -248,6 +245,10 @@ + + + + @@ -311,7 +312,7 @@ document.getElementById("commentDate").value = complaintDetails.complaintcloseddate || ''; document.getElementById("commentuser").value = complaintDetails.Officialname || ''; - document.getElementById("status").value = complaintDetails.complaintcurrentstatus || ''; + document.getElementById("statusshow").value = complaintDetails.complaintcurrentstatus || ''; // Handle nested Comments array if (Array.isArray(complaintDetails.Comments) && complaintDetails.Comments.length > 0) { @@ -441,92 +442,85 @@ $(document).ready(function () { - $('#complaintStatus').change(function () { - if ($(this).val() == '9') { // Show the image field if 'REOPENED' is selected - $('#img').show(); - } else { - $('#img').hide(); - } - }); - - // Handle the form submission - $('.btn').click(function (e) { - e.preventDefault(); - - var complaintId = 'YOUR_COMPLAINT_ID'; // You should fetch this dynamically - var status = $('#complaintStatus').val(); - var message = $('#othercomplaint-details').val(); - - // Validate the "Details of Complaint" field - if (message.trim() === "") { - // Display a SweetAlert validation message if the field is empty - Swal.fire({ - title: 'Validation Error!', - text: 'Please enter the details of the complaint.', - icon: 'warning', - confirmButtonText: 'OK' - }); - return; // Stop the form submission if the field is empty - } - - // Convert image to base64 if it's selected - var imageFile = $('#photo')[0].files[0]; - var compImage = ''; - - if (imageFile) { - var reader = new FileReader(); - reader.readAsDataURL(imageFile); - reader.onload = function () { - compImage = reader.result.split(',')[1]; // Extract base64 part - - // Proceed with the AJAX call after the image is converted - updateComplaint(complaintId, message, status, compImage); - }; - } else { - // No image selected, proceed with the AJAX call without the image - updateComplaint(complaintId, message, status, ''); - } - }); - - // Function to send the AJAX request to the backend - function updateComplaint(complaintId, message, status, compImage) { - $.ajax({ - url: '/updateComplaint', // Adjust this to match your endpoint - type: 'POST', - data: { - ComplaintId: complaintId, // complaintId mapped from your backend - Message: message, // message field - Status: status, // status dropdown - Comp_Image: compImage // base64 image data - }, - success: function (response) { - // Display SweetAlert and redirect on 'OK' - Swal.fire({ - title: 'Success!', - text: 'Complaint updated successfully.', - icon: 'success', - confirmButtonText: 'OK' - }).then((result) => { - if (result.isConfirmed) { - // Redirect to home.html after clicking OK - window.location.href = 'home'; - } - }); - }, - error: function (xhr, status, error) { - // Handle error - console.error('Error updating complaint:', error); - } - }); - } - }); - + $('#complaintStatus').change(function () { + if ($(this).val() == '9') { // Show the image field if 'REOPENED' is selected + $('#img').show(); + } else { + $('#img').hide(); + } + }); + + $('.btn').click(function (e) { + e.preventDefault(); + + var complaintId = $('#complaintid').val(); + var complaintStatus = $('#complaintStatus').val(); + var message = $('#othercomplaint-details').val(); + + // Validate "Details of Complaint" field + if (message.trim() === "") { + Swal.fire({ + title: 'Validation Error!', + text: 'Please enter the details of the complaint.', + icon: 'warning', + confirmButtonText: 'OK' + }); + return; + } + + if (complaintStatus == '0') { + Swal.fire({ + title: 'Validation Error!', + text: 'Please select a valid complaint status.', + icon: 'warning', + confirmButtonText: 'OK' + }); + return; + } + + var formData = new FormData(); + formData.append("ComplaintId", complaintId); + formData.append("Message", message); + formData.append("Status", complaintStatus); + + var imageFile = $('#photo')[0].files[0]; + if (imageFile) { + formData.append("Comp_Image", imageFile); + } + + $.ajax({ + url: '/updateComplaint', + type: 'POST', + data: formData, + processData: false, + contentType: false, + success: function (response) { + Swal.fire({ + title: 'Success!', + text: 'Complaint updated successfully.', + icon: 'success', + confirmButtonText: 'OK' + }).then((result) => { + if (result.isConfirmed) { + window.location.href = 'home'; + } + }); + }, + error: function (xhr, status, error) { + console.error('Error updating complaint:', error); + let errorMessage = xhr.responseText ? xhr.responseText : 'An error occurred while updating the complaint.'; + Swal.fire({ + title: 'Error!', + text: errorMessage, + icon: 'error', + confirmButtonText: 'OK' + }); + } + }); + }); +}); - - - - \ No newline at end of file diff --git a/src/main/resources/templates/checklistuser/checklistuser.html b/src/main/resources/templates/checklistuser/checklistuser.html deleted file mode 100644 index e1723ff..0000000 --- a/src/main/resources/templates/checklistuser/checklistuser.html +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - CheckList User - - - - - - - - - - - - - - -
- -
- -
- -
-
-
- - -

Check Availability Status

-
-
- -
-
-
- Complainant Number: -
-
- Date: -
-
-
-
- Complainant Mode: -
-
- Expiry: -
-
-
-
1. Complaining Person's Details -
-
-
-
- Complainant Mobile Number: - -
-
- Complainant Name: - -
-
- Complainant Email: - -
-
- Gender: - -
-
-
- -
- -
-
2. Complaint Location Details -
-
-
-
- Complainant Street: - -
-
- Complainant Zone: - -
-
- Complainant Ward: - -
-
- Complainant Area: - -
-
- Complainant Locality: - -
-
-
- -
- -
-
3. Complaint Type
-
-
-
- Complainant Type: - -
-
- Complainant Sub-Type: - -
-
- Complainant Title: - -
-
- Complainant Description: - -
- -
-
- -
-
- - -
-
Complaint Action
-
-
-
Aug 24
7.00 pm
-
Officer - AE Zone 15
Lorem ipsum dolor sit amet, consectetur adipiscing - elit. In sit arcu aliquet ut dui egestas.
-
-
-
-
Aug 25
10.00 am
-
Citizen
Lorem ipsum dolor sit amet, consectetur adipiscing elit. - Ullamcorper ullamcorper quis.
-
-
-
-
Aug 26
3.00 pm
-
Officer - AE Zone 15
Lorem ipsum dolor sit amet, consectetur adipiscing - elit. In sit arcu aliquet ut dui egestas.
-
-
-
-
- -
-
Update Complaint
-
-
-
- Change Complaint Status: - -
- - - - -
- -
- - - - - -
-
- - - - -
-
-
- Complainant Locality: - -
-
-
- -
-
- - -
-
- - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/officer/officercomplaint.html b/src/main/resources/templates/officer/officercomplaint.html deleted file mode 100644 index 41763b4..0000000 --- a/src/main/resources/templates/officer/officercomplaint.html +++ /dev/null @@ -1,685 +0,0 @@ - - - - - - Main Page - - - - - - - - - - - - - -
- - -
-
-
- - -

Registration of Complaint

-
-
- - -
-

Instructions:

-

Please fill your complaint details below and click the ‘Submit’ button at the bottom. You will be given a - Complaint Number upon submitting the complaint that you can use to track the complaint.

-
-
- -
-
-
1. Complaining Person's Details:
-
-
- -
- -
- -
-
-
-
- -
-
-
-
- - -
-
- -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
2. Complaint Location Details:
-
-
-
-
- -
-
- - -
-
-
-
- - -
-
-
3. Complaint Type:
-
-
- Pothole -

Pothole

-
-
- garbage -

Garbage

-
-
- broken-bin -

Broken-Bin

-
-
- StreetLight -

StreetLight

-
-
- public-toilet -

Public Toilet

-
-
- mosquito -

Mosquito Menace

-
-
- waterstag -

WaterStagnation

-
-
- sewage -

Storm Water Drains

-
-
- dog -

Street Dog

-
-
- weather -

Tree Fallen

-
-
- Others -

Others

-
-
-
-
-
- - -
-
- - -
-
-
-
- - -
-
-
- - -
-
- - -
-
- - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/staff/appoinment.html b/src/main/resources/templates/staff/appoinment.html deleted file mode 100644 index c62a512..0000000 --- a/src/main/resources/templates/staff/appoinment.html +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - Create Order - - - - - - - - - - - - - - - -
-

Create Order

-
-
- -
- -
- -
- -
- - -
-
Order Details
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
- - - -
-
-
-
-
- -
- -
- - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/staff/appoinmentscreen.html b/src/main/resources/templates/staff/appoinmentscreen.html deleted file mode 100644 index e077193..0000000 --- a/src/main/resources/templates/staff/appoinmentscreen.html +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - Appoinment Screen - - - - - - - - - - - - - - -
-

Appoinment Screen

-
- -
- - - -
- - - -
- -
-
-
- - -
-
- -
- -
- - - -
-
-
-
- -
-
-
-
-

16 June 2024

-
-
-

85/100

-
-
-
-
- -
- -
-
-
-

Order Description Long text

-
-
-
-
- - - - -
- - -
-
-
- - -
-

-
- - -
- -
-
-
- - - - -
- - - -
-
- -
- - - - - - - -
- - - - -
- - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/staff/createorder.html b/src/main/resources/templates/staff/createorder.html deleted file mode 100644 index 905ab3e..0000000 --- a/src/main/resources/templates/staff/createorder.html +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - Create Order - - - - - - - - - - - - - - - -
-

Create Order

-
-
- -
- -
- -
- - - -
-
Order Details -
-
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- -
- - - - -
-
- - - -
-
- -
- - - - -
- - - - -
- - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/staff/schemegroup.html b/src/main/resources/templates/staff/schemegroup.html deleted file mode 100644 index bc18022..0000000 --- a/src/main/resources/templates/staff/schemegroup.html +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - CheckList User - - - - - - - - - - - - - -
- - - - -
-
- - -

Acknowledgement

-
-
- -
- -
- -
-
-
- 1. User Details -
-
- - - - - - - - - - - - - - - - - - - -
Name:Yogesh
Complainant Name:John Doe
Complainant Email:john.doe@example.com
Gender:Male
-
- - -
-
- -
-
-
- 2. Complaint Location Details -
-
- - - - - - - - - - - - - - - - - - - -
Name:Yogesh
Complainant Name:John Doe
Complainant Email:john.doe@example.com
Gender:Male
-
-
-
-
- - -
-
-
-
- 3. Complaint Type -
-
- - - - - - - - - - - - - - - - - - - -
Name:Yogesh
Complainant Name:John Doe
Complainant Email:john.doe@example.com
Gender:Male
-
-
-
-
- -
-
-
-
- 3. Complaint Type -
-
- - - - - - - - - - - - - - - - - - - -
Name:Yogesh
Complainant Name:John Doe
Complainant Email:john.doe@example.com
Gender:Male
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/templates/staff/staffenrollment.html b/src/main/resources/templates/staff/staffenrollment.html deleted file mode 100644 index 3f3d5df..0000000 --- a/src/main/resources/templates/staff/staffenrollment.html +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - Staff Enrollment - - - - - - - - - - - - - - - -
-

Staff Enrollment

-
- -
- - - -
- - - -
-
Personal Information's -
-
-
-
- - -
-
- - -
-
- -
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
- -
- -
-
-
- - -
-
-
-
- - -
-
- -
-
- - -
-
-
-
- - -
-
- -
-
-
- -
- - - -
-
- - - -
-
- - -
-
- - - -
-
- - -
-
- - - -
-
-
-
- - - - -
-
- -
- - - - - -
- - - - -
- - - - - - - - - - - - - \ No newline at end of file