Browse Source

Changes in registration form

master
Hariprasath S 1 month ago
parent
commit
74308fc302
  1. BIN
      cd_waste_docs/cdwaste_aadhar/10_bird.jpg
  2. BIN
      cd_waste_docs/cdwaste_aadhar/9_duck-7406987.jpg
  3. BIN
      cd_waste_docs/cdwaste_rcbookdoc/10_joban-khangura-hG8B9pKiilw-unsplash.jpg
  4. BIN
      cd_waste_docs/cdwaste_rcbookdoc/9_bird.jpg
  5. BIN
      cd_waste_docs/cdwaste_userphoto/10_duck-7406987.jpg
  6. BIN
      cd_waste_docs/cdwaste_userphoto/9_duck-7406987.jpg
  7. 12
      src/main/java/com/volunteersregistration/controller/ApiController.java
  8. 41
      src/main/java/com/volunteersregistration/controller/VolunteerController.java
  9. 152
      src/main/java/com/volunteersregistration/controller/VolunteerRegistrationController.java
  10. 32
      src/main/java/com/volunteersregistration/entity/CorporateInformation.java
  11. 33
      src/main/java/com/volunteersregistration/entity/NgoInformation.java
  12. 60
      src/main/java/com/volunteersregistration/entity/VolunteerInformation.java
  13. 7
      src/main/java/com/volunteersregistration/repository/VolunteerRegistrationRepo.java
  14. 35
      src/main/java/com/volunteersregistration/service/DateTimeUtil.java
  15. 7
      src/main/java/com/volunteersregistration/service/MobileAlreadyRegisteredException.java
  16. 333
      src/main/java/com/volunteersregistration/service/VolunteerRegistrationService.java
  17. 2
      src/main/java/com/volunteersregistration/wasteCollector/controller/ApiController.java
  18. 5
      src/main/resources/application-dev.properties
  19. 4
      src/main/resources/application-prod.properties
  20. 2
      src/main/resources/application.properties
  21. 2
      src/main/resources/templates/allreports.html
  22. 770
      src/main/resources/templates/index.html
  23. 757
      src/main/resources/templates/index_tamil.html
  24. 853
      src/main/resources/templates/webindex.html
  25. 818
      src/main/resources/templates/webindex_tamil.html

BIN
cd_waste_docs/cdwaste_aadhar/10_bird.jpg

After

Width: 1280  |  Height: 897  |  Size: 191 KiB

BIN
cd_waste_docs/cdwaste_aadhar/9_duck-7406987.jpg

After

Width: 5401  |  Height: 3601  |  Size: 3.2 MiB

BIN
cd_waste_docs/cdwaste_rcbookdoc/10_joban-khangura-hG8B9pKiilw-unsplash.jpg

After

Width: 2400  |  Height: 3001  |  Size: 2.5 MiB

BIN
cd_waste_docs/cdwaste_rcbookdoc/9_bird.jpg

After

Width: 1280  |  Height: 897  |  Size: 191 KiB

BIN
cd_waste_docs/cdwaste_userphoto/10_duck-7406987.jpg

After

Width: 5401  |  Height: 3601  |  Size: 3.2 MiB

BIN
cd_waste_docs/cdwaste_userphoto/9_duck-7406987.jpg

After

Width: 5401  |  Height: 3601  |  Size: 3.2 MiB

12
src/main/java/com/volunteersregistration/controller/ApiController.java

@ -84,7 +84,7 @@ public class ApiController {
System.out.print("\n otp---:"+otp);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm");
LocalDateTime now = LocalDateTime.now();
System.out.println(dtf.format(now));
System.out.println("\n"+dtf.format(now));
// String generatedToken = "OTP for Volunteer ";
// String key="qxg4mklD";
@ -162,4 +162,14 @@ public class ApiController {
return volunteerRegistrationRepo.getSubCategoryById(category_id);
}
@GetMapping(value = "/getAllExpertise")
public List<Map<String, Object>> getAllExpertise() {
return volunteerRegistrationRepo.getAllExpertise();
}
@GetMapping(value = "/getAllVolunteerDocs")
public List<Map<String, Object>> getAllVolunteerDocs() {
return volunteerRegistrationRepo.getAllVolunteerDocs();
}
}

41
src/main/java/com/volunteersregistration/controller/VolunteerController.java

@ -44,8 +44,8 @@ public class VolunteerController {
model.addAttribute("ref", ref);
//return "webindex";
return "coming_soon";
return "webindex";
//return "coming_soon";
}
@GetMapping("/webtamil")
@ -54,8 +54,8 @@ public class VolunteerController {
model.addAttribute("ref", ref);
//return "webindex_tamil";
return "coming_soon";
return "webindex_tamil";
//return "coming_soon";
}
@GetMapping(value = { "/", "", "/index" })
@ -64,8 +64,8 @@ public class VolunteerController {
model.addAttribute("ref", ref);
//return "index";
return "coming_soon";
return "index";
//return "coming_soon";
}
@GetMapping(value = {"/index_tamil" })
@ -74,11 +74,36 @@ public class VolunteerController {
model.addAttribute("ref", ref);
//return "index_tamil";
return "coming_soon";
return "index_tamil";
//return "coming_soon";
}
//testing urls
@GetMapping("/devtest")
public String MobileViewdevtest(@RequestParam(required = false) String ref, Model model) {
System.out.println("indesx page....." + ref);
model.addAttribute("ref", ref);
return "index";
//return "coming_soon";
}
@GetMapping("/devtestweb")
public String MobileViewdevtestweb(@RequestParam(required = false) String ref, Model model) {
System.out.println("indesx page....." + ref);
model.addAttribute("ref", ref);
return "webindex";
//return "coming_soon";
}
//
// Check session and redirect to login if user is not logged in
private boolean isLoggedIn() {

152
src/main/java/com/volunteersregistration/controller/VolunteerRegistrationController.java

@ -1,38 +1,174 @@
package com.volunteersregistration.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.volunteersregistration.entity.CorporateInformation;
import com.volunteersregistration.entity.NgoInformation;
import com.volunteersregistration.entity.VolunteerInformation;
import com.volunteersregistration.service.MobileAlreadyRegisteredException;
import com.volunteersregistration.service.VolunteerRegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import java.util.Map;
@RestController
@RequestMapping("/volunteer/api")
public class VolunteerRegistrationController {
@Autowired
private ObjectMapper objectMapper;
@Autowired
private VolunteerRegistrationService volunteerRegistrationService;
@PostMapping("/register")
public String register(@RequestBody VolunteerInformation vol, Model model) {
System.out.println("save volunteers.....");
return volunteerRegistrationService.register(vol);
// @PostMapping("/register")
// public String register(@RequestBody VolunteerInformation vol, Model model) {
// System.out.println("save volunteers.....");
// return volunteerRegistrationService.register(vol);
// }
// @PostMapping(value = "/register", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
// public String register(
// @RequestPart("volunteer") String volunteerJson,
// @RequestPart("doc_url") MultipartFile docFile) {
//
// try {
//
// VolunteerInformation vol =
// objectMapper.readValue(
// volunteerJson,
// VolunteerInformation.class
// );
//
// return volunteerRegistrationService.register(vol, docFile);
//
// } catch (Exception e) {
//
// e.printStackTrace();
// return "error";
// }
// }
@PostMapping(
value = "/register",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE
)
public ResponseEntity<?> register(
@RequestPart("volunteer") String volunteerJson,
@RequestPart("doc_url") MultipartFile docFile) {
try {
VolunteerInformation vol =
objectMapper.readValue(
volunteerJson,
VolunteerInformation.class
);
String result =
volunteerRegistrationService.register(vol, docFile);
return ResponseEntity.ok(result);
} catch (MobileAlreadyRegisteredException e) {
return ResponseEntity
.status(HttpStatus.CONFLICT)
.body(Map.of(
"status", "DUPLICATE_MOBILE",
"message", "This mobile number is already registered"
));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Map.of(
"status", "ERROR",
"message", "Error saving data"
));
}
}
@PostMapping("/registerAsCorporate")
public String register(@RequestBody CorporateInformation copInfo, Model model) {
public ResponseEntity<?> register(@RequestBody CorporateInformation copInfo, Model model) {
System.out.println("save volunteers.....");
return volunteerRegistrationService.registerAsCorporate(copInfo);
try {
String result = volunteerRegistrationService.registerAsCorporate(copInfo);
return ResponseEntity.ok(result);
} catch (MobileAlreadyRegisteredException e) {
return ResponseEntity
.status(HttpStatus.CONFLICT)
.body(Map.of(
"status", "DUPLICATE_MOBILE",
"message", "This mobile number is already registered"
));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Map.of(
"status", "ERROR",
"message", "Error saving data"
));
}
}
@PostMapping("/registerAsNgo")
public String register(@RequestBody NgoInformation ngoInfo, Model model) {
public ResponseEntity<?> register(@RequestBody NgoInformation ngoInfo, Model model) {
System.out.println("save volunteers.....");
return volunteerRegistrationService.registerAsNgo(ngoInfo);
try {
String result = volunteerRegistrationService.registerAsNgo(ngoInfo);
return ResponseEntity.ok(result);
} catch (MobileAlreadyRegisteredException e) {
return ResponseEntity
.status(HttpStatus.CONFLICT)
.body(Map.of(
"status", "DUPLICATE_MOBILE",
"message", "This mobile number is already registered"
));
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(Map.of(
"status", "ERROR",
"message", "Error saving data"
));
}
}

32
src/main/java/com/volunteersregistration/entity/CorporateInformation.java

@ -32,11 +32,43 @@ public class CorporateInformation {
private String category;
private String subCategory;
private String ephno;
private int expertise_area;
private String other_expertise;
// @Column(name = "category_id")
// private Category category;
private String referBy;
public String getEphno() {
return ephno;
}
public void setEphno(String ephno) {
this.ephno = ephno;
}
public int getExpertise_area() {
return expertise_area;
}
public void setExpertise_area(int expertise_area) {
this.expertise_area = expertise_area;
}
public String getOther_expertise() {
return other_expertise;
}
public void setOther_expertise(String other_expertise) {
this.other_expertise = other_expertise;
}
public int getCop_id() {
return cop_id;
}

33
src/main/java/com/volunteersregistration/entity/NgoInformation.java

@ -35,9 +35,42 @@ public class NgoInformation {
private String referBy;
private String ephno;
private int expertise_area;
private String other_expertise;
// @Column(name = "category_id")
// private Category category;
public String getEphno() {
return ephno;
}
public void setEphno(String ephno) {
this.ephno = ephno;
}
public int getExpertise_area() {
return expertise_area;
}
public void setExpertise_area(int expertise_area) {
this.expertise_area = expertise_area;
}
public String getOther_expertise() {
return other_expertise;
}
public void setOther_expertise(String other_expertise) {
this.other_expertise = other_expertise;
}
public int getNgo_id() {
return ngo_id;
}

60
src/main/java/com/volunteersregistration/entity/VolunteerInformation.java

@ -55,6 +55,66 @@ public class VolunteerInformation {
private String aadhar;
private String bloodgroup;
private String ephno;
private int expertise_area;
private String other_expertise;
private int doc_type;
private String doc_number;
private String doc_url;
public String getEphno() {
return ephno;
}
public void setEphno(String ephno) {
this.ephno = ephno;
}
public int getExpertise_area() {
return expertise_area;
}
public void setExpertise_area(int expertise_area) {
this.expertise_area = expertise_area;
}
public String getOther_expertise() {
return other_expertise;
}
public void setOther_expertise(String other_expertise) {
this.other_expertise = other_expertise;
}
public int getDoc_type() {
return doc_type;
}
public void setDoc_type(int doc_type) {
this.doc_type = doc_type;
}
public String getDoc_number() {
return doc_number;
}
public void setDoc_number(String doc_number) {
this.doc_number = doc_number;
}
public String getDoc_url() {
return doc_url;
}
public void setDoc_url(String doc_url) {
this.doc_url = doc_url;
}
public int getVolunteer_id() {
return volunteer_id;
}

7
src/main/java/com/volunteersregistration/repository/VolunteerRegistrationRepo.java

@ -29,4 +29,11 @@ public interface VolunteerRegistrationRepo extends JpaRepository<VolunteerInform
@Query(value ="SELECT * FROM sub_category_master WHERE is_active=1 AND is_delete=0 AND category_id=:category_id", nativeQuery = true)
List<Map<String, Object>> getSubCategoryById(@Param("category_id") int category_id);
@Query(value = "SELECT * FROM expertise_area_master WHERE is_active=1 AND is_delete=0 order by orderby ASC", nativeQuery = true)
List<Map<String, Object>> getAllExpertise();
@Query(value = "SELECT * FROM volunteer_docs WHERE is_active=1 AND is_delete=0", nativeQuery = true)
List<Map<String, Object>> getAllVolunteerDocs();
}

35
src/main/java/com/volunteersregistration/service/DateTimeUtil.java

@ -0,0 +1,35 @@
package com.volunteersregistration.service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.springframework.stereotype.Component;
@Component("volunteerDateTimeUtil")
public final class DateTimeUtil {
public static String getCurrentDateTime() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("ddMMyyyyHHmmss");
LocalDateTime now = LocalDateTime.now();
return now.format(formatter);
}
public static String getCurrentYear() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy");
LocalDateTime now = LocalDateTime.now();
return now.format(formatter);
}
public static String getCurrentMonth() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM");
LocalDateTime now = LocalDateTime.now();
return now.format(formatter);
}
public static String getCurrentDay() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd");
LocalDateTime now = LocalDateTime.now();
return now.format(formatter);
}
public static String getCurrentDateTimeMysql() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
return now.format(formatter);
}
}

