package main_package;

import group_head_package.DataBaseIncomeExpense;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.faces.validator.ValidatorException;
import javax.servlet.http.HttpSession;

import org.primefaces.context.RequestContext;
import org.primefaces.event.FlowEvent;
import org.primefaces.model.UploadedFile;

import com.google.gson.JsonObject;

import apiClients.AadhaarApiClient;
import apiClients.AadhaarOtpApiClient;
import apiClients.AadhaarOtpApiClient.AadhaarOtpResult;
import apiClients.CibilApiClient;
import apiClients.PanApiClient;
import apiPackage.UrlInfoBean;

@ManagedBean(name="memberRegistration")
@ViewScoped

public class MemberRegistrationBean implements Serializable
{   
	DataBaseMethods obj=new DataBaseMethods();
	private static final long serialVersionUID = 1L;
	String office_application_no, shareNo,crNo, first_applicantName,father_husband_name, guardian_name, guardian_relation,status,bank_name, cityName, relation;
	String PAN,bank_accountNo,branch, address, mobile, nominee_name,perAddress,nominee_relation, nominee_address,account_status;
	String applicant_photoPath,category,signPath,formPath,submittedBankName,transferShareHolderNo,paymentMode="cash",label,bankNameCheque,chequeNo;
	UploadedFile applicant_photo,signPhoto,formPhoto, doc1photo,aadharFrontDoc1, doc2photo, doc3photo, doc4photo, doc5photo,doc6photo,doc7photo,doc8photo;
	double noOfShare,companyShares,shareAmount,totalAmount;
	boolean disableAdd=false,checkBox,transferCheckBox,showTransferFields,showCheque, showAutoBtn, showRegBtn,requiredCibilFiled ,renderPayMode=true,requiredCenter, skip;
	Date office_date=new Date(),application_date,dob,nominee_dob;
	ArrayList<SelectItem> categoryList, bankList, maritalStatusList, relationList, telephoneIndicatorList, religionList, stateCodeList,centerList, qualificationList, occupationList;
	public static List<String> list;
	int id,transferId, noOfDependent,membershipFees;
	String votrId, uniqueId, dlNo, rationNo, resCert, electBill, tBill, appCheque, gCheque;
	String doc1Path,doc2Path,doc3Path,doc4Path,doc5Path,doc6Path,doc7Path,doc8Path, userId, confirmDetailMsg="", dobInWord,aadharBackPathDoc01,voterBackPathDoc03;
	boolean shareCheck=true, autoSaving, disDsa, requiredFiled, renAutoShareNo, renManualShareNo;
	String gender, maritalStatus, keyPersonName, keyPersonRelation, telephoneIndicator, religion, stateCode="RJ", pinCode, dsaCode;
	UserInfo appMemberRow;
	String email, qualification, occupation, bankIfsc, referenceBy, remark, title, monthlyIncome, center, nomTitle, nomGender, latitude, longitude;
	String nomAadhar,nomPan, area, business, businessPlace, caste, brideFhname, brideMname, brideAddress, brideBusiness, brideBusinessPlace, brideMobileNo, brideRemark;
	double loginFee=0.0;
	ArrayList<SelectItem> dsaList;
	String loginfeeBank,feeMode,feeTransactionNo;
	Date feeTransactionDate;
	boolean showFee;
	String nomineeFather,nomineeMother;
	String nomVoterId,nomContactNo;
	ArrayList<String> duplicateContactDetails = new ArrayList<>();
    String duplicateType;

	String nomBankName,nomBankBranch,nomAccNo,nomIfscCode;
	String memberStateCode,memberReligion, memberPinCode;
    ArrayList<SelectItem> stateCodeListForMemberStateCodeReligion;	
	String altContactNo;
	int flag=1;
	
	String requestId, otp;
	private String aadhaarNumber;

	private String panHolderName, panCategory, message;
	
	private String firstName, lastName;

	private String cibilScore = "", cibilReportLink = "", cibilReportPath = "", cibilClientId = "", cibilStatus = "", 
				   cibilMessage = "", consent = "y", reportType = "score";
	
	
    private boolean showPan = false, showCibil = false;
	
	private boolean showOtp, aadhaarVerified, showOtpButton = true;
	
	DataBaseMethodTaheer dbmt = new DataBaseMethodTaheer();	
	UploadedFile aadharBackPhoto, voterBackPhoto;
	String aadharFrontPathDoc1;
	//String aadharBackPathDoc01, voterBackPathDoc03;
	
	public MemberRegistrationBean() 
	{		
		
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		Connection conn=DataBaseConnection.JAVAConnection();
		DataBaseMethodsHemant dh= new DataBaseMethodsHemant();
		
		dataFromApp();
		userId=obj.userId();
		centerList=obj.allcenter(branchId,"all",conn);
		categoryList=obj.allCategoryList();  // Static Caste-Catgory List
		shareNo=obj.shareHolderNo(branchId);   // To Find Member Reg. No.
		if(shareNo.equalsIgnoreCase(""))
		{
			renManualShareNo=true;
			renAutoShareNo=false;
		}
		else
		{
			renManualShareNo=false;
			renAutoShareNo=true;
		}
		office_application_no=shareNo;
		companyShares=obj.checkRemainingCompanyShares();   // Total Remaining Share of the Company
		shareCheck=obj.checkShareAllotmentFromMember();
		if(shareCheck==true)
		{
			shareAmount=obj.extractCompanyShareAmount(conn);   // Share Amount of the Company
			if(shareAmount==100)
			{
				noOfShare=1;
			}
			else
			{
				shareAmount=10;
				noOfShare=10;
			}
			
			// Developement on 23 march due to defualt share transfer
			if(companyShares==0)
			{
				transferCheckBox=true;
				showShareTransfer();
				transferShareHolderNo=obj.checkDefaultShareTransferFrom(conn);
			}
		}
		else
		{
			showRegBtn=true;
		}
		
		bankList=new DataBaseIncomeExpense().allBankList(conn);    
		maritalStatusList=obj.highMarkTableList("Marital Status", conn);
		relationList=obj.highMarkTableList("Relationship", conn);
		telephoneIndicatorList=obj.highMarkTableList("Telephone Indicator", conn); 
		religionList=obj.highMarkTableList("Religion", conn); 
		stateCodeList=obj.highMarkTableList("State Code", conn);
		stateCodeListForMemberStateCodeReligion = dh.highMarkTableListForCustomerStateReligion("State Code", conn);
		
		dsaList=obj.allDsaList(branchId,"Loan",conn);
		
		if(obj.userType().equals("employee"))
		{
			dsaCode=obj.dsaCodeByEmpUserId(userId, conn);
			disDsa=true;
		}
		
		HeaderBean hh=new HeaderBean();
		if(hh.getName().equalsIgnoreCase("UVAJAGRITI NARI SHAKTI MAHILA SARVANGIN VIKAS SAHKARI SAMITI LTD"))
		{
			autoSaving=true;
		}
		
		else
		{
			autoSaving=obj.checkShareAllotmentFromMember();
		}
		
		if(hh.getName().equalsIgnoreCase("DEVKRIPA MICROFINANCE FOUNDATION"))
		{
			requiredCenter=true;
		}
		else
		{
			requiredCenter=false;
		}
		
		String crifNo=obj.checkSMessageApiDetailFromTable("crif_no","", conn);
		
		if(crifNo!=null && !crifNo.equalsIgnoreCase(""))
		{
			requiredCibilFiled=true;
		}
		
		else
		{
			requiredCibilFiled=false;
		}
		
		if(hh.getName().equalsIgnoreCase("MUDRABAZAAR FINCAP FOUNDATION"))
		{
			requiredFiled=true;
		}
		else
		{
			requiredFiled=false;
		}
		
		qualificationList=obj.qualificationList();
		occupationList=obj.occupationList();
		
		try {
			conn.close();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	private void dataFromApp() 
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		appMemberRow=(UserInfo) ss.getAttribute("selectedMemberRow");
		
		if(appMemberRow!=null)
		{
			office_date=appMemberRow.getOffice_date();
			dob=appMemberRow.getDob();
			first_applicantName=appMemberRow.getName();
			father_husband_name=appMemberRow.getFather_husband_name();
			mobile=appMemberRow.getMobile();
			address=appMemberRow.getAddress();
			perAddress=appMemberRow.getAddress();
			relation=appMemberRow.getRelation();
			nominee_name=appMemberRow.getNominee_name();
			nominee_relation=appMemberRow.getNominee_relation();
			gender=appMemberRow.getGender();
			uniqueId=appMemberRow.getUniqueId();
			votrId=appMemberRow.getVoterId();
			PAN=appMemberRow.getPAN();
			rationNo=appMemberRow.getRationNo();
			status=appMemberRow.getMaritalStatus();
			
			applicant_photoPath=appMemberRow.getApplicant_photo();
			signPath=appMemberRow.getSignPhoto();
			formPath=appMemberRow.getFormPhoto();
			doc1Path=appMemberRow.getDoc1Path();
			doc2Path=appMemberRow.getDoc2Path();
			doc3Path=appMemberRow.getDoc3Path();
			doc4Path=appMemberRow.getDoc4Path();
			doc5Path=appMemberRow.getDoc5Path();
			doc6Path=appMemberRow.getDoc6Path();
			doc7Path=appMemberRow.getDoc7Path();
			doc8Path=appMemberRow.getDoc8Path();
			bank_name=appMemberRow.getBank_name();
			bank_accountNo=appMemberRow.getBank_accountNo();
			bankIfsc=appMemberRow.getBankIfsc();
			branch=appMemberRow.getBranch();
			center=appMemberRow.getCenterId();
			latitude=appMemberRow.getLatitude();
			longitude=appMemberRow.getLongitude();
			System.out.println("bank account :"+bank_accountNo);
		}
	}

//	public void ageCal()
//	{
//		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
//		int branchId =(int) ss.getAttribute("branchId");
//		Connection conn=DataBaseConnection.JAVAConnection();
//		dobInWord=obj.ageCalcullationMethod(dob);
//		if(dobInWord!=null && !dobInWord.equalsIgnoreCase(""))
//		{
//			String arr[]=dobInWord.split("year");
//			int year=Integer.parseInt(arr[0].trim());
//			int ageLimit=obj.checkMemberAgeLimit(conn);
//			if(year>ageLimit)
//			{
//				RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO, "Age Limit Exceeding... !!!", "Dear User, Member Age Limit Exceeding. Please Try Again... Maximum Age Limit of the Member is "+ageLimit+" Years. Thank you."));
//				dob=null;
//			}
//		}
//		
//		try {
//			conn.close();
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//	}
	
	
	public void ageCal() {
	    HttpSession ss = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
	    int branchId = (int) ss.getAttribute("branchId");

	    Connection conn = null;

	    try {
	        conn = DataBaseConnection.JAVAConnection();

	        dobInWord = obj.ageCalcullationMethod(dob);

	        if (dobInWord != null && !dobInWord.trim().isEmpty()) {
	            String[] parts = dobInWord.split("year");
	            if (parts.length > 0) {
	                try {
	                    int year = Integer.parseInt(parts[0].trim());
	                    int ageLimit = obj.checkMemberAgeLimit(conn);

	                    if (year < 18) {
	                        RequestContext.getCurrentInstance().showMessageInDialog(
	                            new FacesMessage(FacesMessage.SEVERITY_WARN,
	                            "Underage Warning",
	                            "Dear User, You are not eligible. Minimum required age is 18 years.")
	                        );
	                        dob = null;
	                    } else if (year >= ageLimit) {
	                        RequestContext.getCurrentInstance().showMessageInDialog(
	                            new FacesMessage(FacesMessage.SEVERITY_INFO,
	                            "Age Limit Exceeded",
	                            "Dear User, Member Age Limit Exceeding. Please Try Again... Maximum Age Limit of the Member is " + ageLimit + " Years. Thank you.")
	                        );
	                        dob = null;
	                    }

	                } catch (NumberFormatException e) {
	                    e.printStackTrace(); // Log format error
	                }
	            }
	        }
	    } catch (Exception e) {
	        e.printStackTrace(); // Handle any runtime exceptions
	    } finally {
	        if (conn != null) {
	            try {
	                conn.close();
	            } catch (SQLException e) {
	                e.printStackTrace();
	            }
	        }
	    }
	}

	
	public void ageCal2() {
	    HttpSession ss = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
	    int branchId = (int) ss.getAttribute("branchId");

	    Connection conn = null;

	    try {
	        conn = DataBaseConnection.JAVAConnection();

	        dobInWord = obj.ageCalcullationMethod(nominee_dob);

	        if (dobInWord != null && !dobInWord.trim().isEmpty()) {
	            String[] parts = dobInWord.split("year");
	            if (parts.length > 0) {
	                try {
	                    int year = Integer.parseInt(parts[0].trim());
	                    int ageLimit = obj.checkMemberAgeLimit(conn);

	                    if (year < 18) {
	                        RequestContext.getCurrentInstance().showMessageInDialog(
	                            new FacesMessage(FacesMessage.SEVERITY_WARN,
	                            "Underage Warning",
	                            "Dear User, You are not eligible. Minimum required age is 18 years.")
	                        );
	                        nominee_dob = null;
	                    } else if (year > ageLimit) {
	                        RequestContext.getCurrentInstance().showMessageInDialog(
	                            new FacesMessage(FacesMessage.SEVERITY_INFO,
	                            "Age Limit Exceeded",
	                            "Dear User, Member Age Limit Exceeding. Please Try Again... Maximum Age Limit of the Member is " + ageLimit + " Years. Thank you.")
	                        );
	                        nominee_dob = null;
	                    }

	                } catch (NumberFormatException e) {
	                    e.printStackTrace(); // Log format error
	                }
	            }
	        }
	    } catch (Exception e) {
	        e.printStackTrace(); // Handle any runtime exceptions
	    } finally {
	        if (conn != null) {
	            try {
	                conn.close();
	            } catch (SQLException e) {
	                e.printStackTrace();
	            }
	        }
	    }
	}

	
	public String onFlowProcess(FlowEvent event) 
	{
        if(skip) {
            skip = false;   //reset in case user goes back
            return "confirm";
        }
        else {
            return event.getNewStep();
        }
    }
	
	public List<String> completeText(String name)
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		list=new DataBaseAutoCompAndDuplicate().shareHolderAllNoWithoutTransfer(branchId,name);
     	return list;
	}

	
	public void showShareTransfer()
	{
		if(transferCheckBox==true)
		{
			showTransferFields=true;
			renderPayMode=false;
		}
		else
		{
			showTransferFields=false;
			renderPayMode=true;
		}
	}
	
