Ejemplo n.º 1
0
  public void sendCustSaleConfirmEmail(HttpServletRequest request, ServletContext servletContext)
      throws Exception {
    ContentBean contentBean = ContentLookupDispatchAction.getContentBean(request);
    SiteDomain siteDomain = contentBean.getContentSessionBean().getSiteDomain();
    Long siteProfileClassId = contentBean.getContentSessionKey().getSiteProfileClassId();
    SiteDomainLanguage siteDomainLanguage =
        contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage();
    if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
      for (SiteDomainLanguage language :
          contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguages()) {
        if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
          siteDomainLanguage = language;
          break;
        }
      }
    }
    SiteDomainParamBean siteDomainParamBean =
        SiteDomainDAO.getSiteDomainParamBean(
            contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage(),
            siteDomainLanguage);
    Site site = siteDomain.getSite();

    TemplateEngine engine = TemplateEngine.getInstance();
    engine.init(request, servletContext, true);
    engine.setParameter("orderHeaderId", orderHeader.getOrderHeaderId());
    String body = engine.mergeData("mail/custSaleConfirmation.vm", "template", engine);
    Mailer mailer = new Mailer(site);

    String mailFrom = siteDomainParamBean.getMailFromCustSales();
    String subject = siteDomainParamBean.getSubjectCustSales();
    String mailTo = orderHeader.getCustEmail();
    if (mailFrom == null) {
      mailFrom = "";
    }
    if (subject == null) {
      subject = "";
    }
    if (Format.isNullOrEmpty(mailFrom) || Format.isNullOrEmpty(mailTo)) {
      logger.error("Unable to send customer sales email");
      logger.error("mailFrom = " + mailFrom);
      logger.error("mailTo = " + mailTo);
      logger.error("subject = " + subject);
    }
    mailer.sendMail(mailFrom, mailTo, subject, body, "text/html");

    body = engine.mergeData("mail/adminSaleNotification.vm", "template", engine);
    mailTo = siteDomainParamBean.getCheckoutNotificationEmail();
    mailFrom = siteDomainParamBean.getMailFromNotification();
    subject = siteDomainParamBean.getSubjectNotification();
    if (!Format.isNullOrEmpty(mailFrom) && !Format.isNullOrEmpty(mailTo)) {
      mailer.sendMail(mailFrom, mailTo, subject, body, "text/html");
    }
  }
Ejemplo n.º 2
0
  public void sendShippingQuoteEmail(ServletContext servletContext) throws Exception {
    SiteDomain siteDomain = orderHeader.getSiteDomain();
    Long siteProfileClassId =
        orderHeader.getSiteProfile().getSiteProfileClass().getSiteProfileClassId();
    SiteDomainLanguage siteDomainLanguage = siteDomain.getSiteDomainLanguage();
    if (siteProfileClassId.equals(
        siteDomain.getSiteDomainLanguage().getSiteProfileClass().getSiteProfileClassId())) {
      for (SiteDomainLanguage language : siteDomain.getSiteDomainLanguages()) {
        if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
          siteDomainLanguage = language;
          break;
        }
      }
    }
    SiteDomainParamBean siteDomainParamBean =
        SiteDomainDAO.getSiteDomainParamBean(
            siteDomain.getSiteDomainLanguage(), siteDomainLanguage);
    Site site = siteDomain.getSite();

    TemplateEngine engine = TemplateEngine.getInstance();
    engine.init(
        orderHeader.getSiteDomain(),
        orderHeader.getSiteProfile(),
        orderHeader.getSiteCurrency(),
        servletContext);
    engine.setParameter("orderHeaderId", orderHeader.getOrderHeaderId());
    String body = engine.mergeData("mail/shippingQuote.vm", "template", engine);
    Mailer mailer = new Mailer(site);

    String mailFrom = siteDomainParamBean.getMailFromShippingQuote();
    String subject = siteDomainParamBean.getSubjectShippingQuote();
    String mailTo = orderHeader.getCustEmail();
    if (mailFrom == null) {
      mailFrom = "";
    }
    if (subject == null) {
      subject = "";
    }
    if (Format.isNullOrEmpty(mailFrom) || Format.isNullOrEmpty(mailTo)) {
      logger.error("Unable to send customer sales email");
      logger.error("mailFrom = " + mailFrom);
      logger.error("mailTo = " + mailTo);
      logger.error("subject = " + subject);
    }
    mailer.sendMail(mailFrom, mailTo, subject, body, "text/html");
  }