7
src/main/java/com/volunteersregistration/service/MobileAlreadyRegisteredException.java

@ -0,0 +1,7 @@
package com.volunteersregistration.service;
public class MobileAlreadyRegisteredException extends RuntimeException{
public MobileAlreadyRegisteredException(String message) {
super(message);
}
}

333
src/main/java/com/volunteersregistration/service/VolunteerRegistrationService.java

@ -6,13 +6,26 @@ import com.volunteersregistration.entity.VolunteerInformation;
import com.volunteersregistration.repository.CompanyInfoRepo;
import com.volunteersregistration.repository.NgoInfoRepo;
import com.volunteersregistration.repository.VolunteerRegistrationRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
@ -20,9 +33,24 @@ import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
@Service
public class VolunteerRegistrationService {
private final Environment environment;
public VolunteerRegistrationService(Environment environment) {
this.environment = environment;
}
@Autowired
private JdbcTemplate jdbcTemplate;
@Autowired
private VolunteerRegistrationRepo volunteerRegistrationRepo;
@ -32,44 +60,266 @@ public class VolunteerRegistrationService {
@Autowired
private NgoInfoRepo ngoInfoRepo;
private boolean isMobileAlreadyRegistered(Long mobileNo) {
String sql = " SELECT COUNT(*) "
+ " FROM ( "
+ " SELECT mobile_no "
+ " FROM volunteer_information"
+ " WHERE mobile_no = ? and isactive=1 "
+ ""
+ " UNION ALL "
+ ""
+ " SELECT contact_per_mobile "
+ " FROM corporate_information "
+ " WHERE contact_per_mobile = ? and isactive=1 "
+ ""
+ " UNION ALL "
+ ""
+ " SELECT mobile_no "
+ " FROM ngo_information "
+ " WHERE mobile_no = ? and isactive=1 "
+ " ) AS mobile_check ";
Integer count = jdbcTemplate.queryForObject(
sql,
Integer.class,
mobileNo,
mobileNo,
mobileNo
);
return count != null && count > 0;
}
// public String register(VolunteerInformation volun, MultipartFile docFile) {
//
// volun.setCdate(LocalDateTime.now());
// volun.setIsactive(true);
// try{
// if(volun!=null){
//
// if (docFile != null && !docFile.isEmpty()) {
//
// String docPath = fileUpload(docFile,"volunteer");
//
// // Set returned path into entity
// volun.setDoc_url(docPath);
// }
//
// String preferredAreas[] =volun.getPreferredAreas();
// if (preferredAreas != null) {
// StringJoiner zones = new StringJoiner(",");
// StringJoiner joiner = new StringJoiner(",");
// for (String area : preferredAreas) {
// String areaWZone[] =area.split("-");
// if(areaWZone != null && areaWZone.length==2) {
// joiner.add(areaWZone[1]);
// zones.add(areaWZone[0]);
// }else{
// joiner.add(area);
// }
// }
// volun.setPreferred_area(joiner.toString());
// volun.setPreferred_zones(zones.toString());
// }
// volun= volunteerRegistrationRepo.save(volun);
//
// sendWhatsappMsgENG(volun.getVolunteer_id(),volun.getMobile_no(),"GCC-VOL-");
// sendWhatsappMsgTam(volun.getVolunteer_id(),volun.getMobile_no(),"GCC-VOL-");
//
// return "VOL-"+String.format("%05d",volun.getVolunteer_id());
// } else {
// return "Not Saved";
// }
//
// }catch(Exception e) {
// e.printStackTrace();
// }
// return "error";
// }
public String register(
VolunteerInformation volun,
MultipartFile docFile) {
public String register(VolunteerInformation volun) {
try {
if (volun == null) {
return "Not Saved";
}
// ------------------------------------
// Check mobile number duplication
// ------------------------------------
Long mobileNo = volun.getMobile_no();
if (isMobileAlreadyRegistered(mobileNo)) {
throw new MobileAlreadyRegisteredException(
"This mobile number is already registered"
);
}
// ------------------------------------
// Set common fields
// ------------------------------------
volun.setCdate(LocalDateTime.now());
volun.setIsactive(true);
try{
if(volun!=null){
// ------------------------------------
// Save document
// ------------------------------------
if (docFile != null && !docFile.isEmpty()) {
String docPath = fileUpload(docFile,"volunteer");
volun.setDoc_url(docPath);
}
// ------------------------------------
// Preferred Areas
// ------------------------------------
String preferredAreas[] = volun.getPreferredAreas();
if (preferredAreas != null) {
StringJoiner zones = new StringJoiner(",");
StringJoiner joiner = new StringJoiner(",");
for (String area : preferredAreas) {
String areaWZone[] = area.split("-");
if(areaWZone != null && areaWZone.length==2) {
if (areaWZone.length == 2) {
joiner.add(areaWZone[1]);
zones.add(areaWZone[0]);
} else {
joiner.add(area);
}
}
volun.setPreferred_area(joiner.toString());
volun.setPreferred_zones(zones.toString());
}
// ------------------------------------
// Save volunteer
// ------------------------------------
volun = volunteerRegistrationRepo.save(volun);
sendWhatsappMsgENG(volun.getVolunteer_id(),volun.getMobile_no(),"GCC-VOL-");
sendWhatsappMsgTam(volun.getVolunteer_id(),volun.getMobile_no(),"GCC-VOL-");
// ------------------------------------
// Send WhatsApp
// ------------------------------------
sendWhatsappMsgENG(
volun.getVolunteer_id(),
volun.getMobile_no(),
"GCC-VOL-"
);
sendWhatsappMsgTam(
volun.getVolunteer_id(),
volun.getMobile_no(),
"GCC-VOL-"
);
return "VOL-" + String.format(
"%05d",
volun.getVolunteer_id()
);
} catch (MobileAlreadyRegisteredException e) {
// IMPORTANT:
// Don't convert this to generic "error"
throw e;
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
public String fileUpload(MultipartFile file, String name) {
// Set the file path where you want to save it
String uploadDirectory = environment.getProperty("file.upload.directory.mobile");
String serviceFolderName = environment.getProperty("volunteer_individual_foldername");
var year = DateTimeUtil.getCurrentYear();
var month = DateTimeUtil.getCurrentMonth();
uploadDirectory = uploadDirectory + serviceFolderName + "/" + year + "/" + month;
try {
// Create directory if it doesn't exist
Path directoryPath = Paths.get(uploadDirectory);
if (!Files.exists(directoryPath)) {
Files.createDirectories(directoryPath);
}
// Datetime string
String datetimetxt = DateTimeUtil.getCurrentDateTime();
// File name
String fileName = name + "_" + datetimetxt + "_" + file.getOriginalFilename();
fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename
return "VOL-"+String.format("%05d",volun.getVolunteer_id());
String filePath = uploadDirectory + "/" + fileName;
String filepath_txt = "/" + serviceFolderName + "/" + year + "/" + month + "/" + fileName;
// Create a new Path object
Path path = Paths.get(filePath);
// Get the bytes of the file
byte[] bytes = file.getBytes();
String originalFileName = file.getOriginalFilename();
String extension = originalFileName.substring(originalFileName.lastIndexOf('.') + 1).toLowerCase();
if ("jpg".equals(extension) || "jpeg".equals(extension)) {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes));
byte[] compressedBytes = compressImage(image, 0.5f); // Compress with 50% quality
// Write the compressed bytes to the file
Files.write(path, compressedBytes);
} else {
return "Not Saved";
// Write the original bytes to the file
Files.write(path, bytes);
}
}catch(Exception e) {
//System.out.println(filePath);
return filepath_txt;
} catch (IOException e) {
e.printStackTrace();
return "Failed to save file " + file.getOriginalFilename();
}
return "error";
}
private byte[] compressImage(BufferedImage image, float quality) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream);
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next();
writer.setOutput(imageOutputStream);
ImageWriteParam param = writer.getDefaultWriteParam();
if (param.canWriteCompressed()) {
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(quality);
}
writer.write(null, new javax.imageio.IIOImage(image, null, null), param);
writer.dispose();
imageOutputStream.close();
return byteArrayOutputStream.toByteArray();
}
private String sendWhatsappMsgTam(int id, Long mob_no,String prefix) {
@ -152,7 +402,23 @@ public class VolunteerRegistrationService {
public String registerAsNgo(NgoInformation ngo) {
try {
if (ngo != null) {
if (ngo == null) {
return "Not Saved";
}
// ------------------------------------
// Check mobile number duplication
// ------------------------------------
Long mobileNo = ngo.getMobileNo();
if (isMobileAlreadyRegistered(mobileNo)) {
throw new MobileAlreadyRegisteredException(
"This mobile number is already registered"
);
}
ngo.setCdate(LocalDateTime.now());
ngo.setIsactive(true);
String preferredAreas[] = ngo.getPreferredAreas();
@ -177,19 +443,40 @@ public class VolunteerRegistrationService {
sendWhatsappMsgTam(ngo.getNgo_id(),ngo.getMobileNo(),"GCC-NGO_VOL-");
return "NGO_VOL-"+String.format("%05d",ngo.getNgo_id());
} else {
return "Not Saved";
}
}catch (MobileAlreadyRegisteredException e) {
// IMPORTANT:
// Don't convert this to generic "error"
throw e;
} catch (Exception e) {
e.printStackTrace();
}
return "error";
}
}
public String registerAsCorporate(CorporateInformation cop){
try{
if(cop!=null){
if (cop == null) {
return "Not Saved";
}
// ------------------------------------
// Check mobile number duplication
// ------------------------------------
Long mobileNo = cop.getContactPerMobile();
if (isMobileAlreadyRegistered(mobileNo)) {
throw new MobileAlreadyRegisteredException(
"This mobile number is already registered"
);
}
cop.setCdate(LocalDateTime.now());
cop.setIsactive(true);
String preferredAreas[] =cop.getPreferredAreas();
@ -214,16 +501,22 @@ public class VolunteerRegistrationService {
sendWhatsappMsgTam(cop.getCop_id(),cop.getContactPerMobile(),"GCC-COR_VOL-");
return "COR_VOL-"+String.format("%05d",cop.getCop_id());
} else {
return "Not Saved";
}
} catch (MobileAlreadyRegisteredException e) {
// IMPORTANT:
// Don't convert this to generic "error"
throw e;
} catch (Exception e) {
e.printStackTrace();
}
return "error";
}
}
public List<Map<String, Object>> getKynReport(String fromDate, String toDate, int category) {

2
src/main/java/com/volunteersregistration/wasteCollector/controller/ApiController.java

@ -212,7 +212,7 @@ public class ApiController {
System.out.print("\n otp---:"+otp);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yyyy%20HH:mm");
LocalDateTime now = LocalDateTime.now();
System.out.println(dtf.format(now));
System.out.println("\n"+dtf.format(now));
//String generatedToken = "Welcome to GCC! Your OTP for C%26D waste collectors Registration process is "+otp;
//String generatedToken = "Welcome to GCC "+otp+" is your OTP for gcc QR System";

5
src/main/resources/application-dev.properties

@ -31,5 +31,10 @@ file.leasedoc.fullpath=/cd_waste_docs/
file.rcbookdoc.fullpath=/cd_waste_docs/
file.userphoto.fullpath=/cd_waste_docs/
file.upload.directory.mobile=${user.dir}/gcc_mobile_service_uploads/
volunteer_individual_foldername=volunteer_individual_docs
#testing key
payment.razorpay.my_key_id=rzp_test_tDkHFEqWXmuEi8

4
src/main/resources/application-prod.properties

@ -32,6 +32,10 @@ file.leasedoc.fullpath=/cd_waste_docs/
file.rcbookdoc.fullpath=/cd_waste_docs/
file.userphoto.fullpath=/cd_waste_docs/
file.upload.directory.mobile=${user.dir}/gcc_mobile_service_uploads/
volunteer_individual_foldername=volunteer_individual_docs
#live key
payment.razorpay.my_key_id=rzp_live_ySI5Ns54Y7qOcJ

2
src/main/resources/application.properties

@ -1 +1 @@
spring.profiles.active=prod
spring.profiles.active=dev

2
src/main/resources/templates/allreports.html

@ -310,7 +310,7 @@
<td th:text="${corporate.cnt_per_email}"></td>
<td th:text="${corporate.contact_per_mobile}"></td>
<td th:text="${corporate.contact_person}"></td>
<td th:text="${corporate.landline == null or corporate.landline == 0} ? 'NA' : corporate.landline"></td>
<td th:text="${corporate.landline == '' or corporate.landline == 0} ? 'NA' : corporate.landline"></td>
<td th:text="${corporate.no_of_vol}"></td>
<td th:text="${corporate.pin_code}"></td>
<td th:text="${corporate.preferred_area}"></td>

770
src/main/resources/templates/index.html

@ -551,6 +551,25 @@
</div>
<div class="form-row mb-4">
<div class="col-lg-12 col-md-12 mb-3">
<label for="docs">
Document<span class="req">*</span>
</label>
<select class="form-control" id="docs">
</select>
<span class="text-danger" id="docsError"></span>
</div>
</div>
<!-- Dynamic fields -->
<div class="form-row" id="documentFields"></div>
</div>
<!-- Individual Form -->
@ -643,7 +662,7 @@
<div class="form-row mb-4">
<div class="col-lg-12 col-md-12 mb-3">
<label for="cmpPoc">Name<span class="req">*</span></label>
<input type="text" class="form-control" id="cmpPoc">
<input type="text" class="form-control" id="cmpPoc" placeholder="Enter Person Name...">
<span class="text-danger" id="cmpPocError"></span>
</div>
<div class="col-lg-12 col-md-12 mb-3">
@ -663,7 +682,7 @@
<div class="col-lg-12 col-md-12 mb-3">
<label for="cmdPom">Phone No<span class="req">*</span></label>
<input type="number" class="form-control" id="cmdPom" placeholder="Enter Mobile No...">
<input type="text" class="form-control" id="cmdPom" placeholder="Enter Mobile No...">
<span class="text-danger" id="cmdPomError"></span>
</div>
@ -708,7 +727,7 @@
<div class="col-lg-12 col-md-12 mb-3">
<label for="ngoOrgEmail">Company Email ID</label>
<label for="ngoOrgEmail">Organization Email ID</label>
<input type="text" class="form-control" id="ngoOrgEmail" placeholder="Enter Email ID">
</div>
@ -781,7 +800,7 @@
<div class="form-row mb-4">
<div class="col-lg-12 col-md-12 mb-3">
<label for="oPoc">Name<span class="req">*</span></label>
<input type="text" class="form-control" id="oPoc" placeholder="Person Name">
<input type="text" class="form-control" id="oPoc" placeholder="Enter Person Name">
<span class="text-danger" id="oPocError"></span>
</div>
<div class="col-lg-12 col-md-12 mb-3">
@ -800,7 +819,7 @@
<div class="col-lg-12 col-md-12 mb-3">
<label for="oPom">Phone No<span class="req">*</span></label>
<input type="number" class="form-control" id="oPom" placeholder="Enter Phone No...">
<input type="text" class="form-control" id="oPom" placeholder="Enter Phone No...">
<span class="text-danger" id="oPomError"></span>
</div>
</div>
@ -830,6 +849,40 @@
<!-- NGO Form -->
<div class="form-row">
<div class="col-lg-12 col-md-12 mb-3">
<label for="expertise">Area of Expertise<span class="req">*</span></label>
<select class="form-control" id="expertise">
</select>
<span class="text-danger" id="expertiseError"></span>
</div>
<!-- Dynamic Other Expertise field -->
<div class="col-lg-12 col-md-12 mb-3" id="otherExpertiseContainer" style="display:none;">
<label for="otherExpertise">
Mention Other Expertise<span class="req">*</span>
</label>
<input type="text"
class="form-control"
id="other_expertise"
placeholder="Enter Other Expertise..."
autocomplete="off">
<span class="text-danger" id="otherExpertiseError"></span>
</div>
<div class="col-lg-12 col-md-12 mb-3">
<label for="ephno">Emergency Phone No<span class="req">*</span></label>
<input type="text" class="form-control" id="ephno" placeholder="Enter Emergency Phone No..." maxlength="10" inputmode="numeric" autocomplete="off" required="required">
<span class="text-danger" id="ephnoError"></span>
</div>
</div>
<!-- Preferred area of work checkboxes -->
<h5>Preferred area of work<span class="req">*</span></h5>
@ -1096,7 +1149,71 @@
}
} */
$("#name").on("input", function () {
this.value = this.value.replace(/[^a-zA-Z.\s]/g, '');
});
$("#cmpPoc").on("input", function () {
this.value = this.value.replace(/[^a-zA-Z.\s]/g, '');
});
$("#oPoc").on("input", function () {
this.value = this.value.replace(/[^a-zA-Z.\s]/g, '');
});
$("#dob").on("keydown paste drop", function (e) {
e.preventDefault();
});
$("#pincode").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 6);
});
$("#ephno").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
});
$("#mobile").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
});
$("#cmdPom").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
});
$("#oPom").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
});
$("#expertise").on("change", function () {
var selectedOption = $(this).find("option:selected");
var selectedId = selectedOption.val();
var expertiseArea = selectedOption.attr("data-category") || "";
// Check ID = 7 OR expertise contains "Others"
var isOtherExpertise =
selectedId === "7" ||
expertiseArea.toLowerCase().includes("others");
if (isOtherExpertise) {
$("#otherExpertiseContainer").show();
} else {
$("#otherExpertiseContainer").hide();
// Clear previous value and error
$("#other_expertise").val("");
$("#otherExpertiseError").text("");
}
});
$(document).ready(function () {
$.ajax({
url: "/volunteer/api/registration/getAllCategory",
type: "GET",
@ -1114,6 +1231,79 @@
});
}
});
$.ajax({
url: "/volunteer/api/registration/getAllExpertise",
type: "GET",
success: function (expertise) {
let expertiseDropdown = $('#expertise');
expertiseDropdown.empty();
expertiseDropdown.append(`<option value="">Select</option>`);
expertise.forEach(function (exp) {
$('<option>', {
value: exp.id,
text: exp.expertise_area
}).attr('data-category', exp.expertise_area)
.appendTo(expertiseDropdown);
});
}
});
});
$("#docs").on("change", function () {
var selectedOption = $(this).find("option:selected");
var labelName = selectedOption.attr("data-category") || "";
var option = $(this).val();
var documentFields = $("#documentFields");
documentFields.empty();
$("#docsError").text("");
if (option === "-1" || option === "") {
return;
}
var optionName = labelName;
var html = `
<div class="col-lg-12 col-md-12 mb-3">
<label for="doc_number">
${optionName} Number<span class="req">*</span>
</label>
<input type="text"
class="form-control"
id="doc_number"
name="doc_number"
placeholder="Enter ${optionName} Number..."
autocomplete="off">
<span class="text-danger" id="docNumberError"></span>
</div>
<div class="col-lg-12 col-md-12 mb-3">
<label for="doc_url">
${optionName} image (less than 20 MB - jpg/jpeg/pdf)<span class="req">*</span>
</label>
<input type="file"
class="form-control"
id="doc_url"
name="doc_url"
accept=".pdf,.jpg,.jpeg">
<span class="text-danger" id="docFileError"></span>
</div>
`;
documentFields.html(html);
});
function handleCategoryChange() {
@ -1138,6 +1328,27 @@
$('.ngo-form').show();
} */
if (selectedText === "1") {
$.ajax({
url: "/volunteer/api/registration/getAllVolunteerDocs",
type: "GET",
success: function (docsvalues) {
let docsDropdown = $('#docs');
docsDropdown.empty();
docsDropdown.append(`<option value="">Select</option>`);
docsvalues.forEach(function (docs) {
$('<option>', {
value: docs.id,
text: docs.name
}).attr('data-category', docs.name)
.appendTo(docsDropdown);
});
}
});
$('.individual-form').show();
} else if (selectedText === "2") {
$('.corporate-form').show();
@ -1215,6 +1426,65 @@
isValid = false;
}
var ephno = $.trim($("#ephno").val());
//console.log("ephno===="+ephno);
if (ephno === "") {
$("#ephnoError").text("Please Enter Emergency Phone No");
isValid = false;
} else if (!/^\d{10}$/.test(ephno)) {
$("#ephnoError").text("Phone Number must contain exactly 10 digits");
isValid = false;
} else if (!/^[6-9]/.test(ephno)) {
$("#ephnoError").text("Phone Number should start with 6, 7, 8 or 9");
isValid = false;
}else if (/^(\d)\1{9}$/.test(ephno)) {
$("#ephnoError").text("Phone Number cannot contain the same digit repeatedly");
isValid = false;
} else if (
ephno === "1234567890" ||
ephno === "0123456789" ||
ephno === "9876543210" ||
ephno === "0987654321"
) {
$("#ephnoError").text("Please enter a valid Phone No");
isValid = false;
}
var selectedEOption = $("#expertise option:selected");
var expertisevalue = $.trim(selectedEOption.val());
var expertiseArea = $.trim(selectedEOption.attr("data-category") || "");
if (expertisevalue === "" || expertisevalue === "-1") {
$("#expertiseError").text("Please Select Area of Expertise");
isValid = false;
} else if (
expertisevalue === "7" ||
expertiseArea.toLowerCase().includes("others")
) {
var otherExpertise = $.trim($("#other_expertise").val());
if (otherExpertise === "") {
$("#otherExpertiseError").text("Please Mention Other Expertise");
isValid = false;
}
}
if (selectedTextcategory === "1") {
var name = document.getElementById("name").value = document.getElementById("name").value.trim();
@ -1246,6 +1516,12 @@
$("#dobError").text("Please enter a Date of birth");
isValid = false;
}
if(email!=""){
if (!emailPattern.test(email)) {
$("#emailError").text("Please enter a valid Email ID");
isValid = false;
}
}
if (!genderSelected) {
$("#genderError").text("Please Select Gender !");
isValid = false;
@ -1264,6 +1540,31 @@
$("#mobileError").text("Please enter a valid 10-digit mobile number");
isValid = false;
}
if (!/^\d{10}$/.test(mobile)) {
$("#mobileError").text("Mobile Number must contain exactly 10 digits");
isValid = false;
} if (!/^[6-9]/.test(mobile)) {
$("#mobileError").text("Mobile Number should start with 6, 7, 8 or 9");
isValid = false;
} if (/^(\d)\1{9}$/.test(mobile)) {
$("#mobileError").text("Mobile Number cannot contain the same digit repeatedly");
isValid = false;
} if (
mobile === "1234567890" ||
mobile === "0123456789" ||
mobile === "9876543210" ||
mobile === "0987654321"
) {
$("#mobileError").text("Please enter a valid Mobile Number");
isValid = false;
}
if (address == undefined || address == "") {
$("#addressError").text("Please Enter address !");
isValid = false;
@ -1298,6 +1599,101 @@
isValid = false;
}*/
var docs = $.trim($("#docs").val());
if (docs === "" || docs === "-1") {
$("#docsError").text("Please Select Document");
isValid = false;
} else {
// Get selected document name
var selectedOption = $("#docs option:selected");
var documentName = $.trim(selectedOption.attr("data-category") || "");
// -----------------------------
// Document Number Validation
// -----------------------------
var docNumber = $.trim($("#doc_number").val());
if (docNumber === "") {
$("#docNumberError").text("Please Enter " + documentName + " Number");
isValid = false;
} if (docs === "1") {
// Aadhar = exactly 12 numeric digits
if (!/^\d{12}$/.test(docNumber)) {
$("#docNumberError").text(
"Aadhar Number must contain exactly 12 digits"
);
isValid = false;
}
} else {
// Other documents = alphanumeric, max 10 characters
if (!/^[a-zA-Z0-9]{10}$/.test(docNumber)) {
$("#docNumberError").text(
documentName + " Number must contain 10 characters only (alphabets and numbers)"
);
isValid = false;
}
}
// -----------------------------
// Document File Validation
// -----------------------------
var docFileInput = $("#doc_url")[0];
if (!docFileInput || docFileInput.files.length === 0) {
$("#docFileError").text(
"Please Upload " + documentName + " image"
);
isValid = false;
} else {
var docFile = docFileInput.files[0];
// Maximum 20 MB
var maxSize = 20 * 1024 * 1024;
if (docFile.size >= maxSize) {
$("#docFileError").text(
"File size must be less than 20 MB"
);
isValid = false;
}
// File type
var allowedTypes = [
"image/jpeg",
"application/pdf"
];
if (!allowedTypes.includes(docFile.type)) {
$("#docFileError").text(
"Only JPG, JPEG or PDF files are allowed"
);
isValid = false;
}
}
}
if (!preVolSelected) {
$("#prevolError").text("Please Select Previous Volunteer details !");
@ -1307,6 +1703,9 @@
$("#ngoAnyError").text("Please Enter Company/NGO details !");
isValid = false;
} */
if (i == 0) {
$("#anyAreaError").text("Please select Preferred Area details !");
isValid = false;
@ -1318,6 +1717,37 @@
saveTheIndividualForm();
return false;
}
else{
var firstError = $(".text-danger")
.filter(function () {
return $.trim($(this).text()) !== "";
})
.first();
if (firstError.length) {
var target = firstError
.closest(".mb-3")
.find("input, select, textarea")
.first();
if (target.length) {
$("html, body").animate({
scrollTop: target.offset().top - 120
}, 600);
// Focus the field
target.focus();
}else {
// Fallback to error message
$("html, body").animate({
scrollTop: firstError.offset().top - 120
}, 600);
}
}
}
return false;
}
else if (selectedTextcategory === "2") {
@ -1332,11 +1762,18 @@
var cmdPom = document.getElementById("cmdPom").value = document.getElementById("cmdPom").value.trim();
var cmpPVolSelect = document.querySelector('input[name="cmpPVol"]:checked');
var cmdPoE = document.getElementById("cmdPoE").value = document.getElementById("cmdPoE").value.trim();
var cmdPod = $("#cmdPod").val().trim();
if (cmpName == undefined || cmpName == "") {
$("#cmpNameError").text("Please Enter Company Name");
isValid = false;
}
if(cmpEmail!=""){
if (!emailPattern.test(cmpEmail)) {
$("#cmpEmailError").text("Please enter a valid Email ID");
isValid = false;
}
}
if (cmpAddress == undefined || cmpAddress == "") {
$("#cmpAddressError").text("Please Enter Company Address");
isValid = false;
@ -1348,23 +1785,73 @@
if (cmpNov == undefined || cmpNov == "") {
$("#cmpNovError").text("Please Enter No of Volunteer");
isValid = false;
}
if (!/^[1-9]\d*$/.test(cmpNov)) {
$("#cmpNovError").text("Please Enter a valid number of volunteers");
isValid = false;
}
if (cmpPoc == undefined || cmpPoc == "") {
$("#cmpPocError").text("Please Enter Point of Conduct Name");
$("#cmpPocError").text("Please Enter Point of Contact Name");
isValid = false;
}
if (cmdPod == "") {
$("#cmdPodError").text("Please Enter Point of Contact Designation");
isValid = false;
}
if (cmdPoE === "" || !emailPattern.test(cmdPoE)) {
$("#cmdPoEError").text("Please enter Point of Conduct a valid Email ID");
$("#cmdPoEError").text("Please enter Point of Contact a valid Email ID");
isValid = false;
}
if (cmdPom == undefined || cmdPom == "" || !mobilePattern.test(cmdPom)) {
$("#cmdPomError").text("Please enter Point of Conduct Valid Mobile No");
$("#cmdPomError").text("Please enter Point of Contact Valid Mobile No");
isValid = false;
}
if (!/^\d{10}$/.test(cmdPom)) {
$("#cmdPomError").text("Mobile Number must contain exactly 10 digits");
isValid = false;
} if (!/^[6-9]/.test(cmdPom)) {
$("#cmdPomError").text("Mobile Number should start with 6, 7, 8 or 9");
isValid = false;
} if (/^(\d)\1{9}$/.test(cmdPom)) {
$("#cmdPomError").text("Mobile Number cannot contain the same digit repeatedly");
isValid = false;
} if (
cmdPom === "1234567890" ||
cmdPom === "0123456789" ||
cmdPom === "9876543210" ||
cmdPom === "0987654321"
) {
$("#cmdPomError").text("Please enter a valid Mobile Number");
isValid = false;
}
if (!cmpPVolSelect) {
$("#anyAreaError").text("Please Select previous volunteers details");
isValid = false;
}
var c1mobile = $.trim($("#cmdPom").val());
if(c1mobile !== "" && ephno !== "" && c1mobile === ephno){
Swal.fire({
title: "Warning!",
text: "POC Phone Number and Emergency phone number cannot be same",
icon: "warning",
confirmButtonText: "OK"
});
isValid = false;
}
if (i == 0) {
alert("Please select Preferred Area details !");
isValid = false;
@ -1377,6 +1864,37 @@
saveCorporateDetails();
return false;
}
else{
var firstError = $(".text-danger")
.filter(function () {
return $.trim($(this).text()) !== "";
})
.first();
if (firstError.length) {
var target = firstError
.closest(".mb-3")
.find("input, select, textarea")
.first();
if (target.length) {
$("html, body").animate({
scrollTop: target.offset().top - 120
}, 600);
// Focus the field
target.focus();
}else {
// Fallback to error message
$("html, body").animate({
scrollTop: firstError.offset().top - 120
}, 600);
}
}
}
return false;
}
@ -1392,11 +1910,18 @@
var cmdPom = document.getElementById("oPom").value = document.getElementById("oPom").value.trim();
var cmpPVolSelect = document.querySelector('input[name="oPvolY"]:checked');
var oPoE = document.getElementById("oPoE").value = document.getElementById("oPoE").value.trim();
var oPod = $("#oPod").val().trim();
if (cmpName == ""|| cmpName == undefined ) {
$("#ngoOrgNameError").text("Please Enter Organization Name");
isValid = false;
}
if(ngoOrgEmail!=""){
if (!emailPattern.test(ngoOrgEmail)) {
$("#ngoOrgEmailError").text("Please enter a valid Email ID");
isValid = false;
}
}
if (cmpAddress == undefined || cmpAddress == "") {
$("#oAddressError").text("Please Enter Organisation Address");
isValid = false;
@ -1409,10 +1934,20 @@
$("#oNvolError").text("Please Enter No of Volunteer");
isValid = false;
}
if (!/^[1-9]\d*$/.test(cmpNov)) {
$("#oNvolError").text("Please Enter a valid number of volunteers");
isValid = false;
}
if (cmpPoc == undefined || cmpPoc == "") {
$("#oPocError").text("Please Enter Point of Conduct Name");
isValid = false;
}
if (oPod == "") {
$("#oPodError").text("Please Enter Point of Conduct Designation");
isValid = false;
}
if (oPoE === "" || !emailPattern.test(oPoE)) {
$("#oPoeError").text("Please enter Point of Conduct valid Email ID");
isValid = false;
@ -1421,10 +1956,50 @@
$("#oPomError").text("Please Enter Point of Conduct Mobile No");
isValid = false;
}
if (!/^\d{10}$/.test(cmdPom)) {
$("#oPomError").text("Mobile Number must contain exactly 10 digits");
isValid = false;
} if (!/^[6-9]/.test(cmdPom)) {
$("#oPomError").text("Mobile Number should start with 6, 7, 8 or 9");
isValid = false;
} if (/^(\d)\1{9}$/.test(cmdPom)) {
$("#oPomError").text("Mobile Number cannot contain the same digit repeatedly");
isValid = false;
} if (
cmdPom === "1234567890" ||
cmdPom === "0123456789" ||
cmdPom === "9876543210" ||
cmdPom === "0987654321"
) {
$("#oPomError").text("Please enter a valid Mobile Number");
isValid = false;
}
if (!cmpPVolSelect) {
$("#oPvolYError").text("Please Select previous volunteers details");
isValid = false;
}
var c2mobile = $.trim($("#oPom").val());
if(c2mobile !== "" && ephno !== "" && c2mobile === ephno){
Swal.fire({
title: "Warning!",
text: "POC Phone Number and Emergency phone number cannot be same",
icon: "warning",
confirmButtonText: "OK"
});
isValid = false;
}
if (i == 0) {
alert("Please select Preferred Area details !");
isValid = false;
@ -1434,6 +2009,37 @@
saveNGODetails();
return false;
}
else{
var firstError = $(".text-danger")
.filter(function () {
return $.trim($(this).text()) !== "";
})
.first();
if (firstError.length) {
var target = firstError
.closest(".mb-3")
.find("input, select, textarea")
.first();
if (target.length) {
$("html, body").animate({
scrollTop: target.offset().top - 120
}, 600);
// Focus the field
target.focus();
}else {
// Fallback to error message
$("html, body").animate({
scrollTop: firstError.offset().top - 120
}, 600);
}
}
}
return false;
}
@ -1473,16 +2079,44 @@
referBy: $("#ref").val(),
//aadhar: $("#aadhar").val(),
//bloodgroup: $("#bloodgroup").val(),
preferredAreas: preferredAreas
preferredAreas: preferredAreas,
expertise_area:$("#expertise").val(),
other_expertise:$("#other_expertise").val(),
ephno:$("#ephno").val(),
doc_type:$.trim($("#docs").val()),
doc_number:$.trim($("#doc_number").val()),
};
// Create FormData
var formData = new FormData();
// Add JSON data as Blob
formData.append(
"volunteer",
new Blob(
[JSON.stringify(volunteerData)],
{ type: "application/json" }
)
);
// Add file
var docFile = $("#doc_url")[0].files[0];
if (docFile) {
formData.append("doc_url", docFile);
}
$('#loader').show();
// Send AJAX POST request
$.ajax({
type: "POST",
url: "/volunteer/api/register",
contentType: "application/json",
data: JSON.stringify(volunteerData),
data: formData,
// IMPORTANT
processData: false,
contentType: false,
beforeSend: function() {
$("#pageLoader").show();
},
@ -1490,15 +2124,41 @@
$('#loader').hide();
successPopup(response);
},
error: function (error) {
alert("Error saving data!");
console.log(error);
error: function (xhr) {
$('#loader').hide();
console.log("Error status:", xhr.status);
console.log("Error response:", xhr.responseText);
if (xhr.status === 409) {
var response = xhr.responseJSON;
Swal.fire({
title: "Warning!",
text: response && response.message
? response.message
: "This mobile number is already registered",
icon: "warning",
confirmButtonText: "OK"
});
} else {
Swal.fire({
title: "Error!",
text: "Unable to save registration. Please try again.",
icon: "error",
confirmButtonText: "OK"
});
}
// Allow user to submit again
$("#submitBtn").prop("disabled", false);
},
complete: function () {
// Re-enable the submit button after completion (either success or error)
$("#submitBtn").prop("disabled", true);
$("#pageLoader").hide();
}
});
@ -1527,7 +2187,10 @@
cntPerDesign: $("#cmdPod").val(),
previous_volunteered: $("input[name='cmpPVol']:checked").val(),
referBy: $("#ref").val(),
preferredAreas: preferredAreas
preferredAreas: preferredAreas,
expertise_area:$("#expertise").val(),
other_expertise:$("#other_expertise").val(),
ephno:$("#ephno").val(),
}
$('#loader').show();
$.ajax({
@ -1542,14 +2205,41 @@
$('#loader').hide();
successPopup(response);
},
error: function (error) {
alert("Error saving data!");
console.log(error);
error: function (xhr) {
$('#loader').hide();
console.log("Error status:", xhr.status);
console.log("Error response:", xhr.responseText);
if (xhr.status === 409) {
var response = xhr.responseJSON;
Swal.fire({
title: "Warning!",
text: response && response.message
? response.message
: "This mobile number is already registered",
icon: "warning",
confirmButtonText: "OK"
});
} else {
Swal.fire({
title: "Error!",
text: "Unable to save registration. Please try again.",
icon: "error",
confirmButtonText: "OK"
});
}
// Allow user to submit again
$("#submitBtn").prop("disabled", false);
},
complete: function () {
// Re-enable the submit button after completion (either success or error)
$("#submitBtn").prop("disabled", true);
$("#pageLoader").hide();
},
@ -1581,7 +2271,10 @@
cntPerDesign: $("#oPod").val(),
previous_volunteered: $("input[name='oPvolY']:checked").val(),
referBy: $("#ref").val(),
preferredAreas: preferredAreas
preferredAreas: preferredAreas,
expertise_area:$("#expertise").val(),
other_expertise:$("#other_expertise").val(),
ephno:$("#ephno").val(),
}
$('#loader').show();
@ -1597,14 +2290,41 @@
$('#loader').hide();
successPopup(response);
},
error: function (error) {
alert("Error saving data!");
console.log(error);
error: function (xhr) {
$('#loader').hide();
console.log("Error status:", xhr.status);
console.log("Error response:", xhr.responseText);
if (xhr.status === 409) {
var response = xhr.responseJSON;
Swal.fire({
title: "Warning!",
text: response && response.message
? response.message
: "This mobile number is already registered",
icon: "warning",
confirmButtonText: "OK"
});
} else {
Swal.fire({
title: "Error!",
text: "Unable to save registration. Please try again.",
icon: "error",
confirmButtonText: "OK"
});
}
// Allow user to submit again
$("#submitBtn").prop("disabled", false);
},
complete: function () {
// Re-enable the submit button after completion (either success or error)
$("#submitBtn").prop("disabled", true);
$("#pageLoader").hide();
},
});