	public void checkData()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		if(uniqueId==null || uniqueId.trim().equalsIgnoreCase(""))
		{
			
		}
		else
		{
			Connection conn=DataBaseConnection.JAVAConnection();
			String detail=obj.checkExistDataByAadharNo(uniqueId, "unique_id",conn);
			
			if(detail==null || detail.equalsIgnoreCase(""))
			{
				//RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO, "No Matching Found !!!", "No Mateches Found on the Base of Given Aadhar Card No."));
			}
			else
			{
				RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO, "Member Already Exist!!!", detail));
				flag=0;
			}
			
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public void checkVoterData()
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		if(votrId==null || votrId.trim().equalsIgnoreCase(""))
		{
			
		}
		else
		{
			Connection conn=DataBaseConnection.JAVAConnection();
			String detail=obj.checkExistDataByAadharNo(votrId,"voter_id",conn);
			if(detail==null || detail.equalsIgnoreCase(""))
			{
				//RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO, "No Matching Found !!!", "No Mateches Found on the Base of Given Voter ID No."));
			}
			else
			{
				RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO, "Member Already Exist!!!", detail));
				flag=0;
			}
			
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public void checkPaymentMode()
	{
		if(paymentMode.equalsIgnoreCase("cash"))
		{
			showCheque=false;
		}
		else
		{
			label=paymentMode;
			showCheque=true;
		}
	}
	
	public void fillAddressValue()
	{
		if(checkBox==true)
		{
			perAddress=address;
			disableAdd=true;
		}
		else
		{
			perAddress="";
			disableAdd=false;
		}
	}
	
	public void registarInfo()
    {
		Connection conn=DataBaseConnection.JAVAConnection();
	   if(noOfShare>0 || shareCheck==false)
	   {
		   if(shareAmount>0 || shareCheck==false)
		   {
			   totalAmount= noOfShare*shareAmount;  
			   
			   showRegBtn=true;
			   
			   if(transferCheckBox==true)
			   {
				   if(transferShareHolderNo.contains("/"))
				   {
					   transferShareHolderNo=transferShareHolderNo.substring(0, transferShareHolderNo.indexOf("/"));
				   }
				   UserInfo svDetail=obj.savingAccountDetailByShareHolderNo(transferShareHolderNo);
				   boolean checkAutoTransfer=obj.checkShareAmountFromMember();
				   if(checkAutoTransfer==true)
				   {
					   confirmDetailMsg="Rs. "+totalAmount+" /- Deposit in Saving Account No. "+svDetail.getAccountNo()+", Account Holder Name: "+obj.firstApplicantNameBySHNo(transferShareHolderNo, conn)+" "
					   		+ "and Current Balance Is Rs. "+svDetail.getAmount()+" /-";
					   RequestContext.getCurrentInstance().execute("PF('loanAmt').show();");
					   RequestContext.getCurrentInstance().update("lnamt");
				   }
			   }
			}
		   else
		   {
			   FacesContext fc=FacesContext.getCurrentInstance();
			   fc.addMessage(null, new FacesMessage("Share Amount Must Be Greater Than Zero"));
		   }
	   }
	   else
	   {
		   FacesContext fc=FacesContext.getCurrentInstance();
			fc.addMessage(null, new FacesMessage("No Of Share Must Be Greater Than Zero"));
	   }
	   
	   try {
		conn.close();
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	}
	
	public String registr() throws ParseException 
	{  
		
		if (applicant_photoPath == null )
		{			
		    System.out.println("DOC 1"+aadharFrontDoc1);
		    if (aadharFrontDoc1 != null && aadharFrontDoc1.getSize() > 0) 
			{
		    	aadharFrontPathDoc1 = aadharFrontDoc1.getFileName();
				String exten[]=aadharFrontPathDoc1.split("\\.");
				aadharFrontPathDoc1=shareNo+"_1"+"."+exten[1];
				System.out.println(aadharFrontPathDoc1);
				obj.makeProfile(aadharFrontDoc1, aadharFrontPathDoc1);
			}
		
		if (doc2photo != null && doc2photo.getSize() > 0) 
		{
			doc2Path = doc2photo.getFileName();
			String exten[]=doc2Path.split("\\.");
			doc2Path=shareNo+"_5"+"."+exten[1];
			System.out.println(doc2Path);
			obj.makeProfile(doc2photo, doc2Path);
		}
		
		if (doc3photo != null && doc3photo.getSize() > 0) 
		{
			doc3Path = doc3photo.getFileName();
			String exten[]=doc3Path.split("\\.");
			doc3Path=shareNo+"_6"+"."+exten[1];
			System.out.println(doc3Path);
			obj.makeProfile(doc3photo, doc3Path);
		}if (doc4photo != null && doc4photo.getSize() > 0) 
		{
			doc4Path = doc4photo.getFileName();
//			String exten[]=doc4Path.split("\\.");
//			doc4Path=shareNo+"_7"+"."+exten[1];
			obj.makeProfile(doc4photo, doc4Path);
		}
		if (doc5photo != null && doc5photo.getSize() > 0) 
		{
			doc5Path = doc5photo.getFileName();
			String exten[]=doc5Path.split("\\.");
			doc5Path=shareNo+"_8"+"."+exten[1];
			obj.makeProfile(doc5photo, doc5Path);
		}
		if (doc6photo != null && doc6photo.getSize() > 0) 
		{
			doc6Path = doc6photo.getFileName();
			String exten[]=doc6Path.split("\\.");
			doc6Path=shareNo+"_9"+"."+exten[1];
			obj.makeProfile(doc6photo, doc6Path);
		}if (doc7photo != null && doc7photo.getSize() > 0) 
		{
			doc7Path = doc7photo.getFileName();
			String exten[]=doc7Path.split("\\.");
			doc7Path=shareNo+"_10"+"."+exten[1];
			obj.makeProfile(doc7photo, doc7Path);
		}if (doc8photo != null && doc8photo.getSize() > 0) 
		{
			doc8Path = doc8photo.getFileName();
			String exten[]=doc8Path.split("\\.");
			doc8Path=shareNo+"_11"+"."+exten[1];
			obj.makeProfile(doc8photo, doc8Path);
		}
		if (aadharBackPhoto != null && aadharBackPhoto.getSize() > 0) {
			
		    aadharBackPathDoc01 = aadharBackPhoto.getFileName();
		    String exten[] = aadharBackPathDoc01.split("\\.");
		    aadharBackPathDoc01=shareNo+"_12"+"."+exten[1];
		    obj.makeProfile(aadharBackPhoto, aadharBackPathDoc01);
		}
        
		if (voterBackPhoto != null && voterBackPhoto.getSize() > 0) {
			
		    voterBackPathDoc03 = voterBackPhoto.getFileName();
		    String exten[] = voterBackPathDoc03.split("\\.");
		    voterBackPathDoc03=shareNo+"_12"+"."+exten[1];
		    obj.makeProfile(voterBackPhoto, voterBackPathDoc03);
		}
		System.out.println("ll");
		}
		System.out.println("ll87");
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		Connection conn=DataBaseConnection.JAVAConnection();
		if(renAutoShareNo==true)
		{
			shareNo=obj.shareHolderNo(branchId);
		}
		office_application_no=shareNo;
		//For Trial Period Static Method
		flag=1;
		Date dd= new Date();
		String string = "31/12/2026";
		DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
		Date date = format.parse(string);
		if(dd.after(date))
		{	
			flag=0;
		}
		
		boolean chk=obj.checkLastEntrySettingInDb(branchId,"Share Holder",conn);
		
		if(chk==true)
		{   
			
			String lastDepositNo=obj.lastShareLoanDepositNo("Share Holder");
			Date lastDate=obj.lastShareLoanDepositNoDate(lastDepositNo, "Share Holder");
			
			if(lastDate!=null && !lastDepositNo.equals(""))
			{
				String lastDateStr=new SimpleDateFormat("dd-MMM-yyyy").format(lastDate);
				if(lastDate.after(office_date))
				{
					flag=99;
					FacesContext fc=FacesContext.getCurrentInstance();
					fc.addMessage(null, new FacesMessage("New Customer can't Register Before the Last Customer No. Date. "
													   + "Your Last Customer No. "+lastDepositNo +" Reg. Date is: "+lastDateStr));
				}
			}
		}
		
		String chkStatus=obj.columnValueByColumnNameFromFirmDetailTable("check_mobile_duplicacy",branchId,conn);
		if(chkStatus!=null && !chkStatus.trim().equalsIgnoreCase("") && chkStatus.equalsIgnoreCase("active"))
		{   
			
			
			boolean chkConct=new DataBaseAutoCompAndDuplicate().checkContactNoDuplicacy(branchId,mobile, conn);
			
			if(chkConct==true)
			{
				flag=98;
				System.out.println("flag 98");
				FacesContext fc=FacesContext.getCurrentInstance();
				fc.addMessage(null, new FacesMessage("Dear User, This Mobile No. "+mobile+" Already Register with Existing Member. "
												   + "Please Register with another mobile no. Thank you!!!"));
				 return "memberRegistration.xhtml";
			}
			
		}
		
		checkData();
		checkVoterData();
		
		if(flag==1)
		{
			int issueShare=0;
			if(paymentMode.equalsIgnoreCase("Cash"))
			{
				submittedBankName="N/A";
			}
			
			if(noOfShare>0 || shareCheck==false)
			{
				if(shareAmount>0 || shareCheck==false)
				{
					System.out.println("77");
					totalAmount= noOfShare*shareAmount;  
					int a=new DataBaseMethodsDuplicate().applicationNoDuplicacy(office_application_no);
					if(a>=1)
					{
						FacesContext fc=FacesContext.getCurrentInstance();
						fc.addMessage(null, new FacesMessage("Application No.already exists.Please check!"));
					}
					else
					{
						boolean z=new DataBaseMethodsDuplicate().shareNoDuplicacy(shareNo);
						if(z==true)
						{
							shareNo=obj.shareHolderNo(branchId);
						}
						
						if(transferCheckBox==true)
						{
							if(transferShareHolderNo.contains("/"))
							{
								transferShareHolderNo=transferShareHolderNo.substring(0, transferShareHolderNo.indexOf("/"));
							}
							boolean exist=obj.checkShareHolderExistence(transferShareHolderNo);
							if(exist==true)
							{
								transferId=obj.obtainIdOfShareHolder(transferShareHolderNo);
								boolean check=obj.checkNoOfSharesForTransfer(noOfShare,transferShareHolderNo);
								if(check==true)
								{
									FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You can not transfer "+noOfShare+" shares."));
								}
								else
								{   
									if(nominee_dob.equals(null)) {
										
										System.out.println("value of the nominee_dob :"+nominee_dob);
										
										nominee_dob=dob;
									}
									System.out.println("nominee father is:"+nomineeFather);
									issueShare=0;
									System.out.println("hit1");
									
									id=obj.addNewMemberWithTransfer(branchId,office_application_no,office_date,shareNo,first_applicantName,dob,
											father_husband_name,guardian_name,guardian_relation,status,PAN,bank_accountNo,bank_name,branch,address,mobile,
											nominee_name,nominee_relation,nominee_dob,nominee_address,applicant_photoPath,noOfShare,shareAmount,totalAmount,
											perAddress,signPath,formPath,category,transferShareHolderNo,paymentMode,bankNameCheque,chequeNo, tBill,submittedBankName,
											aadharFrontPathDoc1, doc2Path, doc3Path, doc4Path, doc5Path, issueShare,votrId, uniqueId, rationNo, dlNo, electBill,resCert,tBill,
											appCheque,gCheque,doc6Path,doc7Path,doc8Path, cityName, relation, gender, maritalStatus, keyPersonName, keyPersonRelation,
											telephoneIndicator, noOfDependent, religion, stateCode, pinCode, dsaCode, nomAadhar, nomPan, brideFhname, brideMname, brideAddress, 
											brideBusiness, brideBusinessPlace,
											brideMobileNo,brideRemark,center,nomTitle,nomGender,latitude,longitude,nomineeFather,nomineeMother,nomBankName,nomBankBranch, 
											nomAccNo,nomIfscCode,nomVoterId,nomContactNo, aadharBackPathDoc01, voterBackPathDoc03);




												if(id>=1)
												{
													DataBaseIncomeExpense db= new DataBaseIncomeExpense();
													

													if(loginFee != 0.0)
													{

													   db.addIncome(branchId,office_date,"Other_Cr",feeMode,String.valueOf(loginFee),feeTransactionNo,"",
																loginfeeBank,feeTransactionDate,"Login Fee Receive","Login Fee",0,submittedBankName,
																"0",0,office_application_no,"Personal Loan", office_application_no,"",0,"active","");
													}
													FacesContext fc=FacesContext.getCurrentInstance();
													fc.addMessage(null, new FacesMessage("Member Registered Successfully"));
													 sendMessage(conn);
													autoSavingAccountGenerate(conn);
													addMemberIncome(conn);
													boolean checkAutoTransfer=obj.checkShareAmountFromMember();
												   if(checkAutoTransfer==true)
												   {
													   autoEntrySaving(conn);
												   }
												   
													obj.updateCertificationNoOfTransferShareholder(transferId,noOfShare);
													crNo=obj.certificationNoOfNewShareHolderNoFromTransfer(transferId,noOfShare);
													obj.insertCertificationNoOfShareHolder(crNo,id);
													detailsToSet(conn);
													RequestContext.getCurrentInstance().execute("window.open('shareHolderInfoPrint.xhtml')");
													RequestContext.getCurrentInstance().execute("window.open('printFormNo4ShareHolder.xhtml')");
												    shareNo=obj.shareHolderNo(branchId);
												    companyShares=obj.checkRemainingCompanyShares();
												    
												    
												    return "mainDashBoard.xhtml";
												}
												else
												{
													FacesContext fc=FacesContext.getCurrentInstance();
													fc.addMessage(null, new FacesMessage("An Error Occured... Please Try Again"));
													
													return "";
												}
									
								}
							}
							else
							{
								FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("The Member no.from which you are trying to transfer shares, doesn't exist.Please check and try again!"));
								return "";
							}
							
							
						}
						else
						{
							// System.out.println(companyShares+"======="+noOfShare);
							if(companyShares>=noOfShare)
							{   
								issueShare=(int)noOfShare;
								System.out.println("hit2");
								System.out.println("sending doc1"+doc1Path);
								id=obj.addNewMember(branchId,office_application_no,office_date,shareNo,first_applicantName,dob,
										father_husband_name,guardian_name,guardian_relation,status,PAN,bank_accountNo,bank_name,branch,address,mobile,
										nominee_name,nominee_relation,nominee_dob,nominee_address,applicant_photoPath,noOfShare,shareAmount,totalAmount,
										perAddress,signPath,formPath,category,crNo, votrId, uniqueId, rationNo, dlNo, electBill, resCert, appCheque, gCheque,submittedBankName,
										tBill,paymentMode,bankNameCheque,chequeNo,aadharFrontPathDoc1, doc2Path, doc3Path, doc4Path, doc5Path, issueShare,conn,doc6Path,doc7Path,doc8Path,
										cityName, relation, gender, maritalStatus, keyPersonName, keyPersonRelation,
										telephoneIndicator, noOfDependent, religion, stateCode, pinCode, dsaCode,email, qualification, occupation, bankIfsc, 
										referenceBy, remark, title, monthlyIncome, nomAadhar, nomPan, brideFhname, brideMname, brideAddress, brideBusiness, brideBusinessPlace,
										brideMobileNo,brideRemark,center,nomTitle,nomGender,latitude,longitude,nomineeFather,nomineeMother,nomBankName,nomBankBranch,nomAccNo, 
										nomIfscCode,nomVoterId,nomContactNo,altContactNo, cibilScore, cibilReportPath, aadharBackPathDoc01, voterBackPathDoc03);
										if(id >= 1)
										{
											DataBaseIncomeExpense db= new DataBaseIncomeExpense();
											if(loginFee != 0.0)
											{
											   db.addIncome(branchId,office_date,"Other_Cr",feeMode,String.valueOf(loginFee),feeTransactionNo,"",
														submittedBankName,feeTransactionDate,"Login Fee Receive","Login Fee",0,loginfeeBank,
														"0",0,office_application_no,"Personal Loan", office_application_no,"",0,"active","");
											}
											FacesContext fc=FacesContext.getCurrentInstance();
											fc.addMessage(null, new FacesMessage("Member Registered Successfully"));
											sendMessage(conn);
											//System.out.println("7720");
											autoSavingAccountGenerate(conn);
											addMemberIncome(conn);
											if(shareCheck==true)
											{
												crNo=obj.shareHolderCertificationNo(noOfShare,id,"shareholder_info");
												obj.insertCertificationNoOfShareHolder(crNo,id);
											}
											
											detailsToSet(conn);
											//UserInfo user=obj.userInfoByShareHolderNo(shareNo, conn);
											if(shareCheck==true)
											{
												RequestContext.getCurrentInstance().execute("window.open('shareHolderInfoPrint.xhtml')");
											}
											
											if(paymentMode.equalsIgnoreCase("Cash"))
										    {
										    	obj.increaseCompanyCapitalAmount(branchId,totalAmount,conn);
										    }
										    
										    shareNo=obj.shareHolderNo(branchId);
										    companyShares=obj.checkRemainingCompanyShares();
										    
										    try 
										    {
												conn.close();
											}
										    catch (Exception e) 
										    {
												// TODO: handle exception
											}
										    
										    return "mainDashBoard.xhtml";
										}
										else
										{   
											FacesContext fc=FacesContext.getCurrentInstance();
											fc.addMessage(null, new FacesMessage("An Error Occured... Please Try Again"));
											
											return "";
										}
							}
							else
							{
								FacesContext fc=FacesContext.getCurrentInstance();
								fc.addMessage(null, new FacesMessage("Sorry! Company Do Not Have Sufficient Shares. Only '"+companyShares+"' Shares Are Remaining."));
								return "";
							}

						}
											
					}
				}
				else
				{
					FacesContext fc=FacesContext.getCurrentInstance();
					fc.addMessage(null, new FacesMessage("ShareAmount Must Be Greater Than Zero"));
					
					return "";
				}
			}
			else
			{
				FacesContext fc=FacesContext.getCurrentInstance();
				fc.addMessage(null, new FacesMessage("No Of Share Must Be Greater Than Zero"));
				
				return "";
			}
		}
		else
		{
			FacesContext fc=FacesContext.getCurrentInstance();
			fc.addMessage(null, new FacesMessage("Some Error Occured!!! Try again Later..."));
		}
		return "";
	}
	
	
	public void checkDuplicate(String field) {

	    duplicateContactDetails = new ArrayList<>();
	    String columnName;
	    String value;

	    if ("mobile".equals(field)) {
	        columnName = "mobile";
	        value = mobile;
	        duplicateType = "Mobile Number";

	        if (value == null || !value.matches("\\d{10}")) {
	            RequestContext.getCurrentInstance()
	                    .addCallbackParam("duplicateMobile", false);
	            return;
	        }

	    } else if ("PAN".equals(field)) {
	        columnName = "PAN";
	        value = PAN;
	        duplicateType = "PAN Number";

	        if (value == null || value.trim().isEmpty()) {
	            RequestContext.getCurrentInstance()
	                    .addCallbackParam("duplicateMobile", false);
	            return;
	        }

	    } else if ("unique_id".equals(field)) {
	        columnName = "unique_id";
	        value = uniqueId;
	        duplicateType = "Aadhaar Number";

	        if (value == null || !value.matches("\\d{12}")) {
	            RequestContext.getCurrentInstance()
	                    .addCallbackParam("duplicateMobile", false);
	            return;
	        }

	    } else {
	        RequestContext.getCurrentInstance()
	                .addCallbackParam("duplicateMobile", false);
	        return;
	    }

	    Connection conn = null;

	    try {
	        HttpSession ss = (HttpSession) FacesContext
	                .getCurrentInstance()
	                .getExternalContext().getSession(false);

	        int branchId = (int) ss.getAttribute("branchId");

	        conn = DataBaseConnection.JAVAConnection();

	        DataBaseAutoCompAndDuplicate db =
	                new DataBaseAutoCompAndDuplicate();

	        duplicateContactDetails = db.getDuplicateDetails(
	                branchId, columnName, value.trim(), conn);

	        RequestContext.getCurrentInstance().addCallbackParam(
	                "duplicateMobile",
	                !duplicateContactDetails.isEmpty());

	    } catch (Exception e) {
	        e.printStackTrace();

	        RequestContext.getCurrentInstance()
	                .addCallbackParam("duplicateMobile", false);

	    } finally {
	        try {
	            if (conn != null) {
	                conn.close();
	            }
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	    }
	}
	
	
	private void autoSavingAccountGenerate(Connection conn)
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		if(autoSaving==true)
		{
			String accountNo=obj.savingAccountNo(branchId); 
			String savingPercent=obj.checkSMessageApiDetailFromTable("saving_percent","", conn);
			int i=obj.addSavingAcount(branchId,shareNo,accountNo,office_date,0,Double.parseDouble(savingPercent),0,0,0, dsaCode,center);
		   if(i>=1)
		   {
			   RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(FacesMessage.SEVERITY_INFO, "Saving Account Detail", "Saving Account No. "+accountNo+" Auto-Generate For the Member No. "+shareNo));
		   }
		}
		 
	}
	
	private void sendMessage(Connection conn) 
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		HeaderBean hh=new HeaderBean();
		String check=obj.checkStatusInMessageSettingTable("Share Holder");
		if(check.equals("active"))
		{
			boolean isDLT = dbmt.isDLTMessageApi(conn);
			if (isDLT) 
			{
				Map<String, String> variables = new HashMap<>();
				variables.put("name", first_applicantName);
				variables.put("memberno", shareNo);
				dbmt.sendDLTMessage(mobile, null, variables, conn, "member no");
			}
			else
			{
				String typeMessage="Dear "+first_applicantName.toUpperCase()+", Thanks For Becoming Member Of "+hh.name+". Your Member No. is "+shareNo+". ";
				obj.runMessageUrl(branchId,mobile, typeMessage, userId,"1207166054380527835", conn);
			}
		}
		else
		{
			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Message For This Module is not Active. Please Go to In User Block and Active Message For This Module."));
		}
	}
	
	private void autoEntrySaving(Connection conn)
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		if(transferShareHolderNo.contains("/"))
		{
			transferShareHolderNo=transferShareHolderNo.substring(0, transferShareHolderNo.indexOf("/"));
		}
		 String accno=obj.savingAccountByShareHolderNo(transferShareHolderNo);
		 int	n = obj.userDeposit(branchId,accno, String.valueOf(totalAmount), office_date,paymentMode, chequeNo, null, "","approved",submittedBankName,
				 "Share Amount From "+shareNo, "");
		 if(n>0)
		 {
			 double preAmount=obj.acconuntHolderAmountByAccountNo(accno);
			 Double newAmount=preAmount+totalAmount;
			 obj.updateSavingAmountByAccountNo(accno,newAmount);
			 obj.increaseCompanyCapitalAmount(branchId,totalAmount,conn);
		 }
	}
	
	private void addMemberIncome(Connection conn) 
	{
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		int branchId =(int) ss.getAttribute("branchId");
		if(membershipFees>0)
		{
			
			//String desc="Membership Fees From "+shareNo+" - "+first_applicantName;
			HeaderBean ff = new HeaderBean();
			String voucherNo=obj.generateVoucherNo(branchId,"income_table",conn);
			 int i=new DataBaseIncomeExpense().addIncome(branchId,office_date,"Other_Cr",paymentMode,String.valueOf(membershipFees) ,chequeNo,"",
						"",office_date,ff.getName(),"Membership Fees",0,submittedBankName,
						"0",0,shareNo,"", voucherNo,"",0,"active",""); 
				if(i>=1)
				{
					obj.increaseCompanyCapitalAmount(branchId,membershipFees, conn);
					ss.setAttribute("voucherNo", voucherNo);
					ss.setAttribute("expDate", office_date);
					ss.setAttribute("amount", String.valueOf(membershipFees));
					ss.setAttribute("vchtype", "Credit");
					ss.setAttribute("payTo", ff.getName());
					ss.setAttribute("being", "Membership Fees From "+shareNo+" - "+first_applicantName);
					ss.setAttribute("payMode", paymentMode);

					
					RequestContext.getCurrentInstance().execute("window.open('printVoucher.xhtml')");
				}
		}
	   
	}
	public void detailsToSet(Connection conn)
	{
		String transferShareHolderName=obj.shareHolderNameByShareHolderNo(transferShareHolderNo, conn);
		HttpSession ss=(HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		ss.setAttribute("shareHolderNo",shareNo);
		ss.setAttribute("office_date",office_date);
		ss.setAttribute("first_applicantName",first_applicantName);
		ss.setAttribute("dob",dob);
		ss.setAttribute("address",address);
		ss.setAttribute("nominee_address",nominee_address);
		ss.setAttribute("nominee_name",nominee_name);
		ss.setAttribute("nominee_dob",nominee_dob);
		ss.setAttribute("nominee_relation",nominee_relation);
		ss.setAttribute("noOfShare",noOfShare);
		ss.setAttribute("shareAmount",shareAmount);
		ss.setAttribute("id", id);
		ss.setAttribute("crNo", crNo);
		ss.setAttribute("transferNo", transferShareHolderNo);
		ss.setAttribute("transferName", transferShareHolderName);
		ss.setAttribute("fatherName", father_husband_name);
	}
	
	public void checkPaymentModeforFee()
	{
		if(feeMode.equalsIgnoreCase("online"))
		{
			showFee =true;
		}
		else
		{
			showFee = false;
		}
	}
	
	
	public void sendOtp() throws Exception 
	{	
	    System.out.println("STEP 1: Method started");

	    System.out.println("STEP 2: Creating UrlInfoBean()");
	    UrlInfoBean urlInfoBean = new UrlInfoBean();

	    System.out.println("STEP 3: Getting clientName");
	    String client = urlInfoBean.getClientName();
	    System.out.println("client = " + client);

	    if (client == null || client.isEmpty()) 
	    {
	        return;      
	    }

	    System.out.println("STEP 5: Calling AadhaarApiClient");
	    AadhaarApiClient so = new AadhaarApiClient();
	    JsonObject response = so.callAadhaarApi(aadhaarNumber, client, "101");
	    System.out.println("response = " + response);

	    System.out.println("STEP 6: Parsing response");
	    JsonObject firstItem = response.getAsJsonArray("track").get(0).getAsJsonObject();
	   
	    String message = so.getSafeString(firstItem, "message");
	    
	    boolean status = firstItem.get("Status").getAsBoolean();
	    
	    
	    
	    if (status) 
	    {
//	    	this.disAadhaar = false;
	        this.showOtp = true;
	 		this.showOtpButton = false;
	        System.out.println("Status true → getting requestId");
	        requestId = so.getSafeString(firstItem, "requestId");
	        System.out.println("RequestId: " + requestId);
	    }

	    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message));	   
	}
	
	
	
	public void validateOtp(FacesContext context, UIComponent component, Object value) throws ValidatorException 
	{
	    String otpValue = (String) value;
	    
	    if (otpValue == null || otpValue.isEmpty()) 
	    {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                "OTP cannot be empty!", null));
	    }
	    
	    if (!otpValue.matches("\\d+")) 
	    {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                "OTP must contain only digits!", null));
	    }

	    if (otpValue.length() < 4 || otpValue.length() > 6) 
	    {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                "OTP must be between 4 and 6 digits!", null));
	    }
	}
	
	
	
	public void validateAadhaar(FacesContext context, UIComponent component, Object value) throws ValidatorException 
	{
	    String aadhaarValue = (String) value;

	    if (aadhaarValue == null || aadhaarValue.isEmpty()) 
	    {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                "Aadhaar number cannot be empty!", null));
	    }

	    if (!aadhaarValue.matches("\\d+")) 
	    {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                "Aadhaar number must contain only digits!", null));
	    }

	    if (aadhaarValue.length() != 12) 
	    {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                "Aadhaar number must be exactly 12 digits!", null));
	    }
	}
	
	
	
	public void verifyOtp() 
	{	
		AadhaarOtpApiClient op = new AadhaarOtpApiClient();
        String requestId = this.requestId;  
        String otp       = this.otp;    
        String message   = null;
        AadhaarOtpResult result = null;
		
        System.out.println(requestId + "---------" + otp + "---------" + aadhaarNumber);
        
        try
        {
			result = op.verifyOtp(requestId, otp, aadhaarNumber);
		} 
        catch (Exception e) 
        {
			e.printStackTrace();
		}
        
        System.out.println("Status: " + result.status);
        
        message = result.message;
        if (result.status)
        {
        	 this.first_applicantName = result.name;
	         this.gender = result.gender;
	         this.address = result.fullAddress;
	         this.perAddress = result.fullAddress;
	         this.applicant_photoPath = result.imageUrl;
	         this.father_husband_name = result.careOf;
	         this.showOtp = false;
	         
	         SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
	         try
	         {
	        	 String dobDate = result.dob;
	        	 if (dobDate != null && !dobDate.trim().isEmpty())
	        	 {
	        		    dob = sdf.parse(dobDate);
	        		    ageCal();
	        	 }
	         } 
	         catch (ParseException e) 
	         {
	        	 e.printStackTrace();
	         }
	         
	         this.aadhaarVerified = true;
	         this.uniqueId = this.aadhaarNumber;
	         
	         System.out.println("Name :    " + result.name);
	         System.out.println("Father :  " + result.careOf);
	         System.out.println("Aadhaar : " + result.aadhaarNumber);
	         System.out.println("DOB :     " + result.dob);
	         System.out.println("Gender :  " + result.gender);
	         System.out.println("Address : " + result.fullAddress);
	         System.out.println("Image :   " + (result.imageUrl == null ? null : result.imageUrl));
	         
//	         RequestContext.getCurrentInstance()
//             .execute("PF('aadhaarDlg').hide();");
        }
        else 
        {
        	System.out.println("Error Message: " + result.message);
        }
        
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message));
	}
	
	
	
	public void verifyPan() 
	{
		System.out.println("PAN : " + PAN);
		
		PanApiClient pc = new PanApiClient();
		JsonObject response = null;
		  
		System.out.println("STEP 1: Method started");

		System.out.println("STEP 2: Creating UrlInfoBean()");
		UrlInfoBean urlInfoBean = new UrlInfoBean();

		System.out.println("STEP 3: Getting clientName");
		String client = urlInfoBean.getClientName();
		System.out.println("client = " + client);

		if (client == null || client.isEmpty()) 
		{
			return; 
		}
		    
		try 
		{
			response = pc.callPanApi(PAN,client , "101");
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
		}
	        
		JsonObject firstItem = response.getAsJsonArray("track").get(0).getAsJsonObject();
    
		boolean status = firstItem.get("status").getAsBoolean();
		System.out.println("Status: " + status);
	        
        if (status) 
        {
            String panHolderName = pc.getSafeString(firstItem, "panHolderName");
            String panNumber = pc.getSafeString(firstItem, "panNumber");
            String panCategory = pc.getSafeString(firstItem, "panCategory");
            String message = pc.getSafeString(firstItem, "message");
            
            this.panHolderName = panHolderName;
            this.PAN = panNumber;
            this.panCategory = panCategory;
            this.message = message;
            
            this.showPan = true;
//	    	this.showResult=true;
    		
//    		RequestContext.getCurrentInstance()
//              .execute("PF('panDlg').hide();");
        }
        else 
        {
            String message = pc.getSafeString(firstItem, "message");
            this.message = message;   
        }
        
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message));
		
		if (first_applicantName != null && !first_applicantName.trim().isEmpty() &&
			panHolderName != null && !panHolderName.trim().isEmpty() &&
			!first_applicantName.equalsIgnoreCase(panHolderName)) 
		{
			this.showPan = false;
			
			FacesContext.getCurrentInstance().addMessage(null,
			        new FacesMessage(
			            FacesMessage.SEVERITY_WARN,
			            "Name Mismatch",
			            "The name on the Aadhaar and PAN records does not match. Please verify the customer's details."
			        )
			    );
			}
	}
	
	
	
	public void validatePan(FacesContext context, UIComponent component, Object value) throws ValidatorException 
	{
	    String panValue = (String) value;

	    if (panValue == null || panValue.trim().isEmpty()) 
	    {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                "PAN number cannot be empty!", null));
	    }
	    
	    String panRegex = "[A-Z]{5}[0-9]{4}[A-Z]{1}";

	    if (!panValue.toUpperCase().matches(panRegex)) 
	    {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                "Invalid PAN format! Example: ABCDE1234F", null));
	    }
	}
	
	
	
	public void checkCibilReportType()
	{
		if (reportType.equalsIgnoreCase("score")) 
		{
			fetchCibilScore();
		}
		else
		{
			verifyCibil();
		}
	}
	
	
	
	public void fetchCibilScore()
	{
	    try
	    {
	        System.out.println("======================================");
	        System.out.println("CIBIL SCORE FETCHING STARTED");
	        System.out.println("======================================");

	        System.out.println("First Name : " + firstName);
	        System.out.println("Mobile     : " + mobile);
	        System.out.println("Consent    : " + consent);

	        CibilApiClient cc = new CibilApiClient();

	        JsonObject response = null;

	        try
	        {
	            response = cc.callCibilApi(firstName, lastName, mobile, "", "", "y", reportType);
	        }
	        catch (Exception e)
	        {
	            e.printStackTrace();

	            showCibil = false;
	            cibilStatus = "Failed";
	            cibilMessage = "Unable to connect to CIBIL API.";

	            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(
	                            FacesMessage.SEVERITY_ERROR,
	                            "CIBIL API Error",
	                            "Unable to connect to CIBIL API."
	                    )
	            );

	            return;
	        }

	        System.out.println("CIBIL Response:");
	        System.out.println(response);

	        // API returned no response
	        if (response == null)
	        {
	            showCibil = false;

	            cibilStatus = "Failed";
	            cibilMessage = "No response received from CIBIL API.";

	            FacesContext.getCurrentInstance().addMessage(
	                    null,
	                    new FacesMessage(
	                            FacesMessage.SEVERITY_ERROR,
	                            "CIBIL Verification Failed",
	                            "No response received from CIBIL API."
	                    )
	            );

	            return;
	        }

	        // Check top-level success
	        boolean success = response.has("success")
	                && !response.get("success").isJsonNull()
	                && response.get("success").getAsBoolean();

	        String apiMessage = cc.getSafeString(response, "message");

	        System.out.println("CIBIL Success : " + success);
	        System.out.println("CIBIL Message : " + apiMessage);

	        // ==========================================
	        // FAILED RESPONSE
	        // ==========================================

	        if (!success)
	        {
	            showCibil = false;
	            cibilStatus = "Failed";

	            String errorMessage = apiMessage;

	            // API sends the actual error inside the "message" JSON string
	            try
	            {
	                if (apiMessage != null
	                        && !apiMessage.trim().isEmpty()
	                        && apiMessage.trim().startsWith("{"))
	                {
	                    JsonObject errorObject =
	                            new com.google.gson.JsonParser()
	                                    .parse(apiMessage)
	                                    .getAsJsonObject();

	                    String nestedMessage =
	                            cc.getSafeString(errorObject, "message");

	                    if (nestedMessage != null
	                            && !nestedMessage.trim().isEmpty())
	                    {
	                        errorMessage = nestedMessage;
	                    }
	                }
	            }
	            catch (Exception ex)
	            {
	                System.out.println(
	                        "Unable to parse nested CIBIL error message: "
	                                + ex.getMessage()
	                );
	            }

	            // Final fallback
	            if (errorMessage == null
	                    || errorMessage.trim().isEmpty())
	            {
	                errorMessage = "Unable to fetch CIBIL score.";
	            }

	            cibilMessage = errorMessage;

	            System.out.println("CIBIL Final Error Message : " + errorMessage);

	            FacesContext.getCurrentInstance().addMessage(
	                    null,
	                    new FacesMessage(
	                            "CIBIL Verification " +
	                            errorMessage
	                    )
	            );

	            return;
	        }

	        // ==========================================
	        // SUCCESS RESPONSE
	        // ==========================================

	        JsonObject data = null;

	        if (response.has("data")
	                && !response.get("data").isJsonNull()
	                && response.get("data").isJsonObject())
	        {
	            data = response.getAsJsonObject("data");
	        }

	        if (data == null)
	        {
	            showCibil = false;

	            cibilStatus = "Failed";
	            cibilMessage = "CIBIL data was not received.";

	            FacesContext.getCurrentInstance().addMessage(
	                    null,
	                    new FacesMessage(
	                            "CIBIL Verification Failed " + " CIBIL data was not received."
	                    )
	            );

	            return;
	        }

	        // ==========================================
	        // READ ACTUAL API FIELDS
	        // ==========================================

	        cibilClientId =
	                cc.getSafeString(data, "transactionId");

	        cibilScore =
	                cc.getSafeString(data, "creditScore");

	        String dataStatus =
	                cc.getSafeString(data, "status");

	        String dataMessage =
	                cc.getSafeString(data, "message");

	        System.out.println("CIBIL Transaction ID : " + cibilClientId);
	        System.out.println("CIBIL Score          : " + cibilScore);
	        System.out.println("CIBIL Status         : " + dataStatus);
	        System.out.println("CIBIL Message        : " + dataMessage);

	        // Validate score
	        if (cibilScore == null || cibilScore.trim().isEmpty())
	        {
	            showCibil = false;

	            cibilStatus = "Failed";
	            cibilMessage = "CIBIL score was not received.";

	            FacesContext.getCurrentInstance().addMessage(
	                    null,
	                    new FacesMessage(
	                            "CIBIL Verification Failed " + " CIBIL score was not received."
	                    )
	            );

	            return;
	        }

	        // ==========================================
	        // SUCCESS
	        // ==========================================

	        cibilStatus = "Verified";

	        if (dataMessage != null && !dataMessage.trim().isEmpty())
	        {
	            cibilMessage = dataMessage;
	        }
	        else
	        {
	            cibilMessage = apiMessage;
	        }

	        showCibil = true;

	        FacesContext.getCurrentInstance().addMessage(
	                null,
	                new FacesMessage(
	                        "CIBIL Verification " + " CIBIL report fetched successfully. Score: "
	                                + cibilScore
	                )
	        );

	        System.out.println("======================================");
	        System.out.println("CIBIL VERIFICATION SUCCESS");
	        System.out.println("======================================");
	    }
	    catch (Exception e)
	    {
	        e.printStackTrace();

	        showCibil = false;

	        cibilStatus = "Failed";
	        cibilMessage = e.getMessage();

	        FacesContext.getCurrentInstance().addMessage(
	                null,
	                new FacesMessage(
	                        "CIBIL API Error " + e.getMessage()
	                )
	        );
	    }
	}
	
	
	
	public void verifyCibil()
	{
	    System.out.println("======================================");
	    System.out.println("CIBIL VERIFICATION STARTED");
	    System.out.println("======================================");

	    System.out.println("First Name : " + firstName);
	    System.out.println("First Name : " + lastName);
	    System.out.println("Mobile     : " + mobile);
	    System.out.println("PAN        : " + PAN);
	    System.out.println("Aadhaar    : " + aadhaarNumber);
	    System.out.println("Consent    : " + consent);
	    
	    try
	    {
	        if (mobile == null || mobile.trim().isEmpty())
	        {
	            FacesContext.getCurrentInstance().addMessage(null, 
	            		new FacesMessage(FacesMessage.SEVERITY_WARN, "Mobile number is required.", null));
	            return;
	        }
	        
	        if ((PAN == null || PAN.trim().isEmpty()) && (aadhaarNumber == null || aadhaarNumber.trim().isEmpty())) 
	        {
	        	    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Please Enter Aadhar or PAN"));
	        	    return;
	        }
	        else 
	        {
	        	aadhaarNumber = "";
			}
	        
	        if (consent.equalsIgnoreCase("n")) 
	        {
	        	FacesContext.getCurrentInstance().addMessage(null, 
	        										new FacesMessage("Please Provide Consent to Fetch Cibil Report"));
	        	return;
			}

	        System.out.println("First Name Sent : " + firstName);
	        System.out.println("Last Name Sent  : " + lastName);

	        String panNumber = PAN == null ? "" : PAN.trim();
	        String aadhaar = aadhaarNumber.trim();
	        String mobileNumber = mobile.trim();
            
	        CibilApiClient cc = new CibilApiClient();
	        JsonObject response = cc.callCibilApi(firstName, lastName, mobileNumber, panNumber, aadhaar, "y", reportType);
            
	        System.out.println("CIBIL Response:");
	        System.out.println(response);
            
	        boolean success = response.has("success") && !response.get("success").isJsonNull() 
	        										  && response.get("success").getAsBoolean();

	        String apiMessage = cc.getSafeString(response, "message");

	        System.out.println("CIBIL Success : " + success);
	        System.out.println("CIBIL Message : " + apiMessage);


	        if (!success)
	        {
	            showCibil = false;

	            cibilStatus = "Failed";
	            cibilMessage = apiMessage;

	            FacesContext.getCurrentInstance().addMessage(null,
	                    				new FacesMessage("CIBIL Verification Failed " + apiMessage));
	            return;
	        }

	        JsonObject data = response.getAsJsonObject("data");

	        if (data == null)
	        {
	            showCibil = false;

	            cibilStatus = "Failed";
	            cibilMessage = "CIBIL data was not received.";

	            FacesContext.getCurrentInstance().addMessage(null,
	                    new FacesMessage("CIBIL Verification Failed CIBIL data was not received."));
	            return;
	        }

	        cibilClientId = cc.getSafeString(data, "client_id");
	        cibilScore = cc.getSafeString(data, "credit_score");
	        cibilReportLink = cc.getSafeString(data, "credit_report_link");

	        cibilStatus = "Verified";
	        cibilMessage = apiMessage;

	        System.out.println("CIBIL Client ID : " + cibilClientId);
	        System.out.println("CIBIL Score     : " + cibilScore);
	        System.out.println("CIBIL PDF       : " + cibilReportLink);

	        if (cibilReportLink == null || cibilReportLink.trim().isEmpty())
	        {
	            showCibil = false;

	            cibilStatus = "Failed";
	            cibilMessage = "CIBIL report link was not received.";

	            FacesContext.getCurrentInstance().addMessage(null,
	                    new FacesMessage("CIBIL Verification Failed CIBIL report link was not received."));
	            return;
	        }

	        showCibil = true;

	        FacesContext.getCurrentInstance().addMessage(null,
	                new FacesMessage(FacesMessage.SEVERITY_INFO, "CIBIL Verification", 
	                											 "CIBIL report fetched successfully. Score: " + cibilScore));

	        System.out.println("======================================");
	        System.out.println("CIBIL VERIFICATION SUCCESS");
	        System.out.println("======================================");
	        
	        cibilReportPath = downloadAndSavePdf(cibilReportLink);
	    }
	    catch (Exception e)
	    {
	        e.printStackTrace();

	        showCibil = false;

	        cibilStatus = "Failed";
	        cibilMessage = e.getMessage();


	        FacesContext.getCurrentInstance().addMessage(null,
	                new FacesMessage(FacesMessage.SEVERITY_ERROR, "CIBIL API Error", e.getMessage()));
	    }
	}
	
	
	
	public String downloadAndSavePdf(String pdfUrl)
	{
	    if (pdfUrl == null || pdfUrl.trim().isEmpty())
	    {
	        System.err.println("PDF URL is null or empty.");
	        return null;
	    }

	    HttpURLConnection conn = null;

	    try
	    {
	        URL url = new URL(pdfUrl);

	        conn = (HttpURLConnection) url.openConnection();
	        conn.setRequestMethod("GET");
	        conn.setConnectTimeout(30000);
	        conn.setReadTimeout(60000);

	        conn.setRequestProperty("Accept", "application/pdf, application/octet-stream, */*");

	        int responseCode = conn.getResponseCode();

	        System.out.println("PDF HTTP Response Code: " + responseCode);

	        if (responseCode != HttpURLConnection.HTTP_OK)
	        {
	            throw new Exception("PDF download failed. HTTP Response Code: " + responseCode);
	        }

	        String contentType = conn.getContentType();

	        System.out.println("PDF Content-Type: " + contentType);

	        byte[] pdfBytes;

	        try (InputStream in = conn.getInputStream();
	             ByteArrayOutputStream baos = new ByteArrayOutputStream())
	        {
	            byte[] buffer = new byte[8192];

	            int bytesRead;

	            while ((bytesRead = in.read(buffer)) != -1)
	            {
	                baos.write(buffer, 0, bytesRead);
	            }

	            pdfBytes = baos.toByteArray();
	        }

	        if (pdfBytes.length == 0)
	        {
	            throw new Exception("Downloaded PDF is empty.");
	        }

	        boolean isPdf = false;

	        if (pdfBytes.length >= 5)
	        {
	            String pdfHeader = new String(pdfBytes, 0, 5, StandardCharsets.US_ASCII);

	            System.out.println("PDF Header: " + pdfHeader);

	            if ("%PDF-".equals(pdfHeader))
	            {
	                isPdf = true;
	            }
	        }

	        if (!isPdf)
	        {
	            throw new Exception("Downloaded content is not a valid PDF. " + "Content-Type: " + contentType);
	        }

	        String serverPath = dbmt.filePathDetail();

	        System.out.println("CIBIL Save Directory: " + serverPath);

	        if (serverPath == null || serverPath.trim().isEmpty())
	        {
	            throw new Exception("File path returned by filePathDetail() is empty.");
	        }

	        File directory = new File(serverPath);

	        if (!directory.exists())
	        {
	            if (!directory.mkdirs())
	            {
	                throw new Exception("Unable to create directory: " + serverPath);
	            }
	        }

	        String fileName = "cibil_" + UUID.randomUUID().toString() + ".pdf";

	        File pdfFile = new File(directory, fileName);

	        try (OutputStream out = new FileOutputStream(pdfFile))
	        {
	            out.write(pdfBytes);
	            out.flush();
	        }

	        System.out.println("CIBIL PDF saved successfully.");

	        System.out.println("File Path: " + pdfFile.getAbsolutePath());

	        return pdfFile.getAbsolutePath();
	    }
	    catch (Exception e)
	    {
	        e.printStackTrace();

	        System.err.println("Failed to download & save PDF: " + e.getMessage());

	        new DataBaseMethods().fileCreation(e.getMessage());

	        return null;
	    }
	    finally
	    {
	        if (conn != null)
	        {
	            conn.disconnect();
	        }
	    }
	}

	public String getOffice_application_no() {
		return office_application_no;
	}
	public void setOffice_application_no(String office_application_no) {
		this.office_application_no = office_application_no;
	}
	public String getShareNo() {
		return shareNo;
	}
	public void setShareNo(String shareNo) {
		this.shareNo = shareNo;
	}
	public String getFirst_applicantName() {
		return first_applicantName;
	}
	public void setFirst_applicantName(String first_applicantName) {
		this.first_applicantName = first_applicantName;
	}
	public String getFather_husband_name() {
		return father_husband_name;
	}
	public void setFather_husband_name(String father_husband_name) {
		this.father_husband_name = father_husband_name;
	}
	public String getGuardian_name() {
		return guardian_name;
	}
	public void setGuardian_name(String guardian_name) {
		this.guardian_name = guardian_name;
	}
	public String getGuardian_relation() {
		return guardian_relation;
	}
	public void setGuardian_relation(String guardian_relation) {
		this.guardian_relation = guardian_relation;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getPAN() {
		return PAN;
	}
	public void setPAN(String pAN) {
		PAN = pAN;
	}
	public String getBank_accountNo() {
		return bank_accountNo;
	}
	public void setBank_accountNo(String bank_accountNo) {
		this.bank_accountNo = bank_accountNo;
	}
	public String getBank_name() {
		return bank_name;
	}
	public void setBank_name(String bank_name) {
		this.bank_name = bank_name;
	}
	public String getBranch() {
		return branch;
	}
	public void setBranch(String branch) {
		this.branch = branch;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getNominee_name() {
		return nominee_name;
	}
	public void setNominee_name(String nominee_name) {
		this.nominee_name = nominee_name;
	}
	public String getNominee_relation() {
		return nominee_relation;
	}
	public void setNominee_relation(String nominee_relation) {
		this.nominee_relation = nominee_relation;
	}
	public String getNominee_address() {
		return nominee_address;
	}
	public void setNominee_address(String nominee_address) {
		this.nominee_address = nominee_address;
	}
	public String getAccount_status() {
		return account_status;
	}
	public void setAccount_status(String account_status) {
		this.account_status = account_status;
	}
	public String getApplicant_photoPath() {
		return applicant_photoPath;
	}
	public void setApplicant_photoPath(String applicant_photoPath) {
		this.applicant_photoPath = applicant_photoPath;
	}
	public UploadedFile getApplicant_photo() {
		return applicant_photo;
	}
	public void setApplicant_photo(UploadedFile applicant_photo) {
		this.applicant_photo = applicant_photo;
	}
	public double getNoOfShare() {
		return noOfShare;
	}
	public void setNoOfShare(double noOfShare) {
		this.noOfShare = noOfShare;
	}
	public double getShareAmount() {
		return shareAmount;
	}
	public void setShareAmount(double shareAmount) {
		this.shareAmount = shareAmount;
	}
	public double getTotalAmount() {
		return totalAmount;
	}
	public void setTotalAmount(double totalAmount) {
		this.totalAmount = totalAmount;
	}
	public Date getOffice_date() {
		return office_date;
	}
	public void setOffice_date(Date office_date) {
		this.office_date = office_date;
	}
	public Date getApplication_date() {
		return application_date;
	}
	public void setApplication_date(Date application_date) {
		this.application_date = application_date;
	}
	public Date getDob() {
		return dob;
	}
	public void setDob(Date dob) {
		this.dob = dob;
	}
	public Date getNominee_dob() {
		return nominee_dob;
	}
	public void setNominee_dob(Date nominee_dob) {
		this.nominee_dob = nominee_dob;
	}
	public String getPerAddress() {
		return perAddress;
	}
	public void setPerAddress(String perAddress) {
		this.perAddress = perAddress;
	}
	public UploadedFile getSignPhoto() {
		return signPhoto;
	}
	public void setSignPhoto(UploadedFile signPhoto) {
		this.signPhoto = signPhoto;
	}
	public UploadedFile getFormPhoto() {
		return formPhoto;
	}
	public void setFormPhoto(UploadedFile formPhoto) {
		this.formPhoto = formPhoto;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	public String getSignPath() {
		return signPath;
	}
	public void setSignPath(String signPath) {
		this.signPath = signPath;
	}
	public String getFormPath() {
		return formPath;
	}
	public void setFormPath(String formPath) {
		this.formPath = formPath;
	}
	public ArrayList<SelectItem> getCategoryList() {
		return categoryList;
	}
	public void setCategoryList(ArrayList<SelectItem> categoryList) {
		this.categoryList = categoryList;
	}
	public boolean isDisableAdd() {
		return disableAdd;
	}
	public void setDisableAdd(boolean disableAdd) {
		this.disableAdd = disableAdd;
	}
	public boolean isCheckBox() {
		return checkBox;
	}
	public void setCheckBox(boolean checkBox) {
		this.checkBox = checkBox;
	}

	public double getCompanyShares() {
		return companyShares;
	}

	public UploadedFile getDoc6photo() {
		return doc6photo;
	}

	public void setDoc6photo(UploadedFile doc6photo) {
		this.doc6photo = doc6photo;
	}

	public UploadedFile getDoc7photo() {
		return doc7photo;
	}

	public void setDoc7photo(UploadedFile doc7photo) {
		this.doc7photo = doc7photo;
	}

	public UploadedFile getDoc8photo() {
		return doc8photo;
	}

	public void setDoc8photo(UploadedFile doc8photo) {
		this.doc8photo = doc8photo;
	}

	public void setCompanyShares(double companyShares) {
		this.companyShares = companyShares;
	}

	public String getTransferShareHolderNo() {
		return transferShareHolderNo;
	}

	public void setTransferShareHolderNo(String transferShareHolderNo) {
		this.transferShareHolderNo = transferShareHolderNo;
	}

	public String getPaymentMode() {
		return paymentMode;
	}

	public void setPaymentMode(String paymentMode) {
		this.paymentMode = paymentMode;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getBankNameCheque() {
		return bankNameCheque;
	}

	public void setBankNameCheque(String bankNameCheque) {
		this.bankNameCheque = bankNameCheque;
	}

	public String getChequeNo() {
		return chequeNo;
	}

	public void setChequeNo(String chequeNo) {
		this.chequeNo = chequeNo;
	}

	public boolean isTransferCheckBox() {
		return transferCheckBox;
	}

	public void setTransferCheckBox(boolean transferCheckBox) {
		this.transferCheckBox = transferCheckBox;
	}

	public boolean isShowTransferFields() {
		return showTransferFields;
	}

	public void setShowTransferFields(boolean showTransferFields) {
		this.showTransferFields = showTransferFields;
	}

	public boolean isShowCheque() {
		return showCheque;
	}

	public void setShowCheque(boolean showCheque) {
		this.showCheque = showCheque;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getCrNo() {
		return crNo;
	}

	public void setCrNo(String crNo) {
		this.crNo = crNo;
	}

	public int getTransferId() {
		return transferId;
	}

	public void setTransferId(int transferId) {
		this.transferId = transferId;
	}

	public String getVotrId() {
		return votrId;
	}

	public void setVotrId(String votrId) {
		this.votrId = votrId;
	}
	
	

	public String getSubmittedBankName() {
		return submittedBankName;
	}

	public void setSubmittedBankName(String submittedBankName) {
		this.submittedBankName = submittedBankName;
	}

	public ArrayList<SelectItem> getBankList() {
		return bankList;
	}

	public void setBankList(ArrayList<SelectItem> bankList) {
		this.bankList = bankList;
	}

	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}

	public String getDlNo() {
		return dlNo;
	}

	public void setDlNo(String dlNo) {
		this.dlNo = dlNo;
	}

	public String getRationNo() {
		return rationNo;
	}

	public void setRationNo(String rationNo) {
		this.rationNo = rationNo;
	}

	public String getResCert() {
		return resCert;
	}

	public void setResCert(String resCert) {
		this.resCert = resCert;
	}

	public String getElectBill() {
		return electBill;
	}

	public void setElectBill(String electBill) {
		this.electBill = electBill;
	}

	public String getAppCheque() {
		return appCheque;
	}

	public void setAppCheque(String appCheque) {
		this.appCheque = appCheque;
	}

	public String getgCheque() {
		return gCheque;
	}

	public void setgCheque(String gCheque) {
		this.gCheque = gCheque;
	}

	public String gettBill() {
		return tBill;
	}

	public void settBill(String tBill) {
		this.tBill = tBill;
	}

	public UploadedFile getDoc1photo() {
		return doc1photo;
	}

	public void setDoc1photo(UploadedFile doc1photo) {
		this.doc1photo = doc1photo;
	}

	public UploadedFile getDoc2photo() {
		return doc2photo;
	}

	public void setDoc2photo(UploadedFile doc2photo) {
		this.doc2photo = doc2photo;
	}

	public UploadedFile getDoc3photo() {
		return doc3photo;
	}

	public void setDoc3photo(UploadedFile doc3photo) {
		this.doc3photo = doc3photo;
	}

	public UploadedFile getDoc4photo() {
		return doc4photo;
	}

	public void setDoc4photo(UploadedFile doc4photo) {
		this.doc4photo = doc4photo;
	}

	public UploadedFile getDoc5photo() {
		return doc5photo;
	}

	public void setDoc5photo(UploadedFile doc5photo) {
		this.doc5photo = doc5photo;
	}

	public String getDoc1Path() {
		return doc1Path;
	}

	public void setDoc1Path(String doc1Path) {
		this.doc1Path = doc1Path;
	}

	public String getDoc2Path() {
		return doc2Path;
	}

	public void setDoc2Path(String doc2Path) {
		this.doc2Path = doc2Path;
	}

	public String getDoc3Path() {
		return doc3Path;
	}

	public void setDoc3Path(String doc3Path) {
		this.doc3Path = doc3Path;
	}

	public String getDoc4Path() {
		return doc4Path;
	}

	public void setDoc4Path(String doc4Path) {
		this.doc4Path = doc4Path;
	}

	public String getDoc5Path() {
		return doc5Path;
	}

	public void setDoc5Path(String doc5Path) {
		this.doc5Path = doc5Path;
	}

	public boolean isShowAutoBtn() {
		return showAutoBtn;
	}

	public void setShowAutoBtn(boolean showAutoBtn) {
		this.showAutoBtn = showAutoBtn;
	}

	public boolean isShowRegBtn() {
		return showRegBtn;
	}

	public void setShowRegBtn(boolean showRegBtn) {
		this.showRegBtn = showRegBtn;
	}

	public boolean isRenderPayMode() {
		return renderPayMode;
	}

	public void setRenderPayMode(boolean renderPayMode) {
		this.renderPayMode = renderPayMode;
	}

	public String getConfirmDetailMsg() {
		return confirmDetailMsg;
	}

	public void setConfirmDetailMsg(String confirmDetailMsg) {
		this.confirmDetailMsg = confirmDetailMsg;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public boolean isSkip() {
		return skip;
	}

	public void setSkip(boolean skip) {
		this.skip = skip;
	}

	public String getRelation() {
		return relation;
	}

	public void setRelation(String relation) {
		this.relation = relation;
	}

	public String getDobInWord() {
		return dobInWord;
	}

	public void setDobInWord(String dobInWord) {
		this.dobInWord = dobInWord;
	}

	public boolean isShareCheck() {
		return shareCheck;
	}

	public void setShareCheck(boolean shareCheck) {
		this.shareCheck = shareCheck;
	}

	public boolean isAutoSaving() {
		return autoSaving;
	}

	public void setAutoSaving(boolean autoSaving) {
		this.autoSaving = autoSaving;
	}

	public DataBaseMethods getObj() {
		return obj;
	}

	public void setObj(DataBaseMethods obj) {
		this.obj = obj;
	}

	public ArrayList<SelectItem> getMaritalStatusList() {
		return maritalStatusList;
	}

	public void setMaritalStatusList(ArrayList<SelectItem> maritalStatusList) {
		this.maritalStatusList = maritalStatusList;
	}

	public ArrayList<SelectItem> getRelationList() {
		return relationList;
	}

	public void setRelationList(ArrayList<SelectItem> relationList) {
		this.relationList = relationList;
	}

	public ArrayList<SelectItem> getTelephoneIndicatorList() {
		return telephoneIndicatorList;
	}

	public void setTelephoneIndicatorList(
			ArrayList<SelectItem> telephoneIndicatorList) {
		this.telephoneIndicatorList = telephoneIndicatorList;
	}

	public ArrayList<SelectItem> getReligionList() {
		return religionList;
	}

	public void setReligionList(ArrayList<SelectItem> religionList) {
		this.religionList = religionList;
	}

	public ArrayList<SelectItem> getStateCodeList() {
		return stateCodeList;
	}

	public void setStateCodeList(ArrayList<SelectItem> stateCodeList) {
		this.stateCodeList = stateCodeList;
	}

	public static List<String> getList() {
		return list;
	}

	public static void setList(List<String> list) {
		MemberRegistrationBean.list = list;
	}

	public int getNoOfDependent() {
		return noOfDependent;
	}

	public void setNoOfDependent(int noOfDependent) {
		this.noOfDependent = noOfDependent;
	}

	public String getDoc6Path() {
		return doc6Path;
	}

	public void setDoc6Path(String doc6Path) {
		this.doc6Path = doc6Path;
	}

	public String getDoc7Path() {
		return doc7Path;
	}

	public void setDoc7Path(String doc7Path) {
		this.doc7Path = doc7Path;
	}

	public String getDoc8Path() {
		return doc8Path;
	}

	public void setDoc8Path(String doc8Path) {
		this.doc8Path = doc8Path;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getMaritalStatus() {
		return maritalStatus;
	}

	public void setMaritalStatus(String maritalStatus) {
		this.maritalStatus = maritalStatus;
	}

	public String getKeyPersonName() {
		return keyPersonName;
	}

	public void setKeyPersonName(String keyPersonName) {
		this.keyPersonName = keyPersonName;
	}

	public String getKeyPersonRelation() {
		return keyPersonRelation;
	}

	public void setKeyPersonRelation(String keyPersonRelation) {
		this.keyPersonRelation = keyPersonRelation;
	}

	public String getTelephoneIndicator() {
		return telephoneIndicator;
	}

	public void setTelephoneIndicator(String telephoneIndicator) {
		this.telephoneIndicator = telephoneIndicator;
	}

	public String getReligion() {
		return religion;
	}

	public void setReligion(String religion) {
		this.religion = religion;
	}

	public String getStateCode() {
		return stateCode;
	}

	public void setStateCode(String stateCode) {
		this.stateCode = stateCode;
	}

	public String getPinCode() {
		return pinCode;
	}

	public void setPinCode(String pinCode) {
		this.pinCode = pinCode;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public int getMembershipFees() {
		return membershipFees;
	}

	public void setMembershipFees(int membershipFees) {
		this.membershipFees = membershipFees;
	}

	public boolean isDisDsa() {
		return disDsa;
	}

	public void setDisDsa(boolean disDsa) {
		this.disDsa = disDsa;
	}

	public String getDsaCode() {
		return dsaCode;
	}

	public void setDsaCode(String dsaCode) {
		this.dsaCode = dsaCode;
	}

	public ArrayList<SelectItem> getDsaList() {
		return dsaList;
	}

	public void setDsaList(ArrayList<SelectItem> dsaList) {
		this.dsaList = dsaList;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getQualification() {
		return qualification;
	}

	public void setQualification(String qualification) {
		this.qualification = qualification;
	}

	public String getOccupation() {
		return occupation;
	}

	public void setOccupation(String occupation) {
		this.occupation = occupation;
	}

	public String getBankIfsc() {
		return bankIfsc;
	}

	public void setBankIfsc(String bankIfsc) {
		this.bankIfsc = bankIfsc;
	}

	public String getReferenceBy() {
		return referenceBy;
	}

	public void setReferenceBy(String referenceBy) {
		this.referenceBy = referenceBy;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getMonthlyIncome() {
		return monthlyIncome;
	}

	public void setMonthlyIncome(String monthlyIncome) {
		this.monthlyIncome = monthlyIncome;
	}

	public boolean isRequiredCibilFiled() {
		return requiredCibilFiled;
	}

	public void setRequiredCibilFiled(boolean requiredCibilFiled) {
		this.requiredCibilFiled = requiredCibilFiled;
	}

	public String getNomPan() {
		return nomPan;
	}

	public void setNomPan(String nomPan) {
		this.nomPan = nomPan;
	}

	public String getNomAadhar() {
		return nomAadhar;
	}

	public void setNomAadhar(String nomAadhar) {
		this.nomAadhar = nomAadhar;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public String getBusiness() {
		return business;
	}

	public void setBusiness(String business) {
		this.business = business;
	}

	public String getBusinessPlace() {
		return businessPlace;
	}

	public void setBusinessPlace(String businessPlace) {
		this.businessPlace = businessPlace;
	}

	public String getCaste() {
		return caste;
	}

	public void setCaste(String caste) {
		this.caste = caste;
	}

	public String getBrideFhname() {
		return brideFhname;
	}

	public void setBrideFhname(String brideFhname) {
		this.brideFhname = brideFhname;
	}

	public String getBrideMname() {
		return brideMname;
	}

	public void setBrideMname(String brideMname) {
		this.brideMname = brideMname;
	}

	public String getBrideAddress() {
		return brideAddress;
	}

	public void setBrideAddress(String brideAddress) {
		this.brideAddress = brideAddress;
	}

	public String getBrideBusiness() {
		return brideBusiness;
	}

	public void setBrideBusiness(String brideBusiness) {
		this.brideBusiness = brideBusiness;
	}

	public String getBrideBusinessPlace() {
		return brideBusinessPlace;
	}

	public void setBrideBusinessPlace(String brideBusinessPlace) {
		this.brideBusinessPlace = brideBusinessPlace;
	}

	public String getBrideMobileNo() {
		return brideMobileNo;
	}

	public void setBrideMobileNo(String brideMobileNo) {
		this.brideMobileNo = brideMobileNo;
	}

	public String getBrideRemark() {
		return brideRemark;
	}

	public void setBrideRemark(String brideRemark) {
		this.brideRemark = brideRemark;
	}

	public ArrayList<SelectItem> getCenterList() {
		return centerList;
	}

	public void setCenterList(ArrayList<SelectItem> centerList) {
		this.centerList = centerList;
	}

	public String getCenter() {
		return center;
	}

	public void setCenter(String center) {
		this.center = center;
	}

	public String getNomTitle() {
		return nomTitle;
	}

	public void setNomTitle(String nomTitle) {
		this.nomTitle = nomTitle;
	}

	public String getNomGender() {
		return nomGender;
	}

	public void setNomGender(String nomGender) {
		this.nomGender = nomGender;
	}

	public boolean isRequiredCenter() {
		return requiredCenter;
	}

	public void setRequiredCenter(boolean requiredCenter) {
		this.requiredCenter = requiredCenter;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public boolean isRequiredFiled() {
		return requiredFiled;
	}

	public void setRequiredFiled(boolean requiredFiled) {
		this.requiredFiled = requiredFiled;
	}

	public ArrayList<SelectItem> getQualificationList() {
		return qualificationList;
	}

	public void setQualificationList(ArrayList<SelectItem> qualificationList) {
		this.qualificationList = qualificationList;
	}

	public ArrayList<SelectItem> getOccupationList() {
		return occupationList;
	}

	public void setOccupationList(ArrayList<SelectItem> occupationList) {
		this.occupationList = occupationList;
	}

	public boolean isRenAutoShareNo() {
		return renAutoShareNo;
	}

	public void setRenAutoShareNo(boolean renAutoShareNo) {
		this.renAutoShareNo = renAutoShareNo;
	}

	public boolean isRenManualShareNo() {
		return renManualShareNo;
	}

	public void setRenManualShareNo(boolean renManualShareNo) {
		this.renManualShareNo = renManualShareNo;
	}

	public double getLoginFee() {
		return loginFee;
	}

	public void setLoginFee(double loginFee) {
		this.loginFee = loginFee;
	}

	public String getLoginfeeBank() {
		return loginfeeBank;
	}

	public void setLoginfeeBank(String loginfeeBank) {
		this.loginfeeBank = loginfeeBank;
	}

	public String getFeeMode() {
		return feeMode;
	}

	public void setFeeMode(String feeMode) {
		this.feeMode = feeMode;
	}

	public String getFeeTransactionNo() {
		return feeTransactionNo;
	}

	public void setFeeTransactionNo(String feeTransactionNo) {
		this.feeTransactionNo = feeTransactionNo;
	}

	public Date getFeeTransactionDate() {
		return feeTransactionDate;
	}

	public void setFeeTransactionDate(Date feeTransactionDate) {
		this.feeTransactionDate = feeTransactionDate;
	}

	public boolean isShowFee() {
		return showFee;
	}

	public void setShowFee(boolean showFee) {
		this.showFee = showFee;
	}

	public String getNomineeFather() {
		return nomineeFather;
	}

	public void setNomineeFather(String nomineeFather) {
		this.nomineeFather = nomineeFather;
	}

	public String getNomineeMother() {
		return nomineeMother;
	}

	public void setNomineeMother(String nomineeMother) {
		this.nomineeMother = nomineeMother;
	}


	public String getNomBankName() {
		return nomBankName;
	}

	public void setNomBankName(String nomBankName) {
		this.nomBankName = nomBankName;
	}

	public String getNomBankBranch() {
		return nomBankBranch;
	}

	public void setNomBankBranch(String nomBankBranch) {
		this.nomBankBranch = nomBankBranch;
	}

	

	public String getNomIfscCode() {
		return nomIfscCode;
	}

	public void setNomIfscCode(String nomIfscCode) {
		this.nomIfscCode = nomIfscCode;
	}

	public String getNomAccNo() {
		return nomAccNo;
	}

	public void setNomAccNo(String nomAccNo) {
		this.nomAccNo = nomAccNo;
	}

	public String getMemberStateCode() {
		return memberStateCode;
	}

	public void setMemberStateCode(String memberStateCode) {
		this.memberStateCode = memberStateCode;
	}

	public String getMemberReligion() {
		return memberReligion;
	}

	public void setMemberReligion(String memberReligion) {
		this.memberReligion = memberReligion;
	}

	public String getMemberPinCode() {
		return memberPinCode;
	}

	public void setMemberPinCode(String memberPinCode) {
		this.memberPinCode = memberPinCode;
	}

	public ArrayList<SelectItem> getStateCodeListForMemberStateCodeReligion() {
		return stateCodeListForMemberStateCodeReligion;
	}

	public void setStateCodeListForMemberStateCodeReligion(ArrayList<SelectItem> stateCodeListForMemberStateCodeReligion) {
		this.stateCodeListForMemberStateCodeReligion = stateCodeListForMemberStateCodeReligion;
	}
	
	public String getAltContactNo() {
		return altContactNo;
	}

	public void setAltContactNo(String altContactNo) {
		this.altContactNo = altContactNo;

	}

	public String getNomVoterId() {
		return nomVoterId;
	}

	public void setNomVoterId(String nomVoterId) {
		this.nomVoterId = nomVoterId;
	}

	public String getNomContactNo() {
		return nomContactNo;
	}

	public void setNomContactNo(String nomContactNo) {
		this.nomContactNo = nomContactNo;
	}

	public UserInfo getAppMemberRow() {
		return appMemberRow;
	}

	public void setAppMemberRow(UserInfo appMemberRow) {
		this.appMemberRow = appMemberRow;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	public String getRequestId() {
		return requestId;
	}

	public void setRequestId(String requestId) {
		this.requestId = requestId;
	}

	public String getOtp() {
		return otp;
	}

	public void setOtp(String otp) {
		this.otp = otp;
	}

	public String getAadhaarNumber() {
		return aadhaarNumber;
	}

	public void setAadhaarNumber(String aadhaarNumber) {
		this.aadhaarNumber = aadhaarNumber;
	}

	public String getPanHolderName() {
		return panHolderName;
	}

	public void setPanHolderName(String panHolderName) {
		this.panHolderName = panHolderName;
	}

	public String getPanCategory() {
		return panCategory;
	}

	public void setPanCategory(String panCategory) {
		this.panCategory = panCategory;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public boolean isShowPan() {
		return showPan;
	}

	public void setShowPan(boolean showPan) {
		this.showPan = showPan;
	}

	public boolean isShowOtp() {
		return showOtp;
	}

	public void setShowOtp(boolean showOtp) {
		this.showOtp = showOtp;
	}

	public boolean isAadhaarVerified() {
		return aadhaarVerified;
	}

	public void setAadhaarVerified(boolean aadhaarVerified) {
		this.aadhaarVerified = aadhaarVerified;
	}

	public boolean isShowOtpButton() {
		return showOtpButton;
	}

	public void setShowOtpButton(boolean showOtpButton) {
		this.showOtpButton = showOtpButton;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getCibilScore() {
		return cibilScore;
	}

	public void setCibilScore(String cibilScore) {
		this.cibilScore = cibilScore;
	}

	public String getCibilReportLink() {
		return cibilReportLink;
	}

	public void setCibilReportLink(String cibilReportLink) {
		this.cibilReportLink = cibilReportLink;
	}

	public String getCibilReportPath() {
		return cibilReportPath;
	}

	public void setCibilReportPath(String cibilReportPath) {
		this.cibilReportPath = cibilReportPath;
	}

	public String getCibilClientId() {
		return cibilClientId;
	}

	public void setCibilClientId(String cibilClientId) {
		this.cibilClientId = cibilClientId;
	}

	public String getCibilStatus() {
		return cibilStatus;
	}

	public void setCibilStatus(String cibilStatus) {
		this.cibilStatus = cibilStatus;
	}

	public String getCibilMessage() {
		return cibilMessage;
	}

	public void setCibilMessage(String cibilMessage) {
		this.cibilMessage = cibilMessage;
	}

	public String getConsent() {
		return consent;
	}

	public void setConsent(String consent) {
		this.consent = consent;
	}

	public boolean isShowCibil() {
		return showCibil;
	}

	public void setShowCibil(boolean showCibil) {
		this.showCibil = showCibil;
	}

	public DataBaseMethodTaheer getDbmt() {
		return dbmt;
	}

	public void setDbmt(DataBaseMethodTaheer dbmt) {
		this.dbmt = dbmt;
	}

	public String getReportType() {
		return reportType;
	}

	public void setReportType(String reportType) {
		this.reportType = reportType;
	}

	public ArrayList<String> getDuplicateContactDetails() {
		return duplicateContactDetails;
	}

	public void setDuplicateContactDetails(ArrayList<String> duplicateContactDetails) {
		this.duplicateContactDetails = duplicateContactDetails;
	}

	public String getDuplicateType() {
		return duplicateType;
	}

	public void setDuplicateType(String duplicateType) {
		this.duplicateType = duplicateType;
	}


	public String getAadharBackPathDoc01() {
		return aadharBackPathDoc01;
	}

	public void setAadharBackPathDoc01(String aadharBackPathDoc01) {
		this.aadharBackPathDoc01 = aadharBackPathDoc01;
	}

	public String getVoterBackPathDoc03() {
		return voterBackPathDoc03;
	}

	public void setVoterBackPathDoc03(String voterBackPathDoc03) {
		this.voterBackPathDoc03 = voterBackPathDoc03;
	}

	public UploadedFile getAadharBackPhoto() {
		return aadharBackPhoto;
	}

	public void setAadharBackPhoto(UploadedFile aadharBackPhoto) {
		this.aadharBackPhoto = aadharBackPhoto;
	}

	public UploadedFile getVoterBackPhoto() {
		return voterBackPhoto;
	}

	public void setVoterBackPhoto(UploadedFile voterBackPhoto) {
		this.voterBackPhoto = voterBackPhoto;
	}

	public UploadedFile getAadharFrontDoc1() {
		return aadharFrontDoc1;
	}

	public void setAadharFrontDoc1(UploadedFile aadharFrontDoc1) {
		this.aadharFrontDoc1 = aadharFrontDoc1;
	}

	public String getAadharFrontPathDoc1() {
		return aadharFrontPathDoc1;
	}

	public void setAadharFrontPathDoc1(String aadharFrontPathDoc1) {
		this.aadharFrontPathDoc1 = aadharFrontPathDoc1;
	}

	
	
	

	
}