Esempio 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");
    }
  }
Esempio 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");
  }
Esempio n. 3
0
 public void saveHeader() throws Exception {
   EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
   String userId = user == null ? Constants.USERNAME_SYSTEM : user.getUserId();
   Date current = new Date();
   if (isNew) {
     orderHeader.setOrderNum(
         generateNumber(orderHeader.getSiteDomain().getSite(), Constants.SEQUENCE_ORDER));
     orderHeader.setRecCreateBy(userId);
     orderHeader.setRecCreateDatetime(current);
     orderHeader.setOrderStatus(Constants.ORDERSTATUS_OPEN);
   }
   orderHeader.setRecUpdateBy(userId);
   orderHeader.setRecUpdateDatetime(current);
   if (orderHeader.getOrderHeaderId() == null) {
     em.persist(orderHeader);
   }
   isNew = false;
 }
Esempio n. 4
0
  public OrderHeader clone(OrderHeader header) {
    OrderHeader orderHeader = new OrderHeader();
    orderHeader.setOrderHeaderId(header.getOrderHeaderId());
    orderHeader.setOrderNum(header.getOrderNum());
    orderHeader.setCustEmail(header.getCustEmail());
    orderHeader.setShippingTotal(header.getShippingTotal());
    orderHeader.setShippingDiscountTotal(header.getShippingDiscountTotal());
    orderHeader.setOrderTotal(header.getOrderTotal());
    orderHeader.setPaymentGatewayProvider(header.getPaymentGatewayProvider());
    orderHeader.setCreditCardDesc(header.getCreditCardDesc());
    orderHeader.setCustCreditCardNum(header.getCustCreditCardNum());
    orderHeader.setShippingMethodName(header.getShippingMethodName());
    orderHeader.setOrderStatus(header.getOrderStatus());
    orderHeader.setOrderDate(header.getOrderDate());
    orderHeader.setRecUpdateBy(header.getRecUpdateBy());
    orderHeader.setRecUpdateDatetime(header.getRecUpdateDatetime());
    orderHeader.setRecCreateBy(header.getRecCreateBy());
    orderHeader.setRecCreateDatetime(header.getRecCreateDatetime());
    orderHeader.setSiteDomain(header.getSiteDomain());
    orderHeader.setSiteProfile(header.getSiteProfile());
    orderHeader.setSiteCurrency(header.getSiteCurrency());

    return orderHeader;
  }