757
src/main/resources/templates/index_tamil.html

@ -425,7 +425,7 @@
<div class="col-lg-12 col-md-12 mb-3">
<label for="pincode">அஞ்சல் குறியீடு<span class="req">*</span></label>
<input type="text" class="form-control" minlength="6" maxlength="6" pattern="[0-9]{6}"
id="pincode" placeholder="Eஅஞ்சல் குறியீட்டை உள்ளிடவும்...">
id="pincode" placeholder="அஞ்சல் குறியீட்டை உள்ளிடவும்...">
<span class="text-danger" id="pincodeError"></span>
</div>
@ -551,6 +551,24 @@
</div>
<div class="form-row mb-4">
<div class="col-lg-12 col-md-12 mb-3">
<label for="docs">
ஆவணம்<span class="req">*</span>
</label>
<select class="form-control" id="docs">
</select>
<span class="text-danger" id="docsError"></span>
</div>
</div>
<!-- Dynamic fields -->
<div class="form-row" id="documentFields"></div>
</div>
<!-- Individual Form -->
@ -570,9 +588,8 @@
<div class="col-lg-12 col-md-12 mb-3">
<label for="cmpEmail">நிறுவன மின்னஞ்சல் ஐடி</label>
<input type="text" class="form-control" id="cmpEmail"
placeholder="நிறுவன மின்னஞ்சல் முகவரியை உள்ளிடவும்">
<input type="text" class="form-control" id="cmpEmail" placeholder="நிறுவன மின்னஞ்சல் முகவரியை உள்ளிடவும்">
<span class="text-danger" id="cmpEmailError"></span>
</div>
@ -643,7 +660,7 @@
<div class="form-row mb-4">
<div class="col-lg-12 col-md-12 mb-3">
<label for="cmpPoc">பெயர் <span class="req">*</span></label>
<input type="text" class="form-control" id="cmpPoc">
<input type="text" class="form-control" id="cmpPoc" placeholder="பெயரை உள்ளிடவும்">
<span class="text-danger" id="cmpPocError"></span>
</div>
<div class="col-lg-12 col-md-12 mb-3">
@ -663,7 +680,7 @@
<div class="col-lg-12 col-md-12 mb-3">
<label for="cmdPom">தொலைபேசி எண்<span class="req">*</span></label>
<input type="number" class="form-control" id="cmdPom" placeholder="கைபேசி எண்ணை உள்ளிடவும்...">
<input type="text" class="form-control" id="cmdPom" placeholder="கைபேசி எண்ணை உள்ளிடவும்...">
<span class="text-danger" id="cmdPomError"></span>
</div>
@ -708,7 +725,7 @@
<div class="col-lg-12 col-md-12 mb-3">
<label for="ngoOrgEmail">நிறுவன மின்னஞ்சல் ஐடி</label>
<input type="text" class="form-control" id="ngoOrgEmail" placeholder="மின்னஞ்சல் முகவரியை உள்ளிடவும்">
<span class="text-danger" id="ngoOrgEmailError"></span>
</div>
@ -798,7 +815,7 @@
<div class="col-lg-12 col-md-12 mb-3">
<label for="oPom">தொலைபேசி எண் <span class="req">*</span></label>
<input type="number" class="form-control" id="oPom" placeholder="தொலைபேசி எண்ணை உள்ளிடவும்...">
<input type="text" class="form-control" id="oPom" placeholder="தொலைபேசி எண்ணை உள்ளிடவும்...">
<span class="text-danger" id="oPomError"></span>
</div>
</div>
@ -828,6 +845,41 @@
<!-- NGO Form -->
<div class="form-row">
<div class="col-lg-12 col-md-12 mb-3">
<label for="expertise">நிபுணத்துவத் துறை<span class="req">*</span></label>
<select class="form-control" id="expertise">
</select>
<span class="text-danger" id="expertiseError"></span>
</div>
<!-- Dynamic Other Expertise field -->
<div class="col-lg-12 col-md-12 mb-3" id="otherExpertiseContainer" style="display:none;">
<label for="otherExpertise">
மற்ற நிபுணத்துவத்தைக் குறிப்பிடவும்<span class="req">*</span>
</label>
<input type="text"
class="form-control"
id="other_expertise"
placeholder="மற்ற நிபுணத்துவத்தைக் குறிப்பிடவும்"
autocomplete="off">
<span class="text-danger" id="otherExpertiseError"></span>
</div>
<div class="col-lg-12 col-md-12 mb-3">
<label for="ephno">அவசரக்காலத் தொலைபேசி எண்<span class="req">*</span></label>
<input type="text" class="form-control" id="ephno" placeholder="அவசரக்காலத் தொலைபேசி எண்" maxlength="10" inputmode="numeric" autocomplete="off" required="required">
<span class="text-danger" id="ephnoError"></span>
</div>
</div>
<!-- Preferred area of work checkboxes -->
<h5>விருப்பமான பணியிடம்<span class="req">*</span></h5>
<div class="form-check mb-3">
@ -882,7 +934,7 @@
<div class="form-check">
<input class="form-check-input zone-checkbox" type="checkbox" id="zone6"
name="zone6" value="6-ThiruViKa Nagar" onclick="checkAnyArea()">
<label class="zone-checkbox-label" for="zone6">மண்டலம் 6 <br>(திரு-வி-கா நகர்)</label>
<label class="zone-checkbox-label" for="zone6">மண்டலம் 6 <br>(திரு-வி-க நகர்)</label>
</div>
</div>
<div class="col-6">
@ -1093,6 +1145,69 @@
}
} */
$("#name").on("input", function () {
this.value = this.value.replace(/[^a-zA-Z.\s]/g, '');
});
$("#cmpPoc").on("input", function () {
this.value = this.value.replace(/[^a-zA-Z.\s]/g, '');
});
$("#oPoc").on("input", function () {
this.value = this.value.replace(/[^a-zA-Z.\s]/g, '');
});
$("#dob").on("keydown paste drop", function (e) {
e.preventDefault();
});
$("#pincode").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 6);
});
$("#ephno").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
});
$("#mobile").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
});
$("#cmdPom").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
});
$("#oPom").on("input", function () {
this.value = this.value.replace(/\D/g, '').slice(0, 10);
});
$("#expertise").on("change", function () {
var selectedOption = $(this).find("option:selected");
var selectedId = selectedOption.val();
var expertiseArea = selectedOption.attr("data-category") || "";
// Check ID = 7 OR expertise contains "Others"
var isOtherExpertise =
selectedId === "7" ||
expertiseArea.toLowerCase().includes("others");
if (isOtherExpertise) {
$("#otherExpertiseContainer").show();
} else {
$("#otherExpertiseContainer").hide();
// Clear previous value and error
$("#other_expertise").val("");
$("#otherExpertiseError").text("");
}
});
$(document).ready(function () {
$.ajax({
url: "/volunteer/api/registration/getAllCategory",
@ -1112,6 +1227,78 @@
});
}
});
$.ajax({
url: "/volunteer/api/registration/getAllExpertise",
type: "GET",
success: function (expertise) {
let expertiseDropdown = $('#expertise');
expertiseDropdown.empty();
expertiseDropdown.append(`<option value="">Select</option>`);
expertise.forEach(function (exp) {
$('<option>', {
value: exp.id,
text: exp.expertise_area_tamil
}).attr('data-category', exp.expertise_area_tamil)
.appendTo(expertiseDropdown);
});
}
});
});
$("#docs").on("change", function () {
var selectedOption = $(this).find("option:selected");
var labelName = selectedOption.attr("data-category") || "";
var option = $(this).val();
var documentFields = $("#documentFields");
documentFields.empty();
$("#docsError").text("");
if (option === "-1" || option === "") {
return;
}
var optionName = labelName;
var html = `
<div class="col-lg-12 col-md-12 mb-3">
<label for="doc_number">
${optionName} எண்<span class="req">*</span>
</label>
<input type="text"
class="form-control"
id="doc_number"
name="doc_number"
placeholder="${optionName} எண்..."
autocomplete="off">
<span class="text-danger" id="docNumberError"></span>
</div>
<div class="col-lg-12 col-md-12 mb-3">
<label for="doc_url">
${optionName} படம் (20 MB-க்கும் குறைவானது - jpg/jpeg/pdf)<span class="req">*</span>
</label>
<input type="file"
class="form-control"
id="doc_url"
name="doc_url"
accept=".pdf,.jpg,.jpeg">
<span class="text-danger" id="docFileError"></span>
</div>
`;
documentFields.html(html);
});
function handleCategoryChange() {
@ -1136,6 +1323,26 @@
$('.ngo-form').show();
} */
if (selectedText === "1") {
$.ajax({
url: "/volunteer/api/registration/getAllVolunteerDocs",
type: "GET",
success: function (docsvalues) {
let docsDropdown = $('#docs');
docsDropdown.empty();
docsDropdown.append(`<option value="">Select</option>`);
docsvalues.forEach(function (docs) {
$('<option>', {
value: docs.id,
text: docs.tamil_name
}).attr('data-category', docs.tamil_name)
.appendTo(docsDropdown);
});
}
});
$('.individual-form').show();
} else if (selectedText === "2") {
$('.corporate-form').show();
@ -1213,6 +1420,67 @@
isValid = false;
}
var ephno = $.trim($("#ephno").val());
//console.log("ephno===="+ephno);
if (ephno === "") {
$("#ephnoError").text("அவசரகாலத் தொலைபேசி எண்ணை உள்ளிடவும்");
isValid = false;
} else if (!/^\d{10}$/.test(ephno)) {
$("#ephnoError").text("தொலைபேசி எண் சரியாக 10 இலக்கங்களைக் கொண்டிருக்க வேண்டும்");
isValid = false;
} else if (!/^[6-9]/.test(ephno)) {
$("#ephnoError").text("தொலைபேசி எண் 6, 7, 8 அல்லது 9-இல் தொடங்க வேண்டும்");
isValid = false;
}else if (/^(\d)\1{9}$/.test(ephno)) {
$("#ephnoError").text("தொலைபேசி எண்ணில் ஒரே இலக்கம் மீண்டும் மீண்டும் வரக்கூடாது");
isValid = false;
} else if (
ephno === "1234567890" ||
ephno === "0123456789" ||
ephno === "9876543210" ||
ephno === "0987654321"
) {
$("#ephnoError").text("சரியான தொலைபேசி எண்ணை உள்ளிடவும்");
isValid = false;
}
var selectedEOption = $("#expertise option:selected");
var expertisevalue = $.trim(selectedEOption.val());
var expertiseArea = $.trim(selectedEOption.attr("data-category") || "");
if (expertisevalue === "" || expertisevalue === "-1") {
$("#expertiseError").text("நிபுணத்துவம் உள்ள துறையைத் தேர்ந்தெடுக்கவும்");
isValid = false;
} else if (
expertisevalue === "7" ||
expertiseArea.toLowerCase().includes("others")
) {
var otherExpertise = $.trim($("#other_expertise").val());
if (otherExpertise === "") {
$("#otherExpertiseError").text("மற்ற நிபுணத்துவத்தைக் குறிப்பிடவும்");
isValid = false;
}
}
if (selectedTextcategory === "1") {
var name = document.getElementById("name").value = document.getElementById("name").value.trim();
@ -1244,6 +1512,12 @@
$("#dobError").text("தயவுசெய்து பிறந்த தேதியை உள்ளிடவும்.");
isValid = false;
}
if(email!=""){
if (!emailPattern.test(email)) {
$("#emailError").text("தயவுசெய்து சரியான மின்னஞ்சல் முகவரியை உள்ளிடவும்.");
isValid = false;
}
}
if (!genderSelected) {
$("#genderError").text("தயவுசெய்து பாலினத்தைத் தேர்ந்தெடுக்கவும்.");
isValid = false;
@ -1262,6 +1536,33 @@
$("#mobileError").text("தயவுசெய்து சரியான 10 இலக்க அலைபேசி எண்ணை உள்ளிடவும்.");
isValid = false;
}
if (!/^\d{10}$/.test(mobile)) {
$("#mobileError").text("தொலைபேசி எண்ணில் சரியாக 10 இலக்கங்கள் இருக்க வேண்டும்.");
isValid = false;
} if (!/^[6-9]/.test(mobile)) {
$("#mobileError").text("தொலைபேசி எண் 6, 7, 8 அல்லது 9-இல் தொடங்க வேண்டும்.");
isValid = false;
} if (/^(\d)\1{9}$/.test(mobile)) {
$("#mobileError").text("தொலைபேசி எண்ணில் ஒரே இலக்கம் மீண்டும் மீண்டும் வரக்கூடாது");
isValid = false;
} if (
mobile === "1234567890" ||
mobile === "0123456789" ||
mobile === "9876543210" ||
mobile === "0987654321"
) {
$("#mobileError").text("சரியான தொலைபேசி எண்ணை உள்ளிடவும்");
isValid = false;
}
if (address == undefined || address == "") {
$("#addressError").text("தயவுசெய்து முகவரியை உள்ளிடவும்.");
isValid = false;
@ -1296,11 +1597,120 @@
isValid = false;
}*/
var docs = $.trim($("#docs").val());
if (docs === "" || docs === "-1") {
$("#docsError").text("ஆவணத்தைத் தேர்ந்தெடுக்கவும்");
isValid = false;
} else {
// Get selected document name
var selectedOption = $("#docs option:selected");
var documentName = $.trim(selectedOption.attr("data-category") || "");
// -----------------------------
// Document Number Validation
// -----------------------------
var docNumber = $.trim($("#doc_number").val());
if (docNumber === "") {
$("#docNumberError").text("" + documentName + " எண்ணை உள்ளிடவும்");
isValid = false;
}
if (docs === "1") {
// Aadhar = exactly 12 numeric digits
if (!/^\d{12}$/.test(docNumber)) {
$("#docNumberError").text(
"ஆதார் எண் சரியாக 12 இலக்கங்களைக் கொண்டிருக்க வேண்டும்"
);
isValid = false;
}
} else {
// Other documents = alphanumeric, max 10 characters
if (!/^[a-zA-Z0-9]{10}$/.test(docNumber)) {
$("#docNumberError").text(
documentName + " எண்ணில் எழுத்துக்கள் மற்றும் எண்கள் மட்டுமே இருக்க வேண்டும் (அதிகபட்சம் 10 எழுத்துக்கள்)"
);
isValid = false;
}
}
// -----------------------------
// Document File Validation
// -----------------------------
var docFileInput = $("#doc_url")[0];
if (!docFileInput || docFileInput.files.length === 0) {
$("#docFileError").text(
" " + documentName + " தேர்ந்தெடுக்கவும் "
);
isValid = false;
} else {
var docFile = docFileInput.files[0];
// Maximum 20 MB
var maxSize = 20 * 1024 * 1024;
if (docFile.size >= maxSize) {
$("#docFileError").text(
"அளவு 20 MB-க்குக் குறைவாக இருக்க வேண்டும்"
);
isValid = false;
}
// File type
var allowedTypes = [
"image/jpeg",
"application/pdf"
];
if (!allowedTypes.includes(docFile.type)) {
$("#docFileError").text(
"JPG, JPEG அல்லது PDF கோப்புகள் மட்டுமே அனுமதிக்கப்படும்"
);
isValid = false;
}
}
}
if (!preVolSelected) {
$("#prevolError").text("தயவுசெய்து முந்தைய தன்னார்வலர் விவரங்களைத் தேர்ந்தெடுக்கவும்.");
isValid = false;
}
var cmobile = $.trim($("#mobile").val());
if(cmobile !== "" && ephno !== "" && cmobile === ephno){
Swal.fire({
title: "Warning!",
text: "கைபேசி எண்ணும் அவசரக்காலத் தொலைபேசி எண்ணும் ஒன்றாக இருக்கக்கூடாது",
icon: "warning",
confirmButtonText: "OK"
});
isValid = false;
}
/* if (ngoAny == undefined || ngoAny == "") {
$("#ngoAnyError").text("Please Enter Company/NGO details !");
isValid = false;
@ -1316,6 +1726,37 @@
saveTheIndividualForm();
return false;
}
else{
var firstError = $(".text-danger")
.filter(function () {
return $.trim($(this).text()) !== "";
})
.first();
if (firstError.length) {
var target = firstError
.closest(".mb-3")
.find("input, select, textarea")
.first();
if (target.length) {
$("html, body").animate({
scrollTop: target.offset().top - 120
}, 600);
// Focus the field
target.focus();
}else {
// Fallback to error message
$("html, body").animate({
scrollTop: firstError.offset().top - 120
}, 600);
}
}
}
return false;
}
else if (selectedTextcategory === "2") {
@ -1330,11 +1771,18 @@
var cmdPom = document.getElementById("cmdPom").value = document.getElementById("cmdPom").value.trim();
var cmpPVolSelect = document.querySelector('input[name="cmpPVol"]:checked');
var cmdPoE = document.getElementById("cmdPoE").value = document.getElementById("cmdPoE").value.trim();
var cmdPod = $("#cmdPod").val().trim();
if (cmpName == undefined || cmpName == "") {
$("#cmpNameError").text("தயவுசெய்து நிறுவனத்தின் பெயரை உள்ளிடவும்.");
isValid = false;
}
if(cmpEmail!=""){
if (!emailPattern.test(cmpEmail)) {
$("#cmpEmailError").text("சரியான மின்னஞ்சல் முகவரியை உள்ளிடவும்.");
isValid = false;
}
}
if (cmpAddress == undefined || cmpAddress == "") {
$("#cmpAddressError").text("தயவுசெய்து நிறுவனத்தின் முகவரியை உள்ளிடவும்.");
isValid = false;
@ -1347,10 +1795,20 @@
$("#cmpNovError").text("தயவுசெய்து தன்னார்வலர்களின் எண்ணிக்கையை உள்ளிடவும்.");
isValid = false;
}
if (!/^[1-9]\d*$/.test(cmpNov)) {
$("#cmpNovError").text("சரியான எண்ணிக்கையிலான தன்னார்வலர்களை உள்ளிடவும்.");
isValid = false;
}
if (cmpPoc == undefined || cmpPoc == "") {
$("#cmpPocError").text("நடத்தைக்கான பொறுப்பாளர் பெயரை உள்ளிடவும்.");
isValid = false;
}
if (cmdPod == "") {
$("#cmdPodError").text("நடத்தைக்கான பொறுப்பாளர் பதவியைக் குறிப்பிடவும்");
isValid = false;
}
if (cmdPoE === "" || !emailPattern.test(cmdPoE)) {
$("#cmdPoEError").text("தொடர்பு கொள்ள வேண்டியவருக்கான சரியான மின்னஞ்சல் முகவரியை உள்ளிடவும்.");
isValid = false;
@ -1359,10 +1817,52 @@
$("#cmdPomError").text("தொடர்பு கொள்ள வேண்டியவரின் செல்லுபடியாகும் அலைபேசி எண்ணை உள்ளிடவும்.");
isValid = false;
}
if (!/^\d{10}$/.test(cmdPom)) {
$("#cmdPomError").text("தொலைபேசி எண்ணில் சரியாக 10 இலக்கங்கள் இருக்க வேண்டும்.");
isValid = false;
} if (!/^[6-9]/.test(cmdPom)) {
$("#cmdPomError").text("தொலைபேசி எண் 6, 7, 8 அல்லது 9-இல் தொடங்க வேண்டும்.");
isValid = false;
} if (/^(\d)\1{9}$/.test(cmdPom)) {
$("#cmdPomError").text("தொலைபேசி எண்ணில் ஒரே இலக்கம் மீண்டும் மீண்டும் வரக்கூடாது");
isValid = false;
} if (
cmdPom === "1234567890" ||
cmdPom === "0123456789" ||
cmdPom === "9876543210" ||
cmdPom === "0987654321"
) {
$("#cmdPomError").text("சரியான தொலைபேசி எண்ணை உள்ளிடவும்");
isValid = false;
}
if (!cmpPVolSelect) {
$("#anyAreaError").text("தயவுசெய்து முந்தைய தன்னார்வலர்களின் விவரங்களைத் தேர்ந்தெடுக்கவும்.");
isValid = false;
}
var c1mobile = $.trim($("#cmdPom").val());
if(c1mobile !== "" && ephno !== "" && c1mobile === ephno){
Swal.fire({
title: "Warning!",
text: "கைபேசி எண்ணும் அவசரக்காலத் தொலைபேசி எண்ணும் ஒன்றாக இருக்கக்கூடாது",
icon: "warning",
confirmButtonText: "OK"
});
isValid = false;
}
if (i == 0) {
alert("விருப்பமான பகுதி விவரங்களைத் தேர்ந்தெடுக்கவும்.");
isValid = false;
@ -1375,6 +1875,37 @@
saveCorporateDetails();
return false;
}
else{
var firstError = $(".text-danger")
.filter(function () {
return $.trim($(this).text()) !== "";
})
.first();
if (firstError.length) {
var target = firstError
.closest(".mb-3")
.find("input, select, textarea")
.first();
if (target.length) {
$("html, body").animate({
scrollTop: target.offset().top - 120
}, 600);
// Focus the field
target.focus();
}else {
// Fallback to error message
$("html, body").animate({
scrollTop: firstError.offset().top - 120
}, 600);
}
}
}
return false;
}
@ -1390,11 +1921,18 @@
var cmdPom = document.getElementById("oPom").value = document.getElementById("oPom").value.trim();
var cmpPVolSelect = document.querySelector('input[name="oPvolY"]:checked');
var oPoE = document.getElementById("oPoE").value = document.getElementById("oPoE").value.trim();
var oPod = $("#oPod").val().trim();
if (cmpName == ""|| cmpName == undefined ) {
$("#ngoOrgNameError").text("தயவுசெய்து நிறுவனத்தின் பெயரை உள்ளிடவும்");
isValid = false;
}
if(ngoOrgEmail!=""){
if (!emailPattern.test(ngoOrgEmail)) {
$("#ngoOrgEmailError").text("சரியான மின்னஞ்சல் முகவரியை உள்ளிடவும்.");
isValid = false;
}
}
if (cmpAddress == undefined || cmpAddress == "") {
$("#oAddressError").text("தயவுசெய்து நிறுவனத்தின் முகவரியை உள்ளிடவும்.");
isValid = false;
@ -1407,10 +1945,20 @@
$("#oNvolError").text("தயவுசெய்து தன்னார்வலர்களின் எண்ணிக்கையை உள்ளிடவும்.");
isValid = false;
}
if (!/^[1-9]\d*$/.test(cmpNov)) {
$("#oNvolError").text("சரியான எண்ணிக்கையிலான தன்னார்வலர்களை உள்ளிடவும்.");
isValid = false;
}
if (cmpPoc == undefined || cmpPoc == "") {
$("#oPocError").text("நடத்தைக்கான பொறுப்பாளர் பெயரை உள்ளிடவும்.");
isValid = false;
}
if (oPod == "") {
$("#oPodError").text("நடத்தைக்கான பொறுப்பாளர் பதவியைக் குறிப்பிடவும்");
isValid = false;
}
if (oPoE === "" || !emailPattern.test(oPoE)) {
$("#oPoeError").text("தொடர்பு கொள்ள வேண்டியவருக்கான சரியான மின்னஞ்சல் முகவரியை உள்ளிடவும்.");
isValid = false;
@ -1419,10 +1967,50 @@
$("#oPomError").text("தொடர்பு கொள்ள வேண்டியவரின் செல்லுபடியாகும் அலைபேசி எண்ணை உள்ளிடவும்.");
isValid = false;
}
if (!/^\d{10}$/.test(cmdPom)) {
$("#oPomError").text("தொலைபேசி எண்ணில் சரியாக 10 இலக்கங்கள் இருக்க வேண்டும்.");
isValid = false;
} if (!/^[6-9]/.test(cmdPom)) {
$("#oPomError").text("தொலைபேசி எண் 6, 7, 8 அல்லது 9-இல் தொடங்க வேண்டும்.");
isValid = false;
} if (/^(\d)\1{9}$/.test(cmdPom)) {
$("#oPomError").text("தொலைபேசி எண்ணில் ஒரே இலக்கம் மீண்டும் மீண்டும் வரக்கூடாது");
isValid = false;
} if (
cmdPom === "1234567890" ||
cmdPom === "0123456789" ||
cmdPom === "9876543210" ||
cmdPom === "0987654321"
) {
$("#oPomError").text("சரியான தொலைபேசி எண்ணை உள்ளிடவும்");
isValid = false;
}
if (!cmpPVolSelect) {
$("#oPvolYError").text("தயவுசெய்து முந்தைய தன்னார்வலர்களின் விவரங்களைத் தேர்ந்தெடுக்கவும்.");
isValid = false;
}
var c2mobile = $.trim($("#oPom").val());
if(c2mobile !== "" && ephno !== "" && c2mobile === ephno){
Swal.fire({
title: "Warning!",
text: "கைபேசி எண்ணும் அவசரக்காலத் தொலைபேசி எண்ணும் ஒன்றாக இருக்கக்கூடாது",
icon: "warning",
confirmButtonText: "OK"
});
isValid = false;
}
if (i == 0) {
alert("விருப்பமான பகுதி விவரங்களைத் தேர்ந்தெடுக்கவும்.");
isValid = false;
@ -1432,6 +2020,37 @@
saveNGODetails();
return false;
}
else{
var firstError = $(".text-danger")
.filter(function () {
return $.trim($(this).text()) !== "";
})
.first();
if (firstError.length) {
var target = firstError
.closest(".mb-3")
.find("input, select, textarea")
.first();
if (target.length) {
$("html, body").animate({
scrollTop: target.offset().top - 120
}, 600);
// Focus the field
target.focus();
}else {
// Fallback to error message
$("html, body").animate({
scrollTop: firstError.offset().top - 120
}, 600);
}
}
}
return false;
}
@ -1471,16 +2090,44 @@
referBy: $("#ref").val(),
//aadhar: $("#aadhar").val(),
//bloodgroup: $("#bloodgroup").val(),
preferredAreas: preferredAreas
preferredAreas: preferredAreas,
expertise_area:$("#expertise").val(),
other_expertise:$("#other_expertise").val(),
ephno:$("#ephno").val(),
doc_type:$.trim($("#docs").val()),
doc_number:$.trim($("#doc_number").val()),
};
// Create FormData
var formData = new FormData();
// Add JSON data as Blob
formData.append(
"volunteer",
new Blob(
[JSON.stringify(volunteerData)],
{ type: "application/json" }
)
);
// Add file
var docFile = $("#doc_url")[0].files[0];
if (docFile) {
formData.append("doc_url", docFile);
}
$('#loader').show();
// Send AJAX POST request
$.ajax({
type: "POST",
url: "/volunteer/api/register",
contentType: "application/json",
data: JSON.stringify(volunteerData),
data: formData,
// IMPORTANT
processData: false,
contentType: false,
beforeSend: function() {
$("#pageLoader").show();
},
@ -1488,15 +2135,41 @@
$('#loader').hide();
successPopup(response);
},
error: function (error) {
alert("Error saving data!");
console.log(error);
error: function (xhr) {
$('#loader').hide();
console.log("Error status:", xhr.status);
console.log("Error response:", xhr.responseText);
if (xhr.status === 409) {
var response = xhr.responseJSON;
Swal.fire({
title: "Warning!",
text: response && response.message
? response.message
: "This mobile number is already registered",
icon: "warning",
confirmButtonText: "OK"
});
} else {
Swal.fire({
title: "Error!",
text: "Unable to save registration. Please try again.",
icon: "error",
confirmButtonText: "OK"
});
}
// Allow user to submit again
$("#submitBtn").prop("disabled", false);
},
complete: function () {
// Re-enable the submit button after completion (either success or error)
$("#submitBtn").prop("disabled", true);
$("#pageLoader").hide();
}
});
@ -1525,7 +2198,10 @@
cntPerDesign: $("#cmdPod").val(),
previous_volunteered: $("input[name='cmpPVol']:checked").val(),
referBy: $("#ref").val(),
preferredAreas: preferredAreas
preferredAreas: preferredAreas,
expertise_area:$("#expertise").val(),
other_expertise:$("#other_expertise").val(),
ephno:$("#ephno").val(),
}
$('#loader').show();
$.ajax({
@ -1540,14 +2216,41 @@
$('#loader').hide();
successPopup(response);
},
error: function (error) {
alert("Error saving data!");
console.log(error);
error: function (xhr) {
$('#loader').hide();
console.log("Error status:", xhr.status);
console.log("Error response:", xhr.responseText);
if (xhr.status === 409) {
var response = xhr.responseJSON;
Swal.fire({
title: "Warning!",
text: response && response.message
? response.message
: "This mobile number is already registered",
icon: "warning",
confirmButtonText: "OK"
});
} else {
Swal.fire({
title: "Error!",
text: "Unable to save registration. Please try again.",
icon: "error",
confirmButtonText: "OK"
});
}
// Allow user to submit again
$("#submitBtn").prop("disabled", false);
},
complete: function () {
// Re-enable the submit button after completion (either success or error)
$("#submitBtn").prop("disabled", true);
$("#pageLoader").hide();
},
@ -1579,7 +2282,10 @@
cntPerDesign: $("#oPod").val(),
previous_volunteered: $("input[name='oPvolY']:checked").val(),
referBy: $("#ref").val(),
preferredAreas: preferredAreas
preferredAreas: preferredAreas,
expertise_area:$("#expertise").val(),
other_expertise:$("#other_expertise").val(),
ephno:$("#ephno").val(),
}
$('#loader').show();
@ -1595,14 +2301,9 @@
$('#loader').hide();
successPopup(response);
},
error: function (error) {
alert("Error saving data!");
console.log(error);
$('#loader').hide();
},
complete: function () {
// Re-enable the submit button after completion (either success or error)
$("#submitBtn").prop("disabled", true);
$("#pageLoader").hide();
},
});

853
src/main/resources/templates/webindex.html
File diff suppressed because it is too large
View File

818
src/main/resources/templates/webindex_tamil.html
File diff suppressed because it is too large
View File

Loading…
Cancel
Save