package com.bankaudit.util;

import java.util.Date;

import org.jboss.logging.Logger;

import com.bankaudit.dto.process.EmailTemplateDto;

public class EmailTemplates {

	static final Logger logger = Logger.getLogger(EmailTemplates.class);
	
	
	public static String getSubjectTemplate(EmailTemplateDto eDto,String templateType) {
		StringBuilder template= new StringBuilder();
		StringBuilder templateUnitType= new StringBuilder();
		logger.info("in getSubjectTemplate..."+eDto.getFyEndDate());
		
		String romanNo="";
		String bankName=eDto.getUnitName(), place=eDto.getUnitCity()!=null?eDto.getUnitCity():"";
		String auditTypeCode=eDto.getAuditTypeCode();
		String refInspDate=(eDto.getFyEndDate()!=null?BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate()):" ");
		String inspstDt=eDto.getScheduleStartDate();
		String members=eDto.getMemberName();
		String leadName=eDto.getLeadName();
		String leadDesignation=eDto.getLeadDesignation();
		logger.info("BName::"+bankName+" Place::"+place+" AuditTyp:"+auditTypeCode+" FYDate:"+refInspDate+" Lead:"+leadName+" LeadDesg:"+leadDesignation+" Members:"+members);
		
		if(eDto.getAuditSerialNo()!=null) romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		
		if("RRBI".equalsIgnoreCase(auditTypeCode) || "RRBEI".equalsIgnoreCase(auditTypeCode)) { 
			templateUnitType.append("Statutory Inspection of ").append(bankName).append(", ").append(place);
			templateUnitType.append(" under Section 35(6) of the B. R. Act, 1949 ");		
		}else if("StCBI".equalsIgnoreCase(auditTypeCode) || "DCCBI".equalsIgnoreCase(auditTypeCode) || "StCBEI".equalsIgnoreCase(auditTypeCode) || "DCCBEI".equalsIgnoreCase(auditTypeCode)  ) { 
			templateUnitType.append("Statutory Inspection of ").append(bankName).append(", ").append(place);
			templateUnitType.append(" under Section 35(6) of the B. R. Act, 1949 (AACS) ");		
		}else if("SCARDBI".equalsIgnoreCase(auditTypeCode)) { 
			templateUnitType.append("Voluntary Inspection of ").append(bankName).append(", ").append(place);
		}
		
		if("AI".equalsIgnoreCase(templateType)) {
			template.append("Commencement of ").append(romanNo).append(" ");
			template.append(templateUnitType);
			template.append(" w.r.t the banks financial position as on ").append(refInspDate);			
		}else if("AE".equalsIgnoreCase(templateType) ) {
			template.append("Completion of ").append(romanNo).append(" ");
			template.append(templateUnitType);
			template.append(" w.r.t the banks financial position as on ").append(refInspDate);
		}else if("RAR".equalsIgnoreCase(templateType)) {
			template.append("Completion of IR of ").append(romanNo).append(" ");
			template.append(templateUnitType);
			template.append(" w.r.t the banks financial position as on ").append(refInspDate);
		}else if("AS".equalsIgnoreCase(templateType)) {
			template.append(romanNo).append(" ");
			template.append(templateUnitType);
			template.append("- Issue of Inspection report");
		}else if("AR".equalsIgnoreCase(templateType)) {
			template.append(romanNo).append(" ");
			template.append(templateUnitType);
			template.append("- Compliance Report Submission");
		}else if("AW".equalsIgnoreCase(templateType)) {
			template.append(romanNo).append(" ");
			template.append(templateUnitType);
			template.append("- Further Compliance on Inspection Report observations");
		}
		
		else if("1ST_NOTIFICATION".equalsIgnoreCase(templateType)) {
			template.append(romanNo).append(" ");
			template.append(templateUnitType);
			template.append(" w.r.t the banks financial position as on ").append(refInspDate);
		}else if("2ND_NOTIFICATION".equalsIgnoreCase(templateType)) {
			template.append(romanNo).append(" ");
			template.append(templateUnitType);
			template.append(" w.r.t the banks financial position as on ").append(refInspDate);
		}
		
