diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM (1).jpeg b/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM (1).jpeg new file mode 100644 index 0000000..ecd3d1d Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM (1).jpeg differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM.jpeg b/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM.jpeg new file mode 100644 index 0000000..34f3958 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM.jpeg differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.08 PM.jpeg b/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.08 PM.jpeg new file mode 100644 index 0000000..7a4ea7c Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/WhatsApp Image 2024-09-16 at 5.41.08 PM.jpeg differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/aa.jpg b/cdwastecollectordocuments/cdwaste_adhaar_copy/aa.jpg new file mode 100644 index 0000000..736b2f4 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/aa.jpg differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/booking.png b/cdwastecollectordocuments/cdwaste_adhaar_copy/booking.png new file mode 100644 index 0000000..a354054 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/booking.png differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/calendar.png b/cdwastecollectordocuments/cdwaste_adhaar_copy/calendar.png new file mode 100644 index 0000000..1579552 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/calendar.png differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/id-card.png b/cdwastecollectordocuments/cdwaste_adhaar_copy/id-card.png new file mode 100644 index 0000000..a511801 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/id-card.png differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/ima.jpg b/cdwastecollectordocuments/cdwaste_adhaar_copy/ima.jpg new file mode 100644 index 0000000..587907f Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/ima.jpg differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/lockers.png b/cdwastecollectordocuments/cdwaste_adhaar_copy/lockers.png new file mode 100644 index 0000000..79f772b Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/lockers.png differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/man.png b/cdwastecollectordocuments/cdwaste_adhaar_copy/man.png new file mode 100644 index 0000000..d2881fc Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/man.png differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/schedule.png b/cdwastecollectordocuments/cdwaste_adhaar_copy/schedule.png new file mode 100644 index 0000000..9697a39 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/schedule.png differ diff --git a/cdwastecollectordocuments/cdwaste_adhaar_copy/shower.png b/cdwastecollectordocuments/cdwaste_adhaar_copy/shower.png new file mode 100644 index 0000000..44fea86 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_adhaar_copy/shower.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-08-24 at 12.49.58 PM.jpeg b/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-08-24 at 12.49.58 PM.jpeg new file mode 100644 index 0000000..936f07d Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-08-24 at 12.49.58 PM.jpeg differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-12 at 9.54.20 PM.jpeg b/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-12 at 9.54.20 PM.jpeg new file mode 100644 index 0000000..35c92eb Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-12 at 9.54.20 PM.jpeg differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM (1).jpeg b/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM (1).jpeg new file mode 100644 index 0000000..ecd3d1d Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM (1).jpeg differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM.jpeg b/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM.jpeg new file mode 100644 index 0000000..34f3958 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/WhatsApp Image 2024-09-16 at 5.41.07 PM.jpeg differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/booking.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/booking.png new file mode 100644 index 0000000..a354054 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/booking.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/calendar.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/calendar.png new file mode 100644 index 0000000..1579552 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/calendar.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/ima.jpg b/cdwastecollectordocuments/cdwaste_rcbook_copy/ima.jpg new file mode 100644 index 0000000..587907f Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/ima.jpg differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/lockers.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/lockers.png new file mode 100644 index 0000000..79f772b Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/lockers.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/plus.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/plus.png new file mode 100644 index 0000000..077193c Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/plus.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/portable-toilet.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/portable-toilet.png new file mode 100644 index 0000000..ee1b070 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/portable-toilet.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/received-card.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/received-card.png new file mode 100644 index 0000000..a3a5bb9 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/received-card.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/search.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/search.png new file mode 100644 index 0000000..55fbf04 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/search.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/shower.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/shower.png new file mode 100644 index 0000000..44fea86 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/shower.png differ diff --git a/cdwastecollectordocuments/cdwaste_rcbook_copy/wardrobe.png b/cdwastecollectordocuments/cdwaste_rcbook_copy/wardrobe.png new file mode 100644 index 0000000..bb5c2a0 Binary files /dev/null and b/cdwastecollectordocuments/cdwaste_rcbook_copy/wardrobe.png differ diff --git a/src/main/java/com/volunteersregistration/config/DataSourceConfig.java b/src/main/java/com/volunteersregistration/config/DataSourceConfig.java new file mode 100644 index 0000000..aa3b853 --- /dev/null +++ b/src/main/java/com/volunteersregistration/config/DataSourceConfig.java @@ -0,0 +1,24 @@ +package com.volunteersregistration.config; + +import javax.sql.DataSource; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +public class DataSourceConfig { + +//////////////////////////////(For C & D Waste Collectors Registration ) //////////////////////// +@Bean(name = "volunteers") +public DataSource mysql1913CDwasteDataSource() { +DriverManagerDataSource dataSource = new DriverManagerDataSource(); +dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); +dataSource.setUrl("jdbc:mysql://localhost:3306/volunteer"); +dataSource.setUsername("root"); +dataSource.setPassword("root"); +return dataSource; +} +} diff --git a/src/main/java/com/volunteersregistration/controller/ApiController.java b/src/main/java/com/volunteersregistration/controller/ApiController.java new file mode 100644 index 0000000..20278d9 --- /dev/null +++ b/src/main/java/com/volunteersregistration/controller/ApiController.java @@ -0,0 +1,75 @@ +package com.volunteersregistration.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +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.multipart.MultipartFile; + +import com.volunteersregistration.service.Registrationservice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/gcc/api/registration") +public class ApiController { + + @Autowired + private Environment environment; + + private final Registrationservice registrationService; + + public ApiController(Registrationservice registrationService) { + this.registrationService = registrationService; + } + + @PostMapping("/register") + public ResponseEntity>> registerCollector( + @RequestParam("name") String name, + @RequestParam("mobileNo") String mobileNo, + @RequestParam("address") String address, + @RequestParam("adhaar") MultipartFile adhaarFile, + @RequestParam("vehicleRcBook") MultipartFile vehicleRcBookFile) { + + try { + // Save files to specified folders + String adhaarFolder = environment.getProperty("cdwaste_adhaar_foldername"); + String vehicleRcFolder = environment.getProperty("cdwaste_rc_foldername"); + + // Create directories if they do not exist + Files.createDirectories(Paths.get(adhaarFolder)); + Files.createDirectories(Paths.get(vehicleRcFolder)); + + // Define file paths + Path adhaarPath = Paths.get(adhaarFolder, adhaarFile.getOriginalFilename()); + Path vehicleRcPath = Paths.get(vehicleRcFolder, vehicleRcBookFile.getOriginalFilename()); + + // Save files + adhaarFile.transferTo(adhaarPath); + vehicleRcBookFile.transferTo(vehicleRcPath); + + // Now call the service to save the registration data + List> result = registrationService.saveRegistration(name, mobileNo, address, adhaarFile, vehicleRcBookFile); + + if (result.isEmpty()) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Collections.singletonList(Map.of("status", "error", "message", "Error registering collector!"))); + } + return ResponseEntity.ok(result); + } catch (IOException e) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Collections.singletonList(Map.of("status", "error", "message", "Error uploading files: " + e.getMessage()))); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/volunteersregistration/controller/VolunteerController.java b/src/main/java/com/volunteersregistration/controller/VolunteerController.java index 1f3c150..fdfe44e 100644 --- a/src/main/java/com/volunteersregistration/controller/VolunteerController.java +++ b/src/main/java/com/volunteersregistration/controller/VolunteerController.java @@ -16,4 +16,14 @@ public class VolunteerController { model.addAttribute("ref",ref); return "index"; } + + @GetMapping(value={"/wastecollectors"}) + public String wastecollectors(Model model){ + + return "wastecollectors"; + } + + + + } diff --git a/src/main/java/com/volunteersregistration/controller/VolunteerRegistrationController.java b/src/main/java/com/volunteersregistration/controller/VolunteerRegistrationController.java index 5d8ad0a..73dba6c 100644 --- a/src/main/java/com/volunteersregistration/controller/VolunteerRegistrationController.java +++ b/src/main/java/com/volunteersregistration/controller/VolunteerRegistrationController.java @@ -34,4 +34,7 @@ public class VolunteerRegistrationController { System.out.println("save volunteers....."); return volunteerRegistrationService.registerAsNgo(ngoInfo); } + + + } diff --git a/src/main/java/com/volunteersregistration/service/Registrationservice.java b/src/main/java/com/volunteersregistration/service/Registrationservice.java new file mode 100644 index 0000000..9e7e251 --- /dev/null +++ b/src/main/java/com/volunteersregistration/service/Registrationservice.java @@ -0,0 +1,90 @@ +package com.volunteersregistration.service; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.core.env.Environment; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +@Service +public class Registrationservice { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + private Environment environment; + + @Autowired + public void setDataSource(@Qualifier("volunteers") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public List> saveRegistration(String name, String mobileNo, String address, MultipartFile adhaarFile, MultipartFile vehicleRcBookFile) throws IOException { + + // Define directory paths from application.properties + String adhaarDir = environment.getProperty("cdwaste_adhaar_foldername"); + String rcBookDir = environment.getProperty("cdwaste_rc_foldername"); + + // Ensure directories exist + File adhaarFolder = new File(adhaarDir); + File rcBookFolder = new File(rcBookDir); + + if (!adhaarFolder.exists()) { + adhaarFolder.mkdirs(); + } + if (!rcBookFolder.exists()) { + rcBookFolder.mkdirs(); + } + + // Generate unique file names to avoid overwriting existing files + String adhaarFileName = adhaarFile.getOriginalFilename(); + String rcBookFileName = vehicleRcBookFile.getOriginalFilename(); + + // Paths where files will be stored + String adhaarFilePath = adhaarFolder.getAbsolutePath() + File.separator + adhaarFileName; + String rcBookFilePath = rcBookFolder.getAbsolutePath() + File.separator + rcBookFileName; + + // Save the files to the specified directories + adhaarFile.transferTo(new File(adhaarFilePath)); + vehicleRcBookFile.transferTo(new File(rcBookFilePath)); + + // File URLs to be saved in the database (adjust as per your URL structure) + String adhaarUrl = "/uploads/" + adhaarFileName; + String rcBookUrl = "/uploads/" + rcBookFileName; + + // SQL INSERT query (saving URLs) + String sqlQuery = "INSERT INTO registration (name, mobile_no, address, adhaar, vehicle_rc_book) VALUES (?, ?, ?, ?, ?)"; + int rowsAffected = jdbcTemplate.update(sqlQuery, name, mobileNo, address, adhaarUrl, rcBookUrl); + + // Prepare the response + List> response = new ArrayList<>(); + Map result = new HashMap<>(); + + if (rowsAffected > 0) { + result.put("status", "success"); + result.put("message", "Collector registered successfully!"); + } else { + result.put("status", "error"); + result.put("message", "No rows affected. Registration failed!"); + } + + response.add(result); + return response; + } + + + + +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 07e6010..3269bed 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,8 +2,12 @@ spring.application.name=volunteersregistration spring.datasource.url=jdbc:mysql://localhost:3306/volunteer spring.datasource.username=root -spring.datasource.password=gccroot +spring.datasource.password=root spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver server.port=8071 + +#//////// For C&D Waste Collector Project////////////////// +cdwaste_adhaar_foldername=cdwastecollectordocuments/cdwaste_adhaar_copy +cdwaste_rc_foldername=cdwastecollectordocuments/cdwaste_rcbook_copy diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 6810ca9..59936dc 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -159,6 +159,7 @@
+
@@ -905,7 +906,7 @@ $("#nameError").text("Please Enter Name !"); isValid = false; } - + if (dob == undefined || dob == "") { $("#dobError").text("Please enter a Date of birth"); isValid = false; @@ -1121,11 +1122,13 @@ contentType: "application/json", data: JSON.stringify(volunteerData), success: function (response) { + successPopup(response); }, error: function (error) { alert("Error saving data!"); console.log(error); + } }); return false; @@ -1155,17 +1158,20 @@ referBy: $("#ref").val(), preferredAreas: preferredAreas } + $('#loader').show(); $.ajax({ type: "POST", url: "/volunteer/api/registerAsCorporate", contentType: "application/json", data: JSON.stringify(copInfo), success: function (response) { + $('#loader').hide(); successPopup(response); }, error: function (error) { alert("Error saving data!"); console.log(error); + $('#loader').hide(); } }); return false; @@ -1197,7 +1203,7 @@ referBy: $("#ref").val(), preferredAreas: preferredAreas } - + $('#loader').show(); $.ajax({ type: "POST", @@ -1205,11 +1211,13 @@ contentType: "application/json", data: JSON.stringify(ngoInfo), success: function (response) { + $('#loader').hide(); successPopup(response); }, error: function (error) { alert("Error saving data!"); console.log(error); + $('#loader').hide(); } }); return false; @@ -1221,7 +1229,10 @@ Swal.fire({ title: "Good job!", text: "Thank you for registering as a volunteer \nwith the Greater Chennai Corporation for monsoon support! \nYour registration is successful, and your reference number is [GCC-" + id + "]. \nYou will be contacted once the final listing is complete and deployment details \nare confirmed. Together, we can help Chennai stay safe this monsoon", - icon: "success" + icon: "success", + allowOutsideClick: false, + allowEscapeKey: false, + allowEnterKey: false }).then((result) => { if (result.isConfirmed) { window.location.href = "https://chennaicorporation.gov.in/gcc/"; // Redirect to the desired URL @@ -1230,6 +1241,7 @@ } + diff --git a/src/main/resources/templates/wastecollectors.html b/src/main/resources/templates/wastecollectors.html new file mode 100644 index 0000000..d469d9b --- /dev/null +++ b/src/main/resources/templates/wastecollectors.html @@ -0,0 +1,327 @@ + + + + + + GCC - Volunteers + + + + + + + + + + + + + + + + + + + + +

GCC Volunteers

+

GCC Volunteers Registration

+

Chennai Volunteers

+

Volunteers

+ + + +
+ + + + + +
+
+ + + + + + + +
+
+

C&D Waste Collectors Registration Form

+
+
+ + +
+ +
+
+ +
+ +
+
+
+ + +
+ +
+ + +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + + + + + +
+ + + + +
+
+ +
+ + + + + + + + \ No newline at end of file