		return template.toString();
	}
	
	public static String getInspectionInitiateTemplate(EmailTemplateDto eDto,String templateType) {
		StringBuilder template= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in results...");
		String stVol="", romanNo="",  members="", leadName=eDto.getLeadName(), leadDesignation="", refInspDate="", inspstDt="", parentUnitName="";
		
		if(eDto.getAuditSerialNo() !=null)romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		if(eDto.getLeadName() !=null) leadName=eDto.getLeadName();
		if(eDto.getLeadDesignation() !=null) leadDesignation=eDto.getLeadDesignation();
		if(eDto.getMemberName() !=null) {members=eDto.getMemberName(); members=members.replace(",", ", ");}
		if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
		if(eDto.getActualStartDate() !=null) inspstDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getActualStartDate());
		if(eDto.getParentUnitName() !=null) parentUnitName=eDto.getParentUnitName();
		if(eDto.getAuditSerialNo()!=null) romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		
		//if("RRBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Statutory";
		//else 
		if("SCARDBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Voluntary";
		else stVol="Statutory";
		
		template.append("<p>");
		template.append("To,").append("<br>");
		template.append("NABARD,").append("<br>");
		template.append(parentUnitName).append(" Regional Office,");
		template.append("</p>");
		
		template.append("<p>");
		template.append("Dear Sir/Madam");
		template.append("</p>");
		
		template.append("<p  align=justify>");
		template.append("We advise having commenced the ").append(romanNo).append(" ").append(stVol).append(" ");
		template.append("Inspection of the captioned bank with reference to its financial position as on ");
		template.append(refInspDate).append(" on ").append(inspstDt).append(". ");
		template.append(members);
		template.append(" has/have joined me as Associate Officer(s) for the conduct of the inspection. ");
		template.append("</p>");
		
		template.append("<p>");
		template.append("Yours faithfully").append("<br>");
		
		//template.append("Sd/- ").append("<br>");
		template.append(leadName).append("<br>");
		template.append("Principal Inspecting Officer").append("<br>");
		template.append(leadDesignation);
		template.append("</p>");
		
		template.append("<p>");
	    //template.append("This is a system generated mail. Do not reply this mail");
	    //template.append(environment.getRequiredProperty("email.no_reply_mail_content"));
	    template.append("</body></html>");
		
		return template.toString();
	}
	
	public static String getInspectionExitTemplate(EmailTemplateDto eDto,String templateType) {
		StringBuilder template= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in results...");
		String stVol="", romanNo="",  members="", leadName=eDto.getLeadName(), leadDesignation="", refInspDate="", inspstDt="", parentUnitName="", exitDate="";
		
		if(eDto.getAuditSerialNo() !=null)romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		if(eDto.getLeadName() !=null) members=eDto.getLeadName();
		if(eDto.getLeadDesignation() !=null) leadDesignation=eDto.getLeadDesignation();
		if(eDto.getMemberName() !=null) members=eDto.getMemberName();
		if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
		if(eDto.getActualStartDate() !=null) inspstDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getActualStartDate());
		if(eDto.getReportDate() !=null) exitDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getReportDate());
		if(eDto.getParentUnitName() !=null) parentUnitName=eDto.getParentUnitName();
		if(eDto.getAuditSerialNo()!=null) romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		
		//if("RRBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Statutory";
		//else 
		if("SCARDBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Voluntary";
		else stVol="Statutory";
		
		template.append("<p>");
		template.append("To,").append("<br>");
		template.append("NABARD,").append("<br>");
		template.append(parentUnitName).append(" Regional Office,");
		template.append("</p>");
		
		template.append("<p>").append("Dear Sir/Madam").append("</p>");
		
		template.append("<p  align=justify>");
		template.append("We advise having completed the ").append(romanNo).append(" ").append(stVol);
		template.append("Inspection of the captioned bank with reference to its financial position as on ");
		template.append(refInspDate).append(" on ").append(exitDate).append(".");
		template.append("</p>");
		
		template.append("<p>");
		template.append("Yours faithfully").append("<br>");		
		//template.append("Sd/- ").append("<br>");
		template.append(leadName).append("<br>");
		template.append("Principal Inspecting Officer").append("<br>");
		template.append(leadDesignation);
		template.append("</p>");
		
		template.append("<p>");
	    //template.append("This is a system generated mail. Do not reply this mail");
	    //template.append(environment.getRequiredProperty("email.no_reply_mail_content"));
	    template.append("</body></html>");
		
		return template.toString();
	}
	
	public static String getReadyForReviewTemplate(EmailTemplateDto eDto,String templateType) {
		logger.info("in getReadyForReviewTemplate...");
		StringBuilder template= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in results...");
		String stVol="", romanNo="",  members="", leadName=eDto.getLeadName(), leadDesignation="", refInspDate="", inspstDt="", parentUnitName="";
		
		if(eDto.getAuditSerialNo() !=null)romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		if(eDto.getLeadName() !=null) leadName=eDto.getLeadName();
		if(eDto.getLeadDesignation() !=null) leadDesignation=eDto.getLeadDesignation();
		if(eDto.getMemberName() !=null) members=eDto.getMemberName();
		if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
		if(eDto.getActualStartDate() !=null) inspstDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getActualStartDate());
		if(eDto.getParentUnitName() !=null) parentUnitName=eDto.getParentUnitName();
		if(eDto.getAuditSerialNo()!=null) romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		
		//if("RRBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Statutory";
		//else 
		if("SCARDBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Voluntary";
		else stVol="Statutory";
		
		template.append("<p>");
		template.append("To,").append("<br>");
		template.append("NABARD,").append("<br>");
		template.append(parentUnitName).append(" Regional Office,");
		template.append("</p>");
		
		template.append("<p>").append("Dear Sir/Madam").append("</p>");
		
		template.append("<p  align=justify>");
		template.append("We advise having completed inspection report of ").append(romanNo).append(" ").append(stVol).append(" ");
		template.append("Inspection of the captioned bank with reference to its financial position as on ");
		template.append(refInspDate).append(".");
		template.append("</p>");
		
		template.append("<p>");
		template.append("Yours faithfully").append("<br>");
		//template.append("Sd/- ").append("<br>");
		template.append(leadName).append("<br>");
		template.append("Principal Inspecting Officer").append("<br>");
		template.append(leadDesignation);
		template.append("</p>");
		
		template.append("<p>");
	    //template.append("This is a system generated mail. Do not reply this mail");
	    //template.append(environment.getRequiredProperty("email.no_reply_mail_content"));
	    template.append("</body></html>");
		
		return template.toString();
	}
	
	public static String getInspectionDispatchTemplate(EmailTemplateDto eDto,String templateType) {
		StringBuilder template= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in getInspectionDispatchTemplate ...");
		
		String stVol="", romanNo="",  issuingOffcrName=eDto.getLeadName(), issuingOffcrDesignation="", leadName="", leadDesignation="";
		String refInspDate="", inspStDt="", inspEndDt="", exitDate="", compTargetEndDate="", fromDt="", toDt="",dispDt="",dispAdd60Dt="", unitName="", unitCity="";
		
		if(eDto.getAuditSerialNo() !=null)romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		if(eDto.getLeadName() !=null) leadName=eDto.getLeadName();
		if(eDto.getLeadDesignation() !=null) leadDesignation=eDto.getLeadDesignation();
		if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
		if(eDto.getActualStartDate() !=null) inspStDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getActualStartDate());
		if(eDto.getActualEndDate() !=null) inspEndDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getActualEndDate());
		if(eDto.getReportDate() !=null) exitDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getReportDate());
		if(eDto.getDispatchDate() !=null) dispDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getDispatchDate());
		if(eDto.getRepSubmissionFromDispDt() !=null) dispAdd60Dt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getRepSubmissionFromDispDt());
		if(eDto.getRespondTargetEndDate() !=null) {compTargetEndDate= eDto.getRespondTargetEndDate(); toDt= eDto.getRespondTargetEndDate(); }
		if(eDto.getUnitName() !=null) unitName=eDto.getUnitName();
		if(eDto.getUnitCity() !=null) unitCity=eDto.getUnitCity();
		if(eDto.getAuditSerialNo()!=null) romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		
		/*if("RRBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Statutory";
		else*/ if("SCARDBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Voluntary";
		else stVol="Statutory";
		
		template.append("<p>");
		template.append("To,").append("<br>");
		template.append(unitName).append(",").append("<br>");
		template.append(unitCity).append("");
		template.append("</p>");
		template.append("<p>").append("Dear Sir/Madam").append("</p>");
		
		template.append("<p align=justify>");
		template.append("1. ").append(romanNo).append(" ").append(stVol);
		template.append(" Inspection of your bank was conducted from ").append(inspStDt).append(" to ").append(exitDate);  //.append(inspEndDt);  // Exit/Report date replaced with Inspection end date.
		template.append(" with reference to its financial position as on ").append(refInspDate).append(". ");
		template.append(" In this connection, we inform that the Inspection Report is now available on SuperSoft application. ");
		template.append("</p>");
		
		template.append("<p align=justify>");
		template.append("2.	We request you to place the Inspection Report along with this letter before the Board of "
				+ "Directors of your bank at an early date, initiate steps for rectification of the deficiencies pointed out in the report.");
		template.append("</p>");
		
		template.append("<p align=justify>");
		template.append("3.	The bank is required to prepare a Compliance Report on each of the deficiencies pointed out in Part A "
				+ "of the Inspection Report.  The action taken or proposed to be taken with a definite/specific timeline may also be placed "
				+ "before the Board of Directors for approval. The Compliance Report, together with a copy of the Board resolution approving the "
				+ "compliance, should be submitted to us within a period of sixty days from ");
		template.append(dispDt).append(", i.e. on or before ").append(dispAdd60Dt).append(".");
		template.append("</p>");
		
		template.append("<p align=justify>");
		template.append("4.	We attach considerable importance to the responsiveness of the bank in promptly rectifying "
				+ "the defects and implementing the suggestions made in the Inspection Report. We, therefore, request you to bestow your "
				+ "personal attention in submission of the compliance report to us within the specified time.");
		template.append("</p>");
		
		template.append("<p>").append("With kind regards.").append("</p>");
		
		template.append("<p>").append("Yours sincerely").append("<br>");
		template.append(leadName).append("<br>");
		template.append(leadDesignation);
		template.append("</p>");
		
		//template.append("This is a system generated mail. Do not reply this mail");
	    //template.append(environment.getRequiredProperty("email.no_reply_mail_content"));
	    template.append("</body></html>");
		
		return template.toString();
	}
	
	public static String getComplianceSubmissionTemplate(EmailTemplateDto eDto,String templateType) {
		StringBuilder template= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in getComplianceSubmissionTemplate ...");
		
		String stVol="", romanNo="",  bankUserName="", bankUserDesignation="", parentUnitName="";
		String refInspDate="", inspStDt="", inspEndDt="", dispDt="", compSubmissionDt="";
		
		if(eDto.getAuditSerialNo() !=null)romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		if(eDto.getBankUserName() !=null) bankUserName=eDto.getBankUserName();
		if(eDto.getBankUserDesignation() !=null) bankUserDesignation=eDto.getBankUserDesignation();
		if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
		if(eDto.getActualStartDate() !=null) inspStDt=eDto.getActualStartDate();
		if(eDto.getActualEndDate() !=null) inspEndDt=eDto.getActualEndDate();
		if(eDto.getDispatchDate() !=null) dispDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getDispatchDate());
		if(eDto.getRespondDate() !=null) compSubmissionDt= eDto.getRespondDate(); 
		if(eDto.getParentUnitName() !=null) parentUnitName=eDto.getParentUnitName();
		 	
		/*if("RRBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Statutory";
		else*/ if("SCARDBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Voluntary";
		else stVol="Statutory";
		
		template.append("<p>");
		template.append("To,").append("<br>");
		template.append("NABARD,").append("<br>");
		template.append(parentUnitName).append(" Regional Office,");
		template.append("</p>");
		template.append("<p>").append("Dear Sir/Madam").append("</p>");
		
		template.append("<p align=justify>");
		//template.append(romanNo).append(" ").append(stVol);
		template.append(" Please refer to your mail dated ").append(dispDt).append(" forwarding the Inspection Report with reference ");
		template.append(" to its financial position as on ").append(refInspDate).append(". ").append(" In this connection, we ");
		template.append(" hereby inform that the Compliance Report on the deficiencies pointed out and ");
		template.append(" observations made in the Inspection Report is being submitted and is available on ");
		template.append(" SuperSoft application. The compliance report was placed before the Board."); // .append(" on ").append(compSubmissionDt);
		template.append("</p>");
		
		template.append("<p>").append("Yours faithfully").append("<br>");
		template.append(bankUserName).append("<br>");
		template.append(bankUserDesignation);
		template.append("</p>");
		
		//template.append("This is a system generated mail. Do not reply this mail");
	    //template.append(environment.getRequiredProperty("email.no_reply_mail_content"));
	    template.append("</body></html>");
		
		return template.toString();
	}
	
	//Scrutiny is submitted and at least one item is marked for further compliance
	public static String getFurtherComplianceTemplate(EmailTemplateDto eDto,String templateType) {
		StringBuilder template= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in getComplianceSubmissionTemplate ...");
		
		String stVol="", romanNo="",  reviewerName="", reviewerDesignation="", compFurtherSubmissionDays="15";
		String refInspDate="", inspStDt="", inspEndDt="", dispatchDt="", compDate="", unitName="", unitCity="";
		int resRejRecs=0;
		
		if(eDto.getAuditSerialNo() !=null)romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		if(eDto.getReveiwerName() !=null) reviewerName=eDto.getReveiwerName();
		if(eDto.getReveiwerDesignation() !=null) reviewerDesignation=eDto.getReveiwerDesignation();
		if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
		if(eDto.getActualStartDate() !=null) inspStDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getActualStartDate());
		if(eDto.getActualEndDate() !=null) inspEndDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getActualEndDate());
		if(eDto.getDispatchDate() !=null) dispatchDt=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getDispatchDate());
		if(eDto.getRespondDate() !=null) compDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getRespondDate());
		if(eDto.getCompFurtherSubmissionDays() !=null) compFurtherSubmissionDays= eDto.getCompFurtherSubmissionDays();
		if(eDto.getUnitName() !=null) unitName=eDto.getUnitName();
		if(eDto.getUnitCity() !=null) unitCity=eDto.getUnitCity();
		if(eDto.getCompFurtherRecords() !=null) resRejRecs=eDto.getCompFurtherRecords()!=null?eDto.getCompFurtherRecords():0;
		
		
		/*if("RRBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Statutory";
		else*/ if("SCARDBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Voluntary";
		else stVol="Statutory";
		
		template.append("<p>");
		template.append("To,").append("<br>");
		template.append(unitName).append(",").append("<br>");
		template.append(unitCity).append("");
		template.append("</p>");
		template.append("<p>").append("Dear Sir/Madam").append("</p>");
		
		template.append("<p  align=justify>");
		// template.append(romanNo).append(" ").append(stVol);
		template.append(" 1. Please refer to your mail dated ").append(compDate).append(" regarding the submission of compliance on ");
		template.append(" observations of Inspection Report. We have reviewed the compliance report and found ");
		template.append(" the compliance unsatisfactory on ").append(resRejRecs).append(" point/s. ");
		template.append("</p>");
		
		template.append("<p>");
		template.append(" 2. In this connection, we request you to promptly rectify the defects and re-submit the ");
		template.append(" compliance report within ").append(compFurtherSubmissionDays).append(" days from the date of issue of this letter.");
		template.append("</p>");
		
		template.append("<p>").append("Yours Sincerely");		
		template.append("<br>");
		template.append(reviewerName).append("<br>");
		template.append(reviewerDesignation);
		template.append("</p>");
		
		//template.append("This is a system generated mail. Do not reply this mail");
	    //template.append(environment.getRequiredProperty("email.no_reply_mail_content"));
	    template.append("</body></html>");
		
		return template.toString();
	}
	
	
	/*************** New Format *********/
	public static String getSubjectAuditReviewTemplate(EmailTemplateDto eDto,String templateType) {
		StringBuilder template= new StringBuilder();
		StringBuilder templateUnitAuditFy= new StringBuilder();
		logger.info("in getSubjectAuditReviewTemplate..."+eDto.getFyEndDate());
		
		String romanNo="";
		String bankName=eDto.getUnitName(), place=eDto.getUnitCity()!=null?eDto.getUnitCity():"";
		String auditTypeCode=eDto.getAuditTypeCode();
		String planId=eDto.getPlanId();
		String auditId=eDto.getAuditId();
		String refInspDate=(eDto.getFyEndDate()!=null?BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate()):" ");
		String fy=eDto.getFinancialYear();
		logger.info("BName::"+bankName+" Place::"+place+" AuditTyp:"+auditTypeCode+" FYDate:"+refInspDate+" plan:"+planId+" audit:"+auditId+" fy:"+fy);
		
		if(eDto.getAuditSerialNo()!=null) romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
		
		templateUnitAuditFy=templateUnitAuditFy.append(bankName).append(" - ").append(planId).append(" - ").append(auditId).append(", FY ").append(refInspDate);
		
		if("RRR".equalsIgnoreCase(templateType)) {  // Inspection Report Ready for Review  [Bank Name - Plan ID - Inspection ID]  FY [Year-Year]
			template.append("Inspection Report Ready for Review  ").append(templateUnitAuditFy);			
		}else if("RAR".equalsIgnoreCase(templateType) ) { // Inspection Report Assigned for Review  [Bank Name - Plan ID - Inspection ID], FY [Year-Year]
			template.append("Inspection Report Assigned for Review  ").append(templateUnitAuditFy);
		}else if("RC".equalsIgnoreCase(templateType) ) { // Review Completed for Inspection Report of [Bank Name - Plan ID - Inspection ID]  FY [Year-Year]
			template.append("Review Completed for Inspection Report of  ").append(templateUnitAuditFy);
		}else if("FS".equalsIgnoreCase(templateType) ) { // Inspection Report Modifications Completed for [Bank Name - Plan ID - Inspection ID]  FY [Year-Year]
			template.append("Inspection Report Modifications Completed for ").append(templateUnitAuditFy);
		}else if("RR".equalsIgnoreCase(templateType) ) { // Review Feedback provided by reviewer for Inspection Report of [Bank Name - Plan ID - Inspection ID]  FY [Year-Year]
			template.append("Review Feedback provided by reviewer for Inspection Report of  ").append(templateUnitAuditFy);
		}else if("RA".equalsIgnoreCase(templateType) ) { // Inspection Report Review Accepted for [Bank Name - Plan ID - Inspection ID]  FY [Year]
			template.append("Inspection Report Review Accepted for  ").append(templateUnitAuditFy);
		}else if("RS".equalsIgnoreCase(templateType) ) { // Inspection Report Finalised for [Bank Name - Plan ID - Inspection ID]  FY [Year]
			template.append("Inspection Report Finalised for  ").append(templateUnitAuditFy);
		}
		else if("WI".equalsIgnoreCase(templateType)) { // Compliance Scrutiny Assigned for [Bank Name - Plan ID - Inspection ID], FY [Year-Year]
			template.append("Compliance Scrutiny Assigned for  ").append(templateUnitAuditFy);
		}
		
		return template.toString();
	}
	
	public static String getReviewTemplate(EmailTemplateDto eDto,String templateType) {
		logger.info("in getReviewReadyToAllocatorTemplate...");
		StringBuilder template= new StringBuilder();
		StringBuilder templateUnitAuditFy= new StringBuilder();
		StringBuilder templatebody= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in results...");
		String stVol="", romanNo="",  members="", leadName=eDto.getLeadName(),allMembers="", leadDesignation="", refInspDate="", inspstDt="", parentUnitName="";
		
		if(eDto.getLeadName() !=null) leadName=eDto.getLeadName();
		if(eDto.getMemberName() !=null) members=eDto.getMemberName();
		if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
		
		String bankName=eDto.getUnitName(), place=eDto.getUnitCity()!=null?eDto.getUnitCity():"";
		String planId=eDto.getPlanId();
		String auditId=eDto.getAuditId();
		String rpReviewerName=eDto.getReportReveiwerName();
		allMembers=leadName+ (eDto.getMemberName() !=null?", "+members:"");
				
		templateUnitAuditFy=templateUnitAuditFy.append(bankName).append(" - ").append(planId).append(" - ").append(auditId).append(", FY ").append(refInspDate);
		
		if("RRR".equalsIgnoreCase(templateType)) {  
			templatebody.append("The Inspection Report for ").append(templateUnitAuditFy)
			.append("  has been marked as \"Review Ready\" by the inspection team. Please proceed with the allocation of a reviewer for the draft Inspection report.");			
		}else if("RAR".equalsIgnoreCase(templateType) ) { 
			templatebody.append("The Inspection Report for  ").append(templateUnitAuditFy)
			.append(" has been assigned to you for review. Please proceed with the review process as per the guidelines.");
		}else if("RC".equalsIgnoreCase(templateType) ) { 
			templatebody.append("The review for the Inspection Report of  ").append(templateUnitAuditFy)
			.append(" has been marked as \"Completed\" by the review team (").append(rpReviewerName).append("). Please incorporate the feedback provided and proceed accordingly.");
		}else if("FS".equalsIgnoreCase(templateType) ) { 
			templatebody.append("The Inspection Report for  ").append(templateUnitAuditFy)
			.append("  has been modified by the ").append(allMembers).append(" as per your feedback. Please review the changes and proceed, accordingly.");
		}else if("RR".equalsIgnoreCase(templateType) ) { 
			templatebody.append("The review for the Inspection Report of  ").append(templateUnitAuditFy)
			.append(" has been marked as \"Reviewed\" by the review team (").append(rpReviewerName).append("). Please incorporate the feedback provided and proceed accordingly.");
		}else if("RA".equalsIgnoreCase(templateType) ) { 
			templatebody.append("The review of the Inspection Report for ").append(templateUnitAuditFy)
			.append("  has been marked as \"Accepted\" by ").append(rpReviewerName).append(", indicating satisfaction and approval of its contents. Please proceed with the next steps in the workflow.");
		}else if("RS".equalsIgnoreCase(templateType) ) { 
			templatebody.append("The Inspection Report for ").append(templateUnitAuditFy)
			.append(" has been marked as \"Finalised\" by ").append(rpReviewerName).append(". No further modifications are permitted, and the report is ready for dispatch.");
		}
		
		template.append("<p>").append("Dear Sir/Madam").append("</p>");
		
		template.append("<p  align=justify>");
		template.append(templatebody);
		template.append("</p>");
		
		template.append("<p>");
		template.append("Regards,").append("<br>");
		template.append("Team PMU");
		template.append("</p>");
		
		template.append("<p>");
	    template.append("This is an auto-generated email. For any clarifications, kindly contact dos.supersoft@nabard.org.");
	    template.append("</body></html>");
		
		return template.toString();
	}
	
	public static String getScrutinyAssignTemplate(EmailTemplateDto eDto,String templateType) {
		logger.info("in getScrutinyAssignTemplate...");
		StringBuilder template= new StringBuilder();
		StringBuilder templateUnitAuditFy= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in results...");
		String stVol="", romanNo="",  refInspDate="", inspstDt="", parentUnitName="";
		
		if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
		
		String bankName=eDto.getUnitName(), place=eDto.getUnitCity()!=null?eDto.getUnitCity():"";
		String planId=eDto.getPlanId();
		String auditId=eDto.getAuditId();
						
		templateUnitAuditFy=templateUnitAuditFy.append(bankName).append(" - ").append(planId).append(" - ").append(auditId).append(", FY ").append(refInspDate);
		
		template.append("<p>").append("Dear Sir/Madam").append("</p>");
		
		template.append("<p  align=justify>");
		template.append("The compliance scrutiny for ").append(templateUnitAuditFy).append("  has been assigned to you. Please review the submission and proceed with the scrutiny process at the earliest.");
		template.append("</p>");
		
		template.append("<p>");
		template.append("Regards,").append("<br>");
		template.append("Team PMU");
		template.append("</p>");
		
		template.append("<p>");
	    template.append("This is an auto-generated email. For any clarifications, kindly contact dos.supersoft@nabard.org.");
	    template.append("</body></html>");
		
		return template.toString();
	}
	
	
	/******************* Mail for batch processing *********************/
	//1st Notification of Inspection due 
	public static String get1stNotificationTemplate(EmailTemplateDto eDto,String templateType) {
			StringBuilder template= new StringBuilder();
			template.append("<html><head>"
	                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
	                + "<body>");
	              //  + "<table style=\"width:100%\">");
			logger.info("in get1stNotificationTemplate ...");
			
			String stVol="", romanNo="";
			String refInspDate="", unitName="", unitCity="", parentUnitName="";
			
			if(eDto.getAuditSerialNo() !=null)romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
			if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
			if(eDto.getUnitName() !=null) unitName=eDto.getUnitName();
			if(eDto.getUnitCity() !=null) unitCity=eDto.getUnitCity();
			if(eDto.getParentUnitName() !=null) parentUnitName=eDto.getParentUnitName();
						
			/*if("RRBI".equalsIgnoreCase(eDto.getAuditTypeCode()) || "DCCBI".equalsIgnoreCase(eDto.getAuditTypeCode()) || "StCBI".equalsIgnoreCase(eDto.getAuditTypeCode()) ) stVol="Statutory";
			else*/ if ("SCARDBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Voluntary";
			else stVol="Statutory";
			
			template.append("<p>");
			template.append("To,").append("<br>");
			template.append(unitName).append(",").append("<br>");
			template.append(unitCity).append("");
			template.append("</p>");
			template.append("<p>").append("Dear Sir/Madam").append("</p>");
			
			template.append("<p  align=justify>");
			// template.append(romanNo).append(" ").append(stVol);
			template.append(" 1. We inform that the ").append(romanNo).append(" ").append(stVol).append(" Inspection of your bank");
			template.append(" with reference to its financial position as on ").append(refInspDate).append(" will be undertaken shortly.");
			template.append(" The exact date of commencement of the inspection will be communicated to you in due course.");
			template.append("</p>");
			
			template.append("<p>");
			template.append(" 2. In this connection, we request you to submit the inspection statements, duly filled in, at the earliest.");
			template.append("</p>");
			
			template.append("<p>");
			template.append(" 3. We shall be glad if you will extend all the necessary assistance and cooperation for the smooth conduct of inspection.");
			template.append("</p>");
			
			template.append("<p>").append("Yours faithfully");		
			template.append("<br>");
			template.append("Regards ").append("<br>");
			template.append("DoS - <").append(parentUnitName).append(" Regional Office>");
			template.append("</p>");
			
			//template.append("This is a system generated mail. Do not reply this mail");
		    //template.append(environment.getRequiredProperty("email.no_reply_mail_content"));
		    template.append("</body></html>");
			
			return template.toString();
		}
	
	//2nd Notification of Inspection due 
		public static String get2ndNotificationTemplate(EmailTemplateDto eDto,String templateType) {
				StringBuilder template= new StringBuilder();
				template.append("<html><head>"
		                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
		                + "<body>");
		              //  + "<table style=\"width:100%\">");
				logger.info("in get1stNotificationTemplate ..."+ eDto.getAuditTypeCode());
				
				String stVol="", romanNo="", leadName="", leadDesignation="", members="";
				String schStDate="", schEndDate="", refInspDate="", unitName="", unitCity="", parentUnitName="";
				
				if(eDto.getAuditSerialNo() !=null)romanNo=BankAuditUtil.integerToRomanNumeral(Integer.parseInt(eDto.getAuditSerialNo()));
				if(eDto.getFyEndDate() !=null) refInspDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getFyEndDate());
				if(eDto.getLeadName() !=null) leadName=eDto.getLeadName();
				if(eDto.getLeadDesignation() !=null) leadDesignation=eDto.getLeadDesignation();
				if(eDto.getMemberName() !=null) {members=eDto.getMemberName(); members=members.replace(",", ", ");}
				if(eDto.getScheduleStartDate() !=null) schStDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getScheduleStartDate());
				if(eDto.getScheduleEndDate() !=null) schEndDate=BankAuditUtil.parseStringDateToStringDateddMMyyyy(eDto.getScheduleEndDate());
				if(eDto.getUnitName() !=null) unitName=eDto.getUnitName();
				if(eDto.getUnitCity() !=null) unitCity=eDto.getUnitCity();
				if(eDto.getParentUnitName() !=null) parentUnitName=eDto.getParentUnitName();
							
				/*if("RRBI".equalsIgnoreCase(eDto.getAuditTypeCode()) || "DCCBI".equalsIgnoreCase(eDto.getAuditTypeCode()) || "StCBI".equalsIgnoreCase(eDto.getAuditTypeCode()) ) stVol="Statutory";
				else*/ if("SCARDBI".equalsIgnoreCase(eDto.getAuditTypeCode())) stVol="Voluntary";
				else stVol="Statutory";
				
				template.append("<p>");
				template.append("To,").append("<br>");
				template.append(unitName).append(",").append("<br>");
				template.append(unitCity).append("");
				template.append("</p>");
				template.append("<p>").append("Dear Sir/Madam").append("</p>");
				
				template.append("<p  align=justify>");
				template.append(" 1. We inform that the ").append(romanNo).append(" ").append(stVol).append(" Inspection of your bank");
				template.append(" with reference to its financial position as on ").append(refInspDate).append(" will be undertaken by ");
				template.append(leadName).append(", ").append(leadDesignation).append(" and ").append( members);
				template.append(" from ").append(schStDate).append(" to ").append(schEndDate).append(" (both days inclusive).");
				template.append("</p>");
				
				template.append("<p>");
				template.append(" 2. We shall be glad if you will extend all the necessary assistance and cooperation for the smooth conduct of inspection.");
				template.append("</p>");
				
				template.append("<p>").append("Yours faithfully");		
				template.append("<br>");
				template.append("Regards ").append("<br>");
				template.append("DoS - <").append(parentUnitName).append(" Regional Office>");
				template.append("</p>");
				
				//template.append("This is a system generated mail. Do not reply this mail");
			    //template.append(environment.getRequiredProperty("email.no_reply_mail_content"));
			    template.append("</body></html>");
				
				return template.toString();
		}
	/******** Batch mail, End here ********/
	
	public static String getRestPwdTokenTemplate(EmailTemplateDto eDto,String token) {
		StringBuilder template= new StringBuilder();
		template.append("<html><head>"
                + "<style> table, th, td { border: 1px solid black; padding: 0px;} table{ border-spacing: 0px;}</style></head>"
                + "<body>");
              //  + "<table style=\"width:100%\">");
		logger.info("in getRestPwdTokenTemplate...");
			
		template.append("<p>");
		template.append("Dear User,").append("<br>").append("Please use below Token to reset your Password.").append("</br>");
		template.append("<br>").append("Token:").append("<b>").append(token).append("</b>").append("</br>");
		template.append("</p>");
		
		template.append("<p>").append("").append("</p>");
		template.append("<p>").append("This is a system-generated e-mail regarding your Supersoft Password Reset, please don't reply to this message.").append("</p>");
		
		template.append("</body></html>");
		
		return template.toString();
	}